Skip to main content
InSource KnowledgeCenter

TN AppSvr900 Creating Totalizers In System Platform (App Server)



This article from InSource shows where to construct and how to configure and initialize totalizers.   Totalizers are typically configured and located within the PLC but some customers have asked to have Totalizers also created within Application Server.   

  • Author: Frank Ross
  • Published: 03/29/2019
  • Applies to: Application Server (any version)


Figure-1:  TotalizerCalc Script is set to execute Periodic - every one second.

This example shows a Totalizer Script called "Totalizer Calc" with the execution type equal to Execute based on the Trigger Type equal to Periodic.   The Trigger Period is set to execute every second.  It is important to ensure the "Runs Asynchronously" checkbox is left unchecked or it is possible the script will lag behind the frequency of scheduled execution.    



Figure-2:  Coding the Totalizer Calculation

Calculating a typical Totalizer is a matter of constructing a simple formula which is Totalizer = Totalizer + InputValue,   In the example below, the formula is enhanced to divide the InputValue by 60 seconds because the script is executing every one second.  Furthermore, in this example, the Totalizer is only added to if the Gas Flow is on.    

Looking at the IF STATEMENT below, you will see several conditions being checked before the Totalizer Calculation is actually executed.    The reasons are as follows:

1. It is recommended to allow the system to execute a minimum of 5 cycles before allowing the Totalizers to execute.   This ensures the system is completely operational before referencing any PLC attributes.   

2. It is recommended to check the quality all input tags, used for the calculations, before adding them to the Totalizer.    In the example below, if either of the input tags (GasConsumption_LBSMIN_PV or GasFlow_OnOff_Status) has anything else other than Good Quality, the condition will skip the addition and log a message into the SMC Logger.   

3.  It is recommended to force the Totalizer into a Good Quality Status before adding to it.   See the SetGood reference below.

IF Me.TotalizerCalc.ExecutionCnt >= 5 then
                IF (IsGood(Me.GasConsumption_LBSMIN_PV.Quality)) AND (IsGood(Me.GasFlow_OnOff_Status.Quality)) THEN
                               Me.GasTotalizer_LBS_Total = Me.GasTotalizer_LBS_Total + ((Me.GasConsumption_LBSMIN_PV / 60) * Me.GasFlow_OnOff_Status);
                    LogMessage ("Quality Status GasConsumption_LBSMIN_PV = " + Me. GasConsumption_LBSMIN_PV.Quality);
                    LogMessage ("Quality Status GasFlow_OnOff_Status  = " + Me. GasFlow_OnOff_Status.Quality.Quality);


Figure-3:  TotalizerReset Script is set to execute OnTrue at midnight. 

A 2nd script has been created called "TotalizerReset" and it executes using an OnTrue condition when the time is equal to midnight.  The purpose of this script is to reset the Totalizer(s) to zero.    For purposes of this example, a time-based reset condition is used.    Totalizer resets are based off of what the customer requires, i.e., Work Order changes, etc....  


Figure-4:  Coding the Totalizer Reset

In this example, the code is adding the daily GasTotalizer value to the PeakGasTotalizer and then resetting (or zeroing out the daily GasTotalizer).   This records the last value recorded (Peak) at the time of the reset for that period (day).  

Me.PeakGasTotalizer_LBS_Total = Me.GasTotalizer_LBS_Total;
Me.GasTotalizer_LBS_Total = 0;

Summary:   Totalizers in-and-of themselves are very easy to configure.   However, they are likely to be very customized based on the conditions that the customer sets for doing the calculations and resets.  It is important to note that if the Totalizer is executing every second and calculating a per-minute value, the input value should be divided by 60.  The same is true if executing every second and calculating a per-hour value, the input value should be divided by 3600 (60 seconds in a minute multiplied by 60 minutes in an hour).