fwConfigs  8.4.0
fwDpFunction Statistical

Modules

 fwDpFunction common functions and variables
 

Files

file  fwDpFunction.ctl
 

Configuration object indexes

Used to access the configuration object attributes (object of type dyn_anytype).

const int fwDpFunction_OBJ_STAT_TYPE = 9
 
const int fwDpFunction_OBJ_STAT_INTERVAL = 10
 
const int fwDpFunction_OBJ_STAT_DELAY = 11
 
const int fwDpFunction_OBJ_STAT_READ_ARCHIVE = 12
 

Utility functions

Used to access the configuration object attributes (object of type dyn_anytype).

 fwDpFunction_objectCreateStatistical (dyn_mixed &functionObject, dyn_string functionParams, dyn_string functionGlobals, string functionDefinition, dyn_int statTypes, int intervalS, int delayS, bool readArchive, dyn_string &exceptionInfo, bool runChecks=true)
 
 fwDpFunction_objectExtractStatistical (dyn_mixed functionObject, dyn_string &functionParams, dyn_string &functionGlobals, string &functionDefinition, dyn_int &statTypes, int &intervalS, int &delayS, bool &readArchive, dyn_string &exceptionInfo)
 
bool fwDpFunction_objectIsStatistical (dyn_mixed functionObject)
 

Detailed Description

Define dpFunctions of type statistical. Please refer also to fwDpFunction common functions and variables. For type dpe Connection, refer to fwDpFunction DPE Connection.

Use Examples

The fwDpFunctions library makes use of a configuration object. In order to configure a dpe with a dp function, the configuration setting object must be previously initialized with the dp function parameterization (using utility functions). Such object is then passed to the set function that will make the necessary dpSet.

Statistical functions are partially supported by fwDpFunction. The utility functions allow creating/extracting basic setting of statistical function. For more advanced settings, see their availability using the Configuration object indexes

Setting a dp function of type statistical

A function of statistical type can be set in the following way: one should declare a configuration object of type dyn_anytype, then fill it with the dpFunction settings using the function fwDpFunction_objectCreateStatistical(), then set the setting to the dpe using the function fwDpFunction_objectSet().

Example:

dyn_string exc;
string dpe;
//func object containing one dpfunc set
dyn_mixed dpFuncObject;
//dp func parameters
dyn_string functionParams;
dyn_string functionGlobals;
string functionDefinition;
dyn_int statTypes;
int intervalS;
int delayS;
bool readArchive;
//dp function setting:
//parameters p1, p2
dynAppend(functionParams,"sys1:dp1.val2:_original.._value");
dynAppend(functionParams,"sys1:dp1.val3:_original.._value");
//global parameters g1, g2
dynAppend(functionGlobals,"sys1:dp1.val4:_original.._value");
dynAppend(functionGlobals,"sys1:dp1.val5:_original.._value");
//parameter p1 is a Maximum function, parameter p2 is an Average function
dynAppend(statTypes,SF_MAX);
dynAppend(statTypes,SF_AVG);
//the function definition using the parameters
functionDefinition = "p1+p2+g1+g2";
//time interval
intervalS = 3;
//delay on first start
delayS = 4;
//start reading from archive
readArchive = true;
//create the func object
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);
//dpe where to set the dp function
dpe = "sys1:dp1.val";
//set the func object to the dpe
fwDpFunction_objectSet(dpe, dpFuncObject, exc, true);

Getting a dp function of type statistical

A function of statistical type can be retrieved from a dpe in the following way: one should declare a configuration object of type dyn_anytype, then fill it with the dpFunction settings from the dpe using the function fwDpFunction_objectGet(), then extract the settings from the configuration object using the function fwDpFunction_objectExtractStatistical(). Before extracting the settings, it is possible to check that the settings are really of type stiatistical (function fwDpFunction_objectIsStatistical()).

Example:

dyn_string exc;
string dpe;
dyn_mixed dpFuncObject;
dyn_string functionParams;
dyn_string functionGlobals;
string functionDefinition;
dyn_int statTypes;
int intervalS;
int delayS;
bool readArchive;
bool configExists;
//dpe containing the dp function
dpe = "sys1:dpe1.val";
//get the dp function, store it to the dp function settings object
fwDpFunction_objectGet(dpe, configExists, dpFuncObject, exc);
//extract the statistical function settings, if it exists
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);
DebugN( "fwDpFunction_objectGet():",
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);

Setting many dp functions of type statistical

Functions of statistical type can be set in batch in the following way: one should declare a configuration object of type dyn_anytype (dpFuncObject). This object will be contained in an array of object (one object per dpe), of type dyn_anytype (call it dpFuncObjects). Each dpFuncObject then must be filled with the function fwDpFunction_objectCreateStatistical(), and stored into the array of objects dpFuncObjects. The array of objects is then passed together with the array of dpes to the function fwDpFunction_objectSetMany(). Such procedure is more performing than looping into the dpes with the function fwDpFunction_objectSet().

Example: set 2 dp configs into 2 dpes:

dyn_string exc, dpe;
//func object containing one dpfunc set
dyn_mixed dpFuncObject;
//this contains all the func objects
dyn_mixed dpFuncObjects;
//dp func parameters
dyn_string functionParams;
dyn_string functionGlobals;
string functionDefinition;
dyn_int statTypes;
int intervalS;
int delayS;
bool readArchive;
//dp function settings for dpe1:
//parameters p1, p2
dynAppend(functionParams,"sys1:dp1.val2:_original.._value");
dynAppend(functionParams,"sys1:dp1.val3:_original.._value");
//global parameters g1, g2
dynAppend(functionGlobals,"sys1:dp1.val4:_original.._value");
dynAppend(functionGlobals,"sys1:dp1.val5:_original.._value");
//parameter p1 is a Maximum function, parameter p2 is an Average function
dynAppend(statTypes,SF_MAX);
dynAppend(statTypes,SF_AVG);
//the function definition using the parameters
functionDefinition = "p1+p2+g1+g2";
//time interval
intervalS = 3;
//delay on first start
delayS = 4;
//start reading from archive
readArchive = true;
//create the func object
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);
//add the func object to the objects array
dpFuncObjects[1] = dpFuncObject;
//dp function settings for dpe2:
//clear temp parameters
dynClear(functionParams);
dynClear(functionGlobals);
dynClear(statTypes);
//parameters p1, p2
dynAppend(functionParams,"sys1:dp2.float2:_original.._value");
dynAppend(functionParams,"sys1:dp2.float3:_original.._value");
//global parameters g1, g2
dynAppend(functionGlobals,"sys1:dp2.float4:_original.._value");
dynAppend(functionGlobals,"sys1:dp2.int1:_original.._value");
//parameter p1 is a Maximum function, parameter p2 is an Average function
dynAppend(statTypes,SF_MAX);
dynAppend(statTypes,SF_AVG);
//the function definition using the parameters
functionDefinition = "p1+p2/(g1-g2)";
//time interval
intervalS = 3;
//delay on first start
delayS = 4;
//start reading from archive
readArchive = true;
//create the func object
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);
//add the second func object to the objects array
dpFuncObjects[2] = dpFuncObject;
//list of dpes where to set the dp function
dpe = makeDynString("sys1:dp1.val", "sys1:dp2.val");
//set the func object array to the dpe array
fwDpFunction_objectSetMany(dpe, dpFuncObjects, exc, true);

It is also possible to set many dpes with the same dp function settings. In this case, the array of settings objects must contain one only object, at the index 1.

Getting a dp function of type statistical

A function of statistical type can be retrieved from a dpe in the following way: one should declare a configuration object of type dyn_anytype, then fill it with the dpFunction settings from the dpe using the function fwDpFunction_objectGet(), then extract the settings from the configuration object using the function fwDpFunction_objectExtractStatistical(). Before extracting the settings, it is possible to check that the settings are really of type dpeConnection (function fwDpFunction_objectIsStatistical()).

Example:

dyn_string exc;
string dpe;
dyn_mixed dpFuncObject;
dyn_string functionParams;
dyn_string functionGlobals;
string functionDefinition;
dyn_int statTypes;
int intervalS;
int delayS;
bool readArchive;
bool configExists;
//dpe containing the dp function
dpe = "sys1:dpe1.val";
//get the dp function, store it to the dp function settings object
fwDpFunction_objectGet(dpe, configExists, dpFuncObject, exc);
//extract the statistical function settings, if it exists
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);
DebugN( "fwDpFunction_objectGet():",
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);

Getting many dp functions of type statistical

Functions of statistical type can be retrieved in batch. This is more performing than looping into the dpes with the function fwDpFunction_objectGet(). It can be done in the following way: one should declare a configuration object of type dyn_anytype (dpFuncObject). This object will be contained in an array of object (one object per dpe), of type dyn_anytype (call it dpFuncObjects). The array of objects dpFuncObjects then must be filled with the function fwDpFunction_objectGetMany(). The array is the accessed in a loop, getting each element dpFuncObject inside dpFunctionObject. The parameters can be then accessed using fwDpFunction_objectEctractStatistical().

Example: set 2 dp configs into 2 dpes:

