How to set value of the alarm limit (_alert_hdl.._u_limit\") from the text field input?

Find and share HowTos to various installations / configurations!
3 posts • Page 1 of 1
Hana
Posts:6
Joined: Tue May 29, 2012 11:13 am

How to set value of the alarm limit (_alert_hdl.._u_limit\") from the text field input?

Post by Hana »

Hello,
please can anyone help me to set the value of the alarm limit (_alert_hdl.._u_limit") from the text field input?

I am using following script trying to change the limit value of datapoint (RMT02_S1:02_Arrivals.Usage.runningCapacity) by editin text field "NewAlarm_RunCap"

The script it placed on the "Clicked" action of a button.
----------------------------------
main()
{
float fNewValue;
float fOldValue;
dyn_errClass err;

getValue("NewAlarm_RunCap","text", fNewValue);
DebugN("NewAlarm_RunCap - fNewValue=" + fNewValue);

dpGet("RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.2._u_limit", fOldValue);
DebugN(fOldValue);
dpGet("RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.2._type", fOldValue);
DebugN(fOldValue);
dpGet("RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.2._u_incl",fOldValue);
DebugN(fOldValue);


dpSetTimedWait(0, "RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.._active", FALSE);
//dpSet("RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.._active", FALSE);
DebugN("_active set FALSE");
dpSet("RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.2._u_limit", fNewValue);
//dpSetTimedWait(0, "RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.._active", TRUE);

err = getLastError();

if(dynlen(err)>0)
{
throwError(err);
DebugN(err);
}
}
------------------------

After debugging it I get the following result:
WCCOAui17:["NewAlarm_RunCap - fNewValue=62"]
WCCOAui17:[60]
WCCOAui17:[4]
WCCOAui17:[0]
WCCOAui17:["_active set FALSE"]

the alarm is acknowledged and the alert_hdl gets de-activated, but the limit is never set to the new value.

I tried different combinations of dpSet, dpSetWait, dpSetTimedWait, but non of the commands is responding.

Please can anyone advice me what I am doing wrong? Is it problem of data type or am I missing some settings/pre-conditions?
Thank you in advance!

Hana

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: How to set value of the alarm limit (_alert_hdl.._u_limit\") from the text field input?

Post by leoknipp »

Hello,

if the limit for a threshold shall be changed two attributes need to be set.
The upper limit for one range (_alert_hdl.._u_limit) and the lower limit for the next range (_alert_hdl.._l_limit).

Also you have to acknowledge pending alerts for the given dp-element before you can set it inactive.
If the configuration is possible can be detected by reading the attribute _alert_hdl.._param.

Can you please modify the script and check if it works.

Best Regards
Leopold Knipp
Senior Support Specialist

Hana
Posts:6
Joined: Tue May 29, 2012 11:13 am

Re: How to set value of the alarm limit (_alert_hdl.._u_limit\") from the text field input?

Post by Hana »

Thank you Leopold,
after few hours we finally worked it out :)

So if is anyone interested - I am included our example below:

main()
{
float fNewValue; // Warning (low)
float fUpperLimit; // Warning (low)
float fLowerLimit; // Alarm (low low)
int iAckState;
string sTextFieldUpper = "NewWarn_RunCap";
string sTextFieldLower = "NewAlarm_RunCap";
string dpe = "RMT02_S1:02_Arrivals.Usage.runningCapacity";


getValue(sTextFieldUpper, "text", fNewValue); // get the new value from the text field

// if text field has new value - update the limits
if (fNewValue != 0)
{
// if un-Acknowledged -> Acknowledge the alarm
dpGet(dpe+":_alert_hdl.._ack_state", iAckState);
if (!iAckState)
dpSet(dpe+":_alert_hdl.._ack", 1);

// deactivate the alarm
dpSetTimedWait(0, dpe+":_alert_hdl.._active", FALSE);


//------------------------------------------------------------------------------------------------------------------
// Note: the lower limit must be lower than the upper limit & the upper limit must be higher than the lower limit!
// always set combination of two limits: for upper limit (_alert_hdl.2._u_limit) & (_alert_hdl.3._l_limit)
// for lower limit (_alert_hdl.1._u_limit) & (_alert_hdl.2._l_limit)

dpSet( dpe+":_alert_hdl.2._u_limit", fNewValue,
dpe+":_alert_hdl.3._l_limit", fNewValue);
//dpe+":_alert_hdl.1._u_limit", fNewValue,
//dpe+":_alert_hdl.2._l_limit", fNewValue);

//------------------------------------------------------------------------------------------------------------------

// Activate the alarm
dpSetTimedWait(0, "RMT02_S1:02_Arrivals.Usage.runningCapacity:_alert_hdl.._active", TRUE);
}
}

3 posts • Page 1 of 1