Alarm queryStatus

I hope someone can help.
What im trying to do is when ignition gets a priority high alarm i write a boolean to a PLC.
Im using Ignition version 8, and im writing the script in Gateway Events.
Here is what i have tried
x = system.alarm.queryStatus(priority=[“High”])
if x == 1:

I get no errors on the script and it does not work.
What am i doing wrong.

Your script should be doing the else everytime with how you wrote it. “x” will never equal 1, that function returns a list. Try doing:

x = system.alarm.queryStatus(priority=["High"])
if x:

When a high priority alarm is there then “x” will be true, when no alarms are active it will return an empty list making x false and running your else fucntion.

Thank you for the replay bpreston, I tried the change but it still does not work.

Just keeps writing a 1 to the tag, when there is no alarm.

A list will always return true, even if it’s empty.

x = system.alarm.queryStatus(priority=["High"])

if len(x) > 0:

system.tag.write() is deprecated. Consider using system.tag.writeBlocking

Alternatively, if you want a count of how many are high:

x = system.alarm.queryStatus(priority=["High"])
system.tag.writeBlocking(["[default]PicaVessel/V1_ALARM_Hi"], [len(x)])

Hi Jordan, thank you for the reply.
I changed it to, if len(x) > 0:
This still is writing a 1 when there are no alarms

Try it in your script console to see what it returns while using print’s. I’m on 7.9 and it works for me, it should work on 8.0 without any issues too. I would start out printing x to see what it returns then use print statements inside of your if to see what it returns.

try printing x and see what returns.

This is what im getting for the value of x

[{Source: ‘prov:default:/tag:PicaVessel/TAH0201B/FLT:/alm:TAH0201B_FLT’, Display Path: ‘’, UUID: ‘68d1dde0-6cd7-41e9-a7f2-de287fcc3867’, Current State: ‘Cleared, Acknowledged’, Priority: ‘High’, Active Data: {setpointA=1.0, eventValue=false, systemAck=true, name=TAH0201B_FLT, eventTime=Fri Aug 07 12:17:29 EDT 2020, priority=High}, Clear Data: {eventTime=Fri Aug 07 12:17:29 EDT 2020}, Ack Data: {eventTime=Fri Aug 07 12:17:29 EDT 2020}, Runtime Data: {isInitialEvent=true}}, {Source: ‘prov:default:/tag:PicaVessel/TAH0201A/FLT:/alm:TAH0201A_FLT’, Display Path: ‘’, UUID: ‘7143f77f-4489-453f-896f-4be0b3514d6c’, Current State: ‘Cleared, Acknowledged’, Priority: ‘High’, Active Data: {setpointA=1.0, eventValue=true, name=TAH0201A_FLT, eventTime=Mon Aug 10 12:12:30 EDT 2020, priority=High}, Clear Data: {setpointA=1.0, eventValue=false, name=TAH0201A_FLT, eventTime=Mon Aug 10 14:38:05 EDT 2020, priority=High}, Ack Data: {setpointA=1.0, ackUser=usr-prov:PicaVessel_Users:/usr:admin, name=TAH0201A_FLT, eventTime=Mon Aug 10 14:59:34 EDT 2020, priority=High}, Runtime Data: {isJournaled=false}}]

Well, there you go. :wink:

You’ll also want to add the actual status of the alarms.

x = system.alarm.queryStatus(priority=["High"], state = ["ActiveUnacked", "ActiveAcked"])

Thank you Jordan that did the trick.
Thank you very much for your help and for this forum.