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.

Multiple monitored items with one callbackFunction firing all at once

More
18 Aug 2021 10:29 #10124 by support
The expected behavior is that from the point of the developer, each monitored item subscription behaves as separate from the others. Each significant change to the monitored item should trigger one invocation of its associated callback method. If you use the same callback method for multiple monitored item subscriptions, which is perfectly OK if that is what you want to do, then of course the same method will be called for a change in any of the monitored items, and there needs to be a logic inside the callback to methods to distinguish which monitored item it relates to (using e.g. the Arguments, or State, available in the EventArgs).

If a single monitored item has a significant change, the expected behavior is that a single invocation of the callback method will be made.

Reestablishing the connection affects all monitored items on that connection. It is therefore a significant change for all of them, and in this case the expected behavior that the associated callback will be invoked once for each monitored item on that connection (4 times in your case).

Best regards

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

More
18 Aug 2021 09:47 #10123 by Taid
Hello,

I have a question regarding the behavior of a callbackFunction in a scenario where we have let's say 4 unique items that all have the same callbackFunction defined like this :
tmpItemArguments.Add(
	new EasyUAMonitoredItemArguments(
		BasketInPositionHandler, -- callback triggered on DataChangeEvent
		new UAMonitoredItemArguments(
			pozycja,
			pozycja.OPCServerURL,
			pozycja.OPCNodeID + pozycja.Tags.KoszNaPozycji,
			new OpcLabs.EasyOpc.UA.UAMonitoringParameters() { 
				SamplingInterval = 100
			}
		)
	));
opc.tcp://192.168.52.99:49320 NodeId="nsu=KEPServerEX;ns=2;s=Destacker_1.Station_1.Pos_0.Basket_in_position" Void BasketInPositionHandler 
opc.tcp://192.168.52.99:49320 NodeId="nsu=KEPServerEX;ns=2;s=Destacker_1.Station_1.Pos_1.Basket_in_position" Void BasketInPositionHandler 
opc.tcp://192.168.52.99:49320 NodeId="nsu=KEPServerEX;ns=2;s=Destacker_1.Station_2.Pos_0.Basket_in_position" Void BasketInPositionHandler 
opc.tcp://192.168.52.99:49320 NodeId="nsu=KEPServerEX;ns=2;s=Destacker_1.Station_2.Pos_1.Basket_in_position" Void BasketInPositionHandler

Now my understanding was that the function would only be called when individual item has a change for example,

if Station_1.Pos_0.Basket_in_position changed status or value from 0 to 1 function BasketInPositionHandler would fire once for this particular item.

From what I observed this function is fired 4 times if any of the items Status or Value changes or connection is reestablished? Is this the correct behavior?

Should I write 4 unique callbackFunctions for each of the items to achieve what I originally expected?

Best regards, Piotr

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

Moderators: support
Time to create page: 0.047 seconds