Receiving events from OPC UA server with QOpcUaClient
-
Hi,
I'm trying to receive Events coming from OPC UA Server using QOpcUaClient. I see in UA Expert that the node is sending events, but I just cannot connect the client to them in my code
Here is my code:
QOpcUaClient *mOpcUaClient = nullptr; QScopedPointer<QOpcUaNode> m_eventNode; ... m_eventNode.reset(mOpcUaClient->node("ns=2;s=testObject")); QOpcUaMonitoringParameters monitoringParams(1000); QOpcUaMonitoringParameters::EventFilter filter; filter << QOpcUaSimpleAttributeOperand("Message"); // Select clause of the filter QOpcUaContentFilterElement condition; condition << QOpcUaContentFilterElement::FilterOperator::GreaterThanOrEqual; condition << QOpcUaSimpleAttributeOperand("Severity"); condition << QOpcUaLiteralOperand(10, QOpcUa::Types::UInt16); filter << condition; // Where clause of the filter monitoringParams.setFilter(filter); monitoringParams.setIndexRange("0:20"); m_eventNode->enableMonitoring(QOpcUa::NodeAttribute::EventNotifier, monitoringParams); QObject::connect(m_eventNode.data(), &QOpcUaNode::eventOccurred, []() { qDebug() << "OPC UA Event occurred"; });
Calling the "enableMonitoring()" gives:
qt.opcua.plugins.open62541: Could not add monitored item for QOpcUa::NodeAttribute::EventNotifier of node "ns=2;s=testObject" : BadInternalErrorThe client is working fine otherwise. I'm able to read, write and subsribe values without problems.
Is there anyone who could help me with this?
Also, I would be happy to hear, if anyone could explain what the index range means and what value I should set there on line "monitoringParams.setIndexRange("0:20");"
I'm using Windows 10, Qt 5.15.2, MinGW 64 bit, Qt creator 9.0.2