I can see a number of examples of creating a continuous alarm in script, but I can't seem to find a good example of creating a discrete alarm in scripting.
I tried to follow the para panel, but... WOW, that is a path to confusion.
What confg property contains the continuous vs. discrete vs. multiinstance?
I want to build a button that creates the alarm for S7Plus connection issues:
State.ConnState
0=inactive
1=disconnected
2=connecting
3=connected
4=disconnecting
5=failure
Perfect for a discrete alarm!
create a discrete alarm in script
- tmalone
- Posts:192
- Joined: Mon Nov 22, 2010 11:21 pm
Re: create a discrete alarm in script
I found an example for discrete alert handling for boolean values.
the example for creating a discrete alarm is in the help->Module PARA->_alert_hdl->alert handling of discrete values-> at the bottom.
For non-bool discrete values, is the DPDETAIL_RANGETYPE_MATCH still the way to specify discrete alarms???
the example for creating a discrete alarm is in the help->Module PARA->_alert_hdl->alert handling of discrete values-> at the bottom.
For non-bool discrete values, is the DPDETAIL_RANGETYPE_MATCH still the way to specify discrete alarms???
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: create a discrete alarm in script
Yes, the example is actually for non-bool values. It is a workaround to get a discrete alert handling on boolean values, because in the para it cannot be configured.
- tmalone
- Posts:192
- Joined: Mon Nov 22, 2010 11:21 pm
Re: create a discrete alarm in script
Here is a clean example:
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);
}
}
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);
}
}
- AMRPatricio
- Posts:61
- Joined: Mon Dec 12, 2016 4:43 pm
Re: create a discrete alarm in script
Hi All,
I am trying to do something similar but I am having the following warning:
WCCOAui (1), 2018.06.04 18:34:07.391, PARAM,WARNING, 31, Config type change failed, DP: System1:TestDP_1.element:_alert_hdl.._type, MAN: (SYS: 1 Ui -num 1 CONN: 1)
I am trying to change via script the "limits" associated with a alert_config that is already created. Do I need to delete the config and create it again or it is enough if I disable the config and then put it as active again after the change is done?
Any help?
Thanks,
Antonio
I am trying to do something similar but I am having the following warning:
WCCOAui (1), 2018.06.04 18:34:07.391, PARAM,WARNING, 31, Config type change failed, DP: System1:TestDP_1.element:_alert_hdl.._type, MAN: (SYS: 1 Ui -num 1 CONN: 1)
I am trying to change via script the "limits" associated with a alert_config that is already created. Do I need to delete the config and create it again or it is enough if I disable the config and then put it as active again after the change is done?
Any help?
Thanks,
Antonio
- adaneau
- Posts:310
- Joined: Tue Feb 21, 2012 9:49 am
Re: create a discrete alarm in script
Hi,
If you want to change an alert hdl settings, you need first to ack all instances of alarms for this config, then deactivate . change and reactivate.
Also be aware that changing from continuous to discrete will also implies that all parameters must be changed accordingly
BR
Alex
If you want to change an alert hdl settings, you need first to ack all instances of alarms for this config, then deactivate . change and reactivate.
Also be aware that changing from continuous to discrete will also implies that all parameters must be changed accordingly
BR
Alex