#include <iostream>
#include <thread>
int main() {
client.
connect(
"opc.tcp://localhost:4840");
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.getStatusCode() << std::endl;
std::cout << result.getOutputArguments()[0].getScalar<
opcua::String>() << std::endl;
}
{
std::cout << "Callback with status code: " << result.getStatusCode() << std::endl;
}
);
}
clientThread.join();
}
UA_CallMethodResult wrapper class.
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).
static Variant fromScalar(T &&value)
Create Variant from scalar value.
T & getScalar() &
Get reference to scalar value with given template type (only native or wrapper types).
constexpr UseFutureToken useFuture
Future completion token object.