#480 auxiliary coolant control logic

This commit is contained in:
Mikayla 2025-02-11 22:42:52 +00:00
parent 425a6c8775
commit 7b29702000
3 changed files with 34 additions and 14 deletions

View File

@ -22,7 +22,7 @@ local supervisor = require("supervisor.supervisor")
local svsessions = require("supervisor.session.svsessions") local svsessions = require("supervisor.session.svsessions")
local SUPERVISOR_VERSION = "v1.6.3" local SUPERVISOR_VERSION = "v1.6.4"
local println = util.println local println = util.println
local println_ts = util.println_ts local println_ts = util.println_ts

View File

@ -92,7 +92,8 @@ function unit.new(reactor_id, num_boilers, num_turbines, ext_idle)
io_ctl = nil, ---@type rs_controller io_ctl = nil, ---@type rs_controller
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
valves = {}, ---@type unit_valves valves = {}, ---@type unit_valves
emcool_opened = false, em_cool_opened = false,
aux_cool_opened = false,
-- auto control -- auto control
auto_engaged = false, auto_engaged = false,
auto_idle = false, auto_idle = false,
@ -373,6 +374,7 @@ function unit.new(reactor_id, num_boilers, num_turbines, ext_idle)
local waste_po = _make_valve_iface(IO.WASTE_POPL) local waste_po = _make_valve_iface(IO.WASTE_POPL)
local waste_sps = _make_valve_iface(IO.WASTE_AM) local waste_sps = _make_valve_iface(IO.WASTE_AM)
local emer_cool = _make_valve_iface(IO.U_EMER_COOL) local emer_cool = _make_valve_iface(IO.U_EMER_COOL)
local aux_cool = _make_valve_iface(IO.U_AUX_COOL)
---@class unit_valves ---@class unit_valves
self.valves = { self.valves = {
@ -380,7 +382,8 @@ function unit.new(reactor_id, num_boilers, num_turbines, ext_idle)
waste_sna = waste_sna, waste_sna = waste_sna,
waste_po = waste_po, waste_po = waste_po,
waste_sps = waste_sps, waste_sps = waste_sps,
emer_cool = emer_cool emer_cool = emer_cool,
aux_cool = aux_cool
} }
-- route reactor waste for a given waste product -- route reactor waste for a given waste product
@ -606,7 +609,7 @@ function unit.new(reactor_id, num_boilers, num_turbines, ext_idle)
if #self.redstone > 0 then if #self.redstone > 0 then
logic.handle_redstone(self) logic.handle_redstone(self)
elseif not self.plc_cache.rps_trip then elseif not self.plc_cache.rps_trip then
self.emcool_opened = false self.em_cool_opened = false
end end
end end
@ -724,7 +727,7 @@ function unit.new(reactor_id, num_boilers, num_turbines, ext_idle)
-- queue a command to clear timeout/auto-scram if set -- queue a command to clear timeout/auto-scram if set
function public.auto_cond_rps_reset() function public.auto_cond_rps_reset()
if self.plc_s ~= nil and self.plc_i ~= nil and (not self.auto_was_alarmed) and (not self.emcool_opened) then if self.plc_s ~= nil and self.plc_i ~= nil and (not self.auto_was_alarmed) and (not self.em_cool_opened) then
local rps = self.plc_i.get_rps() local rps = self.plc_i.get_rps()
if rps.timeout or rps.automatic then if rps.timeout or rps.automatic then
self.plc_i.auto_lock(true) -- if it timed out/restarted, auto lock was lost, so re-lock it self.plc_i.auto_lock(true) -- if it timed out/restarted, auto lock was lost, so re-lock it
@ -865,7 +868,7 @@ function unit.new(reactor_id, num_boilers, num_turbines, ext_idle)
-- check if emergency coolant activation has been tripped -- check if emergency coolant activation has been tripped
---@nodiscard ---@nodiscard
function public.is_emer_cool_tripped() return self.emcool_opened end function public.is_emer_cool_tripped() return self.em_cool_opened end
-- get build properties of machines -- get build properties of machines
-- --

View File

