open62541pp 0.16.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
opcua::Subscription< Connection > Class Template Reference

#include <subscription.hpp>

Detailed Description

template<typename Connection>
class opcua::Subscription< Connection >

High-level subscription class.

The API is symmetric for both Server and Client, although servers don't use the subscription mechanism of OPC UA to transport notifications of data changes and events. Instead MonitoredItems are registered locally. Notifications are then forwarded to user-defined callbacks instead of a remote client. The subscriptionId for servers is always 0U.

Template Parameters
ConnectionServer or Client
Note
Not all methods are available and implemented for servers.

Use the free functions in the opcua::services namespace for more advanced usage:

Definition at line 43 of file subscription.hpp.

Public Member Functions

 Subscription (Connection &connection, uint32_t subscriptionId) noexcept
 
Connection & connection () noexcept
 
const Connection & connection () const noexcept
 
uint32_t subscriptionId () const noexcept
 
std::vector< MonitoredItem< Connection > > getMonitoredItems ()
 
void setSubscriptionParameters (const SubscriptionParameters &parameters)
 
void setPublishingMode (bool publishing)
 
MonitoredItem< Connection > subscribeDataChange (const NodeId &id, AttributeId attribute, MonitoringMode monitoringMode, const MonitoringParametersEx &parameters, DataChangeNotificationCallback onDataChange)
 
MonitoredItem< Connection > subscribeDataChange (const NodeId &id, AttributeId attribute, DataChangeNotificationCallback onDataChange)
 
MonitoredItem< Connection > subscribeEvent (const NodeId &id, MonitoringMode monitoringMode, const MonitoringParametersEx &parameters, EventNotificationCallback onEvent)
 
MonitoredItem< Connection > subscribeEvent (const NodeId &id, const EventFilter &eventFilter, EventNotificationCallback onEvent)
 
void deleteSubscription ()
 

Constructor & Destructor Documentation

◆ Subscription()

template<typename Connection >
opcua::Subscription< Connection >::Subscription ( Connection & connection,
uint32_t subscriptionId )
inlinenoexcept

Wrap an existing subscription.

The subscriptionId is ignored and set to 0U for servers.

Definition at line 47 of file subscription.hpp.

Member Function Documentation

◆ connection() [1/2]

◆ connection() [2/2]

template<typename Connection >
const Connection & opcua::Subscription< Connection >::connection ( ) const
inlinenoexcept

Get the server/client instance.

Definition at line 57 of file subscription.hpp.

◆ subscriptionId()

template<typename Connection >
uint32_t opcua::Subscription< Connection >::subscriptionId ( ) const
inlinenoexcept

◆ getMonitoredItems()

template<typename Connection >
std::vector< MonitoredItem< Connection > > opcua::Subscription< Connection >::getMonitoredItems ( )

Get all local monitored items.

◆ setSubscriptionParameters()

template<typename Connection >
void opcua::Subscription< Connection >::setSubscriptionParameters ( const SubscriptionParameters & parameters)
inline

Modify this subscription.

Note
Not implemented for Server.
See also
services::modifySubscription

Definition at line 72 of file subscription.hpp.

◆ setPublishingMode()

template<typename Connection >
void opcua::Subscription< Connection >::setPublishingMode ( bool publishing)
inline

Enable/disable publishing of notification messages.

Note
Not implemented for Server.
See also
services::setPublishingMode

Definition at line 82 of file subscription.hpp.

◆ subscribeDataChange() [1/2]

template<typename Connection >
MonitoredItem< Connection > opcua::Subscription< Connection >::subscribeDataChange ( const NodeId & id,
AttributeId attribute,
MonitoringMode monitoringMode,
const MonitoringParametersEx & parameters,
DataChangeNotificationCallback onDataChange )
inline

Create a monitored item for data change notifications.

Definition at line 87 of file subscription.hpp.

Referenced by opcua::Subscription< Connection >::subscribeDataChange().

◆ subscribeDataChange() [2/2]

template<typename Connection >
MonitoredItem< Connection > opcua::Subscription< Connection >::subscribeDataChange ( const NodeId & id,
AttributeId attribute,
DataChangeNotificationCallback onDataChange )
inline

Create a monitored item for data change notifications (default settings).

The monitoring mode is set to MonitoringMode::Reporting and the default open62541 MonitoringParametersEx are used.

Definition at line 110 of file subscription.hpp.

◆ subscribeEvent() [1/2]

template<typename Connection >
MonitoredItem< Connection > opcua::Subscription< Connection >::subscribeEvent ( const NodeId & id,
MonitoringMode monitoringMode,
const MonitoringParametersEx & parameters,
EventNotificationCallback onEvent )
inline

Create a monitored item for event notifications.

Note
Not implemented for Server.

Definition at line 121 of file subscription.hpp.

Referenced by opcua::Subscription< Connection >::subscribeEvent().

◆ subscribeEvent() [2/2]

template<typename Connection >
MonitoredItem< Connection > opcua::Subscription< Connection >::subscribeEvent ( const NodeId & id,
const EventFilter & eventFilter,
EventNotificationCallback onEvent )
inline

Create a monitored item for event notifications (default settings).

The monitoring mode is set to MonitoringMode::Reporting and the default open62541 MonitoringParametersEx are used.

Note
Not implemented for Server.

Definition at line 143 of file subscription.hpp.

◆ deleteSubscription()

template<typename Connection >
void opcua::Subscription< Connection >::deleteSubscription ( )
inline

Delete this subscription.

Note
Not implemented for Server.

Definition at line 153 of file subscription.hpp.