Loading ksp_client.py +8 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ def main(): 1: "liftoff", 2: "stage_1_separation", 3: "stage_2_separation"} stage_map = dict([(i,i) for i in range(10)]) stage_map = dict(zip(range(10), range(10, 0, -1))) context = zmq.Context() socket = context.socket(zmq.PUB) Loading @@ -38,8 +38,10 @@ def main(): def stage_changed(new_stage): try: socket.send_string(f"{topic} {stage_map[new_stage]}") print(f"Sending event {topic} {new_stage}") stage_mapped = stage_map.get(new_stage, new_stage) stage_name = states.get(stage_mapped, "Unknown") socket.send_string(f"{topic} {stage_name}") print(f"Sending event {stage_name} ({stage_mapped})") except Exception as e: pass Loading @@ -52,6 +54,9 @@ def main(): running.clear() vessel = conn.space_center.active_vessel control = vessel.control vehicle_stages = max([p.stage for p in vessel.parts.all]) + 1 stage_map = dict(zip(range(vehicle_stages + 1), range(vehicle_stages, -1, -1))) stage = conn.add_stream(getattr, control, 'current_stage', scene) stage.add_callback(stage_changed) Loading Loading
ksp_client.py +8 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ def main(): 1: "liftoff", 2: "stage_1_separation", 3: "stage_2_separation"} stage_map = dict([(i,i) for i in range(10)]) stage_map = dict(zip(range(10), range(10, 0, -1))) context = zmq.Context() socket = context.socket(zmq.PUB) Loading @@ -38,8 +38,10 @@ def main(): def stage_changed(new_stage): try: socket.send_string(f"{topic} {stage_map[new_stage]}") print(f"Sending event {topic} {new_stage}") stage_mapped = stage_map.get(new_stage, new_stage) stage_name = states.get(stage_mapped, "Unknown") socket.send_string(f"{topic} {stage_name}") print(f"Sending event {stage_name} ({stage_mapped})") except Exception as e: pass Loading @@ -52,6 +54,9 @@ def main(): running.clear() vessel = conn.space_center.active_vessel control = vessel.control vehicle_stages = max([p.stage for p in vessel.parts.all]) + 1 stage_map = dict(zip(range(vehicle_stages + 1), range(vehicle_stages, -1, -1))) stage = conn.add_stream(getattr, control, 'current_stage', scene) stage.add_callback(stage_changed) Loading