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.

Write is synchronous or asynchronous?

More
24 Oct 2020 18:38 #9025 by support
There is no change, and no change is or was planned.

If you need to do other operations while the OPC call is in progress, there is nothing that prevents you from using a separate thread or task to perform the OPC call.

Best regards

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

More
24 Oct 2020 15:38 #9024 by I-Tecnology

support wrote: In UA client in general, the answer is Yes, you can do async write.

With the current API of EasyUAClient, we do not give you a way of doing reads or writes that would appear as asynchronous to you. But you can emulate that.

Best regards


Hi, I rewrite in this old post to know if there are news about this question? during last two years do you have improved anything to make asynchronous write?
Thank you in advance

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

More
13 Jun 2018 10:39 #6441 by support
Please let us distinguish between making some operation asynchronously in your app, and having asynchronous OPC UA calls. And, "async" is not quite the same as "parallel".

QuickOPC does *not* allow you to make asynchronous OPC UA calls on a single OPC UA connection (session). That is, every Read or Write operation you make runs to a completion, and only then a new operation begins - they are all serialized. The only other thing that runs "in parallel" on the same session are subscription notifications - they are received independently of the Read-s and Write-s (and other operations). The only way to have two Read-s/Write-s in parallel is to use a separate session to the same server, which is normally not recommended (can be achieved by using multiple EasyUAClient instances with .Isolated property set to 'true').

The issue we were working on was that the Write performed from inside the data change handler has delayed the processing of other incoming data changes. That can be resolved by starting a thread for the Write, yes. But when you spin off, say, ten threads like this, the Write-s that they make will be performed in a serialized way, one after another.

The problem may be simply in the server performance. If the server is only capable of doing, say, 10 write operations per second, no amount of client-side tweaking is going to stuff the server with more changes per second.

I should note, however, that it is common for OPC operations to take some "constant", relatively long time, but be not so much dependent on the amount of nodes addressed. So, for example, if writing one node takes 100 milliseconds, it is possible (depends on the server), that writing ten nodes *in one call* will only take e.g. 110 milliseconds, and not 1000 milliseconds. You should experiment/measure these things, and if the server behaves like that and you want to improve the performance, your app should (if the logic allows) accumulate certain amount of "Write-s", and then send them to the server in "batches".

Best regards

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

More
12 Jun 2018 11:46 #6429 by I-Tecnology
Hi,
unluckily I need to convert my application to UA Tecnology so I make some tests with asynchornous calls; I start from write operation; here my code:
public void WriteSingleItemAsync(string nodeId, object value)
{
    UANodeDescriptor nodeDescriptor = GetItemDescriptor(nodeId, UANodeIdType.String);
    UAWriteValueArguments uaw = new UAWriteValueArguments(serverUriTextBox.Text, nodeDescriptor, value);
    new Thread(() => WriteAsync(uaw)).Start();
}
 
private void WriteAsync(UAWriteValueArguments uaw)
{
    easyUAClient.WriteValue(uaw);
}
In this scenario, with about 16 single bit write operation per second and the subscription of other 16 bit variables, I have problem in response time and I miss some operation.
Can you help me?
Best regards

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

More
06 Jun 2018 15:46 #6394 by support
As I wrote:

You may, for example, run the Write in a separate working thread as well.


It's as easy as one or two lines of code. But you need to think of the consequences - for example, what happens when the number of these threads, unfinished, increases. This is, by the way, the same case if the calls were truly asynchronous: What happens if you add them faster that they can be processed - as you do in your code? This is precisely the reason why we have not included the async calls - because these situations are complex and do not have a "one size fits all" solution that we can provide, and we want the developer to think about them and handle them the way that's right for the project.

Best regards

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

More
06 Jun 2018 15:39 #6393 by I-Tecnology

But you can emulate that.

How can I do this?

Thank you

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

More
06 Jun 2018 15:35 #6392 by support
In UA client in general, the answer is Yes, you can do async write.

With the current API of EasyUAClient, we do not give you a way of doing reads or writes that would appear as asynchronous to you. But you can emulate that.

Best regards

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

More
06 Jun 2018 14:57 #6391 by I-Tecnology
So, in UA client is not possible use an asynchronous write?

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

More
06 Jun 2018 14:49 #6390 by support
Hello,
what you describe seems to me the correct behavior, per design.

With respect to your calling thread, the EasyUAClient.ReadXXXX and WriteXXXX methods are always synchronous. That's also clear from the way they return their results (through exceptions and return values, and not through some callback or event).

And, read this: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...20or%20callback%20methods.html .

So, what is happening is that you call the Write, and it is being executed, and your code in the DataChangeNotification handler is blocked (no matter whether you use the same or different EasyUAClient instance or whether they are isolated or not). Apparently the Write is not particularly fast - it is slower than the rate of incoming notifications. So, after every Write, *one* new notification can be processed, Write blocks again, and the other incoming notifications keep queuing. When you "uncheck" the Write, your processing becomes much faster, and the notifications that were queued so far and did not have a chance to be processed are then delivered and quickly processed by you.

If this is not what you want, you need to re-think the approach. You may, for example, run the Write in a separate working thread as well.

Best regards

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

More
06 Jun 2018 13:16 - 06 Jun 2018 13:19 #6389 by I-Tecnology
Hi,
I'm converting my application from DA tecnology to UA tecnology. I have some strange behaviors so I'm using a simple test application to better underestand UA methods.

I make some multiple subscription to 160 bit variables. Here there are some bit that blinks. Only 10 bit are ON every 0,2 seconds (I make a simple register shift on 16 words). I turn on and off 160 labels on the screen. Everything is ok.
If in datachange event I enable a write instruction of a bit (also the same bit, it's just a test), the change color of the label slow enormously. It seems that the write instruction is syncronous, but I can't set it.
When I disable the write option, the labels turn on and off very quickly and after some seconds return to right frequence. it seems that the datachange event were stored and thay run all in a moment.

Here the datachange event:
private void easyUAClient2_DataChangeNotification(object sender, EasyUADataChangeNotificationEventArgs e)
{
    if (e.AttributeData == null) { return; }
    int i = (int)e.Arguments.State;
 
    if ((bool)e.AttributeData.Value)
    {
         labels[i].BackColor = Color.Green;
    }
    else
    {
         labels[i].BackColor = Color.Red;
    }
 
    if (scritturaCheckBox.Checked)
    {
        easyUAClient1.WriteValue(serverUriTextBox.Text, "nsu=TOP Server;ns=2;s=PLC_Siemens.PLC1.M33.7", "False", TypeCode.Boolean);
    }
}

If you need I can send you my test program.
I'm using:
- last version of EasyOpc 5.53.225.1
- Topserver V.6.3.279
- plc siemens S7-315
- framework 4.5.2
- VS 2013

Thank you

PS I have already tryed to use two different easyUAClient Objects (as you can check) and to set the isolated property to true for the two objects.
Last edit: 06 Jun 2018 13:19 by I-Tecnology.

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

Moderators: support
Time to create page: 0.063 seconds