Hello,
I have dp with discrete alarm handling and want to read configured alarm levels.
When I try use dpGet with: myDPname+":..alarm_hdl_..set", I get an empty table ( 0 items) even for config "_num_ranges"
returns correct value (5).
What am I doing wrong?
Regards
Adam
Problem reading discrete alarm ranges
- dbindernagel
- Posts:161
- Joined: Mon Feb 23, 2015 1:34 pm
Re: Problem reading discrete alarm ranges
Not sure if this is just a typo in your forum post but there are some errors in your config.
1. The config is called "_alert_hdl" not "_alarm_hdl".
2. There should be no dots (..) between the datapoint name and the config.
3. There is an error between the config and the attribute: "_..set" should be ".._set".
Try this:
myDPname+":_alert_hdl.._set"
1. The config is called "_alert_hdl" not "_alarm_hdl".
2. There should be no dots (..) between the datapoint name and the config.
3. There is an error between the config and the attribute: "_..set" should be ".._set".
Try this:
myDPname+":_alert_hdl.._set"
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: Problem reading discrete alarm ranges
The _set attribute is set for every range.
If you want to get the configuration for a specific range you have to use the detail number: _alert_hdl.´<range>._set.
Best Regards
Leopold Knipp
Senior Support Specialist
If you want to get the configuration for a specific range you have to use the detail number: _alert_hdl.´<range>._set.
Best Regards
Leopold Knipp
Senior Support Specialist
- ask
- Posts:28
- Joined: Tue Nov 29, 2016 11:37 am
Re: Problem reading discrete alarm ranges
Of course I made mistakes during typing post. Sorry.
But:
When I want to get configuration for specific range using for example: "_alert_hdl.2._set" (it should be int)
I got an error message:
WCCOAui (7), 2019.11.07 08:44:12.287, IMPL, WARNING, 50, Default branch called, IntegerVar, operator=, cannot assign variable of type DYNINTEGER_VAR
So I used dyn_int instead int using this script:
main(mapping event)
{
int nr,typ,level;
string txt,dp=T.text()+".state.position";
dyn_int set;
dpGet(dp+":_alert_hdl.._num_ranges",nr);
dpGet(dp+":_alert_hdl.._set",set);
DebugN("number of levels:",nr);
DebugN("levels set:",set);
for(int i=0;i<=nr;i++)
{
dpGet(dp+":_alert_hdl."+i+"._text",txt);
dpGet(dp+":_alert_hdl."+i+"._type",typ);
dpGet(dp+":_alert_hdl."+i+"._set",set);
dpGet(dp+":_alert_hdl."+i+"._set",level);
DebugN(dp,"level",i,"text",txt,"type",typ,"set",set);
}
}
and I got:
WCCOAui7:["number of levels:"][7]
WCCOAui7:["levels set:"][dyn_int 0 items WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][0]["text"][""]["type"][13]["set"][dyn_int 0 items WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][1]["text"][""]["type"][5]["set"][dyn_int 0 items WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][2]["text"]["POSITION FAULT"]["type"][3]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][3]["text"]["CLOSED"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][4]["text"]["OPEN"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][5]["text"]["OPENING"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][6]["text"]["CLOSING"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][7]["text"]["INTERMEDIATE"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
For almost every level I got the same list of values and the sequence of this values is incorrect beacause real configuration is:
level=7 value=0 text="INTERMEDIATE"
level=6 value=8 text="CLOSING"
level=5 value=4 text="OPENING"
level=4 value=2 text="OPEN"
level=3 value=1 text="CLOSED"
level=2 value!=0,1,2,3,4,8 text="POSITION FAULT"
level=1 without assigned value
So I still cannot read/get value for specific level or list of values with correct sequence.
What I am doing wrong?
Regards
Adam
But:
When I want to get configuration for specific range using for example: "_alert_hdl.2._set" (it should be int)
I got an error message:
WCCOAui (7), 2019.11.07 08:44:12.287, IMPL, WARNING, 50, Default branch called, IntegerVar, operator=, cannot assign variable of type DYNINTEGER_VAR
So I used dyn_int instead int using this script:
main(mapping event)
{
int nr,typ,level;
string txt,dp=T.text()+".state.position";
dyn_int set;
dpGet(dp+":_alert_hdl.._num_ranges",nr);
dpGet(dp+":_alert_hdl.._set",set);
DebugN("number of levels:",nr);
DebugN("levels set:",set);
for(int i=0;i<=nr;i++)
{
dpGet(dp+":_alert_hdl."+i+"._text",txt);
dpGet(dp+":_alert_hdl."+i+"._type",typ);
dpGet(dp+":_alert_hdl."+i+"._set",set);
dpGet(dp+":_alert_hdl."+i+"._set",level);
DebugN(dp,"level",i,"text",txt,"type",typ,"set",set);
}
}
and I got:
WCCOAui7:["number of levels:"][7]
WCCOAui7:["levels set:"][dyn_int 0 items WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][0]["text"][""]["type"][13]["set"][dyn_int 0 items WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][1]["text"][""]["type"][5]["set"][dyn_int 0 items WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][2]["text"]["POSITION FAULT"]["type"][3]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][3]["text"]["CLOSED"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][4]["text"]["OPEN"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][5]["text"]["OPENING"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][6]["text"]["CLOSING"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
WCCOAui7:["A000_HVA04.state.position"]["level"][7]["text"]["INTERMEDIATE"]["type"][5]["set"][dyn_int 5 items
WCCOAui7: 1: 0
WCCOAui7: 2: 1
WCCOAui7: 3: 2
WCCOAui7: 4: 4
WCCOAui7: 5: 8
WCCOAui7:]
For almost every level I got the same list of values and the sequence of this values is incorrect beacause real configuration is:
level=7 value=0 text="INTERMEDIATE"
level=6 value=8 text="CLOSING"
level=5 value=4 text="OPENING"
level=4 value=2 text="OPEN"
level=3 value=1 text="CLOSED"
level=2 value!=0,1,2,3,4,8 text="POSITION FAULT"
level=1 without assigned value
So I still cannot read/get value for specific level or list of values with correct sequence.
What I am doing wrong?
Regards
Adam
- dbindernagel
- Posts:161
- Joined: Mon Feb 23, 2015 1:34 pm
Re: Problem reading discrete alarm ranges
I may be wrong about this but it seems you need to use the attribute "_match" if only a single value is set for the range and "_set" if multiple values are set. You can use the "_type" attribute to find out which to use.
There may be more cases to consider, I'm not sure.
Also be aware that "_match" returns a string and not an int.
This returns the following for me.
There may be more cases to consider, I'm not sure.
Also be aware that "_match" returns a string and not an int.
Code: Select all
int num_ranges;
dpGet("Test01.value01:_alert_hdl.._num_ranges", num_ranges);
DebugN("Ranges", num_ranges);
for (int i = 1; i <= num_ranges; i++)
{
string alert_text;
int alert_type;
string alert_set;
dpGet("Test01.value01:_alert_hdl." + i + "._text", alert_text,
"Test01.value01:_alert_hdl." + i + "._type", alert_type);
if (alert_type == 3)
{
dyn_int temp;
dpGet("Test01.value01:_alert_hdl." + i + "._set", temp);
alert_set = strjoin(temp, ",");
}
else if (alert_type == 5)
{
dpGet("Test01.value01:_alert_hdl." + i + "._match", alert_set);
}
DebugN("Range: "+i, alert_text, alert_type, alert_set);
}
Code: Select all
WCCOAui1:["Ranges"][7]
WCCOAui1:["Range: 1"][""][5]["*"]
WCCOAui1:["Range: 2"]["POSITION FAULT"][3]["0,1,2,4,8"]
WCCOAui1:["Range: 3"]["CLOSED"][5]["1"]
WCCOAui1:["Range: 4"]["OPEN"][5]["2"]
WCCOAui1:["Range: 5"]["OPENING"][5]["4"]
WCCOAui1:["Range: 6"]["CLOSING"][5]["8"]
WCCOAui1:["Range: 7"]["INTERMEDIATE"][5]["0"]
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: Problem reading discrete alarm ranges
If you want to see which attributes are set for the _alert_hdl config you can
-- make an ASCII export for the dp element with the filter P + _alert_hdl
-- open the ASCII file in Excel (tab limited text file)
Then you can modify your script to read the same attributes with the correct detail number.
Best Regards
Leopold Knipp
Senior Support Specialist
-- make an ASCII export for the dp element with the filter P + _alert_hdl
-- open the ASCII file in Excel (tab limited text file)
Then you can modify your script to read the same attributes with the correct detail number.
Best Regards
Leopold Knipp
Senior Support Specialist