QOpcUaMonitoringParameters Class

QOpcUaMonitoringParameters provides a way to set and retrieve parameters for subscriptions and monitored items. More...

Header: #include <QOpcUaMonitoringParameters>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua

Public Types

class DataChangeFilter
class EventFilter
enum class MonitoringMode { Disabled, Sampling, Reporting }
enum class Parameter { PublishingEnabled, PublishingInterval, LifetimeCount, MaxKeepAliveCount, MaxNotificationsPerPublish, …, TriggeredItemIds }
flags Parameters
enum class SubscriptionType { Shared, Exclusive }

Public Functions

QOpcUaMonitoringParameters()
QOpcUaMonitoringParameters(double publishingInterval, QOpcUaMonitoringParameters::SubscriptionType shared = SubscriptionType::Shared, quint32 subscriptionId = 0)
QOpcUaMonitoringParameters(const QOpcUaMonitoringParameters &other)
~QOpcUaMonitoringParameters()
void clearFilter()
void clearFilterResult()
bool discardOldest() const
(since 6.7) QHash<quint32, QOpcUa::UaStatusCode> failedTriggeredItemsStatus() const
QVariant filter() const
QVariant filterResult() const
QString indexRange() const
bool isPublishingEnabled() const
quint32 lifetimeCount() const
quint32 maxKeepAliveCount() const
quint32 maxNotificationsPerPublish() const
quint32 monitoredItemId() const
QOpcUaMonitoringParameters::MonitoringMode monitoringMode() const
quint8 priority() const
double publishingInterval() const
quint32 queueSize() const
double samplingInterval() const
void setDiscardOldest(bool discardOldest)
(since 6.7) void setFailedTriggeredItemsStatus(const QHash<quint32, QOpcUa::UaStatusCode> &status)
void setFilter(const QOpcUaMonitoringParameters::DataChangeFilter &filter)
void setFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter)
void setFilterResult(const QOpcUaEventFilterResult &eventFilterResult)
void setIndexRange(const QString &indexRange)
void setLifetimeCount(quint32 lifetimeCount)
void setMaxKeepAliveCount(quint32 maxKeepAliveCount)
void setMaxNotificationsPerPublish(quint32 maxNotificationsPerPublish)
void setMonitoredItemId(quint32 monitoredItemId)
void setMonitoringMode(QOpcUaMonitoringParameters::MonitoringMode monitoringMode)
void setPriority(quint8 priority)
void setPublishingEnabled(bool publishingEnabled)
void setPublishingInterval(double publishingInterval)
void setQueueSize(quint32 queueSize)
void setSamplingInterval(double samplingInterval)
void setStatusCode(QOpcUa::UaStatusCode statusCode)
void setSubscriptionId(quint32 subscriptionId)
void setSubscriptionType(QOpcUaMonitoringParameters::SubscriptionType shared)
(since 6.7) void setTriggeredItemIds(const QSet<quint32> &ids)
QOpcUa::UaStatusCode statusCode() const
quint32 subscriptionId() const
QOpcUaMonitoringParameters::SubscriptionType subscriptionType() const
(since 6.7) QSet<quint32> triggeredItemIds() const
QOpcUaMonitoringParameters &operator=(const QOpcUaMonitoringParameters &other)

Detailed Description

This class is used in QOpcUaNode::enableMonitoring() requests and as return value for QOpcUaNode::monitoringStatus() in which case it contains the revised values from the server.

Usage

For most use cases, only the publishing interval is required.

QOpcUaMonitoringParameters p(100); // Set a publishing interval of 100ms and share the subscription.
node->enableMonitoring(QOpcUa::NodeAttribute::Value, p);

If an exclusive subscription is required, use the second parameter.

QOpcUaMonitoringParameters p(100, QOpcUaMonitoringParameters::SubscriptionType::Exclusive); // Create a new subscription

To add additional items to an existing subscription, use the third parameter for the next calls to QOpcUaNode::enableMonitoring().

