Add numpad rod presets and keypad handling
This commit is contained in:
@@ -17,6 +17,18 @@ from .state import PlantState
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
_NUMPAD_ROD_KEYS = {
|
||||
curses.KEY_C1: 0.1, # numpad 1
|
||||
curses.KEY_C2: 0.2, # numpad 2
|
||||
curses.KEY_C3: 0.3, # numpad 3
|
||||
curses.KEY_B1: 0.4, # numpad 4
|
||||
curses.KEY_B2: 0.5, # numpad 5
|
||||
curses.KEY_B3: 0.6, # numpad 6
|
||||
curses.KEY_A1: 0.7, # numpad 7
|
||||
curses.KEY_A2: 0.8, # numpad 8
|
||||
curses.KEY_A3: 0.9, # numpad 9
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class DashboardKey:
|
||||
@@ -57,7 +69,7 @@ class ReactorDashboard:
|
||||
DashboardKey("r", "Reset & clear state"),
|
||||
DashboardKey("a", "Toggle auto rod control"),
|
||||
DashboardKey("+/-", "Withdraw/insert rods"),
|
||||
DashboardKey("1-9", "Set rods to 0.1 … 0.9 (manual)"),
|
||||
DashboardKey("1-9 / Numpad", "Set rods to 0.1 … 0.9 (manual)"),
|
||||
DashboardKey("[/]", "Adjust consumer demand −/+50 MW"),
|
||||
DashboardKey("s/d", "Setpoint −/+250 MW"),
|
||||
DashboardKey("p", "Maintain core (shutdown required)"),
|
||||
@@ -104,6 +116,7 @@ class ReactorDashboard:
|
||||
curses.init_pair(3, curses.COLOR_GREEN, -1)
|
||||
curses.init_pair(4, curses.COLOR_RED, -1)
|
||||
stdscr.nodelay(True)
|
||||
stdscr.keypad(True)
|
||||
self._install_log_capture()
|
||||
try:
|
||||
while True:
|
||||
@@ -176,6 +189,8 @@ class ReactorDashboard:
|
||||
elif ord("1") <= ch <= ord("9"):
|
||||
target = (ch - ord("0")) / 10.0
|
||||
self._queue_command(ReactorCommand(rod_position=target, rod_manual=True))
|
||||
elif ch in _NUMPAD_ROD_KEYS:
|
||||
self._queue_command(ReactorCommand(rod_position=_NUMPAD_ROD_KEYS[ch], rod_manual=True))
|
||||
elif ch in (ord("!"), ord("@"), ord("#"), ord("$"), ord("%"), ord("^"), ord("&"), ord("*"), ord("(")):
|
||||
idx = ch - ord("!")
|
||||
if 0 <= idx < len(self.reactor.turbines):
|
||||
|
||||
Reference in New Issue
Block a user