Search in sources :

Example 1 with EnumDefinition

use of org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition 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 EnumDefinition

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

the class DataTypeDictionaryGenerator method createEnumeratedType.

private EnumeratedType createEnumeratedType(EnumDescription description) {
    QualifiedName name = description.getName();
    EnumDefinition definition = description.getEnumDefinition();
    EnumeratedType enumeratedType = new EnumeratedType();
    enumeratedType.setName(name.getName());
    enumeratedType.setLengthInBits(32);
    for (EnumField field : definition.getFields()) {
        EnumeratedValue enumeratedValue = new EnumeratedValue();
        enumeratedValue.setName(field.getName());
        enumeratedValue.setValue(field.getValue().intValue());
        enumeratedType.getEnumeratedValue().add(enumeratedValue);
    }
    return enumeratedType;
}
Also used : EnumField(org.eclipse.milo.opcua.stack.core.types.structured.EnumField) EnumeratedType(org.opcfoundation.opcua.binaryschema.EnumeratedType) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) EnumDefinition(org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition) EnumeratedValue(org.opcfoundation.opcua.binaryschema.EnumeratedValue)

Example 3 with EnumDefinition

use of org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition 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

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