feat: improve manual rod control and reactor power
This commit is contained in:
@@ -46,6 +46,7 @@ class ReactorDashboard:
|
||||
DashboardKey("[/]", "Adjust consumer demand −/+50 MW"),
|
||||
DashboardKey("s", "Setpoint −250 MW"),
|
||||
DashboardKey("d", "Setpoint +250 MW"),
|
||||
DashboardKey("a", "Toggle auto rod control"),
|
||||
]
|
||||
|
||||
def run(self) -> None:
|
||||
@@ -112,23 +113,28 @@ class ReactorDashboard:
|
||||
self._queue_command(ReactorCommand(power_setpoint=self.reactor.control.setpoint_mw - 250.0))
|
||||
elif ch in (ord("d"), ord("D")):
|
||||
self._queue_command(ReactorCommand(power_setpoint=self.reactor.control.setpoint_mw + 250.0))
|
||||
elif ch in (ord("a"), ord("A")):
|
||||
self._queue_command(ReactorCommand(rod_manual=not self.reactor.control.manual_control))
|
||||
|
||||
def _queue_command(self, command: ReactorCommand) -> None:
|
||||
if self.pending_command is None:
|
||||
self.pending_command = command
|
||||
return
|
||||
for field in command.__dataclass_fields__: # type: ignore[attr-defined]
|
||||
value = getattr(command, field)
|
||||
if value is None or value is False:
|
||||
continue
|
||||
if field == "rod_step" and getattr(self.pending_command, field) is not None:
|
||||
setattr(
|
||||
self.pending_command,
|
||||
field,
|
||||
getattr(self.pending_command, field) + value,
|
||||
)
|
||||
else:
|
||||
setattr(self.pending_command, field, value)
|
||||
else:
|
||||
for field in command.__dataclass_fields__: # type: ignore[attr-defined]
|
||||
value = getattr(command, field)
|
||||
if value is None or value is False:
|
||||
continue
|
||||
if field == "rod_step" and getattr(self.pending_command, field) is not None:
|
||||
setattr(
|
||||
self.pending_command,
|
||||
field,
|
||||
getattr(self.pending_command, field) + value,
|
||||
)
|
||||
else:
|
||||
setattr(self.pending_command, field, value)
|
||||
if self.pending_command.rod_position is not None and self.pending_command.rod_manual is None:
|
||||
self.pending_command.rod_manual = True
|
||||
|
||||
|
||||
def _next_command(self, _: float, __: PlantState) -> Optional[ReactorCommand]:
|
||||
cmd = self.pending_command
|
||||
|
||||
Reference in New Issue
Block a user