Search in sources :

Example 16 with UaFolderNode

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);
}
Also used : Reference(org.eclipse.milo.opcua.sdk.core.Reference) UACh(org.iottree.core.UACh) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode)

Example 17 with UaFolderNode

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);
}
Also used : UADev(org.iottree.core.UADev) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode)

Example 18 with UaFolderNode

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);
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) ValueRanks(org.eclipse.milo.opcua.sdk.core.ValueRanks) Array(java.lang.reflect.Array) CustomStructType(org.eclipse.milo.examples.server.types.CustomStructType) EnumDescription(org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription) Unsigned.ulong(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ulong) DataItem(org.eclipse.milo.opcua.sdk.server.api.DataItem) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) SqrtMethod(org.eclipse.milo.examples.server.methods.SqrtMethod) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) DateTime(org.eclipse.milo.opcua.stack.core.types.builtin.DateTime) ValueRank(org.eclipse.milo.opcua.sdk.core.ValueRank) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) Unsigned.uint(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint) BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) XmlElement(org.eclipse.milo.opcua.stack.core.types.builtin.XmlElement) Reference(org.eclipse.milo.opcua.sdk.core.Reference) Range(org.eclipse.milo.opcua.stack.core.types.structured.Range) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) EnumField(org.eclipse.milo.opcua.stack.core.types.structured.EnumField) CustomUnionType(org.eclipse.milo.examples.server.types.CustomUnionType) StructureDescription(org.eclipse.milo.opcua.stack.core.types.structured.StructureDescription) UUID(java.util.UUID) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode) StructureDefinition(org.eclipse.milo.opcua.stack.core.types.structured.StructureDefinition) GenerateEventMethod(org.eclipse.milo.examples.server.methods.GenerateEventMethod) SubscriptionModel(org.eclipse.milo.opcua.sdk.server.util.SubscriptionModel) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) UaObjectTypeNode(org.eclipse.milo.opcua.sdk.server.nodes.UaObjectTypeNode) List(java.util.List) Lifecycle(org.eclipse.milo.opcua.sdk.server.Lifecycle) StructureType(org.eclipse.milo.opcua.stack.core.types.enumerated.StructureType) Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) NodeFactory(org.eclipse.milo.opcua.sdk.server.nodes.factories.NodeFactory) ServerTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerTypeNode) AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) BuiltinDataType(org.eclipse.milo.opcua.stack.core.BuiltinDataType) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) ManagedNamespaceWithLifecycle(org.eclipse.milo.opcua.sdk.server.api.ManagedNamespaceWithLifecycle) AccessLevel(org.eclipse.milo.opcua.sdk.core.AccessLevel) StructureField(org.eclipse.milo.opcua.stack.core.types.structured.StructureField) AttributeFilters(org.eclipse.milo.opcua.sdk.server.nodes.filters.AttributeFilters) EnumDefinition(org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition) UaMethodNode(org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode) UaDataTypeNode(org.eclipse.milo.opcua.sdk.server.nodes.UaDataTypeNode) Logger(org.slf4j.Logger) UaVariableNode(org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode) Unsigned.ushort(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) UaObjectNode(org.eclipse.milo.opcua.sdk.server.nodes.UaObjectNode) LocalizedText(org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText) Unsigned.ubyte(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ubyte) MonitoredItem(org.eclipse.milo.opcua.sdk.server.api.MonitoredItem) CustomEnumType(org.eclipse.milo.examples.server.types.CustomEnumType) UaException(org.eclipse.milo.opcua.stack.core.UaException) DataTypeDictionaryManager(org.eclipse.milo.opcua.sdk.server.dtd.DataTypeDictionaryManager) UaVariableNode(org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)

Example 19 with UaFolderNode

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);
    }
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) UaException(org.eclipse.milo.opcua.stack.core.UaException) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) Range(org.eclipse.milo.opcua.stack.core.types.structured.Range)

Example 20 with UaFolderNode

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);
    }
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) UaVariableNode(org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)

Aggregations

UaFolderNode (org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode)39 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)32 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)30 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)30 ByteString (org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)24 UaVariableNode (org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode)23 Reference (org.eclipse.milo.opcua.sdk.core.Reference)19 AttributeId (org.eclipse.milo.opcua.stack.core.AttributeId)13 UaException (org.eclipse.milo.opcua.stack.core.UaException)13 ExtensionObject (org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject)12 Unsigned.uint (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint)11 AnalogItemTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode)10 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)10 Range (org.eclipse.milo.opcua.stack.core.types.structured.Range)10 List (java.util.List)8 AccessLevel (org.eclipse.milo.opcua.sdk.core.AccessLevel)8 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)8 DataItem (org.eclipse.milo.opcua.sdk.server.api.DataItem)8 ManagedNamespaceWithLifecycle (org.eclipse.milo.opcua.sdk.server.api.ManagedNamespaceWithLifecycle)8 MonitoredItem (org.eclipse.milo.opcua.sdk.server.api.MonitoredItem)8