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);
}
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;
}
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);
}
Aggregations