Search in sources :

Example 1 with EnumDescription

use of org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription in project milo by eclipse.

the class ExampleNamespace method registerCustomEnumType.

private void registerCustomEnumType() throws Exception {
    NodeId dataTypeId = CustomEnumType.TYPE_ID.toNodeIdOrThrow(getServer().getNamespaceTable());
    dictionaryManager.registerEnumCodec(new CustomEnumType.Codec().asBinaryCodec(), "CustomEnumType", dataTypeId);
    UaNode node = getNodeManager().get(dataTypeId);
    if (node instanceof UaDataTypeNode) {
        UaDataTypeNode dataTypeNode = (UaDataTypeNode) node;
        dataTypeNode.setEnumStrings(new LocalizedText[] { LocalizedText.english("Field0"), LocalizedText.english("Field1"), LocalizedText.english("Field2") });
    }
    EnumField[] fields = new EnumField[] { new EnumField(0L, LocalizedText.english("Field0"), LocalizedText.NULL_VALUE, "Field0"), new EnumField(1L, LocalizedText.english("Field1"), LocalizedText.NULL_VALUE, "Field1"), new EnumField(2L, LocalizedText.english("Field2"), LocalizedText.NULL_VALUE, "Field2") };
    EnumDefinition definition = new EnumDefinition(fields);
    EnumDescription description = new EnumDescription(dataTypeId, new QualifiedName(getNamespaceIndex(), "CustomEnumType"), definition, ubyte(BuiltinDataType.Int32.getTypeId()));
    dictionaryManager.registerEnumDescription(description);
}
Also used : EnumField(org.eclipse.milo.opcua.stack.core.types.structured.EnumField) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode) EnumDefinition(org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition) UaDataTypeNode(org.eclipse.milo.opcua.sdk.server.nodes.UaDataTypeNode) EnumDescription(org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription)

Example 2 with EnumDescription

use of org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription in project tech-pdai-spring-demos by realpdai.

the class ExampleNamespace method registerCustomEnumType.

private void registerCustomEnumType() throws Exception {
    NodeId dataTypeId = CustomEnumType.TYPE_ID.toNodeIdOrThrow(getServer().getNamespaceTable());
    dictionaryManager.registerEnumCodec(new CustomEnumType.Codec().asBinaryCodec(), "CustomEnumType", dataTypeId);
    EnumField[] fields = new EnumField[] { new EnumField(0L, LocalizedText.english("Field0"), LocalizedText.NULL_VALUE, "Field0"), new EnumField(1L, LocalizedText.english("Field1"), LocalizedText.NULL_VALUE, "Field1"), new EnumField(2L, LocalizedText.english("Field2"), LocalizedText.NULL_VALUE, "Field2") };
    EnumDefinition definition = new EnumDefinition(fields);
    EnumDescription description = new EnumDescription(dataTypeId, new QualifiedName(getNamespaceIndex(), "CustomEnumType"), definition, ubyte(BuiltinDataType.Int32.getTypeId()));
    dictionaryManager.registerEnumDescription(description);
}
Also used : EnumField(org.eclipse.milo.opcua.stack.core.types.structured.EnumField) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) EnumDefinition(org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition) EnumDescription(org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription)

Aggregations

NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)2 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)2 EnumDefinition (org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition)2 EnumDescription (org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription)2 EnumField (org.eclipse.milo.opcua.stack.core.types.structured.EnumField)2 UaDataTypeNode (org.eclipse.milo.opcua.sdk.server.nodes.UaDataTypeNode)1 UaNode (org.eclipse.milo.opcua.sdk.server.nodes.UaNode)1