C++ Based OPC UA Client/Server SDK  1.5.5.355
EventManagerBase Class Reference

Implements the EventManager interface base functionality independent of the node management It handles all active event monitored items and all event filtering and event field selection. More...

#include <eventmanagerbase.h>

Inherits EventManager.

Inherited by EventManagerUaNode.

Public Member Functions

 EventManagerBase ()
 Constructs an EventManagerBase object providing a base implementation of the EventManager interface. More...
 
virtual ~EventManagerBase ()
 Destroys the EventManagerBase object. More...
 
virtual void shutDownEM ()
 Shut down the event manager instance. More...
 
virtual void fireEvent (UaEventData *pEventData)
 Fire an event with the passed event data to interested clients. More...
 
virtual bool beforeSendEvent (UaEventData *pEventData, Session *pSession)
 Checks if the user is allowed to receive the event. More...
 
virtual void registerEventNotifier (const UaNodeId &parentNotifier, const UaNodeId &newNotifier)
 Add an event notifier to the event notifier tree. More...
 
virtual void registerEventSource (const UaNodeId &parentNotifier, const UaNodeId &newSource)
 Add an event source to the event notifier tree. More...
 
virtual void unregisterEventNotifier (const UaNodeId &notifier)
 Removes an event notifier and all of its notifier children and event sources from the event notifier tree. More...
 
virtual OpcUa_Boolean isNotifier (const UaNodeId &eventNotifier) const
 Checks whether the passed NodeId is the NodeId of an event notifier object. More...
 
virtual OpcUa_Boolean isEventManagerRootNotifier (const UaNodeId &notifier) const
 Checks whether the passed NodeId is a root notifier for this EventManager. More...
 
virtual OpcUa_Boolean inNotifierTree (const UaNodeId &eventNotifier, const UaNodeId &sourceNode, UaEventData *pEventData) const
 Checks whether the passed sourceNode matches the event notifier or is part of the event notifier tree below the eventNotifier. More...
 
virtual UaStatus beginEventTransaction (EventManagerCallback *, const ServiceContext &, OpcUa_UInt32, OpcUa_UInt32, EventTransactionType, OpcUa_Handle &)
 Begins a transaction for modifying the list of event monitored items. More...
 
virtual UaStatus beginStartMonitoring (OpcUa_Handle, OpcUa_UInt32, OpcUa_UInt32, EventCallback *, const EventMonitoringContextCreate &)
 Start monitoring of an event notifier. More...
 
virtual UaStatus beginModifyMonitoring (OpcUa_Handle, OpcUa_UInt32, OpcUa_UInt32, OpcUa_UInt32, const EventMonitoringContext &)
 Notify EventManager about modifying monitoring parameters of an event notifier. More...
 
virtual UaStatus beginStopMonitoring (OpcUa_Handle hEventManagerContext, OpcUa_UInt32, OpcUa_UInt32, OpcUa_UInt32)
 Notify EventManager about stopping monitoring of an event notifier. More...
 
virtual UaStatus finishEventTransaction (OpcUa_Handle)
 Finishes the transaction for changing the list of event monitored items. More...
 
virtual UaStatus beginConditionRefresh (const ServiceContext &serviceContext, OpcUa_UInt32 hEventItem, const UaByteString &, const UaByteString &)
 This method triggers a refresh for all conditions of interest in the EventManager. More...
 
virtual UaStatus sendRefreshRequired (OpcUa_UInt32 hEventItem, const UaByteString &eventId)
 This method triggers a RefreshRequired event to the clients This event forces the clients to synchronize with the current Condition states by calling ConditionRefresh This method needs to be implemented in every EventManager that is part of a system that provides condition objects. More...
 
- Public Member Functions inherited from EventManager
 EventManager ()
 construction
 
virtual ~EventManager ()
 destruction
 

Static Public Member Functions

static void buildEventId (const UaByteString &userEventId, UaByteString &clientEventId)
 Build a unique EventId that can be send to the client and include a user specific part if provided. More...
 
static void getUserEventId (const UaByteString &clientEventId, UaByteString &userEventId)
 Get the user part of a unique EventId that was sent to the client. More...
 
static void registerEventType (const UaNodeId &superType, const UaNodeId &newType)
 Adds a custom event type to the event type tree. More...
 
static OpcUa_UInt32 registerEventField (const UaQualifiedName &fieldName)
 Add a custom event field to assign a unique index for selection of the field of the custom type. More...
 
static OpcUa_UInt32 registerEventField (const UaQualifiedNameArray &path)
 Add a custom event field to assign a unique index for selection of the field of the custom type. More...
 
