C++ Based OPC UA Client/Server SDK  1.5.3.346
UaClientSdk::UaSubscription Class Reference

The UaSubscription class manges a UA Client created subscription. More...

#include <uasubscription.h>

Public Member Functions

UaStatus modifySubscription (ServiceSettings &serviceSettings, SubscriptionSettings &subscriptionSettings)
 Modify the subscription settings. More...
 
UaStatus setPublishingMode (ServiceSettings &serviceSettings, OpcUa_Boolean publishingEnabled)
 Set the publishing mode of the subscription. More...
 
UaStatus createMonitoredItems (ServiceSettings &serviceSettings, OpcUa_TimestampsToReturn timestampsToReturn, const UaMonitoredItemCreateRequests &monitoredItemCreateRequests, UaMonitoredItemCreateResults &monitoredItemCreateResults)
 Creates a list of monitored items in the subscriptions. More...
 
UaStatus modifyMonitoredItems (ServiceSettings &serviceSettings, OpcUa_TimestampsToReturn timestampsToReturn, const UaMonitoredItemModifyRequests &monitoredItemModifyRequests, UaMonitoredItemModifyResults &monitoredItemModifyResults)
 Modify monitored items. More...
 
UaStatus setMonitoringMode (ServiceSettings &serviceSettings, OpcUa_MonitoringMode monitoringMode, const UaUInt32Array &monitoredItemIds, UaStatusCodeArray &results)
 Set monitoring mode for monitored items. More...
 
UaStatus setTriggering (ServiceSettings &serviceSettings, OpcUa_UInt32 triggeringItemId, const UaUInt32Array &linksToAdd, const UaUInt32Array &linksToRemove, UaStatusCodeArray &addResults, UaStatusCodeArray &removeResults)
 Creates or deletes links from trigger items to triggered monitored items. More...
 
UaStatus deleteMonitoredItems (ServiceSettings &serviceSettings, const UaUInt32Array &monitoredItemIds, UaStatusCodeArray &results)
 Delete monitored items. More...
 
UaStatus republish (ServiceSettings &serviceSettings, OpcUa_UInt32 retransmitSequenceNumber, UaDataNotifications &dataNotifications, UaDiagnosticInfos &diagnosticInfos, UaEventFieldLists &eventFieldList, UaStatus &subscriptionStatus)
 Republish call to get lost notifications. More...
 
UaStatus beginCreateMonitoredItems (ServiceSettings &serviceSettings, OpcUa_TimestampsToReturn timestampsToReturn, const UaMonitoredItemCreateRequests &monitoredItemCreateRequests, OpcUa_UInt32 transactionId)
 Asynchronous call to create a list of monitored items in the subscriptions. More...
 
UaStatus beginModifyMonitoredItems (ServiceSettings &serviceSettings, OpcUa_TimestampsToReturn timestampsToReturn, const UaMonitoredItemModifyRequests &monitoredItemModifyRequests, OpcUa_UInt32 transactionId)
 Asynchronous call to modify monitored items. More...
 
UaStatus beginSetMonitoringMode (ServiceSettings &serviceSettings, OpcUa_MonitoringMode monitoringMode, const UaUInt32Array &monitoredItemIds, OpcUa_UInt32 transactionId)
 Asynchronous call to set monitoring mode for monitored items. More...
 
UaStatus beginDeleteMonitoredItems (ServiceSettings &serviceSettings, const UaUInt32Array &monitoredItemIds, OpcUa_UInt32 transactionId)
 Asynchronous call to delete monitored items. More...
 
OpcUa_UInt32 subscriptionId ()
 Returns the id of the subscription.
 
OpcUa_UInt32 clientSubscriptionHandle ()
 Returns the client subscription handle for the subscription.
 
OpcUa_Double publishingInterval ()
 Returns the publishing interval of the subscription.
 
OpcUa_UInt32 lifetimeCount ()
 Returns the lifetime count of the subscription. More...
 
OpcUa_UInt32 maxKeepAliveCount ()
 Returns the maximum keep alive count of the subscription.
 
