use of org.eclipse.milo.opcua.binaryschema.parser.DictionaryDescription in project milo by eclipse.
the class DataTypeDictionaryReader method createDataTypeDictionary.
private CompletableFuture<DataTypeDictionary<?>> createDataTypeDictionary(NodeId dictionaryNodeId, ByteString bs) {
ByteArrayInputStream is = new ByteArrayInputStream(bs.bytesOrEmpty());
try {
DictionaryDescription dictionaryDescription = bsdParser.parse(is);
String namespaceUri = dictionaryDescription.getNamespaceUri();
OpcUaBinaryDataTypeDictionary dictionary = new OpcUaBinaryDataTypeDictionary(namespaceUri);
List<CodecDescription> enumCodecs = dictionaryDescription.getEnumCodecs();
enumCodecs.forEach(cd -> dictionary.registerEnumCodec(cd.getCodec(), cd.getDescription()));
logger.debug("enumCodecs.size()={}", enumCodecs.size());
List<CodecDescription> structCodecs = dictionaryDescription.getStructCodecs();
logger.debug("structCodecs.size()={}", structCodecs.size());
if (Namespaces.OPC_UA.equals(namespaceUri)) {
return registerBuiltinStructCodecs(dictionary, structCodecs);
} else {
return registerCustomStructCodecs(dictionaryNodeId, dictionary, structCodecs);
}
} catch (JAXBException e) {
return failedFuture(e);
}
}
use of org.eclipse.milo.opcua.binaryschema.parser.DictionaryDescription in project milo by eclipse.
the class BsdParserTest method parseTypeDictionary.
@BeforeSuite
public void parseTypeDictionary() throws Exception {
BsdParser parser = createBsdParser();
DictionaryDescription dictionary = parser.parse(getClass().getClassLoader().getResourceAsStream("dictionaries/BsdParserTest.bsd.xml"));
dictionary.getStructCodecs().forEach(cd -> codecTable.put(dictionary.getNamespaceUri(), cd.getDescription(), cd.getCodec()));
dictionary.getEnumCodecs().forEach(cd -> codecTable.put(dictionary.getNamespaceUri(), cd.getDescription(), cd.getCodec()));
}
Aggregations