def send_read_recursively(_map, path): for key in _map: if type(_map[key]) is dict: send_read_recursively(_map[key], (path + "/" + key) if path != "" else key) else: subscribe_topic = f"storage/read/balance/{path}/{key}" print(f"Subscribing to {subscribe_topic}") pyros.publish(subscribe_topic, "")
def write_value(map_place, name, _path, value): map_place[name] = value if abs(value > 0.1): s = "{0:.2f}".format(value) elif abs(value > 0.01): s = "{0:.3f}".format(value) elif abs(value > 0.001): s = "{0:.4f}".format(value) elif abs(value > 0.0001): s = "{0:.5f}".format(value) else: s = "{0:.6f}".format(value) pyros.publish("storage/write/balance/" + _path, s)
def calibrate(*_args): pyros.publish("balancing/calibrate", "all")
def manual(self, *_args): pyros.publish("manual", "{0:.2f}".format(self.values_panel.manual)) if pyros.is_connected(): self.start_stop_balancing_panel.components[0].set_visible(False) self.start_stop_balancing_panel.components[1].set_visible(True)
def stop_balancing(self, *_args): pyros.publish("balancing/stop", "") if pyros.is_connected(): self.start_stop_balancing_panel.components[0].set_visible(True) self.start_stop_balancing_panel.components[1].set_visible(False)