I’ve got a Siemmens PLC connected via OPC UA.
I want to read a list of records that are stored in a buffer in the device; each record is made available through a collection of tags.
There is need of a way for the PLC to inform the client that a new record is available and for the client to notify the PLC that the data has been read and it can go on with the next.
We came up with the following solution, based on a DataAvailable bit that is set by the PLC when data are available and reset to 0 in an Ignition Script when data has been consumed.
dataAvailable = system.tag.read("[default]FieldData/dataAvailable").value
if dataAvailable:
whatever = system.tag.read("[default]FieldData/Whatever1").value
#do whatever with the data
system.tag.write("[default]FieldData/dataAvailable", False)
This code seems to be susceptible to both repeated reads (the same data gets read twice, even three times) and data loss.
Obviously this simple ‘handshaking’ has to be implemented correctly on the PLC side.
PLC people say that the implementation is correct on their side, and that there is some sort of problem that is related with the communication delay.
My questions are:
- is this schema too simplistic? Should I use a more comples (two-bits) handshake mechanism?
- is OPC communication protocol connection-based or broadcast-based, that is: when changing a tag’s value, should i relay that tag modification on the other side happens in the same order they are done on the originating side?
I replaced
system.tag.write("[default]FieldData/dataAvailable", False)
with:
system.tag.writeSynchronous("[default]FieldData/dataAvailable", False)
Without success.