_alert_hdl

This chapter describes the attributes of alert handling, attributes of sum alert handling as well as status bits for the _alert_hdl.._state attribute .

There are two different kinds of attributes for an alert handling.

  • Attributes for the configuration

Attributes for configuration, for example, limits of alert handling of a datapoint element are written using dpSet() and read using dpGet() or dpConnect().

  • Attributes of alerts

Attributes of alerts, for example, the _comment for an alarm triggered at 10 o'clock can only be written or read using alertSet(), alertGet(), alertConnect() or dpQuery with SELECT ALERT, since in order to determine the attribute, in addition to the DPE also the alert time is needed.

CAUTION:
dpQuery with SELECT ALERT works solely with attributes that can be queried via alertConnect(). These are attributes that belong to an alert instance (see attributes of alerts above and in the table below). Attributes that belong to a configuration and not to an alert instance can therefore not be queried via SELECT ALERT or alertConnect().

The following table shows all attributes of an alert handling. In the table you can also find the functions that can be used to set or query an attribute.

*The type "var" is the type of the element to which the alert handling is assigned.

Attributes that can be queried with dpQuery - SELECT ALERT

For the following attributes it is possible to use dpQuery - SELECT ALERT (query current alerts) respectively dpQuery - SELECT ALERT + TIME RANGE (historical query).

Attributes for sum alerts

Attributes of the group alerts Type Description
_sumalerts dyn_dpid Shows in which sum alerts an alarm is located.
_summed_abbr dyn_langString List of current abbreviations
_summed_alerts dyn_atime List of current alerts (DPE + alert time)
_summed_colors dyn_string List of current alert colors
_summed_classes dyn_string List of current alert classes
_summed_prios dyn_char List of current priorities
_summed_states dyn_int List of current alert status (came acknowledge...)
_summed_alerts_count int Shows the number of alarms which are located in the sum alerts.
CTRL constant int value Description
DPCONFIG_NONE 0 no alert handling
DPCONFIG_ALERT_BINARYSIGNAL 12 alert handling binary values
DPCONFIG_ALERT_NONBINARYSIGNAL 13 alert handling analogous values

DPCONFIG_SUM_ALERT

59 alert handling sum alerts

"_alert_hdl.<i>._act_state" alert handling

The following integer constants are used to query the current alert status (acknowledgement status) of an alert range, like the entire alert handling, for a datapoint element. The detail number in the attribute refers to the index of the alert range (see attributes "_alert_hdl.<i>._type"). If this is omitted or set to zero, the attribute refers to the current status of the alert handling (see dpGet()).

CTRL constant int value Description
DPATTR_ALERTSTATE_NONE 0 no alert
DPATTR_ALERTSTATE_APP_NOT_ACK 1 CAME or CAME/unacknowledged
DPATTR_ALERTSTATE_APP_ACK 2 CAME/acknowledged
DPATTR_ALERTSTATE_DISAPP_NOT_ACK 3 WENT/unacknowledged
DPATTR_ALERTSTATE_APP_DISAPP_NOT_ACK 4 CAME/WENT/unacknowledged

"_alert_hdl.<i>._ack_state" alert handling

The following integer constants can be used to query the acknowledgement state of a datapoint element.

In the function alertSet() the _ack_state has to be used with the correct detail number (alarm range for analog alerts) and the correct time. With alertSet() a special alert can be acknowledged. This function is used in the AEScreen.

CTRL constant int value Description
DPATTR_ACKTYPE_NOT 0 Not acknowledged
DPATTR_ACKTYPE_MULTIPLE 1 Acknowledge all
DPATTR_ACKTYPE_SINGLE 2 Single acknowledgement

"_alert_hdl.<i>._event" alert handling

The following integer constants can be used to set event actions.

CTRL constant int value Description
DPATTR_ALERTEVENT_CAME 0 Alert CAME.
DPATTR_ALERTEVENT_CAME_IMPULSE 1 Alert CAME with impulse alarm.
DPATTR_ALERTEVENT_WENT 2 Alert WENT.
DPATTR_ALERTEVENT_MULTIPLE_ACK 3 Alert was sum acknowledged.
DPATTR_ALERTEVENT_SINGLE_ACK 4 Alert was single acknowledged.
DPATTR_ALERTEVENT_WENT_INACTIVE 5 Deactivated alert WENT.
DPATTR_ALERTEVENT_WENT_OBSOLETE 7 Neither a CAME nor a WENT event is triggered. You can use the constant to delete an alarm explicitly (e.g., when an alarm does not exist on a PLC anymore).

"_alert_hdl.<i>._hyst_type" alert handling

The following integer constants can be used to determine whether a hysteresis is assigned to an alert handling.

CTRL constant int value Description
DPATTR_HYST_NONE 0 no hysteresis
DPATTR_HYST_VALUE 1 hysteresis
DPATTR_HYST_TIME 2 The _hyst_time attribute (called Delay in the alert_hdl configuration) specifies the minimum time in seconds that an alert must be in a bad range for it to be triggered. When the alert is back in a good range, it is immediately cleared. For an alert instance, the _alert_hdl.<detail>._hyst_time can be used to get the values used for an alert instance. The configuration applies per alert range.

"_alert_hdl.<i>._type" alert handling for analog values

The integer constants below can be used to determine the type of alert-handling of the alert range of a datapoint element. The detail number in the attribute determines the alert range: "alert_hdl.1._type" refers to the first (or lowest) range (see dpSet()).

