Search in sources :

Example 1 with SwitchOperand

use of org.opcfoundation.opcua.binaryschema.SwitchOperand in project milo by eclipse.

the class AbstractCodec method fieldIsAbsent.

private boolean fieldIsAbsent(FieldType field, Map<String, MemberT> members) {
    if (field.getSwitchField() == null) {
        return false;
    } else {
        MemberT controlField = members.get(field.getSwitchField());
        String controlTypeName = structuredType.getField().stream().filter(f -> f.getName().equals(field.getSwitchField())).findFirst().map(f -> f.getTypeName().getLocalPart()).orElse("Int32");
        long controlValue = ((Number) memberTypeToOpcUaScalar(controlField, controlTypeName)).longValue();
        long switchValue = field.getSwitchValue() != null ? field.getSwitchValue() : 1L;
        SwitchOperand switchOperand = field.getSwitchOperand() != null ? field.getSwitchOperand() : SwitchOperand.EQUALS;
        return !compareToSwitchValue(controlValue, switchOperand, switchValue);
    }
}
Also used : OpcUaBinaryDataTypeCodec(org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec) FieldType(org.opcfoundation.opcua.binaryschema.FieldType) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) HashMap(java.util.HashMap) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) DateTime(org.eclipse.milo.opcua.stack.core.types.builtin.DateTime) Function(java.util.function.Function) PeekingIterator(com.google.common.collect.PeekingIterator) Iterators(com.google.common.collect.Iterators) LinkedHashMap(java.util.LinkedHashMap) StructuredType(org.opcfoundation.opcua.binaryschema.StructuredType) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) SerializationContext(org.eclipse.milo.opcua.stack.core.serialization.SerializationContext) UShort(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort) SwitchOperand(org.opcfoundation.opcua.binaryschema.SwitchOperand) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) XmlElement(org.eclipse.milo.opcua.stack.core.types.builtin.XmlElement) BigInteger(java.math.BigInteger) OpcUaBinaryStreamDecoder(org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamDecoder) StatusCodes(org.eclipse.milo.opcua.stack.core.StatusCodes) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ImmutableMap(com.google.common.collect.ImmutableMap) UByte(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) LocalizedText(org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText) UaSerializationException(org.eclipse.milo.opcua.stack.core.UaSerializationException) UUID(java.util.UUID) ULong(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.ULong) OpcUaBinaryStreamEncoder(org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder) DiagnosticInfo(org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo) Nullable(org.jetbrains.annotations.Nullable) Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) BuiltinDataType(org.eclipse.milo.opcua.stack.core.BuiltinDataType) Namespaces(org.eclipse.milo.opcua.stack.core.util.Namespaces) SwitchOperand(org.opcfoundation.opcua.binaryschema.SwitchOperand) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterators (com.google.common.collect.Iterators)1 PeekingIterator (com.google.common.collect.PeekingIterator)1 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 BiConsumer (java.util.function.BiConsumer)1 Function (java.util.function.Function)1 BuiltinDataType (org.eclipse.milo.opcua.stack.core.BuiltinDataType)1 StatusCodes (org.eclipse.milo.opcua.stack.core.StatusCodes)1 UaSerializationException (org.eclipse.milo.opcua.stack.core.UaSerializationException)1 OpcUaBinaryStreamDecoder (org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamDecoder)1 OpcUaBinaryStreamEncoder (org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder)1 SerializationContext (org.eclipse.milo.opcua.stack.core.serialization.SerializationContext)1 OpcUaBinaryDataTypeCodec (org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec)1 ByteString (org.eclipse.milo.opcua.stack.core.types.builtin.ByteString)1 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)1 DateTime (org.eclipse.milo.opcua.stack.core.types.builtin.DateTime)1