def _value_to_variant(type, value): variant = proto.VariantValue() if type == proto.eDOUBLE: variant.d_value = value elif type == proto.eUINT64: variant.f_value = value elif type == proto.eINT64: variant.ui64_value = value elif type == proto.eFLOAT: variant.i64_value = value elif type == proto.eUINT: variant.ui_value = value elif type == proto.eINT: variant.i_value = value elif type == proto.eUSHORT: variant.us_value = value elif type == proto.eSHORT: variant.s_value = value elif type == proto.eUCHAR: variant.uc_value = value elif type == proto.eCHAR: variant.c_value = value elif type == proto.eBOOL: variant.b_value = value elif type == proto.eSTRING: variant.str_value = str(value) return variant
def __init__(self, parent, connection, structure): self._connection = connection self._structure = structure self._children = [] self._structure_subscriptions = [] self._value_subscriptions = [] self._value = proto.VariantValue() self._parent = parent for child in self._structure.node: self._children.append(Node(self, connection, child))
from cdp_client import cdp_pb2 as proto from copy import copy value1 = proto.VariantValue() value1.node_id = 5 value1.d_value = 55 value1.timestamp = 777 value2 = proto.VariantValue() value2.node_id = 5 value2.d_value = 66 value2.timestamp = 888 value1_node = proto.Node() value1_node.info.node_id = 5 value1_node.info.name = "Value1" value1_node.info.node_type = proto.CDP_PROPERTY value1_node.info.value_type = proto.eDOUBLE value1_node.info.flags = proto.Info.eNodeIsLeaf comp1_node = proto.Node() comp1_node.info.node_id = 9 comp1_node.info.name = "Comp1" comp1_node.info.node_type = proto.CDP_COMPONENT comp1_node.info.value_type = proto.eUNDEFINED comp1_node.info.flags = proto.Info.eValueIsReadOnly app1_node = proto.Node() app1_node.info.node_id = 1 app1_node.info.name = "App1" app1_node.info.node_type = proto.CDP_APPLICATION