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

Class implementing the OPC UA subscription object. More...

#include <uasubscription.h>

Inherits ReferenceCounter, EventManagerCallback, and IOManagerCallback.

Public Types

enum  State {
  CLOSED, CREATING, NORMAL, LATE,
  KEEPALIVE
}
 Subscription state enumeration. More...
 

Public Member Functions

 UaSubscription (UaSession *pSession, ServerManager *pServerManager, OpcUa_Double publishingInterval, OpcUa_UInt32 &lifetimeCount, OpcUa_UInt32 maxKeepAliveCount, OpcUa_UInt32 maxRetransmissionQueueSize, OpcUa_UInt32 maxNotificationPerPublish, OpcUa_Boolean publishingEnabled, OpcUa_Byte priority)
 construction More...
 
OpcUa_UInt32 activeTransactionCount ()
 Get number of active transactions. More...
 
void waitForTransactionCompletion (OpcUa_UInt32 nExpectedCount=0)
 Wait for completion of all subscription related transactions. More...
 
virtual void setPublishingMode (OpcUa_Boolean publishingEnabled)
 Set publishing mode. More...
 
virtual void modifySubscription (OpcUa_Double publishingInterval, OpcUa_UInt32 &lifetimeCount, OpcUa_UInt32 maxKeepAliveCount, OpcUa_UInt32 maxNotificationPerPublish, OpcUa_Byte priority)
 Modify the subscription settings. More...
 
virtual UaStatus close (OpcUa_Boolean calledFromSessionClose=OpcUa_False, OpcUa_Boolean doNotBlock=OpcUa_False)
 Close subscription. More...
 
virtual UaStatus transfer (UaSession *pSession, OpcUa_Boolean sendInitialValues, UaUInt32Array &availableSequenceNumbers)
 Transfer the subscription to another session.
 
virtual UaStatus beginCreateMonitoredItems (UaCreateMonitoredItemsContext *pUaCreateMonitoredItemsContext)
 Create new monitored items. More...
 
virtual UaStatus beginModifyMonitoredItems (UaModifyMonitoredItemsContext *pUaModifyMonitoredItemsContext)
 Modify monitored items. More...
 
virtual UaStatus beginSetMonitoringMode (UaSetMonitoringModeContext *pUaSetMonitoringModeContext)
 Set monitoring mode of monitored items. More...
 
virtual UaStatus setTriggering (OpcUa_UInt32 triggeringItemId, const UaUInt32Array &linksToAdd, const UaUInt32Array &linksToRemove, UaStatusCodeArray &addResults, UaStatusCodeArray &removeResults)
 Set triggering of monitored items. More...
 
virtual UaStatus beginDeleteMonitoredItems (UaDeleteMonitoredItemsContext *pUaDeleteMonitoredItemsContext)
 Delete monitored items. More...
 
virtual void createMonitoredItemsFinished (OpcUa_CreateMonitoredItemsRequest *, const UaMonitoredItemCreateResults &)
 Event for derived class after create monitored items is finished.
 
virtual void modifyMonitoredItemsFinished (OpcUa_ModifyMonitoredItemsRequest *, const UaMonitoredItemModifyResults &)
 Event for derived class after delete monitored items is finished.
 
virtual void setMonitoringModeFinished (OpcUa_SetMonitoringModeRequest *, const UaStatusCodeArray &)
 Event for derived class after delete monitored items is finished.
 
virtual void deleteMonitoredItemsFinished (OpcUa_DeleteMonitoredItemsRequest *, const UaStatusCodeArray &)
 Event for derived class after delete monitored items is finished.
 
UaStatus beginConditionRefresh (const ServiceContext &serviceContext)
 Refresh condition state for the subscription. More...
 
UaStatus beginConditionRefresh2 (const ServiceContext &serviceContext, OpcUa_UInt32 monitoredItemId)
 Refresh condition state for the passed monitored item in the subscription. More...
 
void dynamicEventManagerRegistered (EventManager *pEventManager)
 Executes the registration of a new EventManager added to the server. More...
 
virtual UaStatus publish (UaPublishContext *pUaPublishContext, OpcUa_Boolean &hasMoreNotifications)
 Publish the notification message. More...
 
