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.

Increased Computation time with the client imlpementation

More
09 Nov 2021 09:36 #10342 by support
Hello.

QuickOPC quarantees that when Succeeded is 'true', the Value contains the data shipped by the UA server. In OPC UA, however, this Value is transferred as OPC UA "variant" built-in type, which means that, if the server is either buggy or not configured the way you expect it to be, the value might be null, or it can be of a data type different from what you expect.

So, if you have the server fully under your control and you do things right, you could say that neither a null reference exception, or an incorrect typecast exception, can ever occur. On the other hand, if the server is not under your control, you cannot rule out that you will receive a null, or a different data type, and your code needs to handle that properly.

Regarding the optimal way of retrieving the values: Your code is fine - as any other reasonable code will be. In my estimate, the amount of instructions/time needed for the retrieval, compared to what goes on inside ReadMultiple, is at the rough other of magnitude 1:1000, 1:10000 or higher. So, it is an unimportant detail.

Best regards

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

More
08 Nov 2021 13:06 #10339 by Mirhaj
Hi,
Thanks for your reply. The things regarding ReadMultiple and WriteMultiple seems reduced the computation time quite much. But there is one issue remaining and that is when using "ReadMultiple" for reading nodes and put them all in an array, I should then assign each item in this array (valueResultArray) to a property that I want to use inside my calculations. What is the most optimum way of doing that in QuickOPC?

As of now, I have done it like below;

UAAttributeDataResult[] valueResultArray = _client.ReadMultiple(new[]
{

// reading parameters of different types (i.e. short, bool, float)

});

parameter1= valueResultArray[0].Succeeded ? (short) valueResultArray[0].AttributeData.Value : (short)0;
parameter2 = valueResultArray[1].Succeeded ? (bool) valueResultArray[1].AttributeData.Value : false;
parameter3 = valueResultArray[2].Succeeded ? (float) valueResultArray[2].AttributeData.Value : 0;

parameter1, parameter2 and parameter3 are the properties that should be mapped to each item in the valueResultArray to be used inside my calculations.

Is the way I have applied optimum? Another thing is that when I use this, VS/Csharp gives warning on the line "valueResultArray.AttributeData.Value" that Possible System.NullReferenceException happens. Should this be solved by the usual way of treating possible NullReferenceException or will QuickOPC recommends another way? Do you have this in your documentation?

Best,
Ahmad

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

More
01 Nov 2021 12:54 #10336 by support
Hello. Thanks for clarification.

It is no surprise that the time has increased. Doing client-server operations is much more time demanding that any local computation. Among many things that need to be considered, there are times needed for network communication (this is partially true even if the server is local), and the time needed by the server to process the request and respond.

Note also that if something goes wrong in the communication or on the server, the return time from the method call can be many seconds, before it times out.

Things that can be done:
- if the application nature allows it, do not periodically read. Instead, use subscriptions.
- Replace multiple sequential reads or writes by calls to ReadMultiple and WriteMultiple. opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...%20instead%20of%20looping.html

Regards

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

More
01 Nov 2021 12:32 #10335 by Mirhaj
Hi,

There is no separate thread for OPC read/write. The read/write has been added to an existing thread (that was doing some other calculations), but the thread computation time was drastically increased (as the magnitude said in the previous post) when the read/write was added.

Best,
Ahmad

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

More
01 Nov 2021 12:27 #10334 by support
Hello.

Please clarify: You OPC reads and writes are part of the code that runs the computation loop?

Or, are you saying that the OPC reads/writes are running independently (e.g. on a separate thread), but influence the computation loop which should largely be independent?

Regards

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

More
01 Nov 2021 12:20 #10333 by Mirhaj
Hi,

I have implemented the client on a real time application. The application had an computation of approximately 40 milliseconds per frame. When adding the client with reading 4 and writing 5 values to the OpcUa server (values are of the types Boolean, integer and float), the computation time has increased to 200 to 250 milliseconds per frame. Did I do something not efficient with calling read/write functions of the sdk? Is there a Sleep() method used inside the sdk that makes this to happen? The following is how I read and write from and to the server;

***Writing to the server;
_client.WriteValue("opc.tcp://92.220.119.221:4840", "ns=6;i=4", (float)(MyDoubleParameter));

***Reading from the server;
DoubleParameter = Convert.ToDouble(_client.Read("opc.tcp://92.220.119.221:4840", "ns=5;i=4").Value);

And I repeat the lines above for every node that I read from and write to.

Best,
Ahmad

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

Moderators: support
Time to create page: 0.048 seconds