#144 added radiation monitor integration; displays, unit alarms, connection states, other bugfixes

This commit is contained in:
Mikayla Fischler 2023-02-13 22:11:31 -05:00
parent ef27da8daf
commit 1fe2acb5c5
14 changed files with 224 additions and 52 deletions

View File

@ -31,13 +31,15 @@ function iocontrol.init(conf, comms)
auto_saturated = false, auto_saturated = false,
auto_scram = false, auto_scram = false,
num_units = conf.num_units, ---@type integer radiation = { radiation = 0, unit = "nSv" }, ---@type radiation_reading
save_cfg_ack = function (success) end, ---@param success boolean num_units = conf.num_units, ---@type integer
start_ack = function (success) end, ---@param success boolean
stop_ack = function (success) end, ---@param success boolean save_cfg_ack = function (success) end, ---@param success boolean
scram_ack = function (success) end, ---@param success boolean start_ack = function (success) end, ---@param success boolean
ack_alarms_ack = function (success) end, ---@param success boolean stop_ack = function (success) end, ---@param success boolean
scram_ack = function (success) end, ---@param success boolean
ack_alarms_ack = function (success) end, ---@param success boolean
ps = psil.create(), ps = psil.create(),
@ -62,7 +64,8 @@ function iocontrol.init(conf, comms)
---@class ioctl_unit ---@class ioctl_unit
local entry = { local entry = {
unit_id = i, ---@type integer ---@type integer
unit_id = i,
num_boilers = 0, num_boilers = 0,
num_turbines = 0, num_turbines = 0,
@ -70,8 +73,9 @@ function iocontrol.init(conf, comms)
control_state = false, control_state = false,
burn_rate_cmd = 0.0, burn_rate_cmd = 0.0,
waste_control = 0, waste_control = 0,
radiation = { radiation = 0, unit = "nSv" }, ---@type radiation_reading
a_group = 0, -- auto control group a_group = 0, -- auto control group
start = function () process.start(i) end, start = function () process.start(i) end,
scram = function () process.scram(i) end, scram = function () process.scram(i) end,
@ -370,6 +374,24 @@ function iocontrol.update_facility_status(status)
else else
log.debug(log_header .. "induction matrix list not a table") log.debug(log_header .. "induction matrix list not a table")
end end
-- environment detector status
if type(rtu_statuses.rad_mon) == "table" then
if #rtu_statuses.rad_mon > 0 then
local rad_mon = rtu_statuses.rad_mon[1]
local rtu_faulted = rad_mon[1] ---@type boolean
fac.radiation = rad_mon[2] ---@type number
fac.ps.publish("RadMonOnline", util.trinary(rtu_faulted, 2, 3))
fac.ps.publish("radiation", fac.radiation)
else
fac.radiation = { radiation = 0, unit = "nSv" }
fac.ps.publish("RadMonOnline", 1)
end
else
log.debug(log_header .. "radiation monitor list not a table")
return false
end
end end
end end
@ -575,6 +597,24 @@ function iocontrol.update_unit_statuses(statuses)
log.debug(log_header .. "turbine list not a table") log.debug(log_header .. "turbine list not a table")
return false return false
end end
-- environment detector status
if type(rtu_statuses.rad_mon) == "table" then
if #rtu_statuses.rad_mon > 0 then
local rad_mon = rtu_statuses.rad_mon[1]
local rtu_faulted = rad_mon[1] ---@type boolean
unit.radiation = rad_mon[2] ---@type number
unit.unit_ps.publish("RadMonOnline", util.trinary(rtu_faulted, 2, 3))
unit.unit_ps.publish("radiation", unit.radiation)
else
unit.radiation = { radiation = 0, unit = "nSv" }
unit.unit_ps.publish("RadMonOnline", 1)
end
else
log.debug(log_header .. "radiation monitor list not a table")
return false
end
else else
log.debug(log_header .. "rtu list not a table") log.debug(log_header .. "rtu list not a table")
end end
@ -658,20 +698,6 @@ function iocontrol.update_unit_statuses(statuses)
else else
log.debug(log_header .. "unit state not a table") log.debug(log_header .. "unit state not a table")
end end
-- auto control state fields
local auto_ctl_state = status[6]
if type(auto_ctl_state) == "table" then
if #auto_ctl_state == 0 then
---@todo
else
log.debug(log_header .. "auto control state length mismatch")
end
else
log.debug(log_header .. "auto control state not a table")
end
end end
io.facility.ps.publish("burn_sum", burn_rate_sum) io.facility.ps.publish("burn_sum", burn_rate_sum)

View File

@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
local renderer = require("coordinator.renderer") local renderer = require("coordinator.renderer")
local sounder = require("coordinator.sounder") local sounder = require("coordinator.sounder")
local COORDINATOR_VERSION = "beta-v0.9.8" local COORDINATOR_VERSION = "beta-v0.9.9"
local print = util.print local print = util.print
local println = util.println local println = util.println

View File

@ -14,6 +14,7 @@ local TextBox = require("graphics.elements.textbox")
local DataIndicator = require("graphics.elements.indicators.data") local DataIndicator = require("graphics.elements.indicators.data")
local IndicatorLight = require("graphics.elements.indicators.light") local IndicatorLight = require("graphics.elements.indicators.light")
local RadIndicator = require("graphics.elements.indicators.rad")
local TriIndicatorLight = require("graphics.elements.indicators.trilight") local TriIndicatorLight = require("graphics.elements.indicators.trilight")
local VerticalBar = require("graphics.elements.indicators.vbar") local VerticalBar = require("graphics.elements.indicators.vbar")
@ -42,6 +43,7 @@ local function new_view(root, x, y)
local bw_fg_bg = cpair(colors.black, colors.white) local bw_fg_bg = cpair(colors.black, colors.white)
local hzd_fg_bg = cpair(colors.white, colors.gray) local hzd_fg_bg = cpair(colors.white, colors.gray)
local lu_cpair = cpair(colors.gray, colors.gray)
local dis_colors = cpair(colors.white, colors.lightGray) local dis_colors = cpair(colors.white, colors.lightGray)
local main = Div{parent=root,width=104,height=24,x=x,y=y} local main = Div{parent=root,width=104,height=24,x=x,y=y}
@ -52,12 +54,13 @@ local function new_view(root, x, y)
facility.scram_ack = scram.on_response facility.scram_ack = scram.on_response
facility.ack_alarms_ack = ack_a.on_response facility.ack_alarms_ack = ack_a.on_response
local all_ok = IndicatorLight{parent=main,y=5,label="Unit Systems Online",colors=cpair(colors.green,colors.red)} local all_ok = IndicatorLight{parent=main,y=5,label="Unit Systems Online",colors=cpair(colors.green,colors.red)}
local ind_mat = IndicatorLight{parent=main,label="Induction Matrix",colors=cpair(colors.green,colors.gray)} local ind_mat = IndicatorLight{parent=main,label="Induction Matrix",colors=cpair(colors.green,colors.gray)}
local rad_mon = IndicatorLight{parent=main,label="Radiation Monitor",colors=cpair(colors.green,colors.gray)} local rad_mon = TriIndicatorLight{parent=main,label="Radiation Monitor",c1=colors.gray,c2=colors.yellow,c3=colors.green}
facility.ps.subscribe("all_sys_ok", all_ok.update) facility.ps.subscribe("all_sys_ok", all_ok.update)
facility.induction_ps_tbl[1].subscribe("computed_status", function (status) ind_mat.update(status > 1) end) facility.induction_ps_tbl[1].subscribe("computed_status", function (status) ind_mat.update(status > 1) end)
facility.ps.subscribe("RadMonOnline", rad_mon.update)
main.line_break() main.line_break()
@ -65,21 +68,25 @@ local function new_view(root, x, y)
local auto_act = IndicatorLight{parent=main,label="Process Active",colors=cpair(colors.green,colors.gray)} local auto_act = IndicatorLight{parent=main,label="Process Active",colors=cpair(colors.green,colors.gray)}
local auto_ramp = IndicatorLight{parent=main,label="Process Ramping",colors=cpair(colors.white,colors.gray),flash=true,period=period.BLINK_250_MS} local auto_ramp = IndicatorLight{parent=main,label="Process Ramping",colors=cpair(colors.white,colors.gray),flash=true,period=period.BLINK_250_MS}
local auto_sat = IndicatorLight{parent=main,label="Min/Max Burn Rate",colors=cpair(colors.yellow,colors.gray)} local auto_sat = IndicatorLight{parent=main,label="Min/Max Burn Rate",colors=cpair(colors.yellow,colors.gray)}
local auto_scram = IndicatorLight{parent=main,label="Automatic SCRAM",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
facility.ps.subscribe("auto_ready", auto_ready.update) facility.ps.subscribe("auto_ready", auto_ready.update)
facility.ps.subscribe("auto_active", auto_act.update) facility.ps.subscribe("auto_active", auto_act.update)
facility.ps.subscribe("auto_ramping", auto_ramp.update) facility.ps.subscribe("auto_ramping", auto_ramp.update)
facility.ps.subscribe("auto_saturated", auto_sat.update) facility.ps.subscribe("auto_saturated", auto_sat.update)
facility.ps.subscribe("auto_scram", auto_scram.update)
main.line_break() main.line_break()
local _ = IndicatorLight{parent=main,label="Unit Off-line",colors=cpair(colors.yellow,colors.gray),flash=true,period=period.BLINK_1000_MS} local auto_scram = IndicatorLight{parent=main,label="Automatic SCRAM",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
local _ = IndicatorLight{parent=main,label="Unit RPS Trip",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS} local _ = IndicatorLight{parent=main,label="Matrix Disconnected",colors=cpair(colors.yellow,colors.gray),flash=true,period=period.BLINK_250_MS}
local _ = IndicatorLight{parent=main,label="Matrix Charge High",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
local _ = IndicatorLight{parent=main,label="Unit Critical Alarm",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS} local _ = IndicatorLight{parent=main,label="Unit Critical Alarm",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
local _ = IndicatorLight{parent=main,label="High Charge Level",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS} local _ = IndicatorLight{parent=main,label="Gen. Control Fault",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_MS}
facility.ps.subscribe("auto_scram", auto_scram.update)
TextBox{parent=main,y=23,text="Radiation",height=1,width=21,fg_bg=style.label}
local radiation = RadIndicator{parent=main,label="",format="%9.3f",lu_colors=lu_cpair,width=13,fg_bg=bw_fg_bg}
facility.ps.subscribe("radiation", radiation.update)
--------------------- ---------------------
-- process control -- -- process control --

View File

@ -16,6 +16,7 @@ local AlarmLight = require("graphics.elements.indicators.alight")
local CoreMap = require("graphics.elements.indicators.coremap") local CoreMap = require("graphics.elements.indicators.coremap")
local DataIndicator = require("graphics.elements.indicators.data") local DataIndicator = require("graphics.elements.indicators.data")
local IndicatorLight = require("graphics.elements.indicators.light") local IndicatorLight = require("graphics.elements.indicators.light")
local RadIndicator = require("graphics.elements.indicators.rad")
local TriIndicatorLight = require("graphics.elements.indicators.trilight") local TriIndicatorLight = require("graphics.elements.indicators.trilight")
local VerticalBar = require("graphics.elements.indicators.vbar") local VerticalBar = require("graphics.elements.indicators.vbar")
@ -133,9 +134,9 @@ local function init(parent, id)
local damage_p = DataIndicator{parent=main,x=32,label="",format="%11.0f",value=0,unit="%",lu_colors=lu_cpair,width=13,fg_bg=bw_fg_bg} local damage_p = DataIndicator{parent=main,x=32,label="",format="%11.0f",value=0,unit="%",lu_colors=lu_cpair,width=13,fg_bg=bw_fg_bg}
u_ps.subscribe("damage", damage_p.update) u_ps.subscribe("damage", damage_p.update)
---@todo radiation monitor
TextBox{parent=main,x=32,y=31,text="Radiation",height=1,width=21,fg_bg=style.label} TextBox{parent=main,x=32,y=31,text="Radiation",height=1,width=21,fg_bg=style.label}
DataIndicator{parent=main,x=32,label="",format="%7.2f",value=0,unit="mSv/h",lu_colors=lu_cpair,width=13,fg_bg=bw_fg_bg} local radiation = RadIndicator{parent=main,x=32,label="",format="%9.3f",lu_colors=lu_cpair,width=13,fg_bg=bw_fg_bg}
u_ps.subscribe("radiation", radiation.update)
------------------- -------------------
-- system status -- -- system status --
@ -164,13 +165,13 @@ local function init(parent, id)
annunciator.line_break() annunciator.line_break()
---@todo radiation monitor local rad_mon = TriIndicatorLight{parent=annunciator,label="Radiation Monitor",c1=colors.gray,c2=colors.yellow,c3=colors.green}
local rad_mon = IndicatorLight{parent=annunciator,label="Radiation Monitor",colors=cpair(colors.green,colors.gray)}
u_ps.subscribe("PLCOnline", plc_online.update) u_ps.subscribe("PLCOnline", plc_online.update)
u_ps.subscribe("PLCHeartbeat", plc_hbeat.update) u_ps.subscribe("PLCHeartbeat", plc_hbeat.update)
u_ps.subscribe("status", r_active.update) u_ps.subscribe("status", r_active.update)
u_ps.subscribe("AutoControl", r_auto.update) u_ps.subscribe("AutoControl", r_auto.update)
u_ps.subscribe("RadMonOnline", rad_mon.update)
annunciator.line_break() annunciator.line_break()
@ -213,7 +214,7 @@ local function init(parent, id)
local rps_nof = IndicatorLight{parent=rps_annunc,label="No Fuel",colors=cpair(colors.yellow,colors.gray)} local rps_nof = IndicatorLight{parent=rps_annunc,label="No Fuel",colors=cpair(colors.yellow,colors.gray)}
local rps_noc = IndicatorLight{parent=rps_annunc,label="Coolant Level Low Low",colors=cpair(colors.yellow,colors.gray)} local rps_noc = IndicatorLight{parent=rps_annunc,label="Coolant Level Low Low",colors=cpair(colors.yellow,colors.gray)}
local rps_flt = IndicatorLight{parent=rps_annunc,label="PPM Fault",colors=cpair(colors.yellow,colors.gray),flash=true,period=period.BLINK_500_MS} local rps_flt = IndicatorLight{parent=rps_annunc,label="PPM Fault",colors=cpair(colors.yellow,colors.gray),flash=true,period=period.BLINK_500_MS}
local rps_tmo = IndicatorLight{parent=rps_annunc,label="Timeout",colors=cpair(colors.yellow,colors.gray),flash=true,period=period.BLINK_500_MS} local rps_tmo = IndicatorLight{parent=rps_annunc,label="Connection Timeout",colors=cpair(colors.yellow,colors.gray),flash=true,period=period.BLINK_500_MS}
local rps_sfl = IndicatorLight{parent=rps_annunc,label="System Failure",colors=cpair(colors.orange,colors.gray),flash=true,period=period.BLINK_500_MS} local rps_sfl = IndicatorLight{parent=rps_annunc,label="System Failure",colors=cpair(colors.orange,colors.gray),flash=true,period=period.BLINK_500_MS}
u_ps.subscribe("rps_tripped", rps_trp.update) u_ps.subscribe("rps_tripped", rps_trp.update)

View File

@ -34,6 +34,7 @@ local element = {}
---|icon_indicator_args ---|icon_indicator_args
---|indicator_light_args ---|indicator_light_args
---|power_indicator_args ---|power_indicator_args
---|rad_indicator_args
---|state_indicator_args ---|state_indicator_args
---|tristate_indicator_light_args ---|tristate_indicator_light_args
---|vbar_args ---|vbar_args

View File

@ -0,0 +1,88 @@
-- Radiation Indicator Graphics Element
local util = require("scada-common.util")
local element = require("graphics.element")
---@class rad_indicator_args
---@field label string indicator label
---@field format string data format (lua string format)
---@field commas? boolean whether to use commas if a number is given (default to false)
---@field lu_colors? cpair label foreground color (a), unit foreground color (b)
---@field value any default value
---@field parent graphics_element
---@field id? string element id
---@field x? integer 1 if omitted
---@field y? integer 1 if omitted
---@field width integer length
---@field fg_bg? cpair foreground/background colors
-- new radiation indicator
---@param args rad_indicator_args
---@return graphics_element element, element_id id
local function rad(args)
assert(type(args.label) == "string", "graphics.elements.indicators.rad: label is a required field")
assert(type(args.format) == "string", "graphics.elements.indicators.rad: format is a required field")
assert(util.is_int(args.width), "graphics.elements.indicators.rad: width is a required field")
-- single line
args.height = 1
-- create new graphics element base object
local e = element.new(args)
-- label color
if args.lu_colors ~= nil then
e.window.setTextColor(args.lu_colors.color_a)
end
-- write label
e.window.setCursorPos(1, 1)
e.window.write(args.label)
local label_len = string.len(args.label)
local data_start = 1
local clear_width = args.width
if label_len > 0 then
data_start = data_start + (label_len + 1)
clear_width = args.width - (label_len + 1)
end
-- on state change
---@param value any new value
function e.on_update(value)
e.value = value.radiation
-- clear old data and label
e.window.setCursorPos(data_start, 1)
e.window.write(util.spaces(clear_width))
-- write data
local data_str = util.sprintf(args.format, e.value)
e.window.setCursorPos(data_start, 1)
e.window.setTextColor(e.fg_bg.fgd)
if args.commas then
e.window.write(util.comma_format(data_str))
else
e.window.write(data_str)
end
-- write unit
if args.lu_colors ~= nil then
e.window.setTextColor(args.lu_colors.color_b)
end
e.window.write(" " .. value.unit)
end
-- set the value
---@param val any new value
function e.set_value(val) e.on_update(val) end
-- initial value draw
e.on_update({ radiation = 0, unit = "nSv" })
return e.get()
end
return rad

View File

@ -11,6 +11,10 @@ local types = {}
---@field name string ---@field name string
---@field amount integer ---@field amount integer
---@class radiation_reading
---@field radiation number
---@field unit string
---@class coordinate ---@class coordinate
---@field x integer ---@field x integer
---@field y integer ---@field y integer

View File

@ -149,15 +149,12 @@ function coordinator.new_session(id, in_queue, out_queue, timeout, facility)
for i = 1, #self.units do for i = 1, #self.units do
local unit = self.units[i] ---@type reactor_unit local unit = self.units[i] ---@type reactor_unit
local auto_ctl = {}
status[unit.get_id()] = { status[unit.get_id()] = {
unit.get_reactor_status(), unit.get_reactor_status(),
unit.get_rtu_statuses(), unit.get_rtu_statuses(),
unit.get_annunciator(), unit.get_annunciator(),
unit.get_alarms(), unit.get_alarms(),
unit.get_state(), unit.get_state()
auto_ctl
} }
end end

View File

@ -49,8 +49,9 @@ local facility = {}
function facility.new(num_reactors, cooling_conf) function facility.new(num_reactors, cooling_conf)
local self = { local self = {
units = {}, units = {},
induction = {},
redstone = {}, redstone = {},
induction = {},
envd = {},
status_text = { "START UP", "initializing..." }, status_text = { "START UP", "initializing..." },
all_sys_ok = false, all_sys_ok = false,
-- process control -- process control
@ -199,11 +200,18 @@ function facility.new(num_reactors, cooling_conf)
table.insert(self.induction, imatrix) table.insert(self.induction, imatrix)
end end
-- link an environment detector RTU session
---@param envd unit_session
function public.add_envd(envd)
table.insert(self.envd, envd)
end
-- purge devices associated with the given RTU session ID -- purge devices associated with the given RTU session ID
---@param session integer RTU session ID ---@param session integer RTU session ID
function public.purge_rtu_devices(session) function public.purge_rtu_devices(session)
util.filter_table(self.redstone, function (s) return s.get_session_id() ~= session end) util.filter_table(self.redstone, function (s) return s.get_session_id() ~= session end)
util.filter_table(self.induction, function (s) return s.get_session_id() ~= session end) util.filter_table(self.induction, function (s) return s.get_session_id() ~= session end)
util.filter_table(self.envd, function (s) return s.get_session_id() ~= session end)
end end
-- UPDATE -- -- UPDATE --
@ -211,8 +219,9 @@ function facility.new(num_reactors, cooling_conf)
-- update (iterate) the facility management -- update (iterate) the facility management
function public.update() function public.update()
-- unlink RTU unit sessions if they are closed -- unlink RTU unit sessions if they are closed
_unlink_disconnected_units(self.induction)
_unlink_disconnected_units(self.redstone) _unlink_disconnected_units(self.redstone)
_unlink_disconnected_units(self.induction)
_unlink_disconnected_units(self.envd)
-- current state for process control -- current state for process control
local charge_update = 0 local charge_update = 0
@ -785,7 +794,15 @@ function facility.new(num_reactors, cooling_conf)
} }
end end
---@todo other RTU statuses -- radiation monitors (environment detectors)
status.rad_mon = {}
for i = 1, #self.envd do
local envd = self.envd[i] ---@type unit_session
status.rad_mon[envd.get_device_idx()] = {
envd.is_faulted(),
envd.get_db().radiation
}
end
return status return status
end end

View File

@ -136,6 +136,10 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
-- turbine (Mekanism 10.1+) -- turbine (Mekanism 10.1+)
unit = svrs_turbinev.new(id, i, unit_advert, self.modbus_q) unit = svrs_turbinev.new(id, i, unit_advert, self.modbus_q)
if type(unit) ~= "nil" then target_unit.add_turbine(unit) end if type(unit) ~= "nil" then target_unit.add_turbine(unit) end
elseif u_type == RTU_UNIT_TYPES.ENV_DETECTOR then
-- environment detector
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
if type(unit) ~= "nil" then target_unit.add_envd(unit) end
else else
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-specific RTU type ", type_string)) log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-specific RTU type ", type_string))
end end
@ -157,6 +161,7 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
elseif u_type == RTU_UNIT_TYPES.ENV_DETECTOR then elseif u_type == RTU_UNIT_TYPES.ENV_DETECTOR then
-- environment detector -- environment detector
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q) unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
if type(unit) ~= "nil" then facility.add_envd(unit) end
else else
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-independent RTU type ", type_string)) log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-independent RTU type ", type_string))
end end

View File

@ -44,7 +44,7 @@ function envd.new(session_id, unit_id, advert, out_queue)
---@class envd_session_db ---@class envd_session_db
db = { db = {
last_update = 0, last_update = 0,
radiation = {}, radiation = { radiation = 0, unit = "nSv" }, ---@type radiation_reading
radiation_raw = 0 radiation_raw = 0
} }
} }

