#162 #168 status indicator for emergency coolant, display number of connected RTUs, added RCS hardware fault and radiation warning indicators
This commit is contained in:
@@ -60,6 +60,7 @@ function facility.new(num_reactors, cooling_conf)
|
||||
envd = {},
|
||||
status_text = { "START UP", "initializing..." },
|
||||
all_sys_ok = false,
|
||||
rtu_conn_count = 0,
|
||||
-- process control
|
||||
units_ready = false,
|
||||
mode = PROCESS.INACTIVE,
|
||||
@@ -224,6 +225,12 @@ function facility.new(num_reactors, cooling_conf)
|
||||
|
||||
-- UPDATE --
|
||||
|
||||
-- supervisor sessions reporting the list of active RTU sessions
|
||||
---@param rtu_sessions table session list of all connected RTUs
|
||||
function public.report_rtus(rtu_sessions)
|
||||
self.rtu_conn_count = #rtu_sessions
|
||||
end
|
||||
|
||||
-- update (iterate) the facility management
|
||||
function public.update()
|
||||
-- unlink RTU unit sessions if they are closed
|
||||
@@ -801,6 +808,9 @@ function facility.new(num_reactors, cooling_conf)
|
||||
function public.get_rtu_statuses()
|
||||
local status = {}
|
||||
|
||||
-- total count of all connected RTUs in the facility
|
||||
status.count = self.rtu_conn_count
|
||||
|
||||
-- power averages from induction matricies
|
||||
status.power = {
|
||||
self.avg_charge.compute(),
|
||||
|
||||
@@ -144,7 +144,7 @@ end
|
||||
---@param sessions table
|
||||
local function _close(sessions)
|
||||
for i = 1, #sessions do
|
||||
local session = sessions[i] ---@type plc_session_struct
|
||||
local session = sessions[i] ---@type plc_session_struct|rtu_session_struct
|
||||
if session.open then
|
||||
_shutdown(session)
|
||||
end
|
||||
@@ -156,7 +156,7 @@ end
|
||||
---@param timer_event number
|
||||
local function _check_watchdogs(sessions, timer_event)
|
||||
for i = 1, #sessions do
|
||||
local session = sessions[i] ---@type plc_session_struct
|
||||
local session = sessions[i] ---@type plc_session_struct|rtu_session_struct
|
||||
if session.open then
|
||||
local triggered = session.instance.check_wd(timer_event)
|
||||
if triggered then
|
||||
@@ -400,6 +400,9 @@ function svsessions.iterate_all()
|
||||
-- iterate coordinator sessions
|
||||
_iterate(self.coord_sessions)
|
||||
|
||||
-- report RTU sessions to facility
|
||||
self.facility.report_rtus(self.rtu_sessions)
|
||||
|
||||
-- iterate facility
|
||||
self.facility.update()
|
||||
|
||||
|
||||
@@ -163,10 +163,12 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
-- reactor
|
||||
PLCOnline = false,
|
||||
PLCHeartbeat = false, -- alternate true/false to blink, each time there is a keep_alive
|
||||
RadiationMonitor = 1,
|
||||
AutoControl = false,
|
||||
ReactorSCRAM = false,
|
||||
ManualReactorSCRAM = false,
|
||||
AutoReactorSCRAM = false,
|
||||
RadiationWarning = false,
|
||||
RCPTrip = false,
|
||||
RCSFlowLow = false,
|
||||
CoolantLevelLow = false,
|
||||
@@ -175,16 +177,19 @@ function unit.new(for_reactor, num_boilers, num_turbines)
|
||||
FuelInputRateLow = false,
|
||||
WasteLineOcclusion = false,
|
||||
HighStartupRate = false,
|
||||
-- boiler
|
||||
-- cooling
|
||||
RCSFault = false,
|
||||
EmergencyCoolant = 1,
|
||||
CoolantFeedMismatch = false,
|
||||
BoilRateMismatch = false,
|
||||
SteamFeedMismatch = false,
|
||||
MaxWaterReturnFeed = false,
|
||||
-- boilers
|
||||
BoilerOnline = {},
|
||||
HeatingRateLow = {},
|
||||
WaterLevelLow = {},
|
||||
BoilRateMismatch = false,
|
||||
CoolantFeedMismatch = false,
|
||||
-- turbine
|
||||
-- turbines
|
||||
TurbineOnline = {},
|
||||
SteamFeedMismatch = false,
|
||||
MaxWaterReturnFeed = false,
|
||||
SteamDumpOpen = {},
|
||||
TurbineOverSpeed = {},
|
||||
TurbineTrip = {}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local log = require("scada-common.log")
|
||||
local rsio = require("scada-common.rsio")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
@@ -7,6 +8,8 @@ local ALARM_STATE = types.ALARM_STATE
|
||||
local TRI_FAIL = types.TRI_FAIL
|
||||
local DUMPING_MODE = types.DUMPING_MODE
|
||||
|
||||
local IO = rsio.IO
|
||||
|
||||
local aistate_string = {
|
||||
"INACTIVE",
|
||||
"TRIPPING",
|
||||
@@ -19,6 +22,7 @@ local aistate_string = {
|
||||
-- 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_ALERT_LEVEL = 0.00001 -- 10 uSv/h
|
||||
local RADIATION_ALARM_LEVEL = 0.00005 -- 50 uSv/h, not yet damaging but this isn't good
|
||||
|
||||
---@class unit_logic_extension
|
||||
@@ -33,6 +37,8 @@ function logic.update_annunciator(self)
|
||||
local num_boilers = self.num_boilers
|
||||
local num_turbines = self.num_turbines
|
||||
|
||||
self.db.annunciator.RCSFault = false
|
||||
|
||||
-- variables for boiler, or reactor if no boilers used
|
||||
local total_boil_rate = 0.0
|
||||
|
||||
@@ -114,6 +120,29 @@ function logic.update_annunciator(self)
|
||||
self.plc_cache.ok = false
|
||||
end
|
||||
|
||||
---------------
|
||||
-- MISC RTUs --
|
||||
---------------
|
||||
|
||||
self.db.annunciator.RadiationMonitor = 1
|
||||
self.db.annunciator.RadiationWarning = false
|
||||
for i = 1, #self.envd do
|
||||
local envd = self.envd[i] ---@type unit_session
|
||||
self.db.annunciator.RadiationMonitor = util.trinary(envd.is_faulted(), 2, 3)
|
||||
self.db.annunciator.RadiationWarning = envd.get_db().radiation_raw > RADIATION_ALERT_LEVEL
|
||||
break
|
||||
end
|
||||
|
||||
self.db.annunciator.EmergencyCoolant = 1
|
||||
for i = 1, #self.redstone do
|
||||
local db = self.redstone[i].get_db() ---@type redstone_session_db
|
||||
local io = db.io[IO.U_EMER_COOL] ---@type rs_db_dig_io|nil
|
||||
if io ~= nil then
|
||||
self.db.annunciator.EmergencyCoolant = util.trinary(io.read(), 3, 2)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-------------
|
||||
-- BOILERS --
|
||||
-------------
|
||||
@@ -133,6 +162,8 @@ function logic.update_annunciator(self)
|
||||
local session = self.boilers[i] ---@type unit_session
|
||||
local boiler = session.get_db() ---@type boilerv_session_db
|
||||
|
||||
self.db.annunciator.RCSFault = self.db.annunciator.RCSFault or (not boiler.formed) or session.is_faulted()
|
||||
|
||||
-- update ready state
|
||||
-- - must be formed
|
||||
-- - must have received build, state, and tanks at least once
|
||||
@@ -225,6 +256,8 @@ function logic.update_annunciator(self)
|
||||
local session = self.turbines[i] ---@type unit_session
|
||||
local turbine = session.get_db() ---@type turbinev_session_db
|
||||
|
||||
self.db.annunciator.RCSFault = self.db.annunciator.RCSFault or (not turbine.formed) or session.is_faulted()
|
||||
|
||||
-- update ready state
|
||||
-- - must be formed
|
||||
-- - must have received build, state, and tanks at least once
|
||||
|
||||
Reference in New Issue
Block a user