Setting multiple tag values when a button is pressed

Hello,

I am trying to set multiple tag values when a button is pressed in vision. I’m having trouble with my script running and couldn’t find any examples to reference. I appreciate any pointers

paths = ["event.source.parent.ForceOpen", "event.source.parent.ForceClosed"]
values = [1, 0]
system.tag.writeAll(paths, values)

ForceOpen and ForceClosed are custom properties I created.

Custom properties are not tags so I doubt that you can use system.tag.writAll() to alter them.
Try:

event.source.parent.ForceOpen = 1
event.source.parent.ForceClosed = 0
1 Like

Thanks for your reply. I tried the code suggested and it does change the state for the ForceClosed and ForcedOpen tags in the template properties but it doesn’t change the state for the actual tags shown in the tag browser. I created an additional pop up window where I used the code below and that worked perfectly, however, a template would be easier to maintain rather than dozens of individual popup windows. Does anything stand out for what I’m doing wrong? Or is there a better way to do this?

Code that worked for individual windows.
Force Open:

system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force On"], [1])
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force Off"], [0])

Forced Closed:

system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force On"], [0])
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force Off"], [1])

Auto:

system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force On"], [0])
system.tag.writeBlocking(["[default]Reactor Room/HMI Tags/Valves/R230 Valves/XV-1416 Vent Valve Force Off"], [0])

Code I tried for template that I’m trying to get to work.
Force Open:

event.source.parent.ForceOpen = 1
event.source.parent.ForceClosed = 0

Forced Closed:

event.source.parent.ForceOpen = 0
event.source.parent.ForceClosed = 1

Auto:

event.source.parent.ForceOpen = 0
event.source.parent.ForceClosed = 0

Are the bindings on the custom properties set to bi-directional?

2 Likes

Make sure the bindings are set for bidirectional.

2 Likes

Also, don’t make two calls to writeBlocking back-to-back–put both tags in one call. That’s why the args to it are lists.

2 Likes