I have a gateway tag event script that when triggered, populates Tag A with a value, and then triggers tag B Boolean for another system to read it.
The issue I am running into is that even though I am using writeBlocking, the tag A isn't updating fast enough and when Tab B boolean is triggered, Tag A is still showing the previous value when its read.
I validated this using time.sleep with a 1 second delay. I know Time.sleep is frowned upon, what do you recommend using to delay between two tag writes by 500ms or 1s?
I saw an older post where they created a while loop in between, passed in the current time and it exited after 1 sec had passed but that doesn't feel write (Pun intended).
Any suggestions? Thanks!
Are these OPC tags?
If so, then the easiest path would be to use system.opc.writeValue and system.opc.ReadValue instead of system.tag.read/write.
This will ensure that you are getting the actual value from the PLC outside of any scan class timing issues you might be seeing.
When you say another system reading it, how is that system connected? Does it read from the Ignition Tag or the PLC?
There are Ignition memory tags and the other system is connected through an exposed tag provider, it watches the boolean to go true and then reads the value tag. I will try the opc read and see how it goes. Thanks
If they are memory tags than OPC won't work.
I am having a hard time understanding why a memory tag write would not be immediately available with the new value being written though.
What type of scan class do you have the memory tag on?
Can you add the delay inside the other system (presumably a PLC)? "Other system" sees the boolean change, waits, then reads the value you're wanting it to read?
Another question, why do it this way at all? Just have the other system store the previous value on change and then do whatever you're wanting to do.