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.
- Forum
- Discussions
- QuickOPC-Classic in COM
- Reading, Writing, Subscriptions, Property Access
- ReadItemValue is working very slowly
ReadItemValue is working very slowly
Please Log in or Create an account to join the conversation.
In the end, the problem was that the quality of the tag I was trying to read was uncertain. So, instead of using .ReadItemValue, I ended up using .GetPropertyValue and pulling Property 2, which is value. This way I didn't have to wait for the quality to be good before reading the value.
Please Log in or Create an account to join the conversation.
Here is what I think is happening:
Step 1. An initial connection to the server requires 8-10 seconds (taken by the server)
Step 2. A time from the moment of the initial connection to the first "good" quality takes additional 8-10 seconds (taken by the server).
QuickOPC maintains the connections automatically. If not connected, the connection has to be made first. Therefore both methods (ReadItem and ReadItemValue) require at least the Step 1 delay; the ReadItemValue then also requires the Step 2 delay.
The initial delays are cause by the server and therefore *must* happen at some time. The only optimization that can be done is to avoid disconnections from the server, so that they are not required over and over.
One way to go is to enforce the connection - which is what you have done by using the Subscribe. Note that you have not really avoided the initial delay - that is impossible, you now have it between the SubscribeItem call and the first DataChange notification - but made it more suitable for your app. You do not need three EasyDAClient objects for this - it can be done with just one.
Other method (probably not so good in your case) is to significantly increase the HoldPeriod, which is for how long the client keeps the connection to the server open after it has been used. Normally it is just a couple of seconds, but you can make it e.g. 1 day or so or even more. This will get rid of the delay in case of second and third etc. Reads, but the first Read will still require the delay as before.
For some applications, it is also possible to *shorten* the timeout for Read methods (possibly combined with the previous method). Then, the first Read will simply timeout very quickly, but still initiate a connection. You can set the timeout e.g. to 1 second only. If you can handle the timeout by ignoring it or showing that the value is momentarily unavailable, and then come to do the same thing later, you would prevent what you call "freeze". The Read method won't take more than the configured timeout.
Best regards
Please Log in or Create an account to join the conversation.
//First I subscribe to the OPC tag
daClient1.SubscribeItem(machine, server, tag_pv, 500);
//After the subscription is complete (7-20s) I read the values with ReadItemValue command
pv_value = Convert.ToSingle(daClient.ReadItemValue(machine, server, tag_pv));
The reason I prefer to use ".SubscribeItem" before ".ReadItemValue" is that my application doesn't freeze up and the user is able to select other parameters while the OPC connection is established in the background. I would only perform a read using ".ReadItemValue" instead of the "daClient1_ItemChanged" event if the OPC tag is staying constant and I need to get its value.
I have 3 tags (PV, MV and SV) that I need to read/write from. Do you think it would be ok for me to create 3 EasyDACLients and subscribe to them all in order for my reads not to cause any lag/freezing in the application?
If you can suggest any other more-efficient methods in order to get rid of the application freezing the first time I read a value, please do so.
Thanks,
Mike
Please Log in or Create an account to join the conversation.
var target = new EasyDAClient();
target.InstanceParameters.UpdateRates.ReadAutomatic = 1000;
Please Log in or Create an account to join the conversation.
Do you have any other ideas to speed up the read?
Thanks a lot!
Please Log in or Create an account to join the conversation.
pv_value_ini = Convert.ToSingle(client.ReadItemValue(
new ServerDescriptor(machine, server), tag_pv, DAReadParameters.DeviceSource));
And, try a .CacheSource as well.
Please Log in or Create an account to join the conversation.
string machine = "HIS0164";
string server = "Yokogawa.CSHIS_OPC.1";
string tag_pv = "FCS0101!FIC100.PV";
//In another function, I read from OPC and there's a 20s delay
pv_value_ini = Convert.ToSingle(daClient.ReadItemValue(machine, server, tag_pv));
Please Log in or Create an account to join the conversation.
Best regards
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-Classic in COM
- Reading, Writing, Subscriptions, Property Access
- ReadItemValue is working very slowly