Method
An OPC UA Method node is an RPC interface exposed by the server. It is invoked by calling Session::Call(...).
Subpage Redirect
- Complete method signature / Memory ownership / Finding methods—please NodeId refer to Call.
- Don't want to jerk off? Use
std::vector<Variant>MethodBuilder Chain-like structure. - Alarm Acknowledge / Confirm is the standard method defined in Part 9; there SDK is an encapsulation with the same name
Acknowledge()/ (Confirm())<darra/opcua/alarm_condition.hpp>, see Alarms and Conditions; They also use the service Call, but the business side doesn't have to manually set the parameters.
One-Minute Example
#include <darra/opcua/client.hpp>
#include <iostream>
using namespace darra::opcua;
Session s("opc.tcp://localhost:4840");
s.Connect();
std::vector<Variant> args;
{ Variant a; a.SetInt32(3); args.push_back(std::move(a)); }
{ Variant b; b.SetInt32(4); args.push_back(std::move(b)); }
auto outputs = s.Call(
"ns=2;s=Calculator",
"ns=2;s=Calculator.Add",
args);
for (auto const& v : outputs) {
int32_t sum = 0; v.TryGetInt32(sum);
std::cout << "sum = " << sum << "\n";
}