#include <iomanip>
#include <iostream>
#include <string_view>
switch (nodeClass) {
return "Object";
return "Variable";
return "Method";
return "ObjectType";
return "VariableType";
return "ReferenceType";
return "DataType";
return "View";
default:
return "Unknown";
}
}
std::cout << std::setw(indent) << "- " << child.readBrowseName().name() << " ("
<< toString(child.readNodeClass()) << ")\n";
printNodeTree(child, indent + 2);
}
}
int main() {
client.
connect(
"opc.tcp://localhost:4840");
opcua::Node nodeRoot(client, opcua::ObjectId::RootFolder);
printNodeTree(nodeRoot, 0);
auto nodeServer = nodeRoot.browseChild({{0, "Objects"}, {0, "Server"}});
auto nodeServerParent = nodeServer.browseParent();
std::cout << nodeServer.readDisplayName().text() << "'s parent node is "
<< nodeServerParent.readDisplayName().text() << "\n";
}
void connect(std::string_view endpointUrl)
Connect to the selected server.
High-level node class to access node attribute, browse and populate address space.
std::vector< Node > browseChildren(const NodeId &referenceType=ReferenceTypeId::HierarchicalReferences, Bitmask< NodeClass > nodeClassMask=NodeClass::Unspecified)
Browse child nodes (only local nodes).