virtual UaStatus republish (UaRepublishContext *pUaRepublishContext)
 Republish a lost notification message. More...
 
virtual OpcUa_UInt32 checkPublishTimer (OpcUa_Boolean &doCheckAvailableNotifications)
 Check if the publish timer expired and returns the remaining time in milliseconds to the next event. More...
 
virtual void checkAvailableNotifications ()
 Check if notifications are available. More...
 
OpcUa_StatusCode ackNotification (OpcUa_UInt32 sequenceNumber)
 Achnowledge and delete a notification message. More...
 
State state ()
 Get state of the subscription. More...
 
void setThreadPool (UaThreadPool *pThreadPool)
 Set thread pool for service processing. More...
 
void setSubscriptionId (OpcUa_UInt32 subscriptionId)
 Set subscription Id. More...
 
OpcUa_UInt32 subscriptionId () const
 Get subscription Id. More...
 
OpcUa_Double publishingInterval () const
 Get the cyclic rate that the Subscription is being requested to return Notifications to the Client.
 
OpcUa_UInt32 lifetimeCount () const
 Returns the lifetime count of the Subscription When the publishing timer has expired this number of times without a publish request being available to send a NotificationMessage, then the subscription will be deleted by the server.
 
OpcUa_UInt32 keepAliveCount () const
 Returns the keep alive count of the Subscription When the publishing timer has expired this number of times without requiring any NotificationMessage to be sent, the Subscription sends an empty keep-alive message to the Client.
 
UaStatus finishRead (OpcUa_UInt32, OpcUa_UInt32, UaDataValue &, OpcUa_Boolean, OpcUa_Boolean, UaDiagnosticInfo *)
 Finished reading of an attribute value of a node. More...
 
UaStatus finishWrite (OpcUa_UInt32, OpcUa_UInt32, const UaStatus &, OpcUa_Boolean)
 Finished writing of an attribute value of a node. More...
 
UaStatus finishStartMonitoring (OpcUa_UInt32 hTransaction, OpcUa_UInt32 callbackHandle, OpcUa_UInt32 hIOVariable, OpcUa_Double revisedSamplingInterval, OpcUa_Boolean initialDataValueAvailable, const UaDataValue &initialDataValue, const UaStatus &statusCode)
 Finished transaction to start monitoring a data item. More...
 
UaStatus finishModifyMonitoring (OpcUa_UInt32 hTransaction, OpcUa_UInt32 callbackHandle, OpcUa_Double revisedSamplingInterval, const UaStatus &statusCode)
 Finished modifying monitoring of a data item. More...
 
UaStatus finishStopMonitoring (OpcUa_UInt32 hTransaction, OpcUa_UInt32 callbackHandle, const UaStatus &statusCode)
 Finished stopping monitoring of an data item. More...
 
UaStatus finishStartMonitoring (OpcUa_UInt32, OpcUa_UInt32, OpcUa_UInt32, OpcUa_UInt32, OpcUa_Double, const UaStatus &, OpcUa_EventFilterResult *)
 Finished transaction to start monitoring an event item. More...
 
UaStatus finishModifyMonitoring (OpcUa_UInt32, OpcUa_UInt32, OpcUa_UInt32, OpcUa_Double, const UaStatus &, OpcUa_EventFilterResult *)
 Finished modifying monitoring of an event item. More...
 
UaStatus finishStopMonitoring (OpcUa_UInt32, OpcUa_UInt32, OpcUa_UInt32, const UaStatus &)
 Finished stopping monitoring of an event item. More...
 
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter ()
 construction
 
virtual ~ReferenceCounter ()
 destruction
 
- Public Member Functions inherited from EventManagerCallback
 EventManagerCallback ()
 construction
 
virtual ~EventManagerCallback ()
 destruction
 
- Public Member Functions inherited from IOManagerCallback
 IOManagerCallback ()
 Construction.
 
virtual ~IOManagerCallback ()
 Destruction.
 

Protected Member Functions

virtual ~UaSubscription ()
 destruction
 

Detailed Description

Class implementing the OPC UA subscription object.

It manages all subscription relevant settings including the lifetime of the subscription. The object is reference counted and can not be deleted directly.

Member Enumeration Documentation

Subscription state enumeration.

Enumerator
CLOSED 

State: Closed

CREATING 

State: Creating

NORMAL 

State: Normal

LATE 

State: Late

KEEPALIVE 

State: KeepAlive

Constructor & Destructor Documentation

UaSubscription::UaSubscription ( UaSession pSession,
ServerManager pServerManager,
OpcUa_Double  publishingInterval,
OpcUa_UInt32 &  lifetimeCount,
OpcUa_UInt32  maxKeepAliveCount,
OpcUa_UInt32  maxRetransmissionQueueSize,
OpcUa_UInt32  maxNotificationPerPublish,
OpcUa_Boolean  publishingEnabled,
OpcUa_Byte  priority 
)

construction

Parameters
pSessionInterface to the Session context for the method call
pServerManagera pointer to the root ServerManager.
publishingIntervalpublishing interval in milliseconds the server allows
lifetimeCounta count for the the actual lifetime.
maxKeepAliveCountthe maximum of Time to keep the Session alive.
maxRetransmissionQueueSizethe maximum number of notification messages queued for retransmittion.
maxNotificationPerPublishthe maximum of notification per Publish.
publishingEnabledindicates if publishing is enabled or not.
prioritythe priority of the operation.

Member Function Documentation

OpcUa_StatusCode UaSubscription::ackNotification ( OpcUa_UInt32  sequenceNumber)

Achnowledge and delete a notification message.

Parameters
sequenceNumberThe sequence number of the ackloedged notification
OpcUa_UInt32 UaSubscription::activeTransactionCount ( )

Get number of active transactions.

UaStatus UaSubscription::beginConditionRefresh ( const ServiceContext serviceContext)

Refresh condition state for the subscription.

Parameters
serviceContextService context for the call.
UaStatus UaSubscription::beginConditionRefresh2 ( const ServiceContext serviceContext,
OpcUa_UInt32  monitoredItemId 
)

Refresh condition state for the passed monitored item in the subscription.

Parameters
serviceContextService context for the call.
monitoredItemIdMonitoredItemId for the monitored item to refresh.
UaStatus UaSubscription::beginCreateMonitoredItems ( UaCreateMonitoredItemsContext pUaCreateMonitoredItemsContext)
virtual

Create new monitored items.

Parameters
pUaCreateMonitoredItemsContextthe context of the items to create.
Returns
Error code

List of objects to store a subset of the data for a IOManager

UaStatus UaSubscription::beginDeleteMonitoredItems ( UaDeleteMonitoredItemsContext pUaDeleteMonitoredItemsContext)
virtual

Delete monitored items.

Parameters
pUaDeleteMonitoredItemsContextthe context of the monitored items to delete.
Returns
Error code

List of objects to store a subset of the data for an IOManager

UaStatus UaSubscription::beginModifyMonitoredItems ( UaModifyMonitoredItemsContext pUaModifyMonitoredItemsContext)
virtual

Modify monitored items.

Parameters
pUaModifyMonitoredItemsContextthe context for the monitored items to modify.
Returns
Error code

List of objects to store a subset of the data for a IOManager

UaStatus UaSubscription::beginSetMonitoringMode ( UaSetMonitoringModeContext pUaSetMonitoringModeContext)
virtual

Set monitoring mode of monitored items.

Parameters
pUaSetMonitoringModeContextthe monitored context of the item to modify.
Returns
Error code

List of objects to store a subset of the data for a IOManager

void UaSubscription::checkAvailableNotifications ( )
virtual

Check if notifications are available.

OpcUa_UInt32 UaSubscription::checkPublishTimer ( OpcUa_Boolean &  doCheckAvailableNotifications)
virtual

Check if the publish timer expired and returns the remaining time in milliseconds to the next event.

Parameters
doCheckAvailableNotificationsif true, checks if there are notifications available.
Returns
the remaining time in milliseconds to the next event.
UaStatus UaSubscription::close ( OpcUa_Boolean  calledFromSessionClose = OpcUa_False,
OpcUa_Boolean  doNotBlock = OpcUa_False 
)
virtual

Close subscription.