@ -728,7 +728,7 @@ function logic.update_status_text(self)
self.status_text = { "RCS TRANSIENT", "check coolant system" } self.status_text = { "RCS TRANSIENT", "check coolant system" }
-- elseif is_active(self.alarms.RPSTransient) then -- elseif is_active(self.alarms.RPSTransient) then
-- RPS status handled when checking reactor status -- RPS status handled when checking reactor status
elseif self.emcool_opened then elseif self.em_cool_opened then
self.status_text = { "EMERGENCY COOLANT OPENED", "reset RPS to close valve" } self.status_text = { "EMERGENCY COOLANT OPENED", "reset RPS to close valve" }
-- connection dependent states -- connection dependent states
elseif self.plc_i ~= nil then elseif self.plc_i ~= nil then
@ -886,7 +886,7 @@ function logic.handle_redstone(self)
(annunc.CoolantLevelLow or (boiler_water_low and rps.ex_hcool)) and (annunc.CoolantLevelLow or (boiler_water_low and rps.ex_hcool)) and
is_active(self.alarms.ReactorOverTemp)) is_active(self.alarms.ReactorOverTemp))
if enable_emer_cool and not self.emcool_opened then if enable_emer_cool and not self.em_cool_opened then
log.debug(util.c(">> Emergency Coolant Enable Detail Report (Unit ", self.r_id, ") <<")) log.debug(util.c(">> Emergency Coolant Enable Detail Report (Unit ", self.r_id, ") <<"))
log.debug(util.c("| CoolantLevelLow[", annunc.CoolantLevelLow, "] CoolantLevelLowLow[", rps.low_cool, "] ExcessHeatedCoolant[", rps.ex_hcool, "]")) log.debug(util.c("| CoolantLevelLow[", annunc.CoolantLevelLow, "] CoolantLevelLowLow[", rps.low_cool, "] ExcessHeatedCoolant[", rps.ex_hcool, "]"))
log.debug(util.c("| ReactorOverTemp[", AISTATE_NAMES[self.alarms.ReactorOverTemp.state], "]")) log.debug(util.c("| ReactorOverTemp[", AISTATE_NAMES[self.alarms.ReactorOverTemp.state], "]"))
@ -910,13 +910,13 @@ function logic.handle_redstone(self)
end end
end end
if annunc.EmergencyCoolant > 1 and self.emcool_opened then if annunc.EmergencyCoolant > 1 and self.em_cool_opened then
log.info(util.c("UNIT ", self.r_id, " emergency coolant valve closed")) log.info(util.c("UNIT ", self.r_id, " emergency coolant valve closed"))
log.info(util.c("UNIT ", self.r_id, " turbines set to not dump steam")) log.info(util.c("UNIT ", self.r_id, " turbines set to not dump steam"))
end end
self.emcool_opened = false self.em_cool_opened = false
elseif enable_emer_cool or self.emcool_opened then elseif enable_emer_cool or self.em_cool_opened then
-- set turbines to dump excess steam -- set turbines to dump excess steam
for i = 1, #self.turbines do for i = 1, #self.turbines do
local session = self.turbines[i] local session = self.turbines[i]
@ -937,16 +937,33 @@ function logic.handle_redstone(self)
end end
end end
if annunc.EmergencyCoolant > 1 and not self.emcool_opened then if annunc.EmergencyCoolant > 1 and not self.em_cool_opened then
log.info(util.c("UNIT ", self.r_id, " emergency coolant valve opened")) log.info(util.c("UNIT ", self.r_id, " emergency coolant valve opened"))
log.info(util.c("UNIT ", self.r_id, " turbines set to dump excess steam")) log.info(util.c("UNIT ", self.r_id, " turbines set to dump excess steam"))
end end
self.emcool_opened = true self.em_cool_opened = true
end end
-- set valve state always -- set valve state always
if self.emcool_opened then self.valves.emer_cool.open() else self.valves.emer_cool.close() end if self.em_cool_opened then self.valves.emer_cool.open() else self.valves.emer_cool.close() end
-----------------------
-- Auxiliary Coolant --
-----------------------
local enable_aux_cool = boiler_water_low or (annunc.CoolantLevelLow and self.num_boilers == 0)
if enable_aux_cool and not self.aux_cool_opened then
log.info(util.c("UNIT ", self.r_id, " auxiliary coolant valve opened"))
self.aux_cool_opened = true
elseif self.aux_cool_opened and self.turbine_flow_stable and not enable_aux_cool then
log.info(util.c("UNIT ", self.r_id, " auxiliary coolant valve closed"))
self.aux_cool_opened = false
end
-- set valve state always
if self.aux_cool_opened then self.valves.aux_cool.open() else self.valves.aux_cool.close() end
end end
return logic return logic