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. Qt OPC UA callMethod
Forum Updated to NodeBB v4.3 + New Features

Qt OPC UA callMethod

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 147 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.
  • Q Offline
    Q Offline
    Qrix66
    wrote on last edited by
    #1

    I'm trying to call a method using a binary NodeId. The method node is created, but the method call returns BadNodeIdUnknown. However, it works when called via UaExpert.

    1dfd0a4d-2e59-4c03-9e66-206e5e930787-изображение.png

    bool OpcUaManager::callDeleteFile(const QString &fileName)
    {
        if (!m_client || !m_connected) {
            qWarning() << "[OPC UA] Нет подключения.";
            return false;
        }
    
        QOpcUaNode *node = m_client->node("ns=7;b=AQAAAKbhKnGK9zM6r+oscbr6M2CM7kA=");
        if (!node) {
            qWarning() << "[OPC UA] Узел метода не найден.";
            return false;
        }
    
        QList<QOpcUa::TypedVariant> args = {
            QOpcUa::TypedVariant(fileName, QOpcUa::Types::String)
        };
    
        connect(node, &QOpcUaNode::methodCallFinished,
                this, [fileName, node](const QString &, const QVariant &, QOpcUa::UaStatusCode status) {
            QMetaEnum metaEnum = QMetaEnum::fromType<QOpcUa::UaStatusCode>().enclosingMetaObject()
                    ->enumerator(QMetaEnum::fromType<QOpcUa::UaStatusCode>().enclosingMetaObject()
                                 ->indexOfEnumerator("UaStatusCode"));
            const char *name = metaEnum.valueToKey(static_cast<int>(status));
    
            if (status == QOpcUa::UaStatusCode::Good) {
                qDebug().noquote() << "[OPC UA] DeleteFile успешно:" << fileName;
            } else {
                qWarning().noquote() << "[OPC UA] Ошибка DeleteFile:" << fileName
                                     << "| Статус:" << (name ? name : "Unknown")
                                     << QString(" (0x%1)").arg(static_cast<quint32>(status), 8, 16, QLatin1Char('0')).toUpper();
            }
    
            node->deleteLater();
        });
        return node->callMethod("ns=7;b=AQAAAKbhKnGK9zM6r+oscbr6M2CM7m5QjO8lYIzFKXiMgw==", args);;
    }
    
    
    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qrix66
      wrote last edited by
      #2

      I fixed this issue. It was a Qt 6.9.0 bug, but Qt 6.9.1 has the fix

      1 Reply Last reply
      1
      • Q Qrix66 has marked this topic as solved

      • Login

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