Search in sources :

Example 1 with DataTypeEncoding

use of org.eclipse.milo.opcua.stack.core.types.DataTypeEncoding in project milo by eclipse.

the class AttributeReader method transcode.

private static ExtensionObject transcode(AttributeContext context, UaServerNode node, ExtensionObject xo, QualifiedName encodingName) {
    if (xo == null || xo.isNull()) {
        return xo;
    }
    if (encodingName == null || encodingName.isNull()) {
        // TODO default encoding should be derived from session/transport
        encodingName = OpcUaDefaultBinaryEncoding.ENCODING_NAME;
    }
    DataTypeEncoding newEncoding;
    if (OpcUaDefaultBinaryEncoding.ENCODING_NAME.equals(encodingName)) {
        newEncoding = OpcUaDefaultBinaryEncoding.getInstance();
    } else if (OpcUaDefaultXmlEncoding.ENCODING_NAME.equals(encodingName)) {
        newEncoding = OpcUaDefaultXmlEncoding.getInstance();
    } else {
        // TODO look up registered alternate encodings
        newEncoding = OpcUaDefaultBinaryEncoding.getInstance();
    }
    NodeId newEncodingId = getEncodingId(context, node, encodingName);
    if (newEncodingId != null) {
        return xo.transcode(context.getServer().getSerializationContext(), newEncodingId, newEncoding);
    } else {
        return xo;
    }
}
Also used : DataTypeEncoding(org.eclipse.milo.opcua.stack.core.types.DataTypeEncoding) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)

Aggregations

DataTypeEncoding (org.eclipse.milo.opcua.stack.core.types.DataTypeEncoding)1 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)1