use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project OpenMUC by isc-konstanz.
the class ChannelNamespace method addChannelNode.
public void addChannelNode(OpcChannel channel) throws UaException {
String folderName = channel.getFolder();
UaFolderNode folderNode;
if (folderName != null) {
folderNode = new UaFolderNode(getNodeContext(), newNodeId(folderName), newQualifiedName(folderName), LocalizedText.english(folderName));
folderNode.addReference(new Reference(folderNode.getNodeId(), Identifiers.Organizes, Identifiers.ObjectsFolder.expanded(), false));
} else {
folderNode = new UaFolderNode(getNodeContext(), Identifiers.ObjectsFolder, newQualifiedName("ObjectsFolder"), LocalizedText.english("ObjectsFolder"));
folderNode.addReference(new Reference(folderNode.getNodeId(), Identifiers.Organizes, Identifiers.RootFolder.expanded(), false));
}
getNodeManager().addNode(folderNode);
// Adding variable to address space
AttributeContext context = new AttributeContext(getServer());
String name = channel.getDescription();
if (name.isEmpty()) {
name = channel.getId();
}
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId(channel.getId())).setAccessLevel(AccessLevel.toValue(AccessLevel.READ_WRITE)).setBrowseName(newQualifiedName(channel.getId())).setDisplayName(LocalizedText.english(name)).setDataType(channel.getNodeType()).setTypeDefinition(Identifiers.BaseDataVariableType).build();
node.setValue(channel.getValue(context, node));
node.setAttributeDelegate(channel);
getNodeManager().addNode(node);
folderNode.addOrganizes(node);
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project FAAAST-Service by FraunhoferIOSB.
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 FAAAST-Service by FraunhoferIOSB.
the class ExampleNamespace method addDynamicNodes.
private void addDynamicNodes(UaFolderNode rootNode) {
UaFolderNode dynamicFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/Dynamic"), newQualifiedName("Dynamic"), LocalizedText.english("Dynamic"));
getNodeManager().addNode(dynamicFolder);
rootNode.addOrganizes(dynamicFolder);
// Dynamic Boolean
{
String name = "Boolean";
NodeId typeId = Identifiers.Boolean;
Variant variant = new Variant(false);
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/Dynamic/" + name)).setAccessLevel(AccessLevel.READ_WRITE).setBrowseName(newQualifiedName(name)).setDisplayName(LocalizedText.english(name)).setDataType(typeId).setTypeDefinition(Identifiers.BaseDataVariableType).build();
node.setValue(new DataValue(variant));
getNodeManager().addNode(node);
dynamicFolder.addOrganizes(node);
}
// Dynamic Int32
{
String name = "Int32";
NodeId typeId = Identifiers.Int32;
Variant variant = new Variant(0);
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/Dynamic/" + name)).setAccessLevel(AccessLevel.READ_WRITE).setBrowseName(newQualifiedName(name)).setDisplayName(LocalizedText.english(name)).setDataType(typeId).setTypeDefinition(Identifiers.BaseDataVariableType).build();
node.setValue(new DataValue(variant));
getNodeManager().addNode(node);
dynamicFolder.addOrganizes(node);
}
// Dynamic Double
{
String name = "Double";
NodeId typeId = Identifiers.Double;
Variant variant = new Variant(0.0);
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/Dynamic/" + name)).setAccessLevel(AccessLevel.READ_WRITE).setBrowseName(newQualifiedName(name)).setDisplayName(LocalizedText.english(name)).setDataType(typeId).setTypeDefinition(Identifiers.BaseDataVariableType).build();
node.setValue(new DataValue(variant));
getNodeManager().addNode(node);
dynamicFolder.addOrganizes(node);
}
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode in project FAAAST-Service by FraunhoferIOSB.
the class ExampleNamespace method addAdminWritableNodes.
private void addAdminWritableNodes(UaFolderNode rootNode) {
UaFolderNode adminFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/OnlyAdminCanWrite"), newQualifiedName("OnlyAdminCanWrite"), LocalizedText.english("OnlyAdminCanWrite"));
getNodeManager().addNode(adminFolder);
rootNode.addOrganizes(adminFolder);
String name = "String";
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/OnlyAdminCanWrite/" + 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("admin was here")));
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 addDynamicNodes.
private void addDynamicNodes(UaFolderNode rootNode) {
UaFolderNode dynamicFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/Dynamic"), newQualifiedName("Dynamic"), LocalizedText.english("Dynamic"));
getNodeManager().addNode(dynamicFolder);
rootNode.addOrganizes(dynamicFolder);
// Dynamic Boolean
{
String name = "Boolean";
NodeId typeId = Identifiers.Boolean;
Variant variant = new Variant(false);
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/Dynamic/" + name)).setAccessLevel(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(), AttributeFilters.getValue(ctx -> new DataValue(new Variant(random.nextBoolean()))));
getNodeManager().addNode(node);
dynamicFolder.addOrganizes(node);
}
// Dynamic Int32
{
String name = "Int32";
NodeId typeId = Identifiers.Int32;
Variant variant = new Variant(0);
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/Dynamic/" + name)).setAccessLevel(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(), AttributeFilters.getValue(ctx -> new DataValue(new Variant(random.nextInt()))));
getNodeManager().addNode(node);
dynamicFolder.addOrganizes(node);
}
// Dynamic Double
{
String name = "Double";
NodeId typeId = Identifiers.Double;
Variant variant = new Variant(0.0);
UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()).setNodeId(newNodeId("HelloWorld/Dynamic/" + name)).setAccessLevel(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(), AttributeFilters.getValue(ctx -> new DataValue(new Variant(random.nextDouble()))));
getNodeManager().addNode(node);
dynamicFolder.addOrganizes(node);
}
}
Aggregations