mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#144 added radiation monitor integration; displays, unit alarms, connection states, other bugfixes
This commit is contained in:
parent
ef27da8daf
commit
1fe2acb5c5
@ -31,13 +31,15 @@ function iocontrol.init(conf, comms)
|
||||
auto_saturated = 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
|
||||
start_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
|
||||
num_units = conf.num_units, ---@type integer
|
||||
|
||||
save_cfg_ack = function (success) end, ---@param success boolean
|
||||
start_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(),
|
||||
|
||||
@ -62,7 +64,8 @@ function iocontrol.init(conf, comms)
|
||||
|
||||
---@class ioctl_unit
|
||||
local entry = {
|
||||
unit_id = i, ---@type integer
|
||||
---@type integer
|
||||
unit_id = i,
|
||||
|
||||
num_boilers = 0,
|
||||
num_turbines = 0,
|
||||
@ -70,8 +73,9 @@ function iocontrol.init(conf, comms)
|
||||
control_state = false,
|
||||
burn_rate_cmd = 0.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,
|
||||
scram = function () process.scram(i) end,
|
||||
@ -370,6 +374,24 @@ function iocontrol.update_facility_status(status)
|
||||
else
|
||||
log.debug(log_header .. "induction matrix list not a table")
|
||||
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
|
||||
|
||||
@ -575,6 +597,24 @@ function iocontrol.update_unit_statuses(statuses)
|
||||
log.debug(log_header .. "turbine list not a table")
|
||||
return false
|
||||
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
|
||||
log.debug(log_header .. "rtu list not a table")
|
||||
end
|
||||
@ -658,20 +698,6 @@ function iocontrol.update_unit_statuses(statuses)
|
||||
else
|
||||
log.debug(log_header .. "unit state not a table")
|
||||
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
|
||||
|
||||
io.facility.ps.publish("burn_sum", burn_rate_sum)
|
||||
|
@ -19,7 +19,7 @@ local iocontrol = require("coordinator.iocontrol")
|
||||
local renderer = require("coordinator.renderer")
|
||||
local sounder = require("coordinator.sounder")
|
||||
|
||||
local COORDINATOR_VERSION = "beta-v0.9.8"
|
||||
local COORDINATOR_VERSION = "beta-v0.9.9"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
@ -14,6 +14,7 @@ local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local DataIndicator = require("graphics.elements.indicators.data")
|
||||
local IndicatorLight = require("graphics.elements.indicators.light")
|
||||
local RadIndicator = require("graphics.elements.indicators.rad")
|
||||
local TriIndicatorLight = require("graphics.elements.indicators.trilight")
|
||||
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 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 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.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 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.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()
|
||||
|
||||
@ -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_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_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_active", auto_act.update)
|
||||
facility.ps.subscribe("auto_ramping", auto_ramp.update)
|
||||
facility.ps.subscribe("auto_saturated", auto_sat.update)
|
||||
facility.ps.subscribe("auto_scram", auto_scram.update)
|
||||
|
||||
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 _ = IndicatorLight{parent=main,label="Unit RPS Trip",colors=cpair(colors.red,colors.gray),flash=true,period=period.BLINK_250_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="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="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 --
|
||||
|
@ -16,6 +16,7 @@ local AlarmLight = require("graphics.elements.indicators.alight")
|
||||
local CoreMap = require("graphics.elements.indicators.coremap")
|
||||
local DataIndicator = require("graphics.elements.indicators.data")
|
||||
local IndicatorLight = require("graphics.elements.indicators.light")
|
||||
local RadIndicator = require("graphics.elements.indicators.rad")
|
||||
local TriIndicatorLight = require("graphics.elements.indicators.trilight")
|
||||
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}
|
||||
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}
|
||||
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 --
|
||||
@ -164,13 +165,13 @@ local function init(parent, id)
|
||||
|
||||
annunciator.line_break()
|
||||
|
||||
---@todo radiation monitor
|
||||
local rad_mon = IndicatorLight{parent=annunciator,label="Radiation Monitor",colors=cpair(colors.green,colors.gray)}
|
||||
local rad_mon = TriIndicatorLight{parent=annunciator,label="Radiation Monitor",c1=colors.gray,c2=colors.yellow,c3=colors.green}
|
||||
|
||||
u_ps.subscribe("PLCOnline", plc_online.update)
|
||||
u_ps.subscribe("PLCHeartbeat", plc_hbeat.update)
|
||||
u_ps.subscribe("status", r_active.update)
|
||||
u_ps.subscribe("AutoControl", r_auto.update)
|
||||
u_ps.subscribe("RadMonOnline", rad_mon.update)
|
||||
|
||||
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_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_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}
|
||||
|
||||
u_ps.subscribe("rps_tripped", rps_trp.update)
|
||||
|
@ -34,6 +34,7 @@ local element = {}
|
||||
---|icon_indicator_args
|
||||
---|indicator_light_args
|
||||
---|power_indicator_args
|
||||
---|rad_indicator_args
|
||||
---|state_indicator_args
|
||||
---|tristate_indicator_light_args
|
||||
---|vbar_args
|
||||
|
88
graphics/elements/indicators/rad.lua
Normal file
88
graphics/elements/indicators/rad.lua
Normal 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
|
@ -11,6 +11,10 @@ local types = {}
|
||||
---@field name string
|
||||
---@field amount integer
|
||||
|
||||
---@class radiation_reading
|
||||
---@field radiation number
|
||||
---@field unit string
|
||||
|
||||
---@class coordinate
|
||||
---@field x integer
|
||||
---@field y integer
|
||||
|
@ -149,15 +149,12 @@ function coordinator.new_session(id, in_queue, out_queue, timeout, facility)
|
||||
for i = 1, #self.units do
|
||||
local unit = self.units[i] ---@type reactor_unit
|
||||
|
||||
local auto_ctl = {}
|
||||
|
||||
status[unit.get_id()] = {
|
||||
unit.get_reactor_status(),
|
||||
unit.get_rtu_statuses(),
|
||||
unit.get_annunciator(),
|
||||
unit.get_alarms(),
|
||||
unit.get_state(),
|
||||
auto_ctl
|
||||
unit.get_state()
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -49,8 +49,9 @@ local facility = {}
|
||||
function facility.new(num_reactors, cooling_conf)
|
||||
local self = {
|
||||
units = {},
|
||||
induction = {},
|
||||
redstone = {},
|
||||
induction = {},
|
||||
envd = {},
|
||||
status_text = { "START UP", "initializing..." },
|
||||
all_sys_ok = false,
|
||||
-- process control
|
||||
@ -199,11 +200,18 @@ function facility.new(num_reactors, cooling_conf)
|
||||
table.insert(self.induction, imatrix)
|
||||
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
|
||||
---@param session integer RTU session ID
|
||||
function public.purge_rtu_devices(session)
|
||||
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.envd, function (s) return s.get_session_id() ~= session end)
|
||||
end
|
||||
|
||||
-- UPDATE --
|
||||
@ -211,8 +219,9 @@ function facility.new(num_reactors, cooling_conf)
|
||||
-- update (iterate) the facility management
|
||||
function public.update()
|
||||
-- unlink RTU unit sessions if they are closed
|
||||
_unlink_disconnected_units(self.induction)
|
||||
_unlink_disconnected_units(self.redstone)
|
||||
_unlink_disconnected_units(self.induction)
|
||||
_unlink_disconnected_units(self.envd)
|
||||
|
||||
-- current state for process control
|
||||
local charge_update = 0
|
||||
@ -785,7 +794,15 @@ function facility.new(num_reactors, cooling_conf)
|
||||
}
|
||||
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
|
||||
end
|
||||
|
@ -136,6 +136,10 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
||||
-- turbine (Mekanism 10.1+)
|
||||
unit = svrs_turbinev.new(id, i, unit_advert, self.modbus_q)
|
||||
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
|
||||
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-specific RTU type ", type_string))
|
||||
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
|
||||
-- environment detector
|
||||
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
|
||||
if type(unit) ~= "nil" then facility.add_envd(unit) end
|
||||
else
|
||||
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-independent RTU type ", type_string))
|
||||
end
|
||||
|
@ -44,7 +44,7 @@ function envd.new(session_id, unit_id, advert, out_queue)
|
||||
---@class envd_session_db
|
||||
db = {
|
||||
last_update = 0,
|
||||
radiation = {},
|
||||
radiation = { radiation = 0, unit = "nSv" }, ---@type radiation_reading
|
||||
radiation_raw = 0
|
||||
}
|
||||
}
|
||||
|
@ -73,9 +73,10 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
num_turbines = num_turbines,
|
||||
types = { DT_KEYS = DT_KEYS, AISTATE = AISTATE },
|
||||
defs = { FLOW_STABILITY_DELAY_MS = FLOW_STABILITY_DELAY_MS },
|
||||
turbines = {},
|
||||
boilers = {},
|
||||
redstone = {},
|
||||
boilers = {},
|
||||
turbines = {},
|
||||
envd = {},
|
||||
-- auto control
|
||||
ramp_target_br100 = 0,
|
||||
-- state tracking
|
||||
@ -397,12 +398,19 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
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
|
||||
---@param session integer RTU session ID
|
||||
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.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
|
||||
|
||||
--#endregion
|
||||
@ -420,9 +428,10 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
end
|
||||
|
||||
-- unlink RTU unit sessions if they are closed
|
||||
_unlink_disconnected_units(self.redstone)
|
||||
_unlink_disconnected_units(self.boilers)
|
||||
_unlink_disconnected_units(self.turbines)
|
||||
_unlink_disconnected_units(self.redstone)
|
||||
_unlink_disconnected_units(self.envd)
|
||||
|
||||
-- update degraded state for auto control
|
||||
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
|
||||
|
||||
---@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
|
||||
end
|
||||
|
@ -16,6 +16,11 @@ local aistate_string = {
|
||||
"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
|
||||
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)
|
||||
|
||||
-- Containment Radiation
|
||||
---@todo containment radiation alarm
|
||||
_update_alarm_state(self, false, self.alarms.ContainmentRadiation)
|
||||
local rad_alarm = false
|
||||
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
|
||||
_update_alarm_state(self, self.had_reactor and self.plc_i == nil, self.alarms.ReactorLost)
|
||||
|
@ -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.4"
|
||||
local SUPERVISOR_VERSION = "beta-v0.11.5"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
|
Loading…
Reference in New Issue
Block a user