Improve dashboard spacing and steam context

This commit is contained in:
Codex Agent
2025-11-24 00:06:13 +01:00
parent f6ff6fc618
commit 8ece3efb04

View File

@@ -308,18 +308,19 @@ class ReactorDashboard:
log_rows = max(2, min(len(self.log_buffer) + 2, 8))
status_height = min(height - 1, max(min_status, min_status + log_rows))
data_height = max(1, height - status_height)
gap = 2
right_width = max(28, width // 3)
left_width = width - right_width
left_width = width - right_width - gap
if left_width < 50:
left_width = min(50, width - 18)
right_width = width - left_width
left_width = min(50, width - (18 + gap))
right_width = width - left_width - gap
data_height = max(1, data_height)
left_width = max(1, left_width)
right_width = max(1, right_width)
data_win = stdscr.derwin(data_height, left_width, 0, 0)
help_win = stdscr.derwin(data_height, right_width, 0, left_width)
help_win = stdscr.derwin(data_height, right_width, 0, left_width + gap)
status_win = stdscr.derwin(status_height, width, data_height, 0)
self._draw_data_panel(data_win, state)
@@ -341,6 +342,8 @@ class ReactorDashboard:
right_win = win.derwin(inner_height, right_width, 1, 1 + left_width)
for row in range(1, height - 1):
win.addch(row, 1 + left_width, curses.ACS_VLINE)
if left_width + 1 < width - 1:
win.addch(row, 1 + left_width + 1, curses.ACS_VLINE)
left_win.erase()
right_win.erase()
@@ -404,7 +407,7 @@ class ReactorDashboard:
f"{state.secondary_loop.mass_flow_rate:7.0f}/{self.reactor.secondary_pump.nominal_flow * len(self.reactor.secondary_pump_units):.0f} kg/s",
),
("Level", f"{state.secondary_loop.level*100:6.1f}%"),
("Inlet Temp", f"{state.secondary_loop.temperature_in:7.1f} K (Target {constants.PRIMARY_OUTLET_TARGET_K:4.0f})"),
("Inlet Temp", f"{state.secondary_loop.temperature_in:7.1f} K (Target {constants.SECONDARY_OUTLET_TARGET_K:4.0f})"),
("Outlet Temp", f"{state.secondary_loop.temperature_out:7.1f} K (Target {constants.SECONDARY_OUTLET_TARGET_K:4.0f})"),
("Pressure", f"{state.secondary_loop.pressure:5.2f}/{constants.MAX_PRESSURE:4.1f} MPa"),
("Steam Quality", f"{state.secondary_loop.steam_quality:5.2f}/1.00"),
@@ -440,6 +443,10 @@ class ReactorDashboard:
("Load", f"{self._total_load_supplied(state):7.1f}/{self._total_load_demand(state):7.1f} MW"),
("Consumer", f"{consumer_status}"),
("Demand", f"{consumer_demand:7.1f} MW"),
(
"Steam",
f"P={state.secondary_loop.pressure:4.2f} MPa q={state.secondary_loop.steam_quality:4.2f} mdot={state.secondary_loop.mass_flow_rate:6.0f} kg/s",
),
],
)
right_y = self._draw_section(right_win, right_y, "Generators", self._generator_lines(state))
@@ -745,7 +752,16 @@ class _DashboardLogHandler(logging.Handler):
def __init__(self, buffer: deque[str]) -> None:
super().__init__()
self.buffer = buffer
self._last_msg: str | None = None
self._repeat_count: int = 0
def emit(self, record: logging.LogRecord) -> None:
msg = self.format(record)
if msg == self._last_msg:
self._repeat_count += 1
if self._repeat_count > 3:
return
else:
self._last_msg = msg
self._repeat_count = 0
self.buffer.append(msg)