C++ Based OPC UA Client/Server SDK  1.5.3.346
UaClientSdk::UaSubscriptionCallback Class Referenceabstract

UaSubscriptionCallback defines the callback interface for the UaSubscription class. More...

#include <uaclientsdk.h>

Public Member Functions

virtual void subscriptionStatusChanged (OpcUa_UInt32 clientSubscriptionHandle, const UaStatus &status)=0
 Send subscription state change. More...
 
virtual void keepAlive (OpcUa_UInt32 clientSubscriptionHandle)
 Send subscription keep alive. More...
 
virtual void notificationsMissing (OpcUa_UInt32 clientSubscriptionHandle, OpcUa_UInt32 previousSequenceNumber, OpcUa_UInt32 newSequenceNumber)
 Informs the client about missing notification messages. More...
 
virtual void dataChange (OpcUa_UInt32 clientSubscriptionHandle, const UaDataNotifications &dataNotifications, const UaDiagnosticInfos &diagnosticInfos)=0
 Send changed data. More...
 
virtual void newEvents (OpcUa_UInt32 clientSubscriptionHandle, UaEventFieldLists &eventFieldList)=0
 Send new events. More...
 
virtual void createMonitoredItemsComplete (OpcUa_UInt32 transactionId, const UaStatus &result, const UaMonitoredItemCreateResults &createResults, const UaDiagnosticInfos &diagnosticInfos)
 Send createMonitoredItems results. More...
 
virtual void modifyMonitoredItemsComplete (OpcUa_UInt32 transactionId, const UaStatus &result, const UaMonitoredItemModifyResults &modifyResults, const UaDiagnosticInfos &diagnosticInfos)
 Send modifyMonitoredItems results. More...
 
virtual void setMonitoringModeComplete (OpcUa_UInt32 transactionId, const UaStatus &result, const UaStatusCodeArray &setModeResults, const UaDiagnosticInfos &diagnosticInfos)
 Send setMonitoringMode results. More...
 
virtual void deleteMonitoredItemsComplete (OpcUa_UInt32 transactionId, const UaStatus &result, const UaStatusCodeArray &deleteResults, const UaDiagnosticInfos &diagnosticInfos)
 Send deleteMonitoredItems results. More...
 

Detailed Description

UaSubscriptionCallback defines the callback interface for the UaSubscription class.

This callback interface needs to be implemented by the user of the UaSubscription class to receive data change, event and subscription status change callbacks from the Client SDK. The interface provides also a callback function for keep alive calls from the server. This function needs to be implemented only by users of the SDK interested in the keep alive callbacks. The status of the subscription is normally monitored by the SDK and changes are indicated by sending subscription status changed callbacks.

In cases of Subscription errors the user of the SDK is responsible for creating a new subscription since the SDK does not keep the information to recreate the Subscription to not increase memory consumption. The necessary information needs to be kept also by the client application anyway. To duplicate this information in the SDK consumes too much memory.

Callbacks from the SDK APIs are coming from different worker threads and not from the thread that was used to connect to the server. It is in the responsibility of the user of the client API to synchronize the data provided by the callbacks with a GUI main thread if this is necessary.

Publish responses are processed in worker threads from a thread pool. A Publish response may trigger one or more callbacks including dataChange newEvents, notificationsMissing and keepAlive. The Publish responses are processed in the order they are received by the stack. For the UA TCP protocol this normally ensures that the sequence numbers are processed in order. The processing of a Publish response will not start if another Publish response for the same UaSubscription object is still processed and callbacks are not returned by the client application.

Member Function Documentation

void UaClientSdk::UaSubscriptionCallback::createMonitoredItemsComplete ( OpcUa_UInt32  transactionId,
const UaStatus result,
const UaMonitoredItemCreateResults createResults,
const UaDiagnosticInfos &  diagnosticInfos 
)
virtual

Send createMonitoredItems results.

This is the callback function for calls to UaSubscription::beginCreateMonitoredItems.

Parameters
[in]transactionIdClient defined transaction id for the createMonitoredItems
[in]resultOverall createMonitoredItems service result
[in]createResultsList of createMonitoredItems operation results
[in]diagnosticInfosList of diagnostic information
virtual void UaClientSdk::UaSubscriptionCallback::dataChange ( OpcUa_UInt32  clientSubscriptionHandle,
const UaDataNotifications &  dataNotifications,
const UaDiagnosticInfos &  diagnosticInfos 
)
pure virtual

Send changed data.

This callback function provides the data notification for a subscription.

Data changes may arrive for monitored items before the creation of the monitored item is completed and the createMonitoredItems call returns. The client application must be prepared for that and ClientHandles passed in to createMonitoredItems must be valid and usable before createMonitoredItems returns.

Data changes may also arrive after monitored items are deleted, sampling is turned off, or after the publishing is disabled.

This callback is normally not called faster than configured in SubscriptionSettings::publishingInterval but this is controlled by the OPC UA Server and not by the client SDK. If the number of notifications in one publishing interval exceeds the setting SubscriptionSettings::maxNotificationsPerPublish, the OPC UA Server will send more than one Publish response and this dataChange may be called more than one time in the publishingInterval.

If no new data is available in a publishingInterval, no dataChange is called and a UaSubscriptionCallback::keepAlive callback may be called depending on the settings in SubscriptionSettings::maxKeepAliveCount.

The dataChange is called from a worker thread but it should not be blocked by the application since this will block other callbacks like newEvents contained in the same Publish response and also blocks more Publish responses received for the same UaSubscription object. See the general description of the callback class for more details on Publish response processing.