Parameters
calledFromSessionClosetrue if session closed false if not.
doNotBlocktrue if caller should not be blocked to wait for transaction completion.
Returns
Error code

List of objects to store a subset of the data for a IOManager

void UaSubscription::dynamicEventManagerRegistered ( EventManager pEventManager)

Executes the registration of a new EventManager added to the server.

Parameters
pEventManagerEventManager to register with this call
UaStatus UaSubscription::finishModifyMonitoring ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
OpcUa_Double  revisedSamplingInterval,
const UaStatus statusCode 
)
virtual

Finished modifying monitoring of a data item.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginModifyMonitoring method.
revisedSamplingIntervalThe corresponding revised sampling interval for the requested sampling interval in beginStartMonitoring.
statusCodeResult of the finishModifyMonitoring operation.
Returns
Error code

Implements IOManagerCallback.

UaStatus UaSubscription::finishModifyMonitoring ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  eventManagerIndex,
OpcUa_Double  revisedSamplingInterval,
const UaStatus statusCode,
OpcUa_EventFilterResult pEventFilterResult 
)
virtual

Finished modifying monitoring of an event item.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginModifyMonitoring method.
eventManagerIndexan Index of different EventManagers.
revisedSamplingIntervalThe corresponding revised sampling interval for the requested sampling interval in beginStartMonitoring.
statusCodeResult of the finishModifyMonitoring operation.
pEventFilterResultThe resulted status code of the filtered events
Returns
Error code

Implements EventManagerCallback.

UaStatus UaSubscription::finishRead ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
UaDataValue dataValue,
OpcUa_Boolean  detachValue,
OpcUa_Boolean  allowThreadUse,
UaDiagnosticInfo pDiagnosticInfo 
)
inlinevirtual

Finished reading of an attribute value of a node.

The method is called to finish a read call for an attribute value of a node. The read is started with the beginRead method of the interface IOManager.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginRead method.
dataValueContains the value, timestamps and result code for the Read operation.
detachValueIndicates if the method can detach the value from the wrapper class.
allowThreadUseIndicates if the calling thread can be used by the SDK to send the response to the client. This can happen if this method is the called for the last node in the transaction.
True: The thread calling this method can be used to send the response and may block
False: The SDK is using a worker thread to send the response to the client.
pDiagnosticInfoOptional diagnostig information requested by the client in the parameter ServiceContext::returnDiagnostics of IOManager::beginTransaction
Returns
Error code

Implements IOManagerCallback.

UaStatus UaSubscription::finishStartMonitoring ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  hIOVariable,
OpcUa_Double  revisedSamplingInterval,
OpcUa_Boolean  initialDataValueAvailable,
const UaDataValue initialDataValue,
const UaStatus statusCode 
)
virtual

Finished transaction to start monitoring a data item.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginStartMonitoring method.
hIOVariableThe handle of the variable in the IOManager created with beginStartMonitoring. The handle was passed to the SDK in the callback finishStartMonitoring.
revisedSamplingIntervalThe corresponding revised sampling interval for the requested sampling interval in beginStartMonitoring.
initialDataValueAvailablethe available initial data value.
initialDataValuethe actual data value.
statusCodeResult of the finishStartMonitoring operation.
Returns
Error code

Implements IOManagerCallback.

UaStatus UaSubscription::finishStartMonitoring ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  eventManagerIndex,
OpcUa_UInt32  hEventItem,
OpcUa_Double  revisedSamplingInterval,
const UaStatus statusCode,
OpcUa_EventFilterResult pEventFilterResult 
)
virtual

Finished transaction to start monitoring an event item.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginModifyMonitoring method.
eventManagerIndexan Index of different EventManagers.
hEventIteman EventItem used to fire an Event.
revisedSamplingIntervalThe corresponding revised sampling interval for the requested sampling interval in beginStartMonitoring.
statusCodeResult of the finishStartMonitoring operation.
pEventFilterResultThe resulted status code of the filtered events
Returns
Error code

Implements EventManagerCallback.

UaStatus UaSubscription::finishStopMonitoring ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
const UaStatus statusCode 
)
virtual

Finished stopping monitoring of an data item.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginModifyMonitoring method.
statusCodeResult of the finishStopMonitoring operation.
Returns
Error code

