Milo ExtensionObject 到 CustomClass

问题描述

是否有将 ExtensionObject 转换为可以在 SpringBoot 中使用的 CustomClass(在 Camel - Milo 中)的示例?

routeBuilder.from(getUriFrom("ns=4;s=GV_PcHmi.tPcHmi.tPlcToPcHmiSta.atAlarm",1000))
                        .process((Exchange exchange) -> {                                                
                            DataValue data = exchange.getIn().getBody(DataValue.class);

                            if( data.getStatusCode().isGood() )
                            {
                               ExtensionObject[] value = (ExtensionObject[]) data.getValue().getValue();

                               for( ExtensionObject x : xo )
                               {
                                  CONVERSION ???
                               }
                           }                            

解决方法

您将在 ExtensionObject 上调用 decode()

看这个例子:https://github.com/eclipse/milo/blob/6548e3fcaef35de558c913962069c786db67b4b2/milo-examples/client-examples/src/main/java/org/eclipse/milo/examples/client/UnifiedAutomationReadCustomDataTypeExample.java#L51-L55

要解码自定义数据类型,服务器必须公开定义所有自定义类型的 OPC UA 1.03 数据类型字典。