Monitoring OpcUa nodes does not work always
-
I'm trying to enable the monitoring of the value of several QpcUa nodes, but I receive the
handleAttribute
slot only for one.Here I set up my nodes:
typedef struct { QOpcUaNode *node; QVariant value; bool updated; bool enableRead; } Node_t; void MyOpcUa::insertNode(QString key, QString id, bool enableRead) { Node_t node; // my internal struct node.node = _opcUaClient->node(id); // the actual OpcUa node node.value = QVariant(); node.updated = false; node.enableRead = enableRead; Q_ASSERT(node.node); // check the node is valid _mapOpcNodes.insert(key, node); connect(node.node, &QOpcUaNode::attributeRead, this, &MyOpcUa::handleAttributes); connect(node.node, &QOpcUaNode::attributeUpdated, this, &MyOpcUa::handleAttributes); }
After connection, I enable the monitoring:
void MyOpcUa::enableMonitoring() { QMapIterator<QString, Node_t> i(_mapOpcNodes); while (i.hasNext()) { i.next(); Node_t node = i.value(); if (node.enableRead) { qDebug() << node.node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(1000)); } } }
all the calls for
enableMonitoring()
returntrue
.
But, say, I enable the monitoring for 5 nodes, only one is actually read periodically.All of the nodes are of class
variable
hence they support monitoring. Furthermore using Qt OPA UA Viewer example application I can monitoring them.Instead with my application I can monitor only one, the others are not periodically read. Of course I can read them manually.
I don't see any differences among them:
I can monitor only
udiActualOrderLengthRT
with my application. -
@Mark81 I tried to check the signal
enableMonitoringFinished
and I get a success:void MyOpcUa::enableMonitoringFinished(QOpcUa::NodeAttribute attr, QOpcUa::UaStatusCode statusCode) { qDebug() << attr << statusCode; } QOpcUa::NodeAttribute::Value QOpcUa::Good