quint32 subscriptionId = node->monitoringStatus(QOpcUa::NodeAttribute::Value).subscriptionId();
QOpcUaMonitoringParameters p(100, QOpcUaMonitoringParameters::SubscriptionType::Shared, subscriptionId); // Add the monitored item to this subscription

If other parameters are required, they must be set using the setter methods.

Member Type Documentation

enum class QOpcUaMonitoringParameters::MonitoringMode

This enum is used to set the monitoring mode for a monitored item.

ConstantValueDescription
QOpcUaMonitoringParameters::MonitoringMode::Disabled0Sampling is disabled and no notifications are being generated.
QOpcUaMonitoringParameters::MonitoringMode::Sampling1Sampling is enabled and notifications are generated and queued, but reporting is disabled.
QOpcUaMonitoringParameters::MonitoringMode::Reporting2Sampling is enabled, notifications are generated and queued, reporting is enabled.

enum class QOpcUaMonitoringParameters::Parameter
flags QOpcUaMonitoringParameters::Parameters

Enumerates parameters that can be modified at runtime using QOpcUaNode::modifyMonitoring(). Not all values are guaranteed to be supported by all plugins. Lack of support will be reported in the QOpcUaNode::monitoringStatusChanged signal.

ConstantValue
QOpcUaMonitoringParameters::Parameter::PublishingEnabled(1 << 0)
QOpcUaMonitoringParameters::Parameter::PublishingInterval(1 << 1)
QOpcUaMonitoringParameters::Parameter::LifetimeCount(1 << 2)
QOpcUaMonitoringParameters::Parameter::MaxKeepAliveCount(1 << 3)
QOpcUaMonitoringParameters::Parameter::MaxNotificationsPerPublish(1 << 4)
QOpcUaMonitoringParameters::Parameter::Priority(1 << 5)
QOpcUaMonitoringParameters::Parameter::SamplingInterval(1 << 6)
QOpcUaMonitoringParameters::Parameter::Filter(1 << 7)
QOpcUaMonitoringParameters::Parameter::QueueSize(1 << 8)
QOpcUaMonitoringParameters::Parameter::DiscardOldest(1 << 9)
QOpcUaMonitoringParameters::Parameter::MonitoringMode(1 << 10)
QOpcUaMonitoringParameters::Parameter::TriggeredItemIds (since Qt 6.7)(1 << 11)

The Parameters type is a typedef for QFlags<Parameter>. It stores an OR combination of Parameter values.

enum class QOpcUaMonitoringParameters::SubscriptionType

This enum is used to determine if the monitored item can be added to a shared subscription or if a new subscription must be created.

ConstantValueDescription
QOpcUaMonitoringParameters::SubscriptionType::Shared0Share subscription with other monitored items with the same interval
QOpcUaMonitoringParameters::SubscriptionType::Exclusive1Request a new subscription for this attribute

Member Function Documentation

QOpcUaMonitoringParameters::QOpcUaMonitoringParameters()

The default constructor for QOpcUaMonitoringParameters.

QOpcUaMonitoringParameters::QOpcUaMonitoringParameters(double publishingInterval, QOpcUaMonitoringParameters::SubscriptionType shared = SubscriptionType::Shared, quint32 subscriptionId = 0)

This is the constructor which covers most use cases for the Qt OPC UA user. publishingInterval must be supplied, shared and subscriptionId are optional.

QOpcUaMonitoringParameters::QOpcUaMonitoringParameters(const QOpcUaMonitoringParameters &other)

Constructs a QOpcuaMonitoringParameters object from the value of other.

[noexcept] QOpcUaMonitoringParameters::~QOpcUaMonitoringParameters()

The destructor for QOpcUaMonitoringParameters.

void QOpcUaMonitoringParameters::clearFilter()

Removes the current filter from the monitoring parameters.

See also filter() and setFilter().

void QOpcUaMonitoringParameters::clearFilterResult()

Removes the current filter result from the monitoring parameters.

See also filterResult() and setFilterResult().

bool QOpcUaMonitoringParameters::discardOldest() const

Returns the discardOldest setting of the monitored item.