View File

@ -73,9 +73,10 @@ function unit.new(for_reactor, num_boilers, num_turbines)
num_turbines = num_turbines, num_turbines = num_turbines,
types = { DT_KEYS = DT_KEYS, AISTATE = AISTATE }, types = { DT_KEYS = DT_KEYS, AISTATE = AISTATE },
defs = { FLOW_STABILITY_DELAY_MS = FLOW_STABILITY_DELAY_MS }, defs = { FLOW_STABILITY_DELAY_MS = FLOW_STABILITY_DELAY_MS },
turbines = {},
boilers = {},
redstone = {}, redstone = {},
boilers = {},
turbines = {},
envd = {},
-- auto control -- auto control
ramp_target_br100 = 0, ramp_target_br100 = 0,
-- state tracking -- state tracking
@ -397,12 +398,19 @@ function unit.new(for_reactor, num_boilers, num_turbines)
end end
end end
-- link an environment detector RTU session
---@param envd unit_session
function public.add_envd(envd)
table.insert(self.envd, envd)
end
-- purge devices associated with the given RTU session ID -- purge devices associated with the given RTU session ID
---@param session integer RTU session ID ---@param session integer RTU session ID
function public.purge_rtu_devices(session) function public.purge_rtu_devices(session)
util.filter_table(self.turbines, function (s) return s.get_session_id() ~= session end)
util.filter_table(self.boilers, function (s) return s.get_session_id() ~= session end)
util.filter_table(self.redstone, function (s) return s.get_session_id() ~= session end) util.filter_table(self.redstone, function (s) return s.get_session_id() ~= session end)
util.filter_table(self.boilers, function (s) return s.get_session_id() ~= session end)
util.filter_table(self.turbines, function (s) return s.get_session_id() ~= session end)
util.filter_table(self.envd, function (s) return s.get_session_id() ~= session end)
end end
--#endregion --#endregion
@ -420,9 +428,10 @@ function unit.new(for_reactor, num_boilers, num_turbines)
end end
-- unlink RTU unit sessions if they are closed -- unlink RTU unit sessions if they are closed
_unlink_disconnected_units(self.redstone)
_unlink_disconnected_units(self.boilers) _unlink_disconnected_units(self.boilers)
_unlink_disconnected_units(self.turbines) _unlink_disconnected_units(self.turbines)
_unlink_disconnected_units(self.redstone) _unlink_disconnected_units(self.envd)
-- update degraded state for auto control -- update degraded state for auto control
self.db.control.degraded = (#self.boilers ~= num_boilers) or (#self.turbines ~= num_turbines) or (self.plc_i == nil) self.db.control.degraded = (#self.boilers ~= num_boilers) or (#self.turbines ~= num_turbines) or (self.plc_i == nil)
@ -709,7 +718,15 @@ function unit.new(for_reactor, num_boilers, num_turbines)
} }
end end
---@todo other RTU statuses -- radiation monitors (environment detectors)
status.rad_mon = {}
for i = 1, #self.envd do
local envd = self.envd[i] ---@type unit_session
status.rad_mon[envd.get_device_idx()] = {
envd.is_faulted(),
envd.get_db().radiation
}
end
return status return status
end end

