V 10
1
LANG:1 8 (NoName)
PANEL,454 126 290 260 N "_3DFace" 0
EEE E E 1 -1 -1 0  260 160
"" 0 1
EE 2
"CBRef""1"
"EClose"E
""
DISPLAY_LAYER, 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
LAYER, 0 
1
LANG:1 6 Layer1
13 5
"Button2"
""
1 110 540 E E E 1 E 1 E N "_3DText" E N {102,204,255} E E
 E E
6 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-140-100-100-*-*-iso8859-1|-16,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
28 168 262 232
T 
1
LANG:1 19 Read Alert Settings
"//Function Load_Alerts()
main()
{
string dpName;
dpName = getSystemName() + \"TestDP_1.element\";
getAlarms(dpName); 
}
 
void getAlarms(string dpName)
{
string alert_low, warning_low, normal, warning_high, alert_high;
string  alert1, alert2, alert3, alert4, alert5;
int type, type1, type2, type3, type4, type5, ack;
bool u1, u2, u3, u4, l2, l3, l4, l5, num_ranges, orig, active;
float u1_limit, l2_limit, u2_limit, l3_limit, u3_limit, l4_limit, u4_limit, l5_limit; 

    dpGet(dpName + \":_alert_hdl.._type\", type);
    dpGet(dpName + \":_alert_hdl.1._type\", type1);
    dpGet(dpName + \":_alert_hdl.2._type\", type2);
    dpGet(dpName + \":_alert_hdl.3._type\", type3);
    dpGet(dpName + \":_alert_hdl.4._type\", type4);
    dpGet(dpName + \":_alert_hdl.5._type\", type5);
    
    dpGet(dpName + \":_alert_hdl.1._u_limit\", u1_limit); 
    dpGet(dpName + \":_alert_hdl.2._l_limit\", l2_limit); 
    dpGet(dpName + \":_alert_hdl.2._u_limit\", u2_limit); 
    dpGet(dpName + \":_alert_hdl.3._l_limit\", l3_limit); 
    dpGet(dpName + \":_alert_hdl.3._u_limit\", u3_limit); 
    dpGet(dpName + \":_alert_hdl.4._l_limit\", l4_limit); 
    dpGet(dpName + \":_alert_hdl.4._u_limit\", u4_limit); 
    dpGet(dpName + \":_alert_hdl.5._l_limit\", l5_limit); 

    dpGet(dpName + \":_alert_hdl.1._u_incl\", u1); 
    dpGet(dpName + \":_alert_hdl.2._l_incl\", l2);
    dpGet(dpName + \":_alert_hdl.2._u_incl\", u2);
    dpGet(dpName + \":_alert_hdl.3._l_incl\", l3);
    dpGet(dpName + \":_alert_hdl.3._u_incl\", u3);
    dpGet(dpName + \":_alert_hdl.4._l_incl\", l4);
    dpGet(dpName + \":_alert_hdl.4._u_incl\", u4);
    dpGet(dpName + \":_alert_hdl.5._l_incl\", l5);

    dpGet(dpName + \":_alert_hdl.1._text\", alert1);
    dpGet(dpName + \":_alert_hdl.2._text\", alert2);
    dpGet(dpName + \":_alert_hdl.3._text\", alert3);
    dpGet(dpName + \":_alert_hdl.4._text\", alert4);
    dpGet(dpName + \":_alert_hdl.5._text\", alert5);

    dpGet(dpName + \":_alert_hdl.1._class\", alert_low);
    dpGet(dpName + \":_alert_hdl.2._class\", warning_low);
    dpGet(dpName + \":_alert_hdl.4._class\", normal);
    dpGet(dpName + \":_alert_hdl.4._class\", warning_high);
    dpGet(dpName + \":_alert_hdl.5._class\", alert_high);
    
    dpGet(dpName + \":_alert_hdl.._orig_hdl\", orig);
    dpGet(dpName + \":_alert_hdl.._active\", active);
    dpGet(dpName + \":_alert_hdl.._num_ranges\", num_ranges);
    dpGet(dpName + \":_alert_hdl.._ack\", ack); 
 
 DebugN(\"Active ranges: \",type, type1, type2, type3, type4, type5,
 		\"\\nlimits: \", u1_limit, l2_limit, u2_limit, l3_limit, u3_limit, l4_limit, u4_limit, l5_limit,
 		\"\\ncons: \",	u1, l2,  u2,  l3,  u3, l4,  u4,  l5,
 		\"\\ntext: \",	alert1, alert2, alert3, alert4, alert5,
 		\"\\nclasses: \", alert_low, warning_low, normal, warning_high, alert_high,
 		\"\\norig_value: \", orig,
 		\"\\nactive: \", active,
 		\"\\nnum_ranges: \", num_ranges,
 		\"\\nack: \", ack);
}
" 0
 E E E
13 6
"Button5"
""
1 410 500 E E E 1 E 1 E N "_3DText" E N {102,204,255} E E
 E E
7 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-140-100-100-*-*-iso8859-1|-16,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
28 98 262 162
T 
1
LANG:1 10 Set Alerts
"//Function Load_Alerts()
main()
{
string dpName;
dpName = getSystemName() + \"Crate00.Channel00.LVchStat.Recv\";
addAlarm (dpName); 
}
 
addAlarm (string dpename) {
	string prefix = dpename+\":_alert_hdl.\";
	dyn_errClass err;
	int rc, type;
	bool ok;
	dyn_string 	rangeTexts 		= makeDynString (\"Data is fatal Low\", \"Data is warn. Low\", \"Data is Normal\", \"Data is warn. High\", \"Data is fatal High\");
	dyn_string 	rangeClasses 	= makeDynString (\"alert.\", \"warning.\", \"\", \"warning.\", \"alert.\");



	// check if the alarm already exists
	rc = dpGet (prefix+\"._type\", type);
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to check whether alarm already exists for dpe: \"+dpename+\" : \"+rc);
		throwError (err);
		return;
	}

	// if it exists, deactivate the alarm handling (so we can change it)
	if (type != DPCONFIG_NONE) {
		dpDeactivateAlert (dpename, ok);		
		if ( ! ok) {
			DebugN(\"Failed to deactivate alarm on dpe: \"+dpename);
			return;
		}
	}
	
	// configure the alarm
	rc = dpSetWait (prefix+\"._type\", DPCONFIG_ALERT_NONBINARYSIGNAL, // equal to 13!

					prefix+\"1._type\", DPDETAIL_RANGETYPE_MINMAX, // equal to 4!
					prefix+\"1._u_limit\", 15,
					prefix+\"1._l_incl\", TRUE,
					prefix+\"1._u_incl\", FALSE,
					prefix+\"1._text\",  rangeTexts [1],
					prefix+\"1._class\", rangeClasses [1],

					prefix+\"2._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"2._l_limit\", 15,
					prefix+\"2._u_limit\", 25,
					prefix+\"2._l_incl\", TRUE,
					prefix+\"2._u_incl\", FALSE,
					prefix+\"2._text\", rangeTexts [2],
					prefix+\"2._class\", rangeClasses [2],

					prefix+\"3._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"3._l_limit\", 25,
					prefix+\"3._u_limit\", 35,
					prefix+\"3._l_incl\", TRUE,
					prefix+\"3._u_incl\", FALSE,
					prefix+\"3._text\", rangeTexts [3],
					prefix+\"3._class\", rangeClasses [3],

					prefix+\"4._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"4._l_limit\", 35,
					prefix+\"4._u_limit\", 45,
					prefix+\"4._l_incl\", TRUE,
					prefix+\"4._u_incl\", FALSE,
					prefix+\"4._text\", rangeTexts [4],
					prefix+\"4._class\", rangeClasses [4],

					prefix+\"5._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"5._l_limit\", 45,
					prefix+\"5._l_incl\", TRUE,
					prefix+\"5._u_incl\", FALSE,
					prefix+\"5._text\", rangeTexts [5],
					prefix+\"5._class\", rangeClasses [5],

					prefix+\"._orig_hdl\", TRUE);
			
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to set alarm on dpe: \"+dpename+\" : \"+rc);
		throwError (err);
		return;
	}
	
	//activate the alarm handling
	dpActivateAlert (dpename, ok);		
	if ( ! ok) {
		DebugN(\"Failed to activate alarm on dpe: \"+dpename);
		return;
	}
}
" 0
 E E E
13 7
"Button6"
""
1 440 590 E E E 1 E 1 E N "_3DText" E N {102,204,255} E E
 E E
8 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-140-100-100-*-*-iso8859-1|-16,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
28 28 262 92
T 
1
LANG:1 13 Delete Alerts
"//Function Load_Alerts()
main()
{
string dpName;
dpName = getSystemName() + \"TestDP_1.element\";
addAlarm (dpName); 
}
 
addAlarm (string dpename) {
	string prefix = dpename+\":_alert_hdl.\";
	dyn_errClass err;
	int rc, type;
	bool ok;

	// check if the alarm already exists
	rc = dpGet (prefix+\"._type\", type);
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to check whether alarm already exists for dpe: \"+dpename+\" : \"+rc);
		throwError (err);
		return;
	}

	// if it exists, deactivate the alarm handling (so we can change it)
	if (type != DPCONFIG_NONE) {
		dpDeactivateAlert (dpename, ok);		
		if ( ! ok) {
			DebugN(\"Failed to deactivate alarm on dpe: \"+dpename);
			return;
		}
	}
}" 0
 E E E
0
LAYER, 1 
1
LANG:1 6 Layer2
0
LAYER, 2 
1
LANG:1 6 Layer3
0
LAYER, 3 
1
LANG:1 6 Layer4
0
LAYER, 4 
1
LANG:1 6 Layer5
0
LAYER, 5 
1
LANG:1 6 Layer6
0
LAYER, 6 
1
LANG:1 6 Layer7
0
LAYER, 7 
1
LANG:1 6 Layer8
0
0