CTRL constant int value Description
DPDETAIL_RANGETYPE_NONE 0 No alert range
DPDETAIL_RANGETYPE_MINMAX 4 MinMax alert range

Sum alert

CTRL constant int value Description
DPCONFIG_NONE 0 No alert handling
DPCONFIG_SUM_ALERT 59 Sum alert

Example

Applies an alert handling of analog values with 3 ranges:

main()
{
  dyn_float limits;
  dyn_string alerttext;
  dyn_string alertclass;
  dyn_bool limitsincl;
  int rc;
  dyn_errClass err;
  limits=makeDynFloat(20, 80);
  alerttext=makeDynString("Warning", "OK", "Alert");
  alertclass=makeDynString("System1:warning.",
  "System1:alert.");
  limitsincl=makeDynBool(TRUE, TRUE);
  rc = dpSetWait("TestDP_1.element:_alert_hdl.._type",
  DPCONFIG_ALERT_NONBINARYSIGNAL,
  "TestDP_1.element:_alert_hdl.1._type", 4,
  "TestDP_1.element:_alert_hdl.2._type", 4,
  "TestDP_1.element:_alert_hdl.3._type", 4,
  "TestDP_1.element:_alert_hdl.1._u_limit", limits[1],
  "TestDP_1.element:_alert_hdl.2._u_limit", limits[2],
  "TestDP_1.element:_alert_hdl.2._l_limit", limits[1],
  "TestDP_1.element:_alert_hdl.3._l_limit", limits[2],
  "TestDP_1.element:_alert_hdl.1._u_incl", limitsincl[1],
  "TestDP_1.element:_alert_hdl.1._l_incl", limitsincl[1],
  "TestDP_1.element:_alert_hdl.2._u_incl", limitsincl[2],
  "TestDP_1.element:_alert_hdl.2._l_incl", !limitsincl[1],
  "TestDP_1.element:_alert_hdl.3._u_incl", limitsincl[1],
  "TestDP_1.element:_alert_hdl.3._l_incl", !limitsincl[2],
  "TestDP_1.element:_alert_hdl.1._text", alerttext[1],
  "TestDP_1.element:_alert_hdl.2._text", alerttext[2],
  "TestDP_1.element:_alert_hdl.3._text", alerttext[3],
  "TestDP_1.element:_alert_hdl.1._class", alertclass[1],
  "TestDP_1.element:_alert_hdl.3._class", alertclass[2],
  "TestDP_1.element:_alert_hdl.._orig_hdl", TRUE,
  "TestDP_1.element:_alert_hdl.._active", TRUE);
  err = getLastError();
  if(dynlen(err)>0)
  {
    throwError(err);
  }
  DebugN("done", rc);
}

Example

Applies an alert handling of discrete values:

void addCondAlert(string dpeName)
{
  dyn_float limits;
  dyn_string alerttext;
  dyn_string alertclass;
  int rc;
  dyn_errClass err;
  limits=makeDynString("*","2","3","4");
  alerttext=makeDynString("", "Warning", "Fault",
  "Unavailable");
  alertclass=makeDynString("", "warning.", "alert.",
  "information.");
  rc = dpSetTimedWait(0, dpeName + ":_alert_hdl.._type",
  DPCONFIG_ALERT_NONBINARYSIGNAL,
  dpeName + ":_alert_hdl.1._type", DPDETAIL_RANGETYPE_MATCH,
  dpeName + ":_alert_hdl.2._type", DPDETAIL_RANGETYPE_MATCH,
  dpeName + ":_alert_hdl.3._type", DPDETAIL_RANGETYPE_MATCH,
  dpeName + ":_alert_hdl.4._type", DPDETAIL_RANGETYPE_MATCH,
  dpeName + ":_alert_hdl.1._text", alerttext[1],
  dpeName + ":_alert_hdl.2._text", alerttext[2],
  dpeName + ":_alert_hdl.3._text", alerttext[3],
  dpeName + ":_alert_hdl.4._text", alerttext[4],
  dpeName + ":_alert_hdl.1._class", alertclass[1],
  dpeName + ":_alert_hdl.2._class", alertclass[2],
  dpeName + ":_alert_hdl.3._class", alertclass[3],
  dpeName + ":_alert_hdl.4._class", alertclass[4],
  dpeName + ":_alert_hdl.1._match", limits[1],
  dpeName + ":_alert_hdl.2._match", limits[2],
  dpeName + ":_alert_hdl.3._match", limits[3],
  dpeName + ":_alert_hdl.4._match", limits[4],
  dpeName + ":_alert_hdl.._active", TRUE);
  err = getLastError();
  if(dynlen(err)>0)
  {
    DebugTN("Error " + err + " adding alert for " + dpeName);
  }
}

Status bits for attribute _alert_hdl.._state

The status bits 0-15 are reserved for "CAME", the bits 16-31 for "WENT". The Attribute _alert_hdl.._state summarizes these status bits to a bit32 pattern. Besides the attributes in the table the following bits can be set:

Bit 7/23 (alert was single acknowledged?)

Bit 8/24 (all alerts were acknowledged?)

Bit 13/29 + 14/30 for the states of group alerts

For the group alerts states the bits 13/14 (came) or 29/30 (went) are set as follows:

FALSE/FALSE went acknowledged

FALSE/TRUE went unacknowledged

TRUE/FALSE came acknowledged

TRUE/TRUE came unacknowledged

You can find further details on the "_alert_hdl" configuration in the chapter PARA module - _alert_hdl (alert handling)