Persist manual control and pump states
This commit is contained in:
@@ -77,6 +77,7 @@ class ControlSystem:
|
||||
"control": {
|
||||
"setpoint_mw": self.setpoint_mw,
|
||||
"rod_fraction": self.rod_fraction,
|
||||
"manual_control": self.manual_control,
|
||||
},
|
||||
"plant": plant_state.to_dict(),
|
||||
"metadata": metadata or {},
|
||||
@@ -94,6 +95,7 @@ class ControlSystem:
|
||||
control = data.get("control", {})
|
||||
self.setpoint_mw = control.get("setpoint_mw", self.setpoint_mw)
|
||||
self.rod_fraction = control.get("rod_fraction", self.rod_fraction)
|
||||
self.manual_control = control.get("manual_control", self.manual_control)
|
||||
plant = PlantState.from_dict(data["plant"])
|
||||
LOGGER.info("Loaded plant state from %s", path)
|
||||
return plant, data.get("metadata", {}), data.get("health")
|
||||
|
||||
@@ -461,6 +461,21 @@ class Reactor:
|
||||
if health:
|
||||
self.health_monitor.load_snapshot(health)
|
||||
LOGGER.info("Reactor state restored from %s", filepath)
|
||||
# Back-fill pump state lists for compatibility.
|
||||
if not plant.primary_pumps or len(plant.primary_pumps) < 2:
|
||||
plant.primary_pumps = [
|
||||
PumpState(active=self.primary_pump_active, flow_rate=plant.primary_loop.mass_flow_rate / 2, pressure=plant.primary_loop.pressure)
|
||||
for _ in range(2)
|
||||
]
|
||||
if not plant.secondary_pumps or len(plant.secondary_pumps) < 2:
|
||||
plant.secondary_pumps = [
|
||||
PumpState(
|
||||
active=self.secondary_pump_active,
|
||||
flow_rate=plant.secondary_loop.mass_flow_rate / 2,
|
||||
pressure=plant.secondary_loop.pressure,
|
||||
)
|
||||
for _ in range(2)
|
||||
]
|
||||
if len(plant.turbines) < len(self.turbines):
|
||||
ambient = constants.ENVIRONMENT_TEMPERATURE
|
||||
while len(plant.turbines) < len(self.turbines):
|
||||
|
||||
Reference in New Issue
Block a user