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

Function variant_to_binary

opcua/ua/ua_binary.py:364–380  ·  view source on GitHub ↗
(var)

Source from the content-addressed store, hash-verified

362
363
364def variant_to_binary(var):
365 b = []
366 encoding = var.VariantType.value & 0b111111
367 if var.is_array or isinstance(var.Value, (list, tuple)):
368 var.is_array = True
369 encoding = set_bit(encoding, 7)
370 if var.Dimensions is not None:
371 encoding = set_bit(encoding, 6)
372 b.append(Primitives.Byte.pack(encoding))
373 b.append(pack_uatype_array(var.VariantType, ua.flatten(var.Value)))
374 if var.Dimensions is not None:
375 b.append(pack_uatype_array(ua.VariantType.Int32, var.Dimensions))
376 else:
377 b.append(Primitives.Byte.pack(encoding))
378 b.append(pack_uatype(var.VariantType, var.Value))
379
380 return b"".join(b)
381
382
383def variant_from_binary(data):

Callers 15

save_node_valueMethod · 0.90
_format_eventMethod · 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 4

set_bitFunction · 0.85
pack_uatype_arrayFunction · 0.85
pack_uatypeFunction · 0.85
packMethod · 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