summaryrefslogtreecommitdiffstats
path: root/src/OpcUaMonitoredNode.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/OpcUaMonitoredNode.h')
-rw-r--r--src/OpcUaMonitoredNode.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/OpcUaMonitoredNode.h b/src/OpcUaMonitoredNode.h
index ac5983a..3e86cb4 100644
--- a/src/OpcUaMonitoredNode.h
+++ b/src/OpcUaMonitoredNode.h
@@ -56,7 +56,10 @@ class OpcUaMonitoredNode : public QObject, public QQmlParserStatus
Q_PROPERTY (QString nodeId READ nodeId WRITE setNodeId NOTIFY nodeIdChanged)
Q_PROPERTY (
bool monitored READ monitored WRITE setMonitored NOTIFY monitoredChanged)
+ Q_PROPERTY (double publishingInterval READ publishingInterval WRITE
+ setPublishingInterval NOTIFY publishingIntervalChanged)
Q_PROPERTY (QVariant value READ value NOTIFY valueChanged)
+ Q_PROPERTY (bool writable READ writable NOTIFY writableChanged)
Q_PROPERTY (OpcUaNodeInfo info READ info NOTIFY infoChanged)
public:
@@ -68,33 +71,62 @@ public:
bool monitored () const;
void setMonitored (bool monitored);
+ double publishingInterval () const;
+ void setPublishingInterval (double interval);
+
QVariant value () const;
+ bool writable () const;
OpcUaNodeInfo info () const;
+ /**
+ * @brief Write a value to the OPC UA node.
+ *
+ * Coerces @a value to the node's data type (auto-detected from the
+ * server's DataType attribute). For array nodes, a comma-separated
+ * string is split and each element coerced individually.
+ * Result is reported asynchronously via writeCompleted().
+ */
+ Q_INVOKABLE void writeValue (const QVariant &value);
+
void classBegin () override;
void componentComplete () override;
signals:
void nodeIdChanged ();
void monitoredChanged ();
+ void publishingIntervalChanged ();
void valueChanged ();
+ void writableChanged ();
void infoChanged ();
+ void writeCompleted (bool success, const QString &message);
private slots:
void handleAttributeUpdated (QOpcUa::NodeAttribute attr,
const QVariant &value);
void handleValueUpdated (const QVariant &value);
void handleClientConnectedChanged ();
+ void handleAttributeWritten (QOpcUa::NodeAttribute attr,
+ QOpcUa::UaStatusCode statusCode);
+ void handleEnableMonitoringFinished (QOpcUa::NodeAttribute attr,
+ QOpcUa::UaStatusCode statusCode);
+ void handleDisableMonitoringFinished (QOpcUa::NodeAttribute attr,
+ QOpcUa::UaStatusCode statusCode);
private:
void setupNode ();
void teardownNode ();
+ void startMonitoring ();
+ void stopMonitoring ();
+ QVariant coerceValue (const QVariant &input) const;
QString m_nodeId;
bool m_monitored = true;
+ double m_publishingInterval = 100.0;
bool m_componentComplete = false;
QOpcUaNode *m_node = nullptr;
+ QOpcUa::Types m_valueType = QOpcUa::Types::Undefined;
+ bool m_writable = false;
QVariant m_value;
OpcUaNodeInfo m_info;
};