OpcUa_UInt32 maxNotificationsPerPublish ()
 Returns the maximum number of notifications per publish for the subscription.
 
OpcUa_Byte priority ()
 Returns the priority of the subscription.
 
OpcUa_Boolean publishingEnabled ()
 Returns the publish enabled flag of the subscription.
 

Detailed Description

The UaSubscription class manges a UA Client created subscription.

The class provides all Subscription related UA Services as synchronous and asynchronous methods.

The callback interface UaSubscriptionCallback 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 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 also needs to be kept by the client application anyway. To duplicate this information in the SDK consumes too much memory.

A UaSubscription object is thread-safe.

Member Function Documentation

UaStatus UaSubscription::beginCreateMonitoredItems ( ServiceSettings serviceSettings,
OpcUa_TimestampsToReturn  timestampsToReturn,
const UaMonitoredItemCreateRequests monitoredItemCreateRequests,
OpcUa_UInt32  transactionId 
)

Asynchronous call to create a list of monitored items in the subscriptions.

The monitored items could be data monitored items or event monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]timestampsToReturnOPC UA defines two timestamps, the source and the server timestamp. This parameter allows the client to define which timestamps the server should return with the value.

The source timestamp is only available for Value Attributes. The source timestamp is used to reflect the timestamp that was applied to a Variable value by the data source. It should indicate the last change of the value or status code. The source timestamp must be always generated by the same physical clock. This timestamp type was added for OPC UA to cover the use case to get the timestamp of the last value change which is different than the server timestamp definition.

The server timestamp is used to reflect the time that the server received a Variable value or knew it to be accurate if the changes are reported by exception and the connection to the data source is operating. This is the behavior expected by Classic OPC.

Possible values are:
  • OpcUa_TimestampsToReturn_Source
  • OpcUa_TimestampsToReturn_Server
  • OpcUa_TimestampsToReturn_Both
[in]monitoredItemCreateRequestsList of monitored items to create
[in]transactionIdTransaction ID for the asynchronous call used to assign the callback to the transaction
UaStatus UaSubscription::beginDeleteMonitoredItems ( ServiceSettings serviceSettings,
const UaUInt32Array monitoredItemIds,
OpcUa_UInt32  transactionId 
)

Asynchronous call to delete monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]monitoredItemIdsList of monitored items to delete
[in]transactionIdTransaction ID for the asynchronous call used to assign the callback to the transaction
UaStatus UaSubscription::beginModifyMonitoredItems ( ServiceSettings serviceSettings,
OpcUa_TimestampsToReturn  timestampsToReturn,
const UaMonitoredItemModifyRequests monitoredItemModifyRequests,
OpcUa_UInt32  transactionId 
)

Asynchronous call to modify monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]timestampsToReturnOPC UA defines two timestamps, the source and the server timestamp. This parameter allows the client to define which timestamps the server should return with the value.

The source timestamp is only available for Value Attributes. The source timestamp is used to reflect the timestamp that was applied to a Variable value by the data source. It should indicate the last change of the value or status code. The source timestamp must be always generated by the same physical clock. This timestamp type was added for OPC UA to cover the use case to get the timestamp of the last value change which is different than the server timestamp definition.

The server timestamp is used to reflect the time that the server received a Variable value or knew it to be accurate if the changes are reported by exception and the connection to the data source is operating. This is the behavior expected by Classic OPC.

Possible values are:
  • OpcUa_TimestampsToReturn_Source
  • OpcUa_TimestampsToReturn_Server
  • OpcUa_TimestampsToReturn_Both
[in]monitoredItemModifyRequestsList of monitored items to modify
[in]transactionIdTransaction ID for the asynchronous call used to assign the callback to the transaction
UaStatus UaSubscription::beginSetMonitoringMode ( ServiceSettings serviceSettings,
OpcUa_MonitoringMode  monitoringMode,
const UaUInt32Array monitoredItemIds,
OpcUa_UInt32  transactionId 
)

