From 785dbe953392c38e19f3252e2cf35efd5a8020c7 Mon Sep 17 00:00:00 2001 From: Mikayla Date: Tue, 29 Aug 2023 13:19:50 +0000 Subject: [PATCH 1/3] #305 print out cause of multi-condition alarms --- supervisor/startup.lua | 2 +- supervisor/unitlogic.lua | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/supervisor/startup.lua b/supervisor/startup.lua index dbde074..3f0d966 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.0.2" +local SUPERVISOR_VERSION = "v1.0.3" local println = util.println local println_ts = util.println_ts diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index f2ee7aa..6203c12 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -358,6 +358,7 @@ end ---@param self _unit_self unit instance ---@param tripped boolean if the alarm condition is still active ---@param alarm alarm_def alarm table +---@return boolean new_trip if the alarm just changed to being tripped local function _update_alarm_state(self, tripped, alarm) local AISTATE = self.types.AISTATE local int_state = alarm.state @@ -439,7 +440,8 @@ local function _update_alarm_state(self, tripped, alarm) if alarm.state ~= int_state then local change_str = util.c(AISTATE_NAMES[int_state], " -> ", AISTATE_NAMES[alarm.state]) log.debug(util.c("UNIT ", self.r_id, " ALARM ", alarm.id, " (", types.ALARM_NAMES[alarm.id], "): ", change_str)) - end + return alarm.state == AISTATE.TRIPPED + else return false end end -- evaluate alarm conditions @@ -469,11 +471,15 @@ function logic.update_alarms(self) -- Reactor Damage local rps_dmg_90 = plc_cache.rps_status.high_dmg and not self.last_rps_trips.high_dmg - _update_alarm_state(self, (plc_cache.damage > 0) or rps_dmg_90, self.alarms.ReactorDamage) + if (_update_alarm_state(self, (plc_cache.damage > 0) or rps_dmg_90, self.alarms.ReactorDamage)) then + log.debug(util.c("> plc_cache.damage[", plc_cache.damage, "] rps_dmg_90[", rps_dmg_90, "]")) + end -- Over-Temperature 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) + if (_update_alarm_state(self, (plc_cache.temp >= 1200) or rps_high_temp, self.alarms.ReactorOverTemp)) then + log.debug(util.c("> plc_cache.temp[", plc_cache.temp, "] rps_high_temp[", rps_high_temp, "]")) + end -- High Temperature _update_alarm_state(self, plc_cache.temp >= ALARM_LIMS.HIGH_TEMP, self.alarms.ReactorHighTemp) @@ -483,7 +489,9 @@ function logic.update_alarms(self) -- High Waste 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 > ALARM_LIMS.HIGH_WASTE) or rps_high_waste, self.alarms.ReactorHighWaste) + if (_update_alarm_state(self, (plc_cache.waste > ALARM_LIMS.HIGH_WASTE) or rps_high_waste, self.alarms.ReactorHighWaste)) then + log.debug(util.c("> plc_cache.waste[", plc_cache.waste, "] rps_high_waste[", rps_high_waste, "]")) + end -- RPS Transient (excludes timeouts and manual trips) local rps_alarm = false @@ -514,7 +522,12 @@ function logic.update_alarms(self) rcs_trans = rcs_trans or annunc.RCSFlowLow or annunc.BoilRateMismatch or annunc.CoolantFeedMismatch or annunc.SteamFeedMismatch end - _update_alarm_state(self, rcs_trans, self.alarms.RCSTransient) + if (_update_alarm_state(self, rcs_trans, self.alarms.RCSTransient)) then + log.debug(util.c("> any_low[", any_low, "] any_over[", any_over, "] gen_trip[", gen_trip, "]")) + log.debug(util.c("> RCPTrip[", annunc.RCPTrip, "] MaxWaterReturnFeed[", annunc.MaxWaterReturnFeed, "]")) + log.debug(util.c("> RCSFlowLow[", annunc.RCSFlowLow, "] BoilRateMismatch[", annunc.BoilRateMismatch, + "] CoolantFeedMismatch[", annunc.CoolantFeedMismatch, "] SteamFeedMismatch[", annunc.SteamFeedMismatch, "]")) + end -- Turbine Trip local any_trip = false @@ -522,9 +535,7 @@ function logic.update_alarms(self) _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 + for key, val in pairs(plc_cache.rps_status) do self.last_rps_trips[key] = val end end -- update the internal automatic safety control performed while in auto control mode From ca49cf90b4223158254a3bc975608882c2ffd58a Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 29 Aug 2023 22:34:30 -0400 Subject: [PATCH 2/3] #305 improved log message clarity --- supervisor/unitlogic.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index 6203c12..9c78f83 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -472,13 +472,15 @@ function logic.update_alarms(self) -- Reactor Damage local rps_dmg_90 = plc_cache.rps_status.high_dmg and not self.last_rps_trips.high_dmg if (_update_alarm_state(self, (plc_cache.damage > 0) or rps_dmg_90, self.alarms.ReactorDamage)) then - log.debug(util.c("> plc_cache.damage[", plc_cache.damage, "] rps_dmg_90[", rps_dmg_90, "]")) + log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.ReactorDamage.id]," <<")) + log.debug(util.c("| plc_cache.damage[", plc_cache.damage, "] rps_dmg_90[", rps_dmg_90, "]")) end -- Over-Temperature local rps_high_temp = plc_cache.rps_status.high_temp and not self.last_rps_trips.high_temp if (_update_alarm_state(self, (plc_cache.temp >= 1200) or rps_high_temp, self.alarms.ReactorOverTemp)) then - log.debug(util.c("> plc_cache.temp[", plc_cache.temp, "] rps_high_temp[", rps_high_temp, "]")) + log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.ReactorOverTemp.id]," <<")) + log.debug(util.c("| plc_cache.temp[", plc_cache.temp, "] rps_high_temp[", rps_high_temp, "]")) end -- High Temperature @@ -490,7 +492,8 @@ function logic.update_alarms(self) -- High Waste local rps_high_waste = plc_cache.rps_status.ex_waste and not self.last_rps_trips.ex_waste if (_update_alarm_state(self, (plc_cache.waste > ALARM_LIMS.HIGH_WASTE) or rps_high_waste, self.alarms.ReactorHighWaste)) then - log.debug(util.c("> plc_cache.waste[", plc_cache.waste, "] rps_high_waste[", rps_high_waste, "]")) + log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.ReactorHighWaste.id]," <<")) + log.debug(util.c("| plc_cache.waste[", plc_cache.waste, "] rps_high_waste[", rps_high_waste, "]")) end -- RPS Transient (excludes timeouts and manual trips) @@ -523,9 +526,10 @@ function logic.update_alarms(self) end if (_update_alarm_state(self, rcs_trans, self.alarms.RCSTransient)) then - log.debug(util.c("> any_low[", any_low, "] any_over[", any_over, "] gen_trip[", gen_trip, "]")) - log.debug(util.c("> RCPTrip[", annunc.RCPTrip, "] MaxWaterReturnFeed[", annunc.MaxWaterReturnFeed, "]")) - log.debug(util.c("> RCSFlowLow[", annunc.RCSFlowLow, "] BoilRateMismatch[", annunc.BoilRateMismatch, + log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.RCSTransient.id]," <<")) + log.debug(util.c("| any_low[", any_low, "] any_over[", any_over, "] gen_trip[", gen_trip, "]")) + log.debug(util.c("| RCPTrip[", annunc.RCPTrip, "] MaxWaterReturnFeed[", annunc.MaxWaterReturnFeed, "]")) + log.debug(util.c("| RCSFlowLow[", annunc.RCSFlowLow, "] BoilRateMismatch[", annunc.BoilRateMismatch, "] CoolantFeedMismatch[", annunc.CoolantFeedMismatch, "] SteamFeedMismatch[", annunc.SteamFeedMismatch, "]")) end From 31df4a7f7eba5ad5c7f1c2a8f0bc50db4e2bf151 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 29 Aug 2023 22:41:56 -0400 Subject: [PATCH 3/3] removed unnecessary parentheses --- supervisor/unitlogic.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/supervisor/unitlogic.lua b/supervisor/unitlogic.lua index 9c78f83..eb7fa27 100644 --- a/supervisor/unitlogic.lua +++ b/supervisor/unitlogic.lua @@ -471,14 +471,14 @@ function logic.update_alarms(self) -- Reactor Damage local rps_dmg_90 = plc_cache.rps_status.high_dmg and not self.last_rps_trips.high_dmg - if (_update_alarm_state(self, (plc_cache.damage > 0) or rps_dmg_90, self.alarms.ReactorDamage)) then + if _update_alarm_state(self, (plc_cache.damage > 0) or rps_dmg_90, self.alarms.ReactorDamage) then log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.ReactorDamage.id]," <<")) log.debug(util.c("| plc_cache.damage[", plc_cache.damage, "] rps_dmg_90[", rps_dmg_90, "]")) end -- Over-Temperature local rps_high_temp = plc_cache.rps_status.high_temp and not self.last_rps_trips.high_temp - if (_update_alarm_state(self, (plc_cache.temp >= 1200) or rps_high_temp, self.alarms.ReactorOverTemp)) then + if _update_alarm_state(self, (plc_cache.temp >= 1200) or rps_high_temp, self.alarms.ReactorOverTemp) then log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.ReactorOverTemp.id]," <<")) log.debug(util.c("| plc_cache.temp[", plc_cache.temp, "] rps_high_temp[", rps_high_temp, "]")) end @@ -491,7 +491,7 @@ function logic.update_alarms(self) -- High Waste local rps_high_waste = plc_cache.rps_status.ex_waste and not self.last_rps_trips.ex_waste - if (_update_alarm_state(self, (plc_cache.waste > ALARM_LIMS.HIGH_WASTE) or rps_high_waste, self.alarms.ReactorHighWaste)) then + if _update_alarm_state(self, (plc_cache.waste > ALARM_LIMS.HIGH_WASTE) or rps_high_waste, self.alarms.ReactorHighWaste) then log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.ReactorHighWaste.id]," <<")) log.debug(util.c("| plc_cache.waste[", plc_cache.waste, "] rps_high_waste[", rps_high_waste, "]")) end @@ -525,7 +525,7 @@ function logic.update_alarms(self) rcs_trans = rcs_trans or annunc.RCSFlowLow or annunc.BoilRateMismatch or annunc.CoolantFeedMismatch or annunc.SteamFeedMismatch end - if (_update_alarm_state(self, rcs_trans, self.alarms.RCSTransient)) then + if _update_alarm_state(self, rcs_trans, self.alarms.RCSTransient) then log.debug(util.c(">> Trip Detail Report for ", types.ALARM_NAMES[self.alarms.RCSTransient.id]," <<")) log.debug(util.c("| any_low[", any_low, "] any_over[", any_over, "] gen_trip[", gen_trip, "]")) log.debug(util.c("| RCPTrip[", annunc.RCPTrip, "] MaxWaterReturnFeed[", annunc.MaxWaterReturnFeed, "]"))