From 79f98faeeb9f346d05849e108f5b3b0a936a20c8 Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Sat, 22 Nov 2025 20:53:03 +0100 Subject: [PATCH] Group dashboard controls and show turbine control mode --- src/reactor_sim/dashboard.py | 74 +++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/src/reactor_sim/dashboard.py b/src/reactor_sim/dashboard.py index 1fc15ce..4f5da9c 100644 --- a/src/reactor_sim/dashboard.py +++ b/src/reactor_sim/dashboard.py @@ -47,30 +47,45 @@ class ReactorDashboard: self._log_handler: Optional[logging.Handler] = None self._previous_handlers: list[logging.Handler] = [] self._logger = logging.getLogger("reactor_sim") - self.keys = [ - DashboardKey("q", "Quit & save"), - DashboardKey("space", "SCRAM"), - DashboardKey("g", "Toggle primary pump 1"), - DashboardKey("h", "Toggle primary pump 2"), - DashboardKey("j", "Toggle secondary pump 1"), - DashboardKey("k", "Toggle secondary pump 2"), - DashboardKey("b", "Toggle generator 1"), - DashboardKey("v", "Toggle generator 2"), - DashboardKey("x", "Toggle generator auto"), - DashboardKey("t", "Toggle turbine"), - DashboardKey("1/2/3", "Toggle turbine units 1-3"), - DashboardKey("y/u/i", "Maintain turbine 1/2/3"), - DashboardKey("c", "Toggle consumer"), - DashboardKey("r", "Reset & clear state"), - DashboardKey("m/n", "Maintain primary pumps 1/2"), - DashboardKey(",/.", "Maintain secondary pumps 1/2"), - DashboardKey("B/V", "Maintain generator 1/2"), - DashboardKey("k", "Maintain core (requires shutdown)"), - DashboardKey("+/-", "Withdraw/insert rods"), - DashboardKey("[/]", "Adjust consumer demand −/+50 MW"), - DashboardKey("s", "Setpoint −250 MW"), - DashboardKey("d", "Setpoint +250 MW"), - DashboardKey("a", "Toggle auto rod control"), + self.help_sections: list[tuple[str, list[DashboardKey]]] = [ + ( + "Reactor / Safety", + [ + DashboardKey("q", "Quit & save"), + DashboardKey("space", "SCRAM"), + DashboardKey("r", "Reset & clear state"), + DashboardKey("a", "Toggle auto rod control"), + DashboardKey("+/-", "Withdraw/insert rods"), + DashboardKey("[/]", "Adjust consumer demand −/+50 MW"), + DashboardKey("s/d", "Setpoint −/+250 MW"), + ], + ), + ( + "Pumps", + [ + DashboardKey("g/h", "Toggle primary pump 1/2"), + DashboardKey("j/k", "Toggle secondary pump 1/2"), + DashboardKey("m/n", "Maintain primary pumps 1/2"), + DashboardKey(",/.", "Maintain secondary pumps 1/2"), + ], + ), + ( + "Generators", + [ + DashboardKey("b/v", "Toggle generator 1/2"), + DashboardKey("x", "Toggle generator auto"), + DashboardKey("B/V", "Maintain generator 1/2"), + ], + ), + ( + "Turbines / Grid", + [ + DashboardKey("t", "Toggle turbine bank"), + DashboardKey("1/2/3", "Toggle turbine units 1-3"), + DashboardKey("y/u/i", "Maintain turbine 1/2/3"), + DashboardKey("c", "Toggle consumer"), + ], + ), ] def run(self) -> None: @@ -379,6 +394,7 @@ class ReactorDashboard: "Turbine / Grid", [ ("Turbines", " ".join(self._turbine_status_lines())), + ("Turbine Ctrl", "MANUAL"), ("Unit1 Elec", f"{state.turbines[0].electrical_output_mw:7.1f} MW" if state.turbines else "n/a"), ( "Unit2 Elec", @@ -403,10 +419,14 @@ class ReactorDashboard: win.box() win.addstr(0, 2, " Controls ", curses.color_pair(1) | curses.A_BOLD) y = 2 - for entry in self.keys: - win.addstr(y, 2, f"{entry.key:<8} {entry.description}") + for title, entries in self.help_sections: + win.addstr(y, 2, title, curses.color_pair(1) | curses.A_BOLD) y += 1 - win.addstr(y + 1, 2, "Tips:", curses.color_pair(2) | curses.A_BOLD) + for entry in entries: + win.addstr(y, 4, f"{entry.key:<8} {entry.description}") + y += 1 + y += 1 + win.addstr(y, 2, "Tips:", curses.color_pair(2) | curses.A_BOLD) tips = [ "Start pumps before withdrawing rods.", "Bring turbine and consumer online after thermal stabilization.",