Asynchronous call to set monitoring mode for monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]monitoringModeNew monitoring mode. Options are OpcUa_MonitoringMode_Disabled, OpcUa_MonitoringMode_Sampling and OpcUa_MonitoringMode_Reporting
[in]monitoredItemIdsList of monitored items where the monitoring mode should be changed
[in]transactionIdTransaction ID for the asynchronous call used to assign the callback to the transaction
UaStatus UaSubscription::createMonitoredItems ( ServiceSettings serviceSettings,
OpcUa_TimestampsToReturn  timestampsToReturn,
const UaMonitoredItemCreateRequests monitoredItemCreateRequests,
UaMonitoredItemCreateResults monitoredItemCreateResults 
)

Creates a list of monitored items in the subscriptions.

The monitored items could be data monitored items or event monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]timestampsToReturnOPC UA defines two timestamps, the source and the server timestamp. This parameter allows the client to define which timestamps the server should return with the value.

The source timestamp is only available for Value Attributes. The source timestamp is used to reflect the timestamp that was applied to a Variable value by the data source. It should indicate the last change of the value or status code. The source timestamp must be always generated by the same physical clock. This timestamp type was added for OPC UA to cover the use case to get the timestamp of the last value change which is different than the server timestamp definition.

The server timestamp is used to reflect the time that the server received a Variable value or knew it to be accurate if the changes are reported by exception and the connection to the data source is operating. This is the behavior expected by Classic OPC

Possible values are:
  • OpcUa_TimestampsToReturn_Source
  • OpcUa_TimestampsToReturn_Server
  • OpcUa_TimestampsToReturn_Both
[in]monitoredItemCreateRequestsList of monitored items to create identified by an array of OpcUa_MonitoredItemCreateRequest structures

The MonitoredItemCreateRequest consist of
  • ItemToMonitor.NodeId: NodeId of the node to monitor
  • ItemToMonitor.AttributeId: Id of the attribute to monitor for example OpcUa_Attributes_Value
  • ItemToMonitor.IndexRange: Option to request subsets of array or matrix values
  • MonitoringMode: The mode of monitoring, typically OpcUa_MonitoringMode_Reporting. Other options are Disabled and Sampling.
  • RequestedParameters.ClientHandle: Client defined handle for the monitored item sent by the server with data changes for this item
  • RequestedParameters.SamplingInterval: Sampling interval in milliseconds requested from the server for this item
  • RequestedParameters.QueueSize: Queue in the server for the sampled values. This is 1 if a client is just interested in the latest value.
  • RequestedParameters.DiscardOldest: Flag indicating if the oldest or newest value gets deleted in the case of an queue overflow. The typical value is OpcUa_True.

    The IndexRange parameter is used to select a single element of an array, or a single range of indexes for arrays based on a string syntax called NumericRange. The first element is identified by index 0 (zero).
    A single element is selected with an individual integer, for example "6". A single range is represented by two integers separated by the colon (':') character, for example, "5:7".
    Multi-dimensional arrays can be indexed by specifying a range for each dimension separated by a ','. For example, a 2x2 block in a 4x4 matrix could be selected with the range "1:2,0:1". A single element in a multi-dimensional array can be selected by specifying a single number instead of a range. For example, "1,1" specifies selects the [1,1] element in a two dimensional array.

    The following BNF describes the syntax
    <numeric-range> ::= <dimension> [',' <dimension>]
    <dimension> ::= <index> [':' <index>]
    <index> ::= <digit> [<digit>]
    <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
[out]monitoredItemCreateResultsList of create results
UaStatus UaSubscription::deleteMonitoredItems ( ServiceSettings serviceSettings,
const UaUInt32Array monitoredItemIds,
UaStatusCodeArray deleteResults 
)

Delete monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]monitoredItemIdsList of monitored items to delete
[out]deleteResultsList of delete results
OpcUa_UInt32 UaSubscription::lifetimeCount ( )

Returns the lifetime count of the subscription.

UaStatus UaSubscription::modifyMonitoredItems ( ServiceSettings serviceSettings,
OpcUa_TimestampsToReturn  timestampsToReturn,
const UaMonitoredItemModifyRequests monitoredItemModifyRequests,
UaMonitoredItemModifyResults monitoredItemModifyResults 
)

