#include <algorithm>
int main() {
opcua::Node objectsNode(server, opcua::ObjectId::ObjectsFolder);
{1, 1000},
"Greet",
const auto greeting = std::string("Hello ").append(name);
output.at(0) = greeting;
},
);
{1, 1001},
"IncInt32ArrayValues",
const auto values = input.
at(0).array<int32_t>();
const auto delta = input.
at(0).scalar<int32_t>();
std::vector<int32_t> incremented(values.size());
std::transform(values.begin(), values.end(), incremented.begin(), [&](auto v) {
return v + delta;
});
output.at(0) = incremented;
},
{
"int32 array",
{"en-US", "int32[5] array"},
opcua::DataTypeId::Int32,
{5}
),
"int32 delta",
{"en-US", "int32 delta"},
opcua::DataTypeId::Int32,
),
},
{
"each entry is incremented by the delta",
{"en-US", "int32[5] array"},
opcua::DataTypeId::Int32,
{5}
),
}
);
}
High-level node class to access node attribute, browse and populate address space.
Node addMethod(const NodeId &id, std::string_view browseName, services::MethodCallback callback, Span< const Argument > inputArguments, Span< const Argument > outputArguments, const MethodAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add method.
void run()
Run the server's main loop. This method will block until Server::stop is called.
View to a contiguous sequence of objects, similar to std::span in C++20.
constexpr reference at(size_t index) const
Access element by index with bounds checking.
UA_Argument wrapper class.