ssc_defineKPI()

The function adds a KPI definition as a data point of the type _SSC_KPI.

When a KPI definition of the same DP name already exists, the function updates the existing definition.

Synopsis

int ssc_defineKPI(string kpiName, string kpiFunc, dyn_string parameters, string description="");

Parameters

Parameters Description
kpiName The name of the KPI that is created. The name is used as the data point name.
kpiFunc The KPI calculation function. It can be either a formula such as "a*b" or an invocation of a function that is defined in the wincc_oa_path/SmartSCADA_3.15/scripts/libs/SmartSCADA/kpi/kpiFunctions.ctl. Only parameters defined in the "parameters" argument (see below) can be used in the kpiFunc.
parameters The parameter "parameters" contains the variable names that can be used in the kpiFunc (see above).
description A text description of the KPI that is created.

Return Value

The function returns 0 if it was successfully executed and a KPI was created.

The function returns -1 in case of an input error and -2 if an error occurred when creating a DP.

Description

The function adds a KPI definition as a data point of the type _SSC_KPI. When a KPI definition of the same DP name already exists, the function updates the existing definition.

Example

The function creates a new KPI called "myNewKPI". The KPI function is "a+b+c". The parameters used for the function are a, b, c. The description "My new KPI description" is used for the function.

main()
{
  int i;
  string kpiName = "myNewKPI";
  string kpiFunc = "a+b+c";
  dyn_string parameters=makeDynString("a","b","c");
  string description = "My new KPI description";
  i = ssc_defineKPI(kpiName,kpiFunc, parameters, description);
  if(""==kpiFunc)
  {
    DebugN("KPI function must be defined.");
  }
  dyn_errClass errors = getLastError();
  if(dynlen(errors)>0)
  {
    DebugN(errors);
  }
  else
  DebugN("Function return value:", i, "KPI: ", kpiName, "
  created");
}
Figure 1. The new created KPI in the KPI wizard
Figure 2. The new KPI data point "myNewKPI"

Assignment

KPI functions

Availability

SmartSCADA