MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / variant_from_binary

Function variant_from_binary

opcua/ua/ua_binary.py:383–397  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

381
382
383def variant_from_binary(data):
384 dimensions = None
385 array = False
386 encoding = ord(data.read(1))
387 int_type = encoding & 0b00111111
388 vtype = ua.datatype_to_varianttype(int_type)
389 if test_bit(encoding, 7):
390 value = unpack_uatype_array(vtype, data)
391 array = True
392 else:
393 value = unpack_uatype(vtype, data)
394 if test_bit(encoding, 6):
395 dimensions = unpack_uatype_array(ua.VariantType.Int32, data)
396 value = _reshape(value, dimensions)
397 return ua.Variant(value, vtype, dimensions, is_array=array)
398
399
400def _reshape(flat, dims):

Callers 14

read_node_historyMethod · 0.90
read_event_historyMethod · 0.90
test_custom_variantMethod · 0.90
test_guidMethod · 0.90
test_null_stringMethod · 0.90
test_extension_objectMethod · 0.90
test_variantMethod · 0.90
test_variant_arrayMethod · 0.90

Calls 5

test_bitFunction · 0.85
unpack_uatype_arrayFunction · 0.85
unpack_uatypeFunction · 0.85
_reshapeFunction · 0.85
readMethod · 0.45

Tested by 11

test_custom_variantMethod · 0.72
test_guidMethod · 0.72
test_null_stringMethod · 0.72
test_extension_objectMethod · 0.72
test_variantMethod · 0.72
test_variant_arrayMethod · 0.72