Page 1 of 1


Posted: 13 Jun 2019, 15:12
by christoph_krekels

I've got some problems in monitoring events with the UaExpert Client.
I modeled Objects with the UaModeler and generated the code.
Normally I create Objects manually by code with the CreateObjectSetting, where it is possible to set the NotifierParent like this:

Code: Select all

CreateObjectSettings settings = new CreateObjectSettings()      
                    ParentNodeId = new NodeId(1000, InstanceNamespaceIndex),
                    ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
                    RequestedNodeId = new NodeId("CNC", DefaultNamespaceIndex),
                    BrowseName = new QualifiedName("CNC", InstanceNamespaceIndex),
                    TypeDefinitionId = new NodeId(ObjectTypes.MachineToolType, TypeNamespaceIndex),
                    // need to create a notifier hierarchy for events to propagate.
                    [b]NotifierParent = UnifiedAutomation.UaBase.ObjectIds.Server,[/b]
                    EventNotifier = UnifiedAutomation.UaBase.EventNotifiers.SubscribeToEvents, //

                ObjectNode InterNode = CreateObject(Server.DefaultRequestContext, settings);
with this object I have no problems in monitoring events.

But when I try to monitor the UaModeler created Object I can not monitor the events. In the modeler I set the EventNotifier of the specific Object to 1 (EventNotifierSubscribeToEvents), but it is not possible to set the NotfierParent for this Object.

Do you have any example code how to set the NotifierParent to an existing / UaModeler created Object? (Do I have to add it in the XML file?)
Or is there anything else what I can do?

Thank you in advanced.

Re: NotifierParent

Posted: 13 Jan 2021, 10:20
by Support Team
Hello Christoph,

you donĀ“t need to add any code, the creation of a event hierarchy is a bit different in the UaModeler. In the Modeler the NotifierParent will not set at the object. You have to set a reference at the parent itself.
Setting the EventNotifier of the specific object to 1 is correct, but in addition you have to set a HasNotifier reference at the parent to the specific object.

Re: NotifierParent

Posted: 08 Mar 2021, 19:11
by baldo
What if you created the object through the xml but you want to add the HasNotifier reference afterwards through code?

In particular I noticed that BaseNodeManager has a AddReference and a AddNotifier methods. I would like to add a forward HasNotifier reference from the 0:Server node to my object that was imported through the xml (but also a reverse reference from my object to 0:Server). How should I do that?

Re: NotifierParent

Posted: 09 Apr 2021, 16:15
by Support Team
Hello Baldo,

yes the AddReference method is right way to do it.

Let me explain how to use it in two examples.
  • First for References managed by the same NodeManager and
  • second for References to nodes managed by another NodeManager.

Code: Select all

AddReference(context, sourceNodeId, referenceTypeId, isInverse, targetNodeId, addBiDirectional)
Example 1: (creates a normal forward reference)
  • For context use the Server.DefaultRequestContext
  • sourceNodeId will be your ObjectIds.YourSourceNode (would be the server node in your case but because of the server node is normaly not in the same namespace look at Example 2)
  • referenceTypeId is ReferenceTypeIds.HasNotifier
  • isInverse = false ( will be used for backwards references, look at Example 2)
  • targetNodeId will be your ObjectIds.YourTargetNode
  • addBiDirectional should be true (set to true will create the reverse reference NotifierOf at the sourceNode, which can be used for browse)

Code: Select all

AddReference(Server.DefaultRequestContext, ObjectIds.YourSourceNode, ReferenceTypeIds.HasNotifier, true, ObjectIds.YourTargetNode, true)
To set the IsEventNotifier bit use the following code.

Code: Select all

var node = FindInMemoryNode(targetNode)as ObjectNode;
    node.EventNotifier = ((byte)(node.EventNotifier | EventNotifiers.SubscribeToEvents));
Example 2: (creates an inverse reference)
  • For context use the Server.DefaultRequestContext
  • sourceNodeId in this case is your ObjectIds.YourTargetNode (because of the inverse refernce creation)
  • referenceTypeId is ReferenceTypeIds.HasNotifier
  • isInverse = true
  • targetNodeId will be your Server node ObjectIds.Server
  • addBiDirectional should be true (set to true will create the reverse reference NotifierOf at the sourceNode, which can be used for browse)

Code: Select all

AddReference(Server.DefaultRequestContext, ObjectIds.Your"Target"Node, ReferenceTypeIds.HasNotifier, false, ObjectIds.Server, true)
To set the IsEventNotifier bit use the code from Example 1.

You have to create the reference to the server node inverse (Example 2) because your NodeManager will not find the server node within its namespace.

Re: NotifierParent

Posted: 21 May 2021, 11:58
by baldo
I never thank you because maybe it's best practice to avoid posting for such a thing in a forum, so I implicitly do even if I do not reply. But in this case I'm taking the occasion to thank you, this was really helpful!

I have a further question about this. As I mentioned I also see that there is an AddNotifier method (very little mention here: ). Playing around with it I think I managed to obtain the same that I was able to do with the AddReferences that you explained to me, but the way I should rather use (because our CS does not have those references), I mean creating a event notifier hierarchy without adding explicit references. In fact it should be possible to propagate events from an event source to the notifying nodes above it, without the need of a HasNotifier reference, because the event notifier hierarchy can be implicit according to the tree structure. And of course, what I just said only applies to the nodes in between this hierarchy that have the EventNotifier set to SubscribeToEvents, that makes them actually able to propagate the Events.

So, I created a hierarchy from node to subnode with that method, for example from the Server node to the Machines folder (from Machinery Companion Specification):

Code: Select all

AddNotifier(VDMA.McBase.ObjectIds.Machines.ToNodeId(Server.NamespaceUris), UnifiedAutomation.UaBase.ObjectIds.Server);
And so on from the Machines node to the machine instance in it, and then from the machine instance to the node that is source of events, using this very same approach. Now looks like it works perfectly, except if an Event is sent with UnifiedAutomation.UaBase.ObjectIds.Server as SourceNode. It used to work with your approach: I was able to send events of DeviceFailureEventType with that as SourceNode, but looks like with this kind of hierarchy creation i need to be explicit for the whole tree. My guess is that I need to call the AddNotifier method also from Server to something above it, maybe calling it from Server.CoreNodeManager?

Let me please know if this could be a viable way and if so, if I should add an AddNotifier to make the Server node propagate Events as well when it is also a source of events.

Thank you in advance!

Re: NotifierParent

Posted: 18 Jun 2021, 15:19
by Support Team
Hi Baldo,

can you tell us what you think at when you say "from Server to something above it". What is above your server node?