Parameters
[in]clientSubscriptionHandleClient defined handle of the affected subscription. The handle can be ignored if the callback object is only used by one subscription.
[in]dataNotificationsList of data notifications sent by the server
[in]diagnosticInfosList of diagnostic info related to the data notifications. This list can be empty.
void UaClientSdk::UaSubscriptionCallback::deleteMonitoredItemsComplete ( OpcUa_UInt32  transactionId,
const UaStatus result,
const UaStatusCodeArray deleteResults,
const UaDiagnosticInfos &  diagnosticInfos 
)
virtual

Send deleteMonitoredItems results.

This is the callback function for calls to UaSubscription::beginDeleteMonitoredItems.

Parameters
[in]transactionIdClient defined transaction id for the deleteMonitoredItems
[in]resultOverall deleteMonitoredItems service result
[in]deleteResultsList of deleteMonitoredItems operation results
[in]diagnosticInfosList of diagnostic information
void UaClientSdk::UaSubscriptionCallback::keepAlive ( OpcUa_UInt32  clientSubscriptionHandle)
virtual

Send subscription keep alive.

This callback function provides the keep alive messages sent by the server if no changed data or events are available.

The frequency of calls to this callback function depends on the settings in SubscriptionSettings::maxKeepAliveCount and the availability of data and events.

Parameters
[in]clientSubscriptionHandleClient defined handle of the affected subscription. The handle can be ignored if the callback object is only used by one subscription.
void UaClientSdk::UaSubscriptionCallback::modifyMonitoredItemsComplete ( OpcUa_UInt32  transactionId,
const UaStatus result,
const UaMonitoredItemModifyResults modifyResults,
const UaDiagnosticInfos &  diagnosticInfos 
)
virtual

Send modifyMonitoredItems results.

This is the callback function for calls to UaSubscription::beginModifyMonitoredItems.

Parameters
[in]transactionIdClient defined transaction id for the modifyMonitoredItems
[in]resultOverall modifyMonitoredItems service result
[in]modifyResultsList of modifyMonitoredItems operation results
[in]diagnosticInfosList of diagnostic information
virtual void UaClientSdk::UaSubscriptionCallback::newEvents ( OpcUa_UInt32  clientSubscriptionHandle,
UaEventFieldLists eventFieldList 
)
pure virtual

Send new events.

This callback function provides the event notification for a subscription.

New events may arrive for monitored items before the creation of the monitored item is completed and the createMonitoredItems call returns. The client application must be prepared for that and ClientHandles passed in to createMonitoredItems must be valid and usable before createMonitoredItems returns.

New events may also arrive after monitored items are deleted, sampling is turned off, or after the publishing is disabled.

This callback is normally not called faster than configured in SubscriptionSettings::publishingInterval but this is controlled by the OPC UA Server and not by the client SDK. If the number of notifications in one publishing interval exceeds the setting SubscriptionSettings::maxNotificationsPerPublish, the OPC UA Server will send more than one Publish response and this newEvents may be called more than one time in the publishingInterval.

If no new events are available in a publishingInterval, no newEvents is called and a UaSubscriptionCallback::keepAlive callback may be called depending on the settings in SubscriptionSettings::maxKeepAliveCount.

The newEvents is called from a worker thread but it should not be blocked by the application since this will block other callbacks like dataChange contained in the same Publish response and also blocks more Publish responses received for the same UaSubscription object. See the general description of the callback class for more details on Publish response processing.

Parameters
[in]clientSubscriptionHandleClient defined handle of the affected subscription. The handle can be ignored if the callback object is only used by one subscription.
[in]eventFieldListList of event notifications sent by the server
void UaClientSdk::UaSubscriptionCallback::notificationsMissing ( OpcUa_UInt32  clientSubscriptionHandle,
OpcUa_UInt32  previousSequenceNumber,
OpcUa_UInt32  newSequenceNumber 
)
virtual

Informs the client about missing notification messages.

The client SDK monitors the sequence numbers of the received data and event notifications and reports gaps in the sequence numbers using this callback method. The client can use the UaSubscription::republish method to request the missing notifications.

The notificationsMissing is called from a worker thread but it should not be blocked by the application since this will block other callbacks like dataChange contained in the same Publish response and also blocks more Publish responses received for the same UaSubscription object. See the general description of the callback class for more details on Publish response processing.

Parameters
[in]clientSubscriptionHandleClient defined handle of the affected subscription. The handle can be ignored if the callback object is only used by one subscription.
[in]previousSequenceNumberSequence number of the previously received notification
[in]newSequenceNumberSequence number of the new notification
void UaClientSdk::UaSubscriptionCallback::setMonitoringModeComplete ( OpcUa_UInt32  transactionId,
const UaStatus result,
const UaStatusCodeArray setModeResults,
const UaDiagnosticInfos &  diagnosticInfos 
)
virtual

Send setMonitoringMode results.

This is the callback function for calls to UaSubscription::beginSetMonitoringMode.

Parameters
[in]transactionIdClient defined transaction id for the setMonitoringMode
[in]resultOverall setMonitoringMode service result
[in]setModeResultsList of setMonitoringMode operation results
[in]diagnosticInfosList of diagnostic information
virtual void UaClientSdk::UaSubscriptionCallback::subscriptionStatusChanged ( OpcUa_UInt32  clientSubscriptionHandle,
const UaStatus status 
)
pure virtual

Send subscription state change.

This callback function informs the client if the status of a subscription changes. This can happen after a connection error that lasted longer than the lifetime of the subscription. The lifetime is calculated from PublishingInterval x LifetimeCount. A client must create a new subscription to continue data or event monitoring if this callback indicates a bad status for the subscription. UaSession::deleteSubscription should be called even if the subscription is no longer valid in the server to clear the client side subscription object.

Parameters
[in]clientSubscriptionHandleClient defined handle of the affected subscription. The handle can be ignored if the callback object is only used by one subscription.
[in]statusStatus code indicating the error status of the subcription

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