open62541pp 0.19.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
Public Member Functions | Related Symbols | List of all members
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:

Examples
client_subscription.cpp, and events/client_eventfilter.cpp.

Definition at line 42 of file subscription.hpp.

Public Member Functions

 Subscription (Connection &connection, const SubscriptionParameters &parameters={})
 
 Subscription (Connection &connection, IntegerId subscriptionId) noexcept
 
Connection & connection () noexcept
 
const Connection & connection () const noexcept
 
IntegerId subscriptionId () const noexcept
 
std::vector< MonitoredItem< Connection > > monitoredItems ()
 
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 ()
 

Related Symbols

(Note that these are not member symbols.)

template<typename T >
bool operator== (const Subscription< T > &lhs, const Subscription< T > &rhs) noexcept
 
template<typename T >
bool operator!= (const Subscription< T > &lhs, const Subscription< T > &rhs) noexcept
 

Constructor & Destructor Documentation

◆ Subscription() [1/2]

template<typename Connection >
opcua::Subscription< Connection >::Subscription ( Connection &  connection,
const SubscriptionParameters parameters = {} 
)
explicit

Create a new subscription.

The subscription is not automatically deleted by the destructor. You must delete it manually with deleteSubscription or services::deleteSubscription.

◆ Subscription() [2/2]

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

Wrap an existing subscription.

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

Definition at line 51 of file subscription.hpp.

Member Function Documentation

◆ connection() [1/2]

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

Get the server/client instance.

Definition at line 61 of file subscription.hpp.

◆ connection() [2/2]

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

◆ deleteSubscription()

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

Delete this subscription.

Note
Not implemented for Server.

Definition at line 157 of file subscription.hpp.

◆ monitoredItems()

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

Get all local monitored items.

◆ 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 86 of file subscription.hpp.

◆ 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 76 of file subscription.hpp.

◆ subscribeDataChange() [1/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 114 of file subscription.hpp.

◆ subscribeDataChange() [2/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 91 of file subscription.hpp.

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

◆ subscribeEvent() [1/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 147 of file subscription.hpp.

◆ subscribeEvent() [2/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 125 of file subscription.hpp.

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

◆ subscriptionId()

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

Friends And Related Symbol Documentation

◆ operator!=()

template<typename T >
bool operator!= ( const Subscription< T > &  lhs,
const Subscription< T > &  rhs 
)
related

Definition at line 176 of file subscription.hpp.

◆ operator==()

template<typename T >
bool operator== ( const Subscription< T > &  lhs,
const Subscription< T > &  rhs 
)
related

Definition at line 170 of file subscription.hpp.