Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

ReadItemValue is working very slowly

More
21 Oct 2015 18:06 #3621 by support
The ReadItemValue does, with simplification, the following steps:

1. If we have some last data for the item, and it is "fresh enough" (explained later), we give them out and are done. Otherwise:
2. Connects to the server if not connected.
3. Adds the item to OPC group if not yet there.
4. Issues and OPC "read" request and waits for the result.
5. Checks if the quality is Good. If so, returns the value to you.
6. Otherwise, it Subscribes to the item changes, with some initial rate (defaults to 10 seconds), observes the incoming data and returns if the value is now Good or the timeout period expires.

In Step 1, the default setting is to provide values that are no older than 1000 milliseconds. It is possible to change it - e.g. require the OPC Server to always provide data from its Cache, or (on the other side of the spectrum), require the OPC server to always provide data by actually reading from the underlying Device.

One explanation for the observed behavior is that the server gives you a cached Bad quality first (when reading), and as we then set up a subscription automatically, we eventually receive the update with Good quality, but much later (possibly due to the 10 seconds default rate). You can try to experiment with the DataSource settings, e.g. try Cache or Device, like this:

var client = new EasyDAClient();
DAVtq vtq = client.ReadItem("OPCLabs.KitServer.2", "Simulation.Random", 
    new DAReadParameters(DADataSource.Device));

Note that as opposed to the ReadItemValue mthod, the ReadItem method does *not* wait for Good quality - it always returns whatever data (the Value/Timestamp/Quality triple) the server returns. It might be interesting to see what you get if using this method.

Best regards

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

More
21 Oct 2015 02:35 #3620 by mikeboiko
I am having a problem with .ReadItemValue where it is working very slowly. When I connect to a Yokogawa DCS and try to read the PV (Process Variable) value, I have to wait about 20 seconds before the read is completed. When using .SubscribeItem and reading PV in the ItemChanged function, my value appears instantly.

These are the two lines of code described in the above paragraph:

daClient.SubscribeItem(machine, server, tag_pv, 500);

pv_value_ini = Convert.ToSingle(daClient.ReadItemValue(machine, server, tag_pv));

Can you please let help diagnose why the ReadItemValue command is working so slowly? I can use SubscribeItem but I only need to read the initial value. Also, sometimes PV doesn't change instantly so I have to wait for a change in order to see the value. Using SubscribeItem, is there a way I can read the value right away without waiting for PV to change?

Thanks,
Mike

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

Moderators: support
Time to create page: 0.073 seconds