My company make lighting controllers and support various registers for controlling behaviour. I need a way to periodically read the data, but I don’t seem to be able to do so after the first connection and read. What should I do? Below is the script I’ve written so far…
def main3():
device = None
readable_nodes = (
cvb.IntRegNode,
cvb.FloatNode,
cvb.IntegerNode,
cvb.EnumerationNode,
cvb.CommandNode,
cvb.StringRegNode,
cvb.BooleanNode)
nodes_to_read = (
"Cust::ChannelDutyCycle",
"Cust::ChannelLoadCurrent",
"Cust::ChannelLoadVoltage",
"Cust::ControllerTemperature",
"Cust::TriggerCount"
)
try:
serial_number = "920062"
device = connect_to_controller(serial_number)
if device is not None:
dev_node_map = device.node_maps["Device"]
for t in range(5):
for name, node in dev_node_map.nodes.items():
try:
if isinstance(node, readable_nodes):
# print(dir(node))
if node.is_readable:
if node.name in nodes_to_read:
print(f"{node.name}, {node.display_name}, {node.description}, {node.tool_tip}, {node.value}")
else:
pass
# print(node.name)
# print(type(node))
except Exception as e:
print("Exception reading node: " + str(e))
time.sleep(5)
dev_node_map.poll_nodes()
dev_node_map.nodes.update()
except Exception as e:
print(e)
finally:
if device is not None:
device.close()
main3()