Hi there,
This is my first post in this great forum.
We expected the writeBlocking will block the script till the opcTag has been written. After tests and simulations we saw a difference between tags and opcTags after writeBlocking function.
Without sleep-function is a difference between refValue and opcValue
With sleep is no difference.
Can anybody tell me how witeBlocking work?
In my mind writeBlocking block the script but after testing I think it will not do this?!?
Setup:
the Tags we want to write are opcTags on a siemens plc
TagGroup is new defined group with 100ms, mode = direct
Code:
import time
tagPath = '[MyTagProvider]tagPath'
for i in range(0,30):
refValue = i
writeResult = system.tag.writeBlocking([tagPath], [refValue],2000)
#time.sleep(0.10)
opcValue = system.tag.readBlocking([tagPath])[0].value
if not refValue == opcValue:
print('value different - refValue: {0} | opcValue:{1}'.format(refValue, opcValue))
else:
print('No Difference')
Unless you use "optimistic writes" (and you shouldn't, except in specific cases), the write path to an OPC tag does not touch the "current" value of the tag at all. It simply delegates the write to the tag's OPC server to handle. The "current" value of the tag will be updated on the next subscription delivery from that OPC server.
It absolutely blocks the thread. It's just not waiting on what you believe it is waiting on to return.
This is very fast for the standard Ignition driver and IMO is unsuitable. If you need tag reads and writes that are generally faster than 1 sec., then you should be using either Class 1 Comms, or the system.opc.* functions and some type of input buffer.
writeBlocking() returns when the OPC interface says the write has completed. That doesn't mean the new value has yet been read back for a subscription to deliver.