If I have a series of system.tag.writeBlocking and/or system.tag.readBlocking in a script, does the function blocks the execution of the script until it completes the current write?
In reading, will it hang if it cannot complete the read or gets no response?
If you want to not block the script AT ALL, then you could use writeAsync, which allows you to send the call asyncronously, and supply a callback function when the write completes, incase you need to do something else based on the outcome of the tag write.
To add, if you call this from the gui e.g. a button click or event handler script, and the read/write takes a while, the gui will be frozen for that time
If I have ScriptA, ScriptB, Tag1, Tag2 and Tag3. On value change of Tag1 executing ScriptA in ScriptA writing with blocking valut to Tag3. On value change of Tag2 executing ScriptB in ScriptB writing with blocking valut to Tag3. What if happen that ScriptA and ScriptB executing in same time (or overlap in one moment) will writing value to Tag3 wait that previous script finish?
What if I call from tag value change project script (same from Tag1 and Tag2), project script for each call will executed in a separate thread or will wait that previous execution finish?
Undetermined. Tag scripting uses a thread pool, so multiple executing in parallel is possible. But any given execution might be queued behind long-running events.
And you really don’t want to use a lock object, as you’ll block other tasks in the thread pool. If you must do things serialized, start an asynchronous task from your tag event, and have that asynchronous task protect its critical section with a lock object.
Edit: Let me elaborate. temp1 will get the value you retrieved from temp0. Other threads could be writing to either tag simultaneously and disrupt the logic you think will occur.
I understand someone could write to those tags but in terms of ‘continuity’ am I guaranteed to get temp0 back before the second line occurs? If so then what is the point of the function readBlocking/writeBlocking?
Surely statements 1 and 2 have to finish before statement 3 starts??? Or is there a difference between client tags and PLC tags for example? Maybe I read the operator name from the PLC in the future.