Traeger-GmbH / opcuanet-samples

Sample projects for C#, VB.NET and C++/CLI to guide developers using our OPC UA .NET SDKs.
https://opcua.traeger.de
MIT License
88 stars 39 forks source link

Event Subscription Problem #10

Open atheosangel opened 1 year ago

atheosangel commented 1 year ago

Hello,

it's not possible for me to subscribe Events with the Version 2.30-2.33.(look at #9 ) When i downgrade to 2.29 i get the Events without using an filter.

OpcNodeInfo node = Path2NodeID(parentnode, "DeviceSet/IMM_ENGEL_247005");
fclient.SubscribeEvent(node.NodeId, HandleEvent);

When i try to filter the Events, i get nothing.

OpcNodeId[] eventFilterIds = new OpcNodeId[] {
                        Path2NodeID(fclient.BrowseNode(OpcObjectTypes.EventTypesFolder), "BaseEventType/CycleParametersEventType").NodeId,
                        Path2NodeID(fclient.BrowseNode(OpcObjectTypes.EventTypesFolder), "BaseEventType/CycleParametersEventType/EngelCycleParametersEventType").NodeId,
                        Path2NodeID(fclient.BrowseNode(OpcObjectTypes.EventTypesFolder), "BaseEventType/LogbookEventType").NodeId,
                        Path2NodeID(fclient.BrowseNode(OpcObjectTypes.EventTypesFolder), "BaseEventType/LogbookEventType/ProductionStatusChangeLogType").NodeId

                    };

var eventFilter = OpcFilter.Using(fclient).FromEvents(eventFilterIds).Select();
subscription = fclient.SubscribeEvent(OpcObjectTypes.ObjectsFolder, eventFilter, HandleEvent);

I want to get the Event EngelCycleParametersEventType. How do i have to set the filter?

grafik

thanks in advanced atheos

kpreisser commented 1 year ago

Hi @atheosangel, thanks for creating this issue.

Can you show us the code of the Path2NodID method, does it call OpcClient.TranslatePath to translate the browse path into a node id? What NodeIDs do you get in the eventFilterIds array?

Additionally, from you code we can see that in the first sample, you are creating the subscription on the "DeviceSet/IMM_ENGEL_247005" node; however in the second sample, you are creating the subscription on the Objects folder. Was this intentional? If not, please try to also use the Node ID of the "DeviceSet/IMM_ENGEL_247005" node here, as the "Objects" folder probably doesn't have a HasNotifier reference. Alternatively, it would be the "Server" object (OpcObjectTypes.Server) that may also raise events, depending on the server.

Thanks!