Search in sources :

Example 1 with Reference

use of org.eclipse.milo.opcua.sdk.core.Reference in project plc4x by apache.

the class Plc4xNamespace method addNodes.

private void addNodes() {
    for (DeviceConfiguration c : config.getDevices()) {
        NodeId folderNodeId = newNodeId(c.getName());
        UaFolderNode folderNode = new UaFolderNode(getNodeContext(), folderNodeId, newQualifiedName(c.getName()), LocalizedText.english(c.getName()));
        getNodeManager().addNode(folderNode);
        folderNode.addReference(new Reference(folderNode.getNodeId(), Identifiers.Organizes, Identifiers.ObjectsFolder.expanded(), false));
        addConfiguredNodes(folderNode, c);
    }
}
Also used : Reference(org.eclipse.milo.opcua.sdk.core.Reference) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) DeviceConfiguration(org.apache.plc4x.java.opcuaserver.configuration.DeviceConfiguration)

Example 2 with Reference

use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.

the class DataTypeDictionaryManager method registerStructureDescription.

public void registerStructureDescription(StructureDescription description, NodeId binaryEncodingId) {
    structureDescriptions.put(description.getDataTypeId(), description);
    // Add a DataTypeDescriptionTypeNode with a ComponentOf reference to
    // dictionaryNode.
    DataTypeDescriptionTypeNode descriptionNode = new DataTypeDescriptionTypeNode(getNodeContext(), newNodeId(String.format("%s.Description", description.getName())), newQualifiedName(description.getName().getName()), LocalizedText.english(description.getName().getName()), LocalizedText.NULL_VALUE, uint(0), uint(0));
    descriptionNode.setValue(new DataValue(new Variant(description.getName().getName())));
    descriptionNode.setDataType(Identifiers.String);
    descriptionNode.addReference(new Reference(descriptionNode.getNodeId(), Identifiers.HasTypeDefinition, Identifiers.DataTypeDescriptionType.expanded(), Direction.FORWARD));
    descriptionNode.addReference(new Reference(descriptionNode.getNodeId(), Identifiers.HasComponent, dictionaryNode.getNodeId().expanded(), Direction.INVERSE));
    addNode(descriptionNode);
    // Add a DataTypeEncodingTypeNode with a HasDescription reference to
    // descriptionNode and an EncodingOf reference to the DataTypeNode.
    DataTypeEncodingTypeNode dataTypeEncodingNode = new DataTypeEncodingTypeNode(getNodeContext(), binaryEncodingId, new QualifiedName(0, "Default Binary"), LocalizedText.english("Default Binary"), LocalizedText.NULL_VALUE, uint(0), uint(0));
    dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasTypeDefinition, Identifiers.DataTypeEncodingType.expanded(), Direction.FORWARD));
    dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasDescription, descriptionNode.getNodeId().expanded(), Direction.FORWARD));
    dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasEncoding, description.getDataTypeId().expanded(), Direction.INVERSE));
    addNode(dataTypeEncodingNode);
    dictionaryFile.reset();
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) DataTypeDescriptionTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.DataTypeDescriptionTypeNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) Reference(org.eclipse.milo.opcua.sdk.core.Reference) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) DataTypeEncodingTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.DataTypeEncodingTypeNode)

Example 3 with Reference

use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.

the class DataTypeDictionaryManager method registerEnumCodec.

public void registerEnumCodec(OpcUaBinaryDataTypeCodec<?> codec, String description, NodeId dataTypeId) {
    dictionary.registerEnumCodec(codec, description, dataTypeId);
    // Add a custom DataTypeNode with a SubtypeOf reference to Enumeration
    UaDataTypeNode dataTypeNode = new UaDataTypeNode(getNodeContext(), dataTypeId, newQualifiedName(description), LocalizedText.english(description), LocalizedText.NULL_VALUE, uint(0), uint(0), false);
    dataTypeNode.addReference(new Reference(dataTypeId, Identifiers.HasSubtype, Identifiers.Enumeration.expanded(), Direction.INVERSE));
    addNode(dataTypeNode);
    // TODO figure out a way to not require re-registration every time...
    getNodeContext().getServer().getDataTypeManager().registerTypeDictionary(dictionary);
}
Also used : Reference(org.eclipse.milo.opcua.sdk.core.Reference) UaDataTypeNode(org.eclipse.milo.opcua.sdk.server.nodes.UaDataTypeNode)

Example 4 with Reference

use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.

the class ExampleNamespace method createAndAddNodes.

