I need to change a Boolean value via OPC with oneshot behavior. I need the button when clicking a pulse and return to zero, I tested some alternatives that didn't suit me like button (configure events) one click, script:
system.tag.writeBlocking(["Deviations/Pulse"], [1])
system.util.getGlobals().sleep(500)
system.tag.writeBlocking(["Deviations/Pulse"], [0])
I had to set up something recently where clicking a button would enable an OPC connection for 10 minutes, then automatically turn it off. I wanted to also be able to override the behavior.
I ended up making a boolean memory tag that I toggle with the button click.
A change script on the boolean memory tag enables the OPC device and updates a date memory tag with the current timestamp.
I also have an expression tag, and as long as the boolean memory tag is True, the expression tag takes 600 minus the time difference in seconds between the date memory tag and the current timestamp polling every second.
When the expression tag's value reaches 0, a property change script disables the OPC device and resets the boolean and date memory tags.
Sorry if my explanation is a little clumsy. Let me know if you need more info.