Implements IOManagerCallback.

UaStatus UaSubscription::finishStopMonitoring ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
OpcUa_UInt32  eventManagerIndex,
const UaStatus statusCode 
)
virtual

Finished stopping monitoring of an event item.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginModifyMonitoring method.
eventManagerIndexan Index of different EventManagers.
statusCodeResult of the finishStopMonitoring operation.
Returns
Error code

Implements EventManagerCallback.

UaStatus UaSubscription::finishWrite ( OpcUa_UInt32  hTransaction,
OpcUa_UInt32  callbackHandle,
const UaStatus statusCode,
OpcUa_Boolean  allowThreadUse 
)
inlinevirtual

Finished writing of an attribute value of a node.

The method is called to finish a write call for an attribute value of a node. The write is started with the beginWrite method of the interface IOManager.

Parameters
hTransactionHandle for the transaction used by the SDK to identify the transaction in the callbacks. This handle was passed in to the IOManager with the beginTransaction method.
callbackHandleHandle for the node in the callback. This handle was passed in to the IOManager with the beginWrite method.
statusCodeResult of the Write operation. Optional diagnostig information requested by the client in the parameter ServiceContext::returnDiagnostics of IOManager::beginTransaction can be provided through UaStatus::setDiagnosticInfo().
allowThreadUseIndicates if the calling thread can be used by the SDK to send the response to the client. This can happen if this method is the called for the last node in the transaction.
True: The thread calling this method can be used to send the response and may block
False: The SDK is using a worker thread to send the response to the client.
Returns
Error code

Implements IOManagerCallback.

void UaSubscription::modifySubscription ( OpcUa_Double  publishingInterval,
OpcUa_UInt32 &  lifetimeCount,
OpcUa_UInt32  maxKeepAliveCount,
OpcUa_UInt32  maxNotificationPerPublish,
OpcUa_Byte  priority 
)
virtual

Modify the subscription settings.

Parameters
publishingIntervalpublishing interval in milliseconds the server allows
lifetimeCounta count for the the actual lifetime.
maxKeepAliveCountthe maximum of Time to keep the Session alive.
maxNotificationPerPublishthe maximum of notification per Publish.
prioritythe priority of the operation.
UaStatus UaSubscription::publish ( UaPublishContext pUaPublishContext,
OpcUa_Boolean &  hasMoreNotifications 
)
virtual

Publish the notification message.

Parameters
pUaPublishContextthe context of the published notification.
hasMoreNotificationsindicates if there are more notifications in the message.
Returns
Error code
UaStatus UaSubscription::republish ( UaRepublishContext pUaRepublishContext)
virtual

Republish a lost notification message.

Parameters
pUaRepublishContextThe context of the republish call.
Returns
Error code
void UaSubscription::setPublishingMode ( OpcUa_Boolean  publishingEnabled)
virtual

Set publishing mode.

Parameters
publishingEnabledindicates if publishing is enabled or not.
void UaSubscription::setSubscriptionId ( OpcUa_UInt32  subscriptionId)

Set subscription Id.

Sets the subscription id for the subscription.

void UaSubscription::setThreadPool ( UaThreadPool pThreadPool)
inline

Set thread pool for service processing.

UaStatus UaSubscription::setTriggering ( OpcUa_UInt32  triggeringItemId,
const UaUInt32Array linksToAdd,
const UaUInt32Array linksToRemove,
UaStatusCodeArray addResults,
UaStatusCodeArray removeResults 
)
virtual

Set triggering of monitored items.

Parameters
triggeringItemIdhe Id of the items to set triggering to.
linksToAddThe links to add to the monitored item
linksToRemoveThe links to remove from the monitored item
addResultsThe results to add to the monitored item.
removeResultsThe results to remove from the monitored item.
Returns
Error code
UaSubscription::State UaSubscription::state ( )

Get state of the subscription.

OpcUa_UInt32 UaSubscription::subscriptionId ( ) const
inline

Get subscription Id.

void UaSubscription::waitForTransactionCompletion ( OpcUa_UInt32  nExpectedCount = 0)

Wait for completion of all subscription related transactions.


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