static OpcUa_UInt32 registerEventField (const UaString &fieldName)
 Add a custom event field to assign a unique index for selection of the field of the custom type. More...
 
static void unregisterEventType (const UaNodeId &typeToRemove)
 Removes a custom event type from the event type tree. More...
 
static void unregisterEventField (OpcUa_UInt32 fieldIndex)
 Removes a custom event field with the unique index assigned in EventManagerBase::registerEventField(). More...
 
static OpcUa_UInt32 getFieldIndex (const OpcUa_SimpleAttributeOperand &selectClause, OpcUa_StatusCode &fieldResult)
 Internal SDK method to get the index of a registered event field. More...
 
static OpcUa_Boolean isOfType (const UaNodeId &eventType, const UaNodeId &typeToEvaluate)
 Internal SDK method used to evaluate the event type with the event filter. More...
 
static void clearStaticMembers ()
 Internal SDK method to clean up static members. More...
 

Additional Inherited Members

- Public Types inherited from EventManager
enum  EventTransactionType { MONITOR_BEGIN, MONITOR_MODIFY, MONITOR_STOP, INVALID }
 EventTransactionType enumeration. More...
 

Detailed Description

Implements the EventManager interface base functionality independent of the node management It handles all active event monitored items and all event filtering and event field selection.

Constructor & Destructor Documentation

EventManagerBase::EventManagerBase ( )

Constructs an EventManagerBase object providing a base implementation of the EventManager interface.

EventManagerBase::~EventManagerBase ( )
virtual

Destroys the EventManagerBase object.

Member Function Documentation

bool EventManagerBase::beforeSendEvent ( UaEventData pEventData,
Session pSession 
)
virtual

Checks if the user is allowed to receive the event.

This method must be overwritten by a derived class to check if the session user is allowed to receive the event. This default implementation returns true.

Returns
true if the user is allowed to receive the event and false if not.
Parameters
[in]pEventDataThe data for the event to send
[in]pSessionThe Session object containing the client and user context that would receive the event.
UaStatus EventManagerBase::beginConditionRefresh ( const ServiceContext serviceContext,
OpcUa_UInt32  hEventItem,
const UaByteString beginEventId,
const UaByteString endEventId 
)
virtual

This method triggers a refresh for all conditions of interest in the EventManager.

Returns
Status code.

Reimplemented from EventManager.

UaStatus EventManagerBase::beginEventTransaction ( EventManagerCallback pCallback,
const ServiceContext serviceContext,
OpcUa_UInt32  hTransaction,
OpcUa_UInt32  totalItemCountHint,
EventTransactionType  transactionType,
OpcUa_Handle &  hEventManagerContext 
)
virtual

Begins a transaction for modifying the list of event monitored items.

Parameters
pCallbackCallback interface used for the transaction. The EventManager must use this interface to finish the action for each passed event monitored item in the transaction.
serviceContextGeneral context for the service calls containing information like the session object, return diagnostic mask and timeout hint.
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. The Event manager must store this handle and use it in callbacks to EventManagerCallback
totalItemCountHintA hint for the EventManager about the total number of monitored items in the transaction. The EventManager may not be responsible for all items but he can use this hint if he wants to optimize memory allocation.
transactionTypeType of the transaction. The possible enum values are:
  • MONITOR_BEGIN
  • MONITOR_MODIFY
  • MONITOR_STOP
hEventManagerContextHandle provided by the EventManager to identify the transaction in the following begin calls.
Returns
Result code of the method call

Implements EventManager.

UaStatus EventManagerBase::beginModifyMonitoring ( OpcUa_Handle  hEventManagerContext,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  eventManagerIndex,
OpcUa_UInt32  hEventItem,
const EventMonitoringContext eventMonitoringContext 
)
virtual

Notify EventManager about modifying monitoring parameters of an event notifier.

Parameters
hEventManagerContextHandle provided by the EventManager in beginEventTransaction used to identify the transaction context for this call.
callbackHandleHandle for the item in the callback.
eventManagerIndexIndex of the EventManager that needs to be passed to the callback function.
hEventItemHandle used to identify the EventItem in the EventManager. The handle is provided by the EventManager in the callback EventManagerCallback::finishStartMonitoring.
eventMonitoringContextSettings for an event monitored item contained in the EventMonitoringContext class.
Returns
Result code of the method call

Implements EventManager.

UaStatus EventManagerBase::beginStartMonitoring ( OpcUa_Handle  hEventManagerContext,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  eventManagerIndex,
EventCallback pEventCallback,
const EventMonitoringContextCreate eventMonitoringContext 
)
virtual

Start monitoring of an event notifier.

