#include <iostream>
int main() {
opcua::Node parentNode{server, opcua::ObjectId::ObjectsFolder};
{1, "TheAnswer"},
"The Answer",
.setDescription({"en-US", "Answer to the Ultimate Question of Life"})
.setDataType<int>()
);
std::cout <<
"The answer is: " << myIntegerNode.
readValue().
to<
int>() << std::endl;
server.run();
}
High-level node class to access node attribute, browse and populate address space.
Variant readValue()
Read the AttributeId::Value attribute of a node.
Node & writeValue(const Variant &value)
Write the AttributeId::Value attribute of a node.
Node addVariable(const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add variable.
void setApplicationName(std::string_view name)
Set application name, default: open62541-based OPC UA Application.
void setProductUri(std::string_view uri)
Set product URI, default: http://open62541.org.
void setApplicationUri(std::string_view uri)
Set application URI, default: urn:open62541.server.application.
UA_Variant wrapper class.
T to() const &
Converts the variant to the specified type T with automatic conversion if required.
UA_VariableAttributes wrapper class.
auto & setDisplayName(LocalizedText displayName)