See also setDiscardOldest().

[since 6.7] QHash<quint32, QOpcUa::UaStatusCode> QOpcUaMonitoringParameters::failedTriggeredItemsStatus() const

Returns the status codes for all triggered items from setTriggeredItemIds() that could not be successfully added.

This function was introduced in Qt 6.7.

See also setFailedTriggeredItemsStatus().

QVariant QOpcUaMonitoringParameters::filter() const

Returns the current filter.

See also setFilter().

QVariant QOpcUaMonitoringParameters::filterResult() const

Returns the filter result.

This value is empty for an attribute monitoring. In case of an event monitoring, the filter result can be empty if the server did not detect any errors in the filter.

See also setFilterResult().

QString QOpcUaMonitoringParameters::indexRange() const

Returns the index range for the monitored item.

See also setIndexRange().

bool QOpcUaMonitoringParameters::isPublishingEnabled() const

Returns the publishing mode for the subscription.

quint32 QOpcUaMonitoringParameters::lifetimeCount() const

Returns the lifetime count of the subscription.

See also setLifetimeCount().

quint32 QOpcUaMonitoringParameters::maxKeepAliveCount() const

Returns the maximum keepalive count of the subscription.

See also setMaxKeepAliveCount().

quint32 QOpcUaMonitoringParameters::maxNotificationsPerPublish() const

Returns the maximum notifications per publish value of the subscription.

See also setMaxNotificationsPerPublish().

quint32 QOpcUaMonitoringParameters::monitoredItemId() const

Returns the monitored item id assigned by the server. If the monitored item id is 0, the monitored item could not be successfully created.

See also setMonitoredItemId().

QOpcUaMonitoringParameters::MonitoringMode QOpcUaMonitoringParameters::monitoringMode() const

Returns the monitoring mode for the monitored item.

See also setMonitoringMode().

quint8 QOpcUaMonitoringParameters::priority() const

Returns the priority of the subscription used for the monitored item.

See also setPriority().

double QOpcUaMonitoringParameters::publishingInterval() const

Returns the publishing interval of the subscription. The interval is expressed in milliseconds.

See also setPublishingInterval().

quint32 QOpcUaMonitoringParameters::queueSize() const

Returns the queue size of the monitored item.

See also setQueueSize().

double QOpcUaMonitoringParameters::samplingInterval() const

Returns the revised sampling interval of the monitored item. The interval is expressed in milliseconds.

See also setSamplingInterval().

void QOpcUaMonitoringParameters::setDiscardOldest(bool discardOldest)

Set discardOldest as discardOldest setting for the monitored item.

See also discardOldest().

[since 6.7] void QOpcUaMonitoringParameters::setFailedTriggeredItemsStatus(const QHash<quint32, QOpcUa::UaStatusCode> &status)

Sets the status codes for all triggered items that could not be successfully added to status. Setting this value as a client has no effect.

This function was introduced in Qt 6.7.

See also failedTriggeredItemsStatus().

void QOpcUaMonitoringParameters::setFilter(const QOpcUaMonitoringParameters::DataChangeFilter &filter)

Sets DataChangeFilter filter as filter for the monitored item. If another data change filter or an event filter is present, it will be replaced.

If the server does not accept the filter, this will be indicated by the status code after the QOpcUaNode::enableMonitoring() request has finished.

See also filter().

void QOpcUaMonitoringParameters::setFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter)

Request eventFilter as filter for the monitored item. If another event filter or a data change filter is present, it will be replaced. If the server does not accept the filter, this will be indicated by the status code and the event filter result after the QOpcUaNode::enableMonitoring() request has finished.

See also filter().

void QOpcUaMonitoringParameters::setFilterResult(const QOpcUaEventFilterResult &eventFilterResult)

Sets the event filter result to eventFilterResult.

This method must only be used by the backend, setting an event filter result as a user does not have any effect.

See also filterResult().

void QOpcUaMonitoringParameters::setIndexRange(const QString &indexRange)

Requests indexRange as index range for the monitored item. For details on the index range string, see QOpcUaNode::readAttributeRange().