Parameters
hEventManagerContextHandle provided by the EventManager in beginEventTransaction used to identify the transaction context for this call.
callbackHandleHandle for the item in the callback.
eventManagerIndexIndex of the EventManager that needs to be passed to the callback function.
pEventCallbackThe callback Interface for the monitored item.
eventMonitoringContextSettings for an event monitored item contained in the EventMonitoringContext class.
Returns
Result code of the method call

Implements EventManager.

UaStatus EventManagerBase::beginStopMonitoring ( OpcUa_Handle  hEventManagerContext,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  eventManagerIndex,
OpcUa_UInt32  hEventItem 
)
virtual

Notify EventManager about stopping monitoring of an event notifier.

Parameters
hEventManagerContextHandle provided by the EventManager in beginEventTransaction used to identify the transaction context for this call.
callbackHandleHandle for the item in the callback.
eventManagerIndexIndex of the EventManager that needs to be passed to the callback function.
hEventItemHandle used to identify the EventItem in the EventManager. The handle is provided by the EventManager in the callback EventManagerCallback::finishStartMonitoring.
Returns
Result code of the method call

Implements EventManager.

void EventManagerBase::buildEventId ( const UaByteString userEventId,
UaByteString clientEventId 
)
static

Build a unique EventId that can be send to the client and include a user specific part if provided.

Parameters
[in]userEventIdOptional user specific part included in the event id
[out]clientEventIdUnique EventId that can be send to the client
void EventManagerBase::clearStaticMembers ( )
static

Internal SDK method to clean up static members.

UaStatus EventManagerBase::finishEventTransaction ( OpcUa_Handle  hEventManagerContext)
virtual

Finishes the transaction for changing the list of event monitored items.

Returns
Status code.
Parameters
[in]hEventManagerContextHandle of the event transaction

Implements EventManager.

void EventManagerBase::fireEvent ( UaEventData pEventData)
virtual

Fire an event with the passed event data to interested clients.

The event is sent to all clients monitoring the related event notifiers where the provided event fields in the event data match the filter criteria set by the client.

Parameters
[in]pEventDataThe data for the event to fire
OpcUa_UInt32 EventManagerBase::getFieldIndex ( const OpcUa_SimpleAttributeOperand selectClause,
OpcUa_StatusCode fieldResult 
)
static

Internal SDK method to get the index of a registered event field.

void EventManagerBase::getUserEventId ( const UaByteString clientEventId,
UaByteString userEventId 
)
static

Get the user part of a unique EventId that was sent to the client.

Parameters
[in]clientEventIdUnique EventId that was sent to the client
[out]userEventIdOptional user specific part included in the event id
OpcUa_Boolean EventManagerBase::inNotifierTree ( const UaNodeId eventNotifier,
const UaNodeId sourceNode,
UaEventData pEventData 
) const
virtual

Checks whether the passed sourceNode matches the event notifier or is part of the event notifier tree below the eventNotifier.

A derived class can overwrite this check to apply its own logic for the event notifier tree.

Parameters
[in]eventNotifierNodeId of the event notifier used in the event monitored item
[in]sourceNodeNodeId of the source node of the event
[in]pEventDataEvent data for the current event. This information can be used by derived classes to do additional checks based on the event data by overwriting this function.
OpcUa_Boolean EventManagerBase::isEventManagerRootNotifier ( const UaNodeId notifier) const
virtual

Checks whether the passed NodeId is a root notifier for this EventManager.

A root notifier is a node that can be used to receive all events from this EventManager. A derived class is able to overwrite this method to allow additional root notifiers in addition to the Server object that is the root notifier for the whole server. If a node is flagged as root notifier and it is used as monitored item, it is not checked if the source node is part of the notifier hierarchy.

Parameters
[in]notifierNodeId of the event notifier used in the event monitored item
OpcUa_Boolean EventManagerBase::isNotifier ( const UaNodeId node) const
virtual

Checks whether the passed NodeId is the NodeId of an event notifier object.

A derived class can overwrite this check to apply its own for verifying if a node is relevant for monitoring in this EventManager.

Parameters
[in]nodeNodeId of the node to check for beeing an event notifier
OpcUa_Boolean EventManagerBase::isOfType ( const UaNodeId eventType,
const UaNodeId typeToEvaluate 
)
static

Internal SDK method used to evaluate the event type with the event filter.

Parameters
[in]eventTypeEvent type that is requested as filter
[in]typeToEvaluateActual event type that needs to be evaluated with the filter event type
OpcUa_UInt32 EventManagerBase::registerEventField ( const UaQualifiedName fieldName)
static

Add a custom event field to assign a unique index for selection of the field of the custom type.

The field name is used by the EventManagerBase to verify if the client selected event field is valid and to get the unique index for optimized access to the event field through UaEventData::getFieldData().

