#139 emergency coolant enabled on RPS low coolant

This commit is contained in:
Mikayla Fischler 2023-02-13 18:20:48 -05:00
parent ccd9f4b6cc
commit 2affe1b31c
3 changed files with 30 additions and 12 deletions

View File

@ -68,7 +68,10 @@ local IO_PORT = {
R_EXCESS_WS = 18, -- active high, if the reactor has excess waste
R_INSUFF_FUEL = 19, -- active high, if the reactor has insufficent fuel
R_PLC_FAULT = 20, -- active high, if the reactor PLC reports a device access fault
R_PLC_TIMEOUT = 21 -- active high, if the reactor PLC has not been heard from
R_PLC_TIMEOUT = 21, -- active high, if the reactor PLC has not been heard from
-- unit outputs
U_EMER_COOL = 22 -- active low, emergency coolant control
}
rsio.IO_LVL = IO_LVL
@ -104,7 +107,8 @@ function rsio.to_string(port)
"R_EXCESS_WS",
"R_INSUFF_FUEL",
"R_PLC_FAULT",
"R_PLC_TIMEOUT"
"R_PLC_TIMEOUT",
"U_EMER_COOL"
}
if util.is_int(port) and port > 0 and port <= #names then
@ -164,7 +168,9 @@ local RS_DIO_MAP = {
-- R_PLC_FAULT
{ _in = _I_ACTIVE_HIGH, _out = _O_ACTIVE_HIGH, mode = IO_DIR.OUT },
-- R_PLC_TIMEOUT
{ _in = _I_ACTIVE_HIGH, _out = _O_ACTIVE_HIGH, mode = IO_DIR.OUT }
{ _in = _I_ACTIVE_HIGH, _out = _O_ACTIVE_HIGH, mode = IO_DIR.OUT },
-- U_EMER_COOL
{ _in = _I_ACTIVE_LOW, _out = _O_ACTIVE_LOW, mode = IO_DIR.OUT }
}
-- get the mode of a port
@ -192,7 +198,8 @@ function rsio.get_io_mode(port)
IO_MODE.DIGITAL_OUT, -- R_EXCESS_WS
IO_MODE.DIGITAL_OUT, -- R_INSUFF_FUEL
IO_MODE.DIGITAL_OUT, -- R_PLC_FAULT
IO_MODE.DIGITAL_OUT -- R_PLC_TIMEOUT
IO_MODE.DIGITAL_OUT, -- R_PLC_TIMEOUT
IO_MODE.DIGITAL_OUT -- U_EMER_COOL
}
if util.is_int(port) and port > 0 and port <= #modes then
@ -212,7 +219,7 @@ local RS_SIDES = rs.getSides()
---@param port IO_PORT
---@return boolean valid
function rsio.is_valid_port(port)
return util.is_int(port) and (port > 0) and (port <= IO_PORT.R_PLC_TIMEOUT)
return util.is_int(port) and (port > 0) and (port <= IO_PORT.U_EMER_COOL)
end
-- check if a side is valid
@ -261,7 +268,7 @@ end
---@param active boolean
---@return IO_LVL|false
function rsio.digital_write_active(port, active)
if (not util.is_int(port)) or (port < IO_PORT.F_ALARM) or (port > IO_PORT.R_PLC_TIMEOUT) then
if (not util.is_int(port)) or (port < IO_PORT.F_ALARM) or (port > IO_PORT.U_EMER_COOL) then
return false
else
return RS_DIO_MAP[port]._out(active)

View File

@ -108,6 +108,7 @@ function unit.new(for_reactor, num_boilers, num_turbines)
plc_cache = {
active = false,
ok = false,
rps_trip = false,
---@type rps_status
rps_status = {
dmg_crit = false,
@ -315,11 +316,12 @@ function unit.new(for_reactor, num_boilers, num_turbines)
local __rs_w = rs_rtu_io_ctl.digital_write
local __rs_r = rs_rtu_io_ctl.digital_read
-- waste valves
local waste_pu = { open = function () __rs_w(IO.WASTE_PU, true) end, close = function () __rs_w(IO.WASTE_PU, false) end }
local waste_sna = { open = function () __rs_w(IO.WASTE_PO, true) end, close = function () __rs_w(IO.WASTE_PO, false) end }
local waste_po = { open = function () __rs_w(IO.WASTE_POPL, true) end, close = function () __rs_w(IO.WASTE_POPL, false) end }
local waste_sps = { open = function () __rs_w(IO.WASTE_AM, true) end, close = function () __rs_w(IO.WASTE_AM, false) end }
-- valves
local waste_pu = { open = function () __rs_w(IO.WASTE_PU, true) end, close = function () __rs_w(IO.WASTE_PU, false) end }
local waste_sna = { open = function () __rs_w(IO.WASTE_PO, true) end, close = function () __rs_w(IO.WASTE_PO, false) end }
local waste_po = { open = function () __rs_w(IO.WASTE_POPL, true) end, close = function () __rs_w(IO.WASTE_POPL, false) end }
local waste_sps = { open = function () __rs_w(IO.WASTE_AM, true) end, close = function () __rs_w(IO.WASTE_AM, false) end }
local emer_cool = { open = function () __rs_w(IO.U_EMER_COOL, true) end, close = function () __rs_w(IO.U_EMER_COOL, false) end }
--#endregion
@ -462,6 +464,15 @@ function unit.new(for_reactor, num_boilers, num_turbines)
-- update status text
logic.update_status_text(self)
-- check if emergency coolant is needed
if self.plc_cache.rps_status.no_cool then
emer_cool.open()
elseif not self.plc_cache.rps_trip then
-- can't turn off on sufficient coolant level since it might drop again
-- turn off once system is OK again
emer_cool.close()
end
end
-- AUTO CONTROL OPERATIONS --

View File

@ -14,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
local config = require("supervisor.config")
local supervisor = require("supervisor.supervisor")
local SUPERVISOR_VERSION = "beta-v0.11.3"
local SUPERVISOR_VERSION = "beta-v0.11.4"
local print = util.print
local println = util.println