ssc_evalKPIInstance()

The function evaluates a KPI instance.

Synopsis

int ssc_evalKPIInstance(anytype &kpiValue, const string kpiKey, const int runnerType);

Parameters

Parameter Description
kpiValue Returns the calculation result.
kpiKey The internal key of the KPI instance to be evaluated.
runnerType The trigger for the instance: SSC_ADHOC_RUNNER.

Return Value

0 = successful. -1 = error

Description

This function prepares the input parameters for evaluation. If the parameters are correctly prepared, the KPI instance will be evaluated. In other words the KPI calculation is calculated. CAUTION: The parameters "queryResult" and "timeVal" of the ssc_evalKPIInstance() function are only used for internal purposes and therefore not described here.

If a parameter is an online parameter, the function uses the value from either cache or dpQueryConnect callback. The online parameter means that the "Online" check box was checked in the Associate panel - see figure below:

Figure 1. Online check box

If a parameter is a timed parameter, the function uses either the current time or the value from the timed function callback. The timed parameter means that timedFunction option was selected in the Associate panel when configuring the KPI instance - see figure below:

Figure 2. timedFunction radio button

In other cases the function uses the literal value stored in the memory parameter instance. Other cases would be, for example, when a string is used as a value for a KPI instance in the Associate panel. Note that if the Online check box is not checked, the parameter is a constant value and the value is used as a string. Thus, the calculation could be incorrect. If you use constant values, define a customized function in the "SmartSCADA_3.15scripts/libs/SmartSCADA/kpiFunctions.ctl" or only use functions that can process an input string.

Example

The example calls the function ssc_evalKPIInstance for the KPI definition "Electric_Power" and KPI key ".kpi.Electric_Power0".

Figure 3. SSC_KPI_Instance - kpiKey
#uses "SmartSCADA/kpi/kpiEval.ctl"
main()
{
  anytype kpiValue;
  int ret =
  ssc_evalKPIInstance(kpiValue,".kpi.Electric_Power0",SSC_ADHOC_RUNNER);
  DebugN("KPI value:", kpiValue);
}

The script outputs: WCCOAui1:["KPI value:"][value]

Assignment

KPI functions

Availability

SmartSCADA