Parameters
fieldNameField name for a field that is a direct component of the event type.
Returns
Unique index for the event field used in UaEventData::getFieldData()
OpcUa_UInt32 EventManagerBase::registerEventField ( const UaQualifiedNameArray path)
static

Add a custom event field to assign a unique index for selection of the field of the custom type.

The field name is used by the EventManagerBase to verify if the client selected event field is valid and to get the unique index for optimized access to the event field through UaEventData::getFieldData().

Parameters
pathPath of qualified names from the event type to the event field.
Returns
Unique index for the event field used in UaEventData::getFieldData()
OpcUa_UInt32 EventManagerBase::registerEventField ( const UaString fieldName)
static

Add a custom event field to assign a unique index for selection of the field of the custom type.

The field name is used by the EventManagerBase to verify if the client selected event field is valid and to get the unique index for optimized access to the event field through UaEventData::getFieldData().

Examples are

  • ns=0|Time (BaseEventType)
  • ns=0|Message (BaseEventType)
  • ns=0|ActiveState (AlarmConditionType)
  • ns=0|ActiveState/ns=0|Id (AlarmConditionType)
  • ns=6|Temperature (User specific event type)
Parameters
fieldNameField name constructed by calling UaQualifiedName::toFullString() for the brows name of the event field. If the field is not a direct component of the event type the string is is constructed by the path of browse names separated with "/".
Returns
Unique index for the event field used in UaEventData::getFieldData()
void EventManagerBase::registerEventNotifier ( const UaNodeId parentNotifier,
const UaNodeId newNotifier 
)
virtual

Add an event notifier to the event notifier tree.

Event notifier objects are objects where the EventNotifier attribute is set to SubscribeToEvents. They can be used as nodes in event monitored items. This can be used to limit the events from the monitored item to a specific event notifier or to a part of an event notifier tree.

Parameters
[in]parentNotifierEvent notifier used as parent for the new event notifier
[in]newNotifierNew event notifier to add to the event notifier tree
void EventManagerBase::registerEventSource ( const UaNodeId parentNotifier,
const UaNodeId newSource 
)
virtual

Add an event source to the event notifier tree.

Event sources are nodes triggering events through one or more notifier objects. Notifier objects are objects where the EventNotifier attribute is set to SubscribeToEvents. They can be used as nodes in event monitored items. This can be used to limit the events from the monitored item to a specific event notifier or to a part of an event notifier tree. This method is used to register an event source with an event notifier for event filtering.

void EventManagerBase::registerEventType ( const UaNodeId superType,
const UaNodeId newType 
)
static

Adds a custom event type to the event type tree.

Parameters
[in]superTypeSuper type used to add the new type as derived type
[in]newTypeNew type to add to the type tree
UaStatus EventManagerBase::sendRefreshRequired ( OpcUa_UInt32  hEventItem,
const UaByteString eventId 
)
virtual

This method triggers a RefreshRequired event to the clients This event forces the clients to synchronize with the current Condition states by calling ConditionRefresh This method needs to be implemented in every EventManager that is part of a system that provides condition objects.

The method is not allowed to be blocked in the EventManager. If the method is called, the EventManager must issue a RefreshStartEventType, must resend the state for any condition where the retain flag is set to true and must send a RefreshEndEventType after the conditions are processed. The refresh start and end events must be sent independent of the number of conditions.

Parameters
hEventItemHandle used to identify the EventItem in the EventManager. The handle is provided by the EventManager in the callback EventManagerCallback::finishStartMonitoring.
eventIdEventId used for the RefreshRequired. All monitored items must use the same EventId for this event.
Returns
Result code of the method call

Reimplemented from EventManager.

void EventManagerBase::shutDownEM ( )
virtual

Shut down the event manager instance.

This disconnects the event manager from all event receivers created with beginStartMonitoring, clears all resources and invalidates the event manager instance.

void EventManagerBase::unregisterEventField ( OpcUa_UInt32  fieldIndex)
static

Removes a custom event field with the unique index assigned in EventManagerBase::registerEventField().

Parameters
[in]fieldIndexIndex assigned in EventManagerBase::registerEventField().
void EventManagerBase::unregisterEventNotifier ( const UaNodeId notifier)
virtual

Removes an event notifier and all of its notifier children and event sources from the event notifier tree.

Parameters
[in]notifierNodeId of the event notifier used in the event monitored item
void EventManagerBase::unregisterEventType ( const UaNodeId typeToRemove)
static

Removes a custom event type from the event type tree.

Parameters
[in]typeToRemoveType to remove from the type tree

The documentation for this class was generated from the following files: