Extensions described in this article allow you to block the execution and wait until certain condition, based on OPC-DA item data, is fulfilled.
With methods in this group, you can subscribe to specified OPC-DA items, and wait by monitoring their data until specified conditions (predicates) become true, and then automatically unsubscribe. The methods also return when the specified time elapses. The item data that satisfied the specified condition is returned by the method.
In order to use the described functionality, call the IEasyDAClientExtension2.WaitForMultipleItemValues method. There are multiple overloads.
It is not uncommon that an OPC server needs considerable time before it can provide the data requested. When you Read an item or Subscribe to an item with some OPC servers, they will first deliver data with "bad" or "uncertain" quality, and only after a while, data with "good" quality are provided. This behavior, of course, creates a problem if all your code needs is that actual, "good" data value, for further processing. You cannot just do a Read; you need additional logic to overcome the possibility of these initial "uncertain" or "bad" results or updates.
OPC Data Client has ready-made methods that contain the necessary logic. The IEasyDAClientExtension2.WaitForMultipleItemValues method is similar in its usage to ReadMultipleItemValues Method , and the IEasyDAClientExtension2.WaitForItemValue method is similar in its usage to ReadItemValue Method. Internally, however, they use subscriptions to possibly observe the data over a period of time, and automatically overcome the initial "unreliable" updates of the value.
The methods have various overloads that allow you to leave out some of the arguments and use their default values instead. In the full form, you need to specify: