NotifierParent

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
christoph_krekels
Jr. Member
Jr. Member
Posts: 3
Joined: 29 Nov 2018, 10:08

NotifierParent

Post by christoph_krekels »

Hello,

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.

User avatar
Support Team
Hero Member
Hero Member
Posts: 2602
Joined: 18 Mar 2011, 15:09

Re: NotifierParent

Post 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.
Best regards
Unified Automation Support Team

User avatar
baldo
Hero Member
Hero Member
Posts: 20
Joined: 19 Nov 2019, 12:15

Re: NotifierParent

Post 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?

User avatar
Support Team
Hero Member
Hero Member
Posts: 2602
Joined: 18 Mar 2011, 15:09

Re: NotifierParent

Post 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.
Syntax:

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;
lock(InMemoryNodeLock)
{
    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.
Best regards
Unified Automation Support Team

Post Reply