dyn_string exc;
dyn_string dpe;
dyn_mixed dpFuncObjects;
int i;
dyn_string functionParams;
dyn_string functionGlobals;
string functionDefinition;
dyn_bool configExists;
dyn_int statTypes;
int intervalS;
int delayS;
bool readArchive;
//list of dpes
makeDynString("sys1:dpe1.val","sys1:dpe2.val");
fwDpFunction_objectGetMany(dpe, configExists, dpFuncObjects, exc);
for(i=1 ; i<=dynlen(dpe) ; i++)
{
if(fwDpFunction_objectIsStatistical(dpFuncObjects[i]))
functionParams,
functionGlobals,
functionDefinition,
statTypes,
intervalS,
delayS,
readArchive,
exc);
DebugN( "fwDpFunction_objectGetMany():", dpe[i],
functionParams, functionGlobals, functionDefinition,
statTypes,
delayS,
readArchive, exc);
}

Function Documentation

fwDpFunction_objectCreateStatistical ( dyn_mixed &  functionObject,
dyn_string  functionParams,
dyn_string  functionGlobals,
string  functionDefinition,
dyn_int  statTypes,
int  intervalS,
int  delayS,
bool  readArchive,
dyn_string &  exceptionInfo,
bool  runChecks = true 
)

Configures the dp function object with statistical parameters See fwDpFunction_objectSet() for an example. For more advanced parametrization, see parameters availability on the Variable Documentation for the availability of the options.

Constraints
It supports only basic parameters for statistical functions.
Usage
Public
PVSS managers
VISION, CTRL
Parameters
functionObjectThis object will contain the dp function parameters.
functionParamsThe list of dp elements to be used as parameters in the dp function. The # of elements must be = to the # of elements in fwDpFunction_OBJ_STAT_TYPE.
functionGlobalsThe list of dp elements to be used as globals in the dp function
functionDefinitionThe dp function is given here (in terms of p's (parameters) and g's (globals))
statTypesType of stat function (i.e. min, max... see full list on PVSS help, "_dp_fct.._stat_type"). One per parameter. The # of elements must be = to the # of elements in fwDpFunction_OBJ_PARAM.
intervalSTime interval of stat function, in seconds
delaySTime delay of stat function, in seconds
readArchiveRead values from archive starting the stat function
exceptionInfoDetails of any exceptions are returned here
runChecksPerform some consistency checks. Optional. Default value = true
See Also
fwDpFunction_objectSet(), fwDpFunction_objectSetMany()
fwDpFunction_objectExtractStatistical ( dyn_mixed  functionObject,
dyn_string &  functionParams,
dyn_string &  functionGlobals,
string &  functionDefinition,
dyn_int &  statTypes,
int &  intervalS,
int &  delayS,
bool &  readArchive,
dyn_string &  exceptionInfo 
)

Reads the dp function object

Constraints
It supports only basic parameters for statistical functions. For more advanced parametrization, check the list of constants fwDpFunction_OBJ_STAT_* for the availability of the options.
Usage
Public
PVSS managers
VISION, CTRL
Parameters
functionObjectThis object will contain the dp function parameters.
functionParamsThe list of dp elements to be used as parameters in the dp function.
functionGlobalsThe list of dp elements to be used as globals in the dp function
functionDefinitionThe dp function is given here (in terms of p's (parameters) and g's (globals))
statTypesType of stat function (i.e. min, max... see full list on PVSS help, "_dp_fct.._stat_type"). One per parameter (contained in functionParams).
intervalSTime interval of stat function, in seconds
delaySTime delay of stat function, in seconds
readArchiveRead values from archive starting the stat function
exceptionInfoDetails of any exceptions are returned here
bool fwDpFunction_objectIsStatistical ( dyn_mixed  functionObject)

Check wether the configuration object contains statistical function.

Constraints
None
Usage
Public
PVSS managers
VISION, CTRL
Parameters
functionObjectThis object containing the dp function parameters.
Returns
true if statistical dp function, false else.

Variable Documentation

const int fwDpFunction_OBJ_STAT_TYPE = 9
Description
Type of stat function (i.e. min, max... see full list on PVSS help, "_dp_fct.._stat_type"). One per parameter. The # of elements must be = to the # of elements in fwDpFunction_OBJ_PARAM.
Parameter Type
dyn_int
Usage
For Statistical only. Cumpulsory. Default = SF_MIN See use example on fwDpFunction_OBJ_objectSet().
const int fwDpFunction_OBJ_STAT_INTERVAL = 10
Description
Time interval of stat function, in seconds
Parameter Type
int
Usage
For Statistical only. Cumpulsory. Default = 1 See use example on fwDpFunction_OBJ_objectSet().
const int fwDpFunction_OBJ_STAT_DELAY = 11
Description
Time delay of stat function, in seconds
Parameter Type
int
Usage
For Statistical only. Optional. Default = 0 See use example on fwDpFunction_OBJ_objectSet().
const int fwDpFunction_OBJ_STAT_READ_ARCHIVE = 12
Description
Read values from archive starting the stat function
Parameter Type
bool
Usage
For Statistical only. Optional. Default = false See use example on fwDpFunction_OBJ_objectSet().