Receiving Events at BaseObjectType

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

Moderator: uasdkcpp

Post Reply
Syles
Jr. Member
Jr. Member
Posts: 4
Joined: 07 Nov 2018, 09:41

Receiving Events at BaseObjectType

Post by Syles »

Hi,

i'm trying to receive Events at a specific point. I create an object to receive all events from the server. Therefore i call registerEventNotifier on it with the server node id.
This is the actual code in my nodemanager:

Code: Select all

  XmlUaNodeFactoryManager factory;
  UaNodeId idThis = UaNodeId(getNextFreeNodeId(), miNamespaceIndex);
  UaBase::Object *pFolder = new UaBase::Object(idThis);
  pFolder->setBrowseName(UaQualifiedName(folderBrowseName, miNamespaceIndex));
  pFolder->setDisplayName(UaLocalizedText("en-US", folderDisplayName));
  pFolder->setEventNotifier(OpcUa_EventNotifiers_SubscribeToEvents);//new
  
  OpcUa::BaseObjectType *pObjectType = new OpcUa::BaseObjectType(pFolder, (XmlUaNodeFactoryManager*)&factory, this);
  pObjectType->useAccessInfoFromType();
  
  UaStatus ret = addNodeAndReference(parent, pObjectType, OpcUaId_Organizes);
  UA_ASSERT(ret.isGood());

  registerEventNotifier(OpcUaId_Server, pObjectType->nodeId());
I can subscribe to BaseObjectType node in the event view, but i do not receive any events. When i subscribe to the server node, i can receive them. So i just have to create an object (in this case BaseObjectType) and connect the server and my own created node with registerEventNotifier so that all events received at the server node are also received at my own created node, right?

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

Re: Receiving Events at BaseObjectType

Post by Support Team »

Hello Syles,
I create an object to receive all events from the server.
To receive all Events from the server you need to subscribe to the ServerObject.
I'm trying to receive Events at a specific point.
That works the way you did it but you need to keep in mind that you will only receive Events from that subtree of the event hierarchie.
That means:
1) the SourceNode of the Event needs to be reachable in the notifier tree (registerEventNotifier or registerEventSource).
2) When you create the event (fill event fields) you need to set the SourceNodeId correctly
Best regards
Unified Automation Support Team

Post Reply