#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:
Mikayla Fischler
2023-02-15 19:52:28 -05:00
parent 199ce53f52
commit 2babd67198
11 changed files with 105 additions and 44 deletions

View File

@@ -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