View File

@ -16,6 +16,11 @@ local aistate_string = {
"RING_BACK_TRIPPING" "RING_BACK_TRIPPING"
} }
-- background radiation 0.0000001 Sv/h (99.99 nSv/h)
-- "green tint" radiation 0.00001 Sv/h (10 uSv/h)
-- damaging radiation 0.00006 Sv/h (60 uSv/h)
local RADIATION_ALARM_LEVEL = 0.00005 -- 50 uSv/h, not yet damaging but this isn't good
---@class unit_logic_extension ---@class unit_logic_extension
local logic = {} local logic = {}
@ -388,8 +393,12 @@ function logic.update_alarms(self)
_update_alarm_state(self, (not plc_cache.ok) and (plc_cache.damage > 99), self.alarms.ContainmentBreach) _update_alarm_state(self, (not plc_cache.ok) and (plc_cache.damage > 99), self.alarms.ContainmentBreach)
-- Containment Radiation -- Containment Radiation
---@todo containment radiation alarm local rad_alarm = false
_update_alarm_state(self, false, self.alarms.ContainmentRadiation) for i = 1, #self.envd do
rad_alarm = self.envd[i].get_db().radiation_raw > RADIATION_ALARM_LEVEL
break
end
_update_alarm_state(self, rad_alarm, self.alarms.ContainmentRadiation)
-- Reactor Lost -- Reactor Lost
_update_alarm_state(self, self.had_reactor and self.plc_i == nil, self.alarms.ReactorLost) _update_alarm_state(self, self.had_reactor and self.plc_i == nil, self.alarms.ReactorLost)

View File

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