Move component health into main dashboard panel
This commit is contained in:
@@ -325,7 +325,7 @@ class ReactorDashboard:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
y = self._draw_section(win, y, "Maintenance", self._maintenance_lines())
|
y = self._draw_section(win, y, "Maintenance", self._maintenance_lines())
|
||||||
self._draw_health_bar(win, y + 1)
|
y = self._draw_section(win, y, "Component Health", self._health_lines())
|
||||||
|
|
||||||
def _draw_help_panel(self, win: "curses._CursesWindow") -> None:
|
def _draw_help_panel(self, win: "curses._CursesWindow") -> None:
|
||||||
win.erase()
|
win.erase()
|
||||||
@@ -429,6 +429,15 @@ class ReactorDashboard:
|
|||||||
lines.append(("Alphas", f"{particles.get('alpha', 0.0):9.2e}"))
|
lines.append(("Alphas", f"{particles.get('alpha', 0.0):9.2e}"))
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
def _health_lines(self) -> list[tuple[str, str]]:
|
||||||
|
comps = self.reactor.health_monitor.components
|
||||||
|
lines: list[tuple[str, str]] = []
|
||||||
|
for name, comp in comps.items():
|
||||||
|
pct = f"{comp.integrity*100:5.1f}%"
|
||||||
|
state = "FAILED" if comp.failed else pct
|
||||||
|
lines.append((name, state))
|
||||||
|
return lines
|
||||||
|
|
||||||
def _maintenance_lines(self) -> list[tuple[str, str]]:
|
def _maintenance_lines(self) -> list[tuple[str, str]]:
|
||||||
if not self.reactor.maintenance_active:
|
if not self.reactor.maintenance_active:
|
||||||
return [("Active", "None")]
|
return [("Active", "None")]
|
||||||
@@ -440,26 +449,6 @@ class ReactorDashboard:
|
|||||||
state = pumps[index]
|
state = pumps[index]
|
||||||
return f"{'ON ' if state.active else 'OFF'} {state.flow_rate:6.0f} kg/s"
|
return f"{'ON ' if state.active else 'OFF'} {state.flow_rate:6.0f} kg/s"
|
||||||
|
|
||||||
def _draw_health_bar(self, win: "curses._CursesWindow", start_y: int) -> None:
|
|
||||||
height, width = win.getmaxyx()
|
|
||||||
if start_y >= height - 2:
|
|
||||||
return
|
|
||||||
win.addstr(start_y, 2, "Component Health", curses.A_BOLD | curses.color_pair(1))
|
|
||||||
bar_width = max(10, min(width - 28, 40))
|
|
||||||
for idx, (name, comp) in enumerate(self.reactor.health_monitor.components.items(), start=1):
|
|
||||||
filled = int(bar_width * comp.integrity)
|
|
||||||
bar = "█" * filled + "-" * (bar_width - filled)
|
|
||||||
color = 3 if comp.integrity > 0.5 else 2 if comp.integrity > 0.2 else 4
|
|
||||||
row = start_y + idx
|
|
||||||
if row >= height - 1:
|
|
||||||
break
|
|
||||||
label = f"{name:<12}:"
|
|
||||||
win.addstr(row, 4, label[:14], curses.A_BOLD)
|
|
||||||
bar_start = 4 + max(len(label), 14) + 1
|
|
||||||
win.addstr(row, bar_start, bar[:bar_width], curses.color_pair(color))
|
|
||||||
percent_col = min(width - 8, bar_start + bar_width + 2)
|
|
||||||
win.addstr(row, percent_col, f"{comp.integrity*100:5.1f}%", curses.color_pair(color))
|
|
||||||
|
|
||||||
def _current_demand(self) -> float:
|
def _current_demand(self) -> float:
|
||||||
if self.reactor.consumer:
|
if self.reactor.consumer:
|
||||||
return self.reactor.consumer.demand_mw
|
return self.reactor.consumer.demand_mw
|
||||||
|
|||||||
Reference in New Issue
Block a user