private void createAndAddNodes() {
    // Create a "HelloWorld" folder and add it to the node manager
    NodeId folderNodeId = newNodeId("HelloWorld");
    UaFolderNode folderNode = new UaFolderNode(getNodeContext(), folderNodeId, newQualifiedName("HelloWorld"), LocalizedText.english("HelloWorld"));
    getNodeManager().addNode(folderNode);
    // Make sure our new folder shows up under the server's Objects folder.
    folderNode.addReference(new Reference(folderNode.getNodeId(), Identifiers.Organizes, Identifiers.ObjectsFolder.expanded(), false));
    // Add the rest of the nodes
    addVariableNodes(folderNode);
    addSqrtMethod(folderNode);
    addGenerateEventMethod(folderNode);
    try {
        registerCustomEnumType();
        addCustomEnumTypeVariable(folderNode);
    } catch (Exception e) {
        logger.warn("Failed to register custom enum type", e);
    }
    try {
        registerCustomStructType();
        addCustomStructTypeVariable(folderNode);
    } catch (Exception e) {
        logger.warn("Failed to register custom struct type", e);
    }
    try {
        registerCustomUnionType();
        addCustomUnionTypeVariable(folderNode);
    } catch (Exception e) {
        logger.warn("Failed to register custom struct type", e);
    }
    addCustomObjectTypeAndInstance(folderNode);
}
Also used : Reference(org.eclipse.milo.opcua.sdk.core.Reference) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) UaException(org.eclipse.milo.opcua.stack.core.UaException)

Example 5 with Reference

use of org.eclipse.milo.opcua.sdk.core.Reference in project milo by eclipse.

the class ExampleNamespace method addCustomUnionTypeVariable.

private void addCustomUnionTypeVariable(UaFolderNode rootFolder) throws Exception {
    NodeId dataTypeId = CustomUnionType.TYPE_ID.toNodeIdOrThrow(getServer().getNamespaceTable());
    NodeId binaryEncodingId = CustomUnionType.BINARY_ENCODING_ID.toNodeIdOrThrow(getServer().getNamespaceTable());
    UaVariableNode customUnionTypeVariable = UaVariableNode.builder(getNodeContext()).setNodeId(newNodeId("HelloWorld/CustomUnionTypeVariable")).setAccessLevel(AccessLevel.READ_WRITE).setUserAccessLevel(AccessLevel.READ_WRITE).setBrowseName(newQualifiedName("CustomUnionTypeVariable")).setDisplayName(LocalizedText.english("CustomUnionTypeVariable")).setDataType(dataTypeId).setTypeDefinition(Identifiers.BaseDataVariableType).build();
    CustomUnionType value = CustomUnionType.ofBar("hello");
    ExtensionObject xo = ExtensionObject.encodeDefaultBinary(getServer().getSerializationContext(), value, binaryEncodingId);
    customUnionTypeVariable.setValue(new DataValue(new Variant(xo)));
    getNodeManager().addNode(customUnionTypeVariable);
    customUnionTypeVariable.addReference(new Reference(customUnionTypeVariable.getNodeId(), Identifiers.Organizes, rootFolder.getNodeId().expanded(), false));
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) UaVariableNode(org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode) CustomUnionType(org.eclipse.milo.examples.server.types.CustomUnionType) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) Reference(org.eclipse.milo.opcua.sdk.core.Reference) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)

Aggregations

Reference (org.eclipse.milo.opcua.sdk.core.Reference)1583 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)1551 LocalizedText (org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText)1547 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)872 PropertyTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.variables.PropertyTypeNode)477 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)260 StringReader (java.io.StringReader)243 OpcUaXmlStreamDecoder (org.eclipse.milo.opcua.stack.core.serialization.OpcUaXmlStreamDecoder)243 BaseDataVariableTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.variables.BaseDataVariableTypeNode)227 UaMethodNode (org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode)152 UaDataTypeNode (org.eclipse.milo.opcua.sdk.server.nodes.UaDataTypeNode)132 UaObjectTypeNode (org.eclipse.milo.opcua.sdk.server.nodes.UaObjectTypeNode)124 DataTypeEncodingTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.DataTypeEncodingTypeNode)122 DataTypeDescriptionTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.variables.DataTypeDescriptionTypeNode)75 AggregateFunctionTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.AggregateFunctionTypeNode)37 UaVariableTypeNode (org.eclipse.milo.opcua.sdk.server.nodes.UaVariableTypeNode)37 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)28 UaReferenceTypeNode (org.eclipse.milo.opcua.sdk.server.nodes.UaReferenceTypeNode)26 CertificateGroupFolderTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.CertificateGroupFolderTypeNode)20 TransitionTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.TransitionTypeNode)19