I would like to be able to access the Setpoint value of my alarm configurations to show what it is currently set at. I really would like to be able to show it in an alarm table. Currently i can show what the current value of the tag is and that it is in alarm but i can’t display what the alarm limit is. Is there anyway to get the value out without have to make a new memory tag for every alarm setpoint i want to see/edit during runtime?
How are you trying to access it? Through the tag tree? Or in the Alarm Configuration?
I’m curious if you are showing the current value of the tag when it alarms in the alarm display path, and if so how.
We can edit the alarm configuration via scripting, but it does not look like we can view the current configuration.
I do something similar by creating a UDT with both the value tag (OPC tag) and the alarm setpoints (as memory tags) with the alarms already setup. Then I can store history on the alarm setpoints or at least see their current values. If you use the same UDT for a number of different values, then you can also use a single popup to allow users to set alarm setpoint values from the client. Just pass in the UDT or its location.
alarms = system.tag.getAlarmStates(tag_path) if len(alarms) > 0: for a in alarms: props = a.getAlarmProperties() for index in range(len(props)): if 'setpoint' in props[index].property.lower(): print str(props[index].value)
After re-visiting this code I realize now that I could have written it like this:
alarms = system.tag.getAlarmStates(tag_path) for a in alarms: props = a.getAlarmProperties() for p in props: if 'setpoint' in p.property.lower(): print p.property, p.value
Thanks for the reply. I have made this work using the above code and it is fine. My next issue is that some of the parameters i want to read are the default value. ex Enabled = true. According to the documentation the getAlarmProperties will not read any values that are the default. It took me a while but i made a work around by setting my variable for enable to true and then if it finds it as false it will set it to zero. Just the opposite way to look at the values i guess. Definitely will need to revisit this issue on next project. The fact that i am using this data in a popup with passed in parameters doesn’t make it any easier. Picture below shows the popup i am using. Again, thanks for all the help.
Thanks for the code snippet.
I have a similar situation where the customer wants to be able to dynamically adjust alarm setpoints. We ended up using a UDT with memory tag values on the UDT. Those memory tags are then bound to alarm sp’s indirectly so every instance of the UDT derives its alarm sp from the UDT subtag for that parameter. Part of why we did it this way was so that we could tie our animations to tags.
Regardless, it’s good to know how to read these values with a script also.
We used to do that as well. Now we allow users to edit the set point on the UDT instance using the Ignition client.
For the record, you can edit any of the alarm properties, including set points through scripting. The trick is that you have to read ALL of the alarm properties for the tag, change the value for the property that you want to change and then write all of the properties back to the tag.
I am trying to modify this script to view an alarm setpoint that is set via a script number field. I want to have the script refresh the value when mouse clicked to let the operator know if the alarm value has changed. But am having issues getting it to work.
alarms = system.tag.getAlarmStates("myTagPath") for a in alarms: props = a.getAlarmProperties() for p in props: if 'setpointB' in p.property(): p.value="intValue"