Search code examples
opc-uamilo

How to create an ExtensionObject for filtering in milo OPCUA?


I am trying to define a Filter for a Subscription but I dont know how to create the ExtensionObject that is needed. Its either a ByteString or an XmlElement that I am missing but I dont know how or from where to get either one. If I go with a ByteString that is null, it wont connect to the server.

DataChangeFilter filter = new DataChangeFilter(DataChangeTrigger.StatusValue,
            UInteger.valueOf(DeadbandType.Absolute.getValue()), 10.0);

ExtensionObject eoFilter = new ExtensionObject(???, filter.getTypeId());

MonitoringParameters parameters = new MonitoringParameters(clientHandle, 500.0, eoFilter, uint(10), true);

What do I insert for "???" in my code?

Thank you!


Solution

  • Don't use the ExtensionObject constructor. Instead, use the static ExtensionObject.encode(...) and pass it your DataChangeFilter.