Modify monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]timestampsToReturnOPC UA defines two timestamps, the source and the server timestamp. This parameter allows the client to define which timestamps the server should return with the value.

The source timestamp is only available for Value Attributes. The source timestamp is used to reflect the timestamp that was applied to a Variable value by the data source. It should indicate the last change of the value or status code. The source timestamp must be always generated by the same physical clock. This timestamp type was added for OPC UA to cover the use case to get the timestamp of the last value change which is different than the server timestamp definition.

The server timestamp is used to reflect the time that the server received a Variable value or knew it to be accurate if the changes are reported by exception and the connection to the data source is operating. This is the behavior expected by Classic OPC.

Possible values are:
  • OpcUa_TimestampsToReturn_Source
  • OpcUa_TimestampsToReturn_Server
  • OpcUa_TimestampsToReturn_Both
[in]monitoredItemModifyRequestsList of monitored items to modify
[out]monitoredItemModifyResultsList of modify results
UaStatus UaSubscription::modifySubscription ( ServiceSettings serviceSettings,
SubscriptionSettings subscriptionSettings 
)

Modify the subscription settings.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in,out]subscriptionSettingsThe new subscription settings. See SubscriptionSettings for more details
UaStatus UaSubscription::republish ( ServiceSettings serviceSettings,
OpcUa_UInt32  retransmitSequenceNumber,
UaDataNotifications &  dataNotifications,
UaDiagnosticInfos &  diagnosticInfos,
UaEventFieldLists eventFieldList,
UaStatus subscriptionStatus 
)

Republish call to get lost notifications.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]retransmitSequenceNumberThe sequence number which will be retransmitted
[out]dataNotificationsList of data notifications. The list can be empty if the message contains only event notifications.
[out]diagnosticInfosList of diagnostic info related to the data notifications. This list can be empty.
[out]eventFieldListList of event notifications. The list can be empty if the message contains only data change notifications.
[out]subscriptionStatusContains the status of the subscription if it has changed.
UaStatus UaSubscription::setMonitoringMode ( ServiceSettings serviceSettings,
OpcUa_MonitoringMode  monitoringMode,
const UaUInt32Array monitoredItemIds,
UaStatusCodeArray setMonitoringResults 
)

Set monitoring mode for monitored items.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]monitoringModeNew monitoring mode. Options are
  • OpcUa_MonitoringMode_Disabled - the monitored items are deactivated and stop sampling
  • OpcUa_MonitoringMode_Reporting - the monitored items are sampling and delivering changed values to the client
  • OpcUa_MonitoringMode_Sampling - the monitored items are sampling but deliver only values a linked monitored item changes.
See also
setTriggering
Parameters
[in]monitoredItemIdsList of monitored items where the monitoring mode should be changed
[out]setMonitoringResultsList of change results
UaStatus UaSubscription::setPublishingMode ( ServiceSettings serviceSettings,
OpcUa_Boolean  publishingEnabled 
)

Set the publishing mode of the subscription.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]publishingEnabledNew publishing enabled setting.
UaStatus UaSubscription::setTriggering ( ServiceSettings serviceSettings,
OpcUa_UInt32  triggeringItemId,
const UaUInt32Array linksToAdd,
const UaUInt32Array linksToRemove,
UaStatusCodeArray addResults,
UaStatusCodeArray removeResults 
)

Creates or deletes links from trigger items to triggered monitored items.

This service is used to create and delete triggering links for a triggering item. The triggering item and the items to report must belong to the same subscription.

Each triggering link links a triggering item to an item to report. Each link is represented by the MonitoredItem id for the item to report. An error code is returned if this id is invalid.

Parameters
[in,out]serviceSettingsThe general service settings like timeout. See ServiceSettings for more details
[in]triggeringItemIdServer assigned id for the MonitoredItem used as the triggering item
[in]linksToAddThe list of server assigned ids of the items to report that are to be added as triggering links
[in]linksToRemoveThe list of Server-assigned ids of the items to report for the triggering links to be deleted
[out]addResultsList of add results
[out]removeResultsList of remove results

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