Search in sources :

Example 1 with DictionaryDescription

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);
    }
}
Also used : CodecDescription(org.eclipse.milo.opcua.binaryschema.parser.CodecDescription) ByteArrayInputStream(java.io.ByteArrayInputStream) JAXBException(javax.xml.bind.JAXBException) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) DictionaryDescription(org.eclipse.milo.opcua.binaryschema.parser.DictionaryDescription) OpcUaBinaryDataTypeDictionary(org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary)

Example 2 with DictionaryDescription

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()));
}
Also used : BsdParser(org.eclipse.milo.opcua.binaryschema.parser.BsdParser) DictionaryDescription(org.eclipse.milo.opcua.binaryschema.parser.DictionaryDescription) BeforeSuite(org.testng.annotations.BeforeSuite)

Aggregations

DictionaryDescription (org.eclipse.milo.opcua.binaryschema.parser.DictionaryDescription)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 JAXBException (javax.xml.bind.JAXBException)1 BsdParser (org.eclipse.milo.opcua.binaryschema.parser.BsdParser)1 CodecDescription (org.eclipse.milo.opcua.binaryschema.parser.CodecDescription)1 OpcUaBinaryDataTypeDictionary (org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary)1 ByteString (org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)1 BeforeSuite (org.testng.annotations.BeforeSuite)1