CALCSTATFUNC archIdent, time= FromIdent_TmA, timeToIdent_TmA, statFuncIdent_Int, validPercIdent_Int, para= mIdent, retValueIdent, statusIdent_Int [,archivInstance_Int]=20
archIdent  in  Reference to one value of historical value or reference to object, values of which have been archived. Warning: If the parameter is the= reference to an object archived several times, there is not specified whic= h one of the historical objects is to be used. 
timeFromItemIdent_TmA  in  Identifier of AbsTime type  interval beginn= ing. 
timeToItemIdent_TmA  in  Identifier of AbsTime type  interval end. 
statFunctIdent  in  Identifier of Int type  statistical functio= n type. 
validPercIdent  in  Identifier of Int type  validation criteria= . 
paramIdent  in  Identifier of Int or Real types  p= arameter for some types of functions. 
retValueIdent  out  Identifier for calculation result. 
statusIdent  out  Calculation (action) success. 
archivInstance_Int  in  Optional identifier of Int type  ident= ification of archive in= stance. If the parameter is not defined, the value 0 will replace it. 
The action executes calculation of the statistical function given by the= parameter statFuncIdent_Int on the values represented by the hist= orical value archIdent within the time interval given by the param= eter timeFromIdent_TmA and timeToIdent_TmA . After succes= sful execution of the action, the parameter retValueIdent contains= a result value of the calculation. The parameter statusIdent_Intg= ets one of the following values:
Set of implemented functions is equal with the functions, which may be c= onfigured for statistical archive (except the FILTER and EACOAVG= functions). For the individual functions, there are predefined local constants in ESL.
The parameter validPerctIdent_Int represents Validation criteria<= /a> used during the evaluation of the statistical function. It can get valu= es within 1 .. 100 (the error ERR_RANGE_ERROR occurs if the condition is br= oken).
For some statistical function, it is required to enter the parameter paramIdent according to the table:
Statistical function  Parameter description  
_STAT_F_INTEGRAL  Integral time units= . For individual types, there are also established predefined local var= iables according to the table:


_STAT_F_GE_TIME _STAT_F_GT_TIME _STAT_F_LE= _TIME _STAT_F_LT_TIME _STAT_F_ADDITION_PARAM _STAT_F_INCREMENT_PAR= AM _STAT_F_DELTA_PARAM 
Compare value 
For the other statistical archive functions, the parameter paramIden= t is not being evaluated.
Value of parameter archivInstance_Int defines the instance of a= rchive which executes the request. If the parameter is not defined (or the = value is 0), the active instance of archive will execute the request.
Note: When calculating CALCSTATFUNC action, a time limitation which is active in the computations of stati= stical archives and does not allow for calculation for future times, is no applied. With C= ALCSTATFUNC, it is therefore possible, for example, to calculate s= tatistics over a script filled archive that has data in the future.
TIME _bt TIME _et REAL _retValue INT _retCode _bt :=3D %StrToTime("8:01:00 16102003") _et :=3D %StrToTime("8:02:00 16102003") CALCSTATFUNC H.ArchObj, _bt, _et, _STAT_F_SUM, 100, 0, _retValue, _retCod= e=20 IF _retCode =3D _ERR_NO_ERROR THEN ; calculation done ELSE ; an error occurred ENDIF=20
Note 2
If it is necessary to calculate statistics over a periodic archive (e.g.= H.Period), it should be noted that the periodic archive has value= s only in multiples of the period. For example, if it were necessary to cal= culate the integral from the periodic archive and the beginning of the inte= rval would not be multiples of the period, 0 would be integrated from the b= eginning of the interval to the first multiple of the period.
This feature can be circumvented by creating a onchange computed archiv= e object (e.g. H.PeriodOnRead) that is computed onread and that c= opies H.Period. Integral computed from H.PeriodOnRead arc= hive will behave as expected.
Related pages: