CALCSTATFUNC action


Function
Evaluation of a statistical archive function on demand.


Declaration
 CALCSTATFUNC archIdent, timeFromIdent_TmA, timeToIdent_TmA, statFuncIdent_Int, validPercIdent_Int, paramIdent, retValueIdent, statusIdent_Int [,archivInstance_Int]
Parameters
archIdentinReference to one value of historical value or reference to an object, values of which have been archived.

Warning: If the parameter is the reference to an object archived several times, there is not specified which one of the historical objects is to be used.
timeFromItemIdent_TmAinIdentifier of AbsTime type - interval beginning.
timeToItemIdent_TmAinIdentifier of AbsTime type - interval end.
statFunctIdentinIdentifier of Int type - statistical function type.
validPercIdentinIdentifier of Int type - validation criteria.
paramIdentinIdentifier of Int or Real types - parameter for some types of functions.
retValueIdentoutIdentifier for calculation result.
statusIdentoutCalculation (action) success.
archivInstance_IntinOptional identifier of Int type - identification of archive instance. If the parameter is not defined, the value 0 will replace it.
Description

The action executes the calculation of the statistical function given by the statFuncIdent_Int parameter on the values represented by the archIdent historical value within the time interval specified by the timeFromIdent_TmA and timeToIdent_TmA parameters. After successful execution of the action, the retValueIdent parameter contains a result value of the calculation. The statusIdent_Int return code gets one of the following values:

  • _ERR_TRANS_ABORT
  • _ERR_TRANS_ERROR
  • _ERR_TRANS_IGNORED
  • _ERR_NO_ERROR

The set of implemented functions is equal with the functions, which may be configured for statistical archive (except the FILTER and TIMESLICE functions).  For the individual functions, there are predefined local constants in ESL.

The validPerctIdent_Int parameter represents the Validation criteria used during the evaluation of the statistical function. It accepts values within 0 .. 100 (the error ERR_RANGE_ERROR occurs if the condition is not met).

For some statistical function, entering the paramIdent parameter according to the table is required:

Statistical functionParameter description
_STAT_F_INTEGRAL

Integral time units. For individual types, there are also established predefined local variables according to the table:

ConstantDescription
_INTEGRAL_HOURUNITHour integral
_INTEGRAL_MINUNITMinute integral
_INTEGRAL_SECUNITSecond integral
_STAT_F_GE_TIME
_STAT_F_GT_TIME
_STAT_F_LE_TIME
_STAT_F_LT_TIME
_STAT_F_ADDITION_PARAM
_STAT_F_INCREMENT_PARAM
_STAT_F_DELTA_PARAM
Compare value

For the other statistical archive functions, the paramIdent parameter is not being evaluated.

Value of the archivInstance_Int parameter defines the instance of the archive which executes the request. If the parameter is not defined (or the value is 0), the active archive instance will execute the request.

The timestamp of the result is identical to the specified end of time interval timeToItemIdent_TmA.

Note: When calculating CALCSTATFUNC action, a time limit that is active in the computations of statistical archives and does not allow for calculation for future times, is no applied. With CALCSTATFUNC, it is, therefore, possible, for example, to calculate statistics over a script-filled archive that has data in the future.

Example
 TIME _bt
 TIME _et
 REAL _retValue
 INT _retCode


 _bt := %StrToTime("8:01:00 16-10-2003")
 _et := %StrToTime("8:02:00 16-10-2003")

 CALCSTATFUNC H.ArchObj, _bt, _et,  _STAT_F_SUM, 100, 0, _retValue, _retCode 

 IF _retCode = _ERR_NO_ERROR THEN
 ; calculation done
 ELSE
   ; an error occurred
 ENDIF 
Note 1
Using the CALCSTATFUNC action does not allow evaluaton of the FILTER and ECOAVG statistical functions.

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 values only in multiples of the period. For example, if it were necessary to calculate the integral from the periodic archive and the beginning of the interval would not be multiples of the period, 0 would be integrated from the beginning of the interval to the first multiple of the period.

This feature can be circumvented by creating a change-based computed archive object (e.g. H.PeriodOnRead) that is computed on-read and that copies H.Period. Integral computed from H.PeriodOnRead archive will behave as expected.


Related pages:

0 komentárov

Nie ste prihlásený. Akékoľvek zmeny, ktoré vykonáte, sa označia ako anonymné. Ak už máte svoj účet, pravdepodobne sa budete chcieť prihlásiť .