%AvgFloat function


Function
The function returns an arithmetic average of values. It can be used for the object of Eval tag type.
Declaration
REAL %AvgFloat(
   REAL in value,
   INT  in deepTime,
   UNIVAL in calcTrigger,
   INT  in maxValues 
 )
Parameters
valueThe value that is included to the average.
deepTimeTime depth of values in seconds. The value must be valid and > 0.
calcTriggerCalculating trigger - an object of any type. Its change causes a recalculation of the function.
maxValuesMaximum values that are accepted by the function. The value must be valid and > 0.
Description
For purpose of calculation of average value, the function holds an internal list of values. After each recalculation, it includes the value that is defined by the parameter value into the list under the following conditions:
  • the value must be valid and
  • its timestamp is greater than the last value in the list.

Before calculating the arithmetic average, the values that are out of time-depth (they are older than SysTime - deepTime) are removed from the list. Then, the arithmetic average is calculated. If the list does not contain any value, the final average is an invalid value.

The function returns an invalid value, if:

  • the limitation for deepTime and maxValues are not fulfilled or
  • the list of values does not contain any value
Napíšte komentár