I'm currently working on integrating OPC UA functionality into my application using the QOpcUa library in Qt. I'm attempting to add a monitored item for the EventNotifier attribute of a specific node with the ID "i=2253". However, I'm encountering an issue where I receive a "BadIndexRangeInvalid" error when trying to add the monitored item. Or BadInteralError when specyfing a different IndexRange() - follow the example:

QOpcUaNode *node = client->node("i=2253");
if (node)
{
    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

    // Lines above are the same like in the QT documentation
    // https://doc.qt.io/qt-5/qopcuamonitoringparameters-eventfilter.html

    monitoringParams.setFilter(filter);
    // monitoringParams.setIndexRange("0"); !!! This gives BadInteralError when uncomennted.

    // qDebug() << monitoringParams.indexRange();

    node->enableMonitoring(QOpcUa::NodeAttribute::EventNotifier, monitoringParams);

    QObject::connect(node, &QOpcUaNode::eventOccurred, [&](QVariantList eventFields)
    {
        qDebug() << eventFields;
    });
}

The error occurs specifically when specifying the EventNotifier attribute, and it seems to be related to the index range. However, I'm not explicitly setting an index range in the code, so I'm puzzled as to why this error is occurring.

Has anyone encountered a similar issue with adding monitored items for the EventNotifier attribute in the QOpcUa library? Any insights or suggestions on how to resolve this issue would be greatly appreciated.

I've checked the documentation and made sure that the EventNotifier attribute doesn't support index ranges, so I'm unsure why this error persists. I've also checked what would happen if I set the indexRange explicitly to known values (like 0, 1 etc.) and still got errors described above.

0

There are 0 best solutions below