diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2018-03-22 16:28:18 +0100 |
---|---|---|
committer | Jannis Völker <jannis.voelker@basyskom.com> | 2018-04-03 10:42:25 +0000 |
commit | 6f746af15ec2485a09360af9025beedccac41318 (patch) | |
tree | 4a660b4edfa65ece048f6dd9d558f3b4beedba0a | |
parent | 02bfa6d5afabcde4d134af523e314ea429b0637c (diff) |
Fix browse and display name of method nodes in the simulation server
Don't use the node id but the name provided as parameter.
Change-Id: I3e73012ee3ad348089c14a9992917765ab82a2ed
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
-rw-r--r-- | examples/opcua/waterpump/simulationserver/simulationserver.cpp | 14 | ||||
-rw-r--r-- | examples/opcua/waterpump/simulationserver/simulationserver.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/examples/opcua/waterpump/simulationserver/simulationserver.cpp b/examples/opcua/waterpump/simulationserver/simulationserver.cpp index c64b832..fc78edd 100644 --- a/examples/opcua/waterpump/simulationserver/simulationserver.cpp +++ b/examples/opcua/waterpump/simulationserver/simulationserver.cpp @@ -320,16 +320,16 @@ double DemoServer::readTank2TargetValue() return static_cast<double *>(var.data)[0]; } -UA_NodeId DemoServer::addMethod(const UA_NodeId &folder, const QString &variableNode, const QString &description, const QString &browseName, UA_MethodCallback cb) +UA_NodeId DemoServer::addMethod(const UA_NodeId &folder, const QString &variableNode, const QString &description, const QString &name, UA_MethodCallback cb) { UA_NodeId methodNodeId = Open62541Utils::nodeIdFromQString(variableNode); UA_MethodAttributes attr = UA_MethodAttributes_default; attr.description = UA_LOCALIZEDTEXT_ALLOC("en_US", description.toUtf8().constData()); - attr.displayName = UA_LOCALIZEDTEXT_ALLOC("en_US", variableNode.toUtf8().constData()); + attr.displayName = UA_LOCALIZEDTEXT_ALLOC("en_US", name.toUtf8().constData()); attr.executable = true; - UA_QualifiedName methodBrowseName = UA_QUALIFIEDNAME_ALLOC(methodNodeId.namespaceIndex, browseName.toUtf8().constData()); + UA_QualifiedName methodBrowseName = UA_QUALIFIEDNAME_ALLOC(methodNodeId.namespaceIndex, name.toUtf8().constData()); UA_NodeId resultId; UA_StatusCode result = UA_Server_addMethodNode(m_server, methodNodeId, folder, @@ -370,10 +370,10 @@ void DemoServer::launch() m_machineStateNode = addVariable(machineFolder, "ns=2;s=Machine.State", "Machine.State", static_cast<quint32>(MachineState::Idle), QOpcUa::Types::UInt32); addVariable(machineFolder, "ns=2;s=Machine.Designation", "Machine.Designation", "TankExample", QOpcUa::Types::String); - addMethod(machineFolder, "ns=2;s=Machine.Start", "Start", "Machine.Start", &startPumpMethod); - addMethod(machineFolder, "ns=2;s=Machine.Stop", "Stop", "Machine.Start", &stopPumpMethod); - addMethod(machineFolder, "ns=2;s=Machine.FlushTank2", "FlushTank2", "Machine.FlushTank2", &flushTank2Method); - addMethod(machineFolder, "ns=2;s=Machine.Reset", "Reset", "Machine.Reset", &resetMethod); + addMethod(machineFolder, "ns=2;s=Machine.Start", "Starts the pump", "Machine.Start", &startPumpMethod); + addMethod(machineFolder, "ns=2;s=Machine.Stop", "Stops the pump", "Machine.Stop", &stopPumpMethod); + addMethod(machineFolder, "ns=2;s=Machine.FlushTank2", "Flushes tank 2", "Machine.FlushTank2", &flushTank2Method); + addMethod(machineFolder, "ns=2;s=Machine.Reset", "Resets the simulation", "Machine.Reset", &resetMethod); QObject::connect(&m_machineTimer, &QTimer::timeout, [this]() { diff --git a/examples/opcua/waterpump/simulationserver/simulationserver.h b/examples/opcua/waterpump/simulationserver/simulationserver.h index 6136be9..c6d6ce8 100644 --- a/examples/opcua/waterpump/simulationserver/simulationserver.h +++ b/examples/opcua/waterpump/simulationserver/simulationserver.h @@ -74,7 +74,7 @@ public: UA_NodeId addVariable(const UA_NodeId &folder, const QString &variableNode, const QString &name, const QVariant &value, QOpcUa::Types type); - UA_NodeId addMethod(const UA_NodeId &folder, const QString &variableNode, const QString &description, const QString &browseName, UA_MethodCallback cb); + UA_NodeId addMethod(const UA_NodeId &folder, const QString &variableNode, const QString &description, const QString &name, UA_MethodCallback cb); static UA_StatusCode startPumpMethod(UA_Server *server, const UA_NodeId *sessionId, void *sessionHandle, const UA_NodeId *methodId, void *methodContext, |