Hi, I am working in Ignition Perspective and I want to turn an OPC UA Boolean tag ON only for 2 seconds when a button is pressed, and then turn it OFF automatically.
I wrote this script under Button → onActionPerformed → runAction:
Safe if only one user can push the button. And you disable the button to prevent multiple close presses. Not recommended.
Yes.
There is no good way to do this from a message-based multi-user SCADA.
The right answer is to have the target device turn the signal off after two seconds. So that no second message is required. A common flaw encountered with this pattern is a failure or disruption of the second message, leaving the process in a bad state. (Very similar to the problems with momentary buttons.)
If I absolutely had to do this, I'd use a gateway timer event to run PLC-ish logic to write the "off" message repeatedly if there are errors.
I’d make a button that writes (1) to your tag and writes the current time to a memory tag. Have a gateway event that checks the value of your tag. If it’s 1, check the timestamp tag vs the current time. If enough time has elapsed write it back to 0. If it’s 0, do nothing.
Could add a 3rd tag for the time setpoint if you want.
Of course, like Phil said this would ideally be done in the PLC.
Would be cool it there was a way to entirely disable/enable the gateway script based on the target tag’s value.
The best approach with the least overhead is to make one gateway timer event containing all such logic in your system.
Have it do a single system.tag.readBlocking() at the beginning to get all tag values of interest. Conditionally call subroutines based on current states. Assemble two lists, of tag paths and values, to include in a singlesystem.tag.writeAsync() at the end of the event script's library function.
Yes for Vision, but Being perspective, no script action will block the gui since perspective clients run in the gateway and use multiple spawned worker threads to execute user action scripts along with everything else it needs (I'm not explaining that to you btw Phil, since you can do a far better job than I can haha, but to the OP)