use of org.opcfoundation.opcua.binaryschema.EnumeratedType 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.opcfoundation.opcua.binaryschema.EnumeratedType in project milo by eclipse.
the class BsdParser method parse.
/**
* Parse an XML document containing a type dictionary conforming to the OPC Binary XML Schema.
*
* @param inputStream the {@link InputStream} to read the XML document from.
* @return a {@link DictionaryDescription}.
* @throws JAXBException if parsing fails.
*/
public DictionaryDescription parse(InputStream inputStream) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
TypeDictionary typeDictionary = (TypeDictionary) context.createUnmarshaller().unmarshal(inputStream);
List<CodecDescription> enumCodecs = typeDictionary.getOpaqueTypeOrEnumeratedTypeOrStructuredType().stream().filter(typeDescription -> typeDescription instanceof EnumeratedType).map(typeDescription -> {
EnumeratedType enumeratedType = (EnumeratedType) typeDescription;
logger.debug("EnumeratedType: {}", typeDescription.getName());
return new CodecDescription(getEnumCodec(enumeratedType), enumeratedType.getName());
}).collect(toList());
List<CodecDescription> structCodecs = typeDictionary.getOpaqueTypeOrEnumeratedTypeOrStructuredType().stream().filter(typeDescription -> typeDescription instanceof StructuredType).map(typeDescription -> {
StructuredType structuredType = (StructuredType) typeDescription;
logger.debug("StructuredType: {}", typeDescription.getName());
return new CodecDescription(getStructCodec(structuredType), structuredType.getName());
}).collect(toList());
return new DictionaryDescription(typeDictionary.getTargetNamespace(), enumCodecs, structCodecs);
}
Aggregations