See also indexRange().

void QOpcUaMonitoringParameters::setLifetimeCount(quint32 lifetimeCount)

Request lifetimeCount as lifetime count for the subscription.

See also lifetimeCount().

void QOpcUaMonitoringParameters::setMaxKeepAliveCount(quint32 maxKeepAliveCount)

Request maxKeepAliveCount as maximum keepalive count for the subscription.

See also maxKeepAliveCount().

void QOpcUaMonitoringParameters::setMaxNotificationsPerPublish(quint32 maxNotificationsPerPublish)

Set maxNotificationsPerPublish as maximum notifications per publish value for the subscription.

See also maxNotificationsPerPublish().

void QOpcUaMonitoringParameters::setMonitoredItemId(quint32 monitoredItemId)

Sets the monitored item id to monitoredItemId.

Setting this value as a client has no effect.

See also monitoredItemId().

void QOpcUaMonitoringParameters::setMonitoringMode(QOpcUaMonitoringParameters::MonitoringMode monitoringMode)

Set monitoringMode as monitoring mode for the monitored item.

See also monitoringMode().

void QOpcUaMonitoringParameters::setPriority(quint8 priority)

Set priority as priority for the subscription.

See also priority().

void QOpcUaMonitoringParameters::setPublishingEnabled(bool publishingEnabled)

Set publishingEnabled as publishing mode for the subscription.

See also isPublishingEnabled().

void QOpcUaMonitoringParameters::setPublishingInterval(double publishingInterval)

Request publishingInterval as publishing interval for the subscription. The interval is expressed in milliseconds.

See also publishingInterval().

void QOpcUaMonitoringParameters::setQueueSize(quint32 queueSize)

Request queueSize as queue size for the monitored item.

See also queueSize().

void QOpcUaMonitoringParameters::setSamplingInterval(double samplingInterval)

Request samplingInterval as sampling interval for the monitored item. The interval is expressed in milliseconds.

See also samplingInterval().

void QOpcUaMonitoringParameters::setStatusCode(QOpcUa::UaStatusCode statusCode)

Set the status code to statusCode.

See also statusCode().

void QOpcUaMonitoringParameters::setSubscriptionId(quint32 subscriptionId)

Request the monitored items to be created on a known subscription with subscriptionId.

See also subscriptionId().

void QOpcUaMonitoringParameters::setSubscriptionType(QOpcUaMonitoringParameters::SubscriptionType shared)

Request shared as subscription type for the subscription.

See also subscriptionType().

[since 6.7] void QOpcUaMonitoringParameters::setTriggeredItemIds(const QSet<quint32> &ids)

Adds triggering links to all monitored items in ids as described in OPC UA 1.05, 5.12.1.6.

The values in ids must be the monitored item ids of other monitored item on the same subscription. If the monitoring mode of these items is set to Sampling, their data change notifications will be delivered to the client whenever this monitoring detects a data change.

Any ids that could not be added will not be included in the monitoring status but will instead show up in failedTriggeredItemsStatus().

Modifying this setting to an empty set will remove all triggering links.

This function was introduced in Qt 6.7.

See also triggeredItemIds().

QOpcUa::UaStatusCode QOpcUaMonitoringParameters::statusCode() const

Returns the status code of the monitored item creation.

See also setStatusCode().

quint32 QOpcUaMonitoringParameters::subscriptionId() const

Returns the assigned subscription id.

See also setSubscriptionId().

QOpcUaMonitoringParameters::SubscriptionType QOpcUaMonitoringParameters::subscriptionType() const

Returns the subscription type.

See also setSubscriptionType().

[since 6.7] QSet<quint32> QOpcUaMonitoringParameters::triggeredItemIds() const

Returns the ids of the monitored items triggerd by this monitored item.

This function was introduced in Qt 6.7.

See also setTriggeredItemIds().

QOpcUaMonitoringParameters &QOpcUaMonitoringParameters::operator=(const QOpcUaMonitoringParameters &other)

Assigns the value of other to this object.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.