#152 supervisor cleanups and improvements to alarms

This commit is contained in:
Mikayla Fischler 2023-02-07 17:51:55 -05:00
parent 6c09772a74
commit 678dafa62f
6 changed files with 52 additions and 14 deletions

View File

@ -380,7 +380,7 @@ function coordinator.new_session(id, in_queue, out_queue, facility)
-- exit if connection was closed
if not self.connected then
println("connection to coordinator " .. id .. " closed by remote host")
println("connection to coordinator closed by remote host")
log.info(log_header .. "session closed by remote host")
return self.connected
end

View File

@ -332,7 +332,7 @@ function rtu.new_session(id, in_queue, out_queue, advertisement, facility)
-- exit if connection was closed
if not self.connected then
println(log_header .. "connection to RTU closed by remote host")
println("RTU connection " .. id .. " closed by remote host")
log.info(log_header .. "session closed by remote host")
return self.connected
end

View File

@ -135,7 +135,7 @@ local function _shutdown(session)
end
end
log.debug("closed session " .. session.instance.get_id() .. " on remote port " .. session.r_port)
log.debug(util.c("closed ", session.s_type, " session ", session.instance.get_id(), " on remote port ", session.r_port))
end
-- close connections
@ -158,7 +158,8 @@ local function _check_watchdogs(sessions, timer_event)
if session.open then
local triggered = session.instance.check_wd(timer_event)
if triggered then
log.debug("watchdog closing session " .. session.instance.get_id() .. " on remote port " .. session.r_port .. "...")
log.debug(util.c("watchdog closing ", session.s_type, " session ", session.instance.get_id(),
" on remote port ", session.r_port, "..."))
_shutdown(session)
end
end
@ -171,7 +172,8 @@ local function _free_closed(sessions)
local f = function (session) return session.open end
local on_delete = function (session)
log.debug("free'ing closed session " .. session.instance.get_id() .. " on remote port " .. session.r_port)
log.debug(util.c("free'ing closed ", session.s_type, " session ", session.instance.get_id(),
" on remote port ", session.r_port))
end
util.filter_table(sessions, f, on_delete)
@ -296,7 +298,7 @@ function svsessions.establish_plc_session(local_port, remote_port, for_reactor,
local units = self.facility.get_units()
units[for_reactor].link_plc_session(plc_s)
log.debug("established new PLC session to " .. remote_port .. " with ID " .. self.next_plc_id)
log.debug(util.c("established new PLC session to ", remote_port, " with ID ", self.next_plc_id, " for reactor ", for_reactor))
self.next_plc_id = self.next_plc_id + 1

View File

@ -88,11 +88,39 @@ function unit.new(for_reactor, num_boilers, num_turbines)
-- logic for alarms
had_reactor = false,
last_rate_change_ms = 0,
---@type rps_status
last_rps_trips = {
dmg_crit = false,
high_temp = false,
no_cool = false,
ex_waste = false,
ex_hcool = false,
no_fuel = false,
fault = false,
timeout = false,
manual = false,
automatic = false,
sys_fail = false,
force_dis = false
},
plc_cache = {
active = false,
ok = false,
rps_trip = false,
rps_status = {}, ---@type rps_status
---@type rps_status
rps_status = {
dmg_crit = false,
high_temp = false,
no_cool = false,
ex_waste = false,
ex_hcool = false,
no_fuel = false,
fault = false,
timeout = false,
manual = false,
automatic = false,
sys_fail = false,
force_dis = false
},
damage = 0,
temp = 0,
waste = 0
@ -118,11 +146,11 @@ function unit.new(for_reactor, num_boilers, num_turbines)
-- waste >85%
ReactorHighWaste = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 2, id = ALARM.ReactorHighWaste, tier = PRIO.TIMELY },
-- RPS trip occured
RPSTransient = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 0, id = ALARM.RPSTransient, tier = PRIO.URGENT },
RPSTransient = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 1, id = ALARM.RPSTransient, tier = PRIO.URGENT },
-- BoilRateMismatch, CoolantFeedMismatch, SteamFeedMismatch, MaxWaterReturnFeed
RCSTransient = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 5, id = ALARM.RCSTransient, tier = PRIO.TIMELY },
-- "It's just a routine turbin' trip!" -Bill Gibson, "The China Syndrome"
TurbineTrip = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 0, id = ALARM.TurbineTrip, tier = PRIO.URGENT }
TurbineTrip = { state = AISTATE.INACTIVE, trip_time = 0, hold_time = 1, id = ALARM.TurbineTrip, tier = PRIO.URGENT }
},
---@class unit_db
db = {

View File

@ -397,10 +397,12 @@ function logic.update_alarms(self)
_update_alarm_state(self, plc_cache.damage >= 100, self.alarms.CriticalDamage)
-- Reactor Damage
_update_alarm_state(self, plc_cache.damage > 0, self.alarms.ReactorDamage)
local rps_dmg_90 = plc_cache.rps_status.dmg_crit and not self.last_rps_trips.dmg_crit
_update_alarm_state(self, (plc_cache.damage > 0) or rps_dmg_90, self.alarms.ReactorDamage)
-- Over-Temperature
_update_alarm_state(self, plc_cache.temp >= 1200, self.alarms.ReactorOverTemp)
local rps_high_temp = plc_cache.rps_status.high_temp and not self.last_rps_trips.high_temp
_update_alarm_state(self, (plc_cache.temp >= 1200) or rps_high_temp, self.alarms.ReactorOverTemp)
-- High Temperature
_update_alarm_state(self, plc_cache.temp > 1150, self.alarms.ReactorHighTemp)
@ -409,7 +411,8 @@ function logic.update_alarms(self)
_update_alarm_state(self, plc_cache.waste >= 0.99, self.alarms.ReactorWasteLeak)
-- High Waste
_update_alarm_state(self, plc_cache.waste > 0.50, self.alarms.ReactorHighWaste)
local rps_high_waste = plc_cache.rps_status.ex_waste and not self.last_rps_trips.ex_waste
_update_alarm_state(self, (plc_cache.waste > 0.50) or rps_high_waste, self.alarms.ReactorHighWaste)
-- RPS Transient (excludes timeouts and manual trips)
local rps_alarm = false
@ -444,6 +447,11 @@ function logic.update_alarms(self)
local any_trip = false
for i = 1, #annunc.TurbineTrip do any_trip = any_trip or annunc.TurbineTrip[i] end
_update_alarm_state(self, any_trip, self.alarms.TurbineTrip)
-- update last trips table
for key, val in pairs(plc_cache.rps_status) do
self.last_rps_trips[key] = val
end
end
-- update the two unit status text messages

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.10.0"
local SUPERVISOR_VERSION = "beta-v0.10.1"
local print = util.print
local println = util.println