open62541pp 0.16.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
method/client_method.cpp
// This example requires the server example `server_method` to be running.
#include <iostream>
int main() {
opcua::Client client;
client.connect("opc.tcp://localhost:4840");
// Browse method node
const opcua::Node greetMethodNode = objectsNode.browseChild({{1, "Greet"}});
// Call method from parent node (Objects)
const auto result = objectsNode.callMethod(
greetMethodNode.id(), {opcua::Variant::fromScalar("World")}
);
std::cout << result.getOutputArguments()[0].getScalar<opcua::String>() << std::endl;
}
Span< const Variant > getOutputArguments() const noexcept
High-level client class.
Definition client.hpp:121
void connect(std::string_view endpointUrl)
Connect to the selected server.
High-level node class to access node attribute, browse and populate address space.
Definition server.hpp:30
CallMethodResult callMethod(const NodeId &methodId, Span< const Variant > inputArguments)
Call server methods.
Definition node.hpp:660
const NodeId & id() const noexcept
Get the node id.
Definition node.hpp:68
Node browseChild(Span< const QualifiedName > path)
Browse child node specified by its relative path from this node (only local nodes).
Definition node.hpp:623
UA_String wrapper class.
Definition types.hpp:251