Gateway script not working for system.tag.writeblocking

I am trying to organize Maintenance tags into separate groups for Urgent alarm, High alarm, and Low alarm within the gateway script. From there, I aimed to suppress the High and Low alarm sounds when the Urgent alarm sound is active, and similarly suppress the Low alarm sound when the High alarm sound is active.

For example, when an urgent alarm sound is triggered through a Boolean memory tag managed by the gateway tag script, it is intended to deactivate the other Boolean memory tags designated for High alarm sound and Low alarm sound using the same gateway tag script at this instance. However, the current behavior of the gateway script (as provided below) shows that it toggles the High and Low alarm memory tags on and off during each scan when the urgent alarm memory tag is activated, which is not the desired outcome.

Can anyone have a look at the attached script and let me know if anything is missing in the attached gateway tag script?

Also is there a way to enable/disable a gateway tag script from a different gateway tag script?

image

I don't know about the problem you are asking about but all your tag readBlocking() should be executed in the one statement and same with your writeBlocking().

If you post formatted code (rather than a picture of code) we can copy and edit in our answers. See Wiki - how to post code on this forum.

I have got it to work halfway through to my configuration. Basically, to summarise what I did till now - I have 3 Boolean tags for sound (one for low alarm buzzer, one for high alarm buzzer and one for urgent alarm buzzer), and I have 3 gateway scripts running to write to the 3 Boolean tags. The gateway script is checking if a high alarm is present, to suppress low alarm and if critical alarm is present to suppress low and high alarm, it works now.

The other thing I am struggling with is make the gateway tag script to write to a memory Boolean tag a value of "0" when the system reads a value of "0" from the system tag "[System]Gateway/Alarming/Active and Unacked", but this doesn't seem to be working.

I am uploading the script here; can someone have a look and tell me why a value is not writing. Please note "Ackn" is a Boolean memory tag.

Ack = system.tag.readBlocking("[System]Gateway/Alarming/Active and Unacked")[0].getValue()

if (Ack is "0"):
	system.tag.writeBlocking("[default]Alarm Tags/Ackn", 0)

I'd say that's your mistake.
A few things:

  • is checks the identity of something. It doesn't check if they're equal, but if they refer to the same item.
    As a rule of thumb, use is for None or when you do want to compare identities.
    Note: You CAN use is for some number. I don't remember exactly up to which number, but a certain number of them are actually preloaded singletons. So you COULD use Ack is 0. But I don't recommend this, because for example Ack is 983 might not work. It makes the use of the operator inconsistent, for gains that you will never notice.
  • For all other comparison, you should be using == instead of is
  • Putting quotes around a number makes it a string, not a number. You want Ack == 0.
  • For booleans, use True and False. This makes it obvious that they're booleans
4 Likes