Professional OPC
Development Tools


Writing to OPC item - when would the ItemChanged event occur?

01 Oct 2011 16:30 #502 by support
On the OPC interface, and inside QuickOPC, each OPC item actually looks like two different, separate "routes" - one for reading (and subscriptions), one for writing. It is up to the OPC server when to define what successful "write" means, and when (if ever) will manifest itself back to the client in form of updated value.
Consider following scenario - with synchronous OPC Write, for simplicity:

Your application calls WriteItemValue (or WriteItem) method in QuickOPC.
QuickOPC eventually calls appropriate OPC Write method.
OPC Server returns a success code to QuickOPC from the OPC Write method.
Control returns to your application from the WriteItemValue method.

In this scenario, the server will USUALLY write to the device between steps 2-3, and at the same time mark the new value internally, and the value will be shipped to clients. Some servers may do it differently - e.g. just write, and then re-read from device later, which means that the update will come much later. And there are other options as well. But even if the server follows the first (usual) way, you cannot make assumptions about when the update arrives: It may be already between steps 2-4 (indeed! - be ready for it), but also some time after step 4. What actually happens depends on the update rate, current "phase" of the update cycle, percent deadband, and other factors - including the simple fact that the event notifications take place on a different thread which can be delayed (or opposite - run very fast) for whatever reason.
You can make test in your particular situation, but even if this gives you some idea about what to expect, you should not rely on it - the reasons explained above mean that the timing is never guaranteed. The fact that there has not been an error during Write should be an indication to you that the value was written successfuly (as long as the OPC server is compliant). The update with a new value may arrive at some time - your code should not depend on it (or, if there is no way around it, you should set up a reasonable timeout in your code and check for the update during that timeout period).
I hope this helps. If you have specific scenario that you need to help with and is not covered above, let me know.

Please Log in or Create an account to join the conversation.

01 Oct 2011 16:11 #501 by support
From: Ch.
Sent: Friday, September 30, 2011 11:47 PM
To: Zbynek Zahradnik
Subject: .....


[....]. I do not know in depth about the OPC. If WriteItemValue() is called to write a new value to a device, when would the ItemChanged event occurs on the item? When the new value reaches the PC OPC server? Or when the PC OPC server reads from the device? It would be appreciated if you can let me know which.


Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.155 seconds


 Recommend this on Google