#include <iostream>
#include <thread>
int main() {
client.
connect(
"opc.tcp://localhost:4840");
opcua::Node objectsNode(client, opcua::ObjectId::ObjectsFolder);
auto clientThread = std::thread([&] { client.
run(); });
{
);
std::cout << "Waiting for asynchronous operation to complete\n";
future.wait();
std::cout << "Future ready, get method output\n";
auto result = future.get();
std::cout << "Future with status code: " << result.statusCode() << std::endl;
std::cout << result.outputArguments()[0].scalar<
opcua::String>() << std::endl;
}
{
{opcua::Variant("Callback World")},
std::cout << "Callback with status code: " << result.statusCode() << std::endl;
std::cout << result.outputArguments()[0].scalar<opcua::String>() << std::endl;
}
);
}
clientThread.join();
}
void connect(std::string_view endpointUrl)
Connect to the selected server.
void run()
Run the client's main loop by. This method will block until Client::stop is called.
void stop()
Stop the client's main loop.
High-level node class to access node attribute, browse and populate address space.
auto callMethodAsync(const NodeId &methodId, Span< const Variant > inputArguments, CompletionToken &&token=DefaultCompletionToken())
const NodeId & id() const noexcept
Get the node id.
Node browseChild(Span< const QualifiedName > path)
Browse child node specified by its relative path from this node (only local nodes).
UA_CallMethodResult wrapper class.
constexpr UseFutureToken useFuture
Future completion token object.