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.

Problem with reading multiple OPC UA items periodically (every 1 second)

More
13 Apr 2022 16:54 #10807 by support
Hello.

Either you let QuickOPC maintain the connection, which works analogically to OPC DA. You would set
EasyUAClient.AdaptableParameters.SessionParameters.HoldPeriod

(opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...sionParameters~HoldPeriod.html )

Or, you can use Connection Locking:
- opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...tion%20Control%20Services.html

Best regards

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

More
12 Apr 2022 09:07 - 13 Apr 2022 16:46 #10804 by mut9bu
Hello

We are reading the data from the OPC UA Server of a Siemens Simatic TP1500 panel. It is possible that it doesn't support subscribing, because we really get this error also with 1 or 2 items. We will clearify this point with Siemens.

As I said, if I tried yhe code below, I saw from the timestamps,that I cannot read faster then every 1500-2000 ms.
This could be also from the TP1500 side, i will also ask this to Siemens.

But last question to you. In cases where subscripting is not possible, can I use the example code below? Will the OPC connection be established each time repeatedly if I use the code below, or does it stay open for a while? If I would try to execute the code with timer event (timer periof 2 seconds) , instead of for loop, do i have to care that the OPC connection remains open?
For OPC DA there is parameter like "client.InstanceParameters.HoldPeriods.TopicRead= ...." where i can adjust how long the connection should stay open after each reading. Do I have to care for this also in OPC UA?

What do you suggest in general for periodicaly reading of multiple variables?
public static void Multiple_values()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://10.92.116.208:4861";    
 
            // Instantiate the client object.
            var client = new EasyUAClient();
 
 
            for (int i = 0; i < 20; i += 1)
            {
                // Obtain values. By default, the Value attributes of the nodes will be read.
                ValueResult[] valueResultArray = client.ReadMultipleValues(new[]
                {
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_DR_EING_SEK_WT1_HEIZ"),
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_AUSG_SEK_WT1_HEIZ"),
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_EING_SEK_WT1_HEIZ"),
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB99_KÜHLUNG_ISTWERTE_DR_EING_SEK_WT1_KUEHL"),
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB99_KÜHLUNG_ISTWERTE_TEMP_AUSG_SEK_WT1_KUEHL"),
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB99_KÜHLUNG_ISTWERTE_TEMP_EING_SEK_WT1_KUEHL"),
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_DR_EING_SEK_WT2_HEIZ"),
                    new UAReadArguments(endpointDescriptor, "ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_AUSG_SEK_WT2_HEIZ")
                });
 
                // Display results.
                foreach (ValueResult valueResult in valueResultArray)
                {
                    if (valueResult.Succeeded)
                    {
                        Console.WriteLine($"Value: {valueResult.Value}");
                        using (StreamWriter sw = File.AppendText(OPC_Log))
                        {
                            sw.WriteLine("value" + i.ToString()+"  " + Convert.ToString(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)));
                        }
                    }
 
                    else
                    {
                        Console.WriteLine($"*** Failure: {valueResult.ErrorMessageBrief}");
                        using (StreamWriter sw = File.AppendText(OPC_Log))
                        {
                            sw.WriteLine("error" + "  " + Convert.ToString(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)));
                        }
                    }
 
                }
            }
 
        }
Last edit: 13 Apr 2022 16:46 by support. Reason: code formatting

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

More
12 Apr 2022 08:40 #10802 by support
Hello.

Your code is correct in principle.
If this is an embedded server (PLC), it can be quite limited (e.g. in number of subscriptions), or quite slow. Can you share which type of server it is?

But, you really have just one subscription in the first example, so it almost looks like that the server may not support subscriptions at all.

With the periodic reads: Are you saying that each "ReadXXXX" call takes two seconds, OR are they relatively fast, but the data you get is always cca 2 seconds old?

Best regards

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

More
11 Apr 2022 09:06 #10799 by mut9bu
Hello
We want to read multiple OPC UA items periodically. (every 1 second)
First I tried with your example "// This example shows how to subscribe to changes of multiple monitored items and display the value of the monitored item with
// each change."

But i get following errors (BadTooManySubscriptions) in my code (See Att-1 Subscripting)

OpcLabs.EasyOpc.UA.UAEngineBase Error: 0 : UAClientSubscription failed at tick 654370687 and will retry in 3000 ms
OpcLabs.EasyOpc.UA.UAEngineBase Error: 0 : UAClientSubscription failed at tick 654370703 and will retry in 3000 ms
NodeId="ns=3;s=DB98_HEIZUNG_ISTWERTE_DR_EING_SEK_WT1_HEIZ" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
NodeId="ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_AUSG_SEK_WT1_HEIZ" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
NodeId="ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_EING_SEK_WT1_HEIZ" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
NodeId="ns=3;s=DB99_KÜHLUNG_ISTWERTE_DR_EING_SEK_WT1_KUEHL" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
Unsubscribing...
NodeId="ns=3;s=DB99_KÜHLUNG_ISTWERTE_TEMP_AUSG_SEK_WT1_KUEHL" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
NodeId="ns=3;s=DB99_KÜHLUNG_ISTWERTE_TEMP_EING_SEK_WT1_KUEHL" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
Waiting for 5 seconds...
NodeId="ns=3;s=DB98_HEIZUNG_ISTWERTE_DR_EING_SEK_WT2_HEIZ" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
NodeId="ns=3;s=DB98_HEIZUNG_ISTWERTE_TEMP_AUSG_SEK_WT2_HEIZ" *** Failure: UA SDK error (Opc.UA.ServiceResult=0x80770000) in 'Subscription.Create'. OPC UA service result - {BadTooManySubscriptions}. The server has reached its maximum number of subscriptions. [...]
Finished.
The program '[24204] app1.exe' has exited with code 0 (0x0).

After that i have tried to read without subscription , that means reading just the item values in a for loop. (Att-2 For_Loop)
(In order to see how fast i can read)

In this case I can read the valıues but every new data set is coming in appr.2 seconds. I don't know if my OPC UA server is so slow but i dont think.
Is there any default setting for this 2 seconds, that i have missed? What would you suggest for preiodicaly reading multiple tags?

File Attachment:

File Name: 01_Subscribing.txt
File Size:3 KB

File Attachment:

File Name: 02_For_Loop.txt
File Size:3 KB
Attachments:

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

Moderators: support
Time to create page: 0.067 seconds