Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Receiving events from OPC UA server with QOpcUaClient

Receiving events from OPC UA server with QOpcUaClient

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 498 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AnttiAspi
    wrote on last edited by
    #1

    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" : BadInternalError

    The 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

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZEEVICKY
      wrote on last edited by ZEEVICKY
      #2

      did you find any solution? I'am using QT 5.15 LTS with corresponding version of the OPC UA and get the same errors about IndexRangeInvalid or BadInternalError

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NewPony
        wrote on last edited by NewPony
        #3

        Same here i get:
        qt.opcua.plugins.open62541: Could not add monitored item for QOpcUa::NodeAttribute::EventNotifier of node "ns=0;i=2311" : BadAttributeIdInvalid

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved