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.

"SubscribeDataChange" using the read function

More
27 Nov 2019 12:08 #8042 by Moien
As I mentioned in my previous message when I use Read function, I read the value of my variable but as soon as the variable changes the new value isn't delieverd in my Delphi application! If I print out the value there would be no changes in my value, it is the same as the first time that I called read function.

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

More
27 Nov 2019 11:33 #8041 by support
OK, there seems to be basic misunderstandings which we need to clarify first.

The equivalent of OPC DA "Read" in OPC UA is "Read" again. In QuickOPC, this is invoked using various methods whose name starts with "Read", such as ReadMultiple and so. QuickOPC, in addition, takes care of connections (sessions) - there is no need to explicitly connect.

So, in order to read something, you just need to call the Read.

What makes you believe that this is not enough, and that you need to subscribe as well?

Best regards

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

More
27 Nov 2019 09:37 #8040 by Moien
Thank you for your response.

The "SubscribeMultipleMonitoredItems" inside "procedure TOPCClient.InternConnect; " is kind of event handler. It should update the variables every 1000 milliseconds. It is called one time at the beginning. When my Delphi client is connected to the OPC Server, it updates the variables every second. We get every second new values from our PLCs (from pressure gauge, temperature sensors and ...) and these values are changing continuesly.
Moreover, what I still don't understand is the "read" function of QuickOPC! In our current software version we are using OPC DA (DCOM) and the only thing we are using to read variables from OPC DA Server is the standard "read" function (single read or multiple read). This function delievers every second new values without any need to subscribe any data change or so! I am wondering why it is not the case with the "read" function from QuickOPC! What is the exact equivalent function in Quick OPC to read the current value from OPC UA Server without any extra effort?

Best regards,
Moien

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

More
27 Nov 2019 08:03 - 27 Nov 2019 08:05 #8039 by support
Hello,
thanks for the numbers.

What I plan to do is to set up a similar test here and measure the usage, to understand what is happening. Please give me some time. I will post here then again.
I would not be surprised if reading 300 variables once per second would be relatively demanding, but subscriptions should be less demanding than that.

But, I am afraid there might be some profound misunderstanding in play. I have not found any processing of the subscribed items in your code. That is, the part that in our example (opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...es%20for%20data%20changes.html ) is initiated by the statement

Client.OnDataChangeNotification := ClientEventHandlers.OnDataChangeNotification;
But you have no such statement in your code. There is no point in making subscriptions but not using their results. Can you please explain why are you doing that? I can imagine only one reason (to keep the client connected to the server) - but in this case, it would be perfectly sufficient to subscribe to just one item (and even better, that can be done without any subscription, by prolonging the disconnection timeout).

But that's not the whole story. If you actually wanted to have the data of these variables available to you for extended periods of time and not just once, the *highly preferred* approach is to use subscription only. So, in that case, you would keep the subscription call, add an event handler to process the incoming data, but completely remove the periodic calls to Read.

Regards
Last edit: 27 Nov 2019 08:05 by support.

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

More
27 Nov 2019 07:46 #8037 by Moien
1. "procedure TOPCClient.InternConnect;" is called just once at the beginning in order to connect to the OPC UA Server. However, "Procedure TOPCClient.ReadSPSItems;" is called anywhere else every second, as the new variables should be taken into my Delphi application every second.
2. No it's not kind of spike in the CPU usage. It goes up and remains up to about 60%.

2b. I would say "SubscribeMultipleMonitoredItems" and "ReadMultiple" have the same effect on the CPU usage which means equal shares 50-50.

Best regards,
Moien

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

More
27 Nov 2019 07:32 #8036 by support
Hello,
thank you for the code.

Can you please clarify:
1. Are you calling the procedures you listed just once, or in some kind of loop? If in loop, how often (frequency)?
2. Are we talking about a temporary "spike" in the CPU usage, or does it - after one call to the procedure - go high and remain that way?
2b. If so, is that even the case after calling the procedure with the "Read"?

Thank you

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

More
27 Nov 2019 07:19 #8035 by Moien
I attached parts of the code (two procedures) where I am trying to connect to the OPC UA server and read the OPC variables.
I ran my application commenting out the parts related to the subscribing data and reading more than 300 variables on the OPC Server! you can see the commented out parts in the attached file. This leads to a total CPU usage of 13 % which was about 60 % before commenting out those parts!

Best regards,
Moien

File Attachment:

File Name: OPCLabs_question.txt
File Size:5 KB
Attachments:

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

More
26 Nov 2019 15:20 #8033 by support
If you are subscribing to data, you should have an event handler for the event which actually brings you data. In the example I pointed out before, it was this method:
procedure TClientEventHandlers123.OnDataChangeNotification(
  ASender: TObject;
  sender: OleVariant;
  const eventArgs: _EasyUADataChangeNotificationEventArgs);
begin
  // Display the data
  //...
  if eventArgs.Succeeded then
      WriteLn(eventArgs.Arguments.NodeDescriptor.ToString, ': ',
      eventArgs.AttributeData.ToString)
  else
      WriteLn(eventArgs.Arguments.NodeDescriptor.ToString, ' *** Failure: ',
      eventArgs.ErrorMessageBrief);
end;

In the example, the method just displays the incoming data. In your application, I would expect the method to do the actual processing you need with the data. So, I wanted to keep the procedure but leave it basically empty - no executable code inside it, everything commented out.

Regards

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

More
26 Nov 2019 14:03 #8032 by Moien
What do you mean by " comment out the internals of the event handler for the DataChangeNotification event"?

Best regards
Moien

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

More
26 Nov 2019 13:18 #8031 by support
Thank you, but I think you have misunderstood what I asked you to do. I was not asking you to remove *all* code related to QuickOPC - leading to, as you wrote, to not subscribing to any changes. I was asking you to keep the code that does the subscription, but comment out the internals of the event handler for the DataChangeNotification event. This way, there will still be subscription, but depending on the CPU usage, I would be able to tell whether the CPU load came from the processing inside the event handler, or elsewhere.

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

Moderators: support
Time to create page: 0.068 seconds