use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project iot-tree by bambooww.
the class PrjsNamespace method addPrjNodes.
private void addPrjNodes(UAPrj prj) {
NodeId nodeid = newNodeId(prj.getName());
UaFolderNode pnode = new UaFolderNode(getNodeContext(), nodeid, newQualifiedName(prj.getName()), LocalizedText.english(prj.getTitle()));
getNodeManager().addNode(pnode);
// Make sure our new folder shows up under the server's Objects folder.
pnode.addReference(new Reference(pnode.getNodeId(), Identifiers.Organizes, Identifiers.ObjectsFolder.expanded(), false));
// Add the rest of the nodes
for (UACh ch : prj.getChs()) {
addChNodes(ch, pnode);
}
addTagsNodes(prj, pnode);
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project iot-tree by bambooww.
the class PrjsNamespace method addChNodes.
private void addChNodes(UACh ch, UaFolderNode prjn) {
NodeId chnid = newNodeId(ch.getNodePathCxt());
UaFolderNode chn = new UaFolderNode(getNodeContext(), chnid, newQualifiedName(ch.getName()), LocalizedText.english(ch.getTitle()));
getNodeManager().addNode(chn);
prjn.addOrganizes(chn);
List<UADev> devs = ch.getDevs();
if (devs != null) {
for (UADev dev : devs) {
NodeId devnid = newNodeId(dev.getNodePathCxt());
UaFolderNode devn = new UaFolderNode(getNodeContext(), devnid, newQualifiedName(dev.getName()), LocalizedText.english(dev.getTitle()));
getNodeManager().addNode(devn);
chn.addOrganizes(devn);
addTagGNodes(dev, devn);
addTagsNodes(dev, devn);
}
}
addTagGNodes(ch, chn);
addTagsNodes(ch, chn);
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project milo by eclipse.
the class ExampleNamespace method addAdminReadableNodes.
private void addAdminReadableNodes(UaFolderNode rootNode) {
UaFolderNode adminFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/OnlyAdminCanRead"), newQualifiedName("OnlyAdminCanRead"), LocalizedText.english("OnlyAdminCanRead"));
getNodeManager().addNode(adminFolder);
rootNode.addOrganizes(adminFolder);
String name = "String";
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/OnlyAdminCanRead/" + name)).setAccessLevel(AccessLevel.READ_WRITE).setBrowseName(newQualifiedName(name)).setDisplayName(LocalizedText.english(name)).setDataType(Identifiers.String).setTypeDefinition(Identifiers.BaseDataVariableType).build();
node.setValue(new DataValue(new Variant("shh... don't tell the lusers")));
node.getFilterChain().addLast(new RestrictedAccessFilter(identity -> {
if ("admin".equals(identity)) {
return AccessLevel.READ_WRITE;
} else {
return AccessLevel.NONE;
}
}));
getNodeManager().addNode(node);
adminFolder.addOrganizes(node);
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project milo by eclipse.
the class ExampleNamespace method addDataAccessNodes.
private void addDataAccessNodes(UaFolderNode rootNode) {
// DataAccess folder
UaFolderNode dataAccessFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/DataAccess"), newQualifiedName("DataAccess"), LocalizedText.english("DataAccess"));
getNodeManager().addNode(dataAccessFolder);
rootNode.addOrganizes(dataAccessFolder);
try {
AnalogItemTypeNode node = (AnalogItemTypeNode) getNodeFactory().createNode(newNodeId("HelloWorld/DataAccess/AnalogValue"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {
@Override
public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
return true;
}
});
node.setBrowseName(newQualifiedName("AnalogValue"));
node.setDisplayName(LocalizedText.english("AnalogValue"));
node.setDataType(Identifiers.Double);
node.setValue(new DataValue(new Variant(3.14d)));
node.setEURange(new Range(0.0, 100.0));
getNodeManager().addNode(node);
dataAccessFolder.addOrganizes(node);
} catch (UaException e) {
logger.error("Error creating AnalogItemType instance: {}", e.getMessage(), e);
}
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project milo by eclipse.
the class ExampleNamespace method addScalarNodes.
private void addScalarNodes(UaFolderNode rootNode) {
UaFolderNode scalarTypesFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/ScalarTypes"), newQualifiedName("ScalarTypes"), LocalizedText.english("ScalarTypes"));
getNodeManager().addNode(scalarTypesFolder);
rootNode.addOrganizes(scalarTypesFolder);
for (Object[] os : STATIC_SCALAR_NODES) {
String name = (String) os[0];
NodeId typeId = (NodeId) os[1];
Variant variant = (Variant) os[2];
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/ScalarTypes/" + name)).setAccessLevel(AccessLevel.READ_WRITE).setUserAccessLevel(AccessLevel.READ_WRITE).setBrowseName(newQualifiedName(name)).setDisplayName(LocalizedText.english(name)).setDataType(typeId).setTypeDefinition(Identifiers.BaseDataVariableType).build();
node.setValue(new DataValue(variant));
node.getFilterChain().addLast(new AttributeLoggingFilter(AttributeId.Value::equals));
getNodeManager().addNode(node);
scalarTypesFolder.addOrganizes(node);
}
}
Aggregations