#118 refactored rps_status_t

This commit is contained in:
Mikayla Fischler 2023-02-21 11:29:04 -05:00
parent 6e0dde3f30
commit 7c64a66dd3
3 changed files with 42 additions and 43 deletions

View File

@ -6,7 +6,7 @@ local util = require("scada-common.util")
local plc = {}
local rps_status_t = types.rps_status_t
local RPS_TRIP_CAUSE = types.RPS_TRIP_CAUSE
local PROTOCOL = comms.PROTOCOL
local DEVICE_TYPE = comms.DEVICE_TYPE
@ -260,7 +260,7 @@ function plc.rps_init(reactor, is_formed)
-- clear automatic SCRAM if it was the cause
if self.tripped and self.trip_cause == "automatic" then
self.state[state_keys.automatic] = true
self.trip_cause = rps_status_t.ok
self.trip_cause = RPS_TRIP_CAUSE.OK
self.tripped = false
log.debug("RPS: cleared automatic SCRAM for re-activation")
@ -270,9 +270,9 @@ function plc.rps_init(reactor, is_formed)
end
-- check all safety conditions
---@return boolean tripped, rps_status_t trip_status, boolean first_trip
---@return boolean tripped, rps_trip_cause trip_status, boolean first_trip
function public.check()
local status = rps_status_t.ok
local status = RPS_TRIP_CAUSE.OK
local was_tripped = self.tripped
local first_trip = false
@ -298,47 +298,47 @@ function plc.rps_init(reactor, is_formed)
status = self.trip_cause
elseif self.state[state_keys.sys_fail] then
log.warning("RPS: system failure, reactor not formed")
status = rps_status_t.sys_fail
status = RPS_TRIP_CAUSE.SYS_FAIL
elseif self.state[state_keys.force_disabled] then
log.warning("RPS: reactor was force disabled")
status = rps_status_t.force_disabled
status = RPS_TRIP_CAUSE.FORCE_DISABLED
elseif self.state[state_keys.dmg_crit] then
log.warning("RPS: damage critical")
status = rps_status_t.dmg_crit
status = RPS_TRIP_CAUSE.DMG_CRIT
elseif self.state[state_keys.high_temp] then
log.warning("RPS: high temperature")
status = rps_status_t.high_temp
status = RPS_TRIP_CAUSE.HIGH_TEMP
elseif self.state[state_keys.no_coolant] then
log.warning("RPS: no coolant")
status = rps_status_t.no_coolant
status = RPS_TRIP_CAUSE.NO_COOLANT
elseif self.state[state_keys.ex_waste] then
log.warning("RPS: full waste")
status = rps_status_t.ex_waste
status = RPS_TRIP_CAUSE.EX_WASTE
elseif self.state[state_keys.ex_hcoolant] then
log.warning("RPS: heated coolant backup")
status = rps_status_t.ex_hcoolant
status = RPS_TRIP_CAUSE.EX_HCOOLANT
elseif self.state[state_keys.no_fuel] then
log.warning("RPS: no fuel")
status = rps_status_t.no_fuel
status = RPS_TRIP_CAUSE.NO_FUEL
elseif self.state[state_keys.fault] then
log.warning("RPS: reactor access fault")
status = rps_status_t.fault
status = RPS_TRIP_CAUSE.FAULT
elseif self.state[state_keys.timeout] then
log.warning("RPS: supervisor connection timeout")
status = rps_status_t.timeout
status = RPS_TRIP_CAUSE.TIMEOUT
elseif self.state[state_keys.manual] then
log.warning("RPS: manual SCRAM requested")
status = rps_status_t.manual
status = RPS_TRIP_CAUSE.MANUAL
elseif self.state[state_keys.automatic] then
log.warning("RPS: automatic SCRAM requested")
status = rps_status_t.automatic
status = RPS_TRIP_CAUSE.AUTOMATIC
else
self.tripped = false
self.trip_cause = rps_status_t.ok
self.trip_cause = RPS_TRIP_CAUSE.OK
end
-- if a new trip occured...
if (not was_tripped) and (status ~= rps_status_t.ok) then
if (not was_tripped) and (status ~= RPS_TRIP_CAUSE.OK) then
first_trip = true
self.tripped = true
self.trip_cause = status
@ -376,7 +376,7 @@ function plc.rps_init(reactor, is_formed)
---@param quiet? boolean true to suppress the info log message
function public.reset(quiet)
self.tripped = false
self.trip_cause = rps_status_t.ok
self.trip_cause = RPS_TRIP_CAUSE.OK
for i = 1, #self.state do
self.state[i] = false
@ -390,8 +390,8 @@ function plc.rps_init(reactor, is_formed)
self.state[state_keys.automatic] = false
self.state[state_keys.timeout] = false
if self.trip_cause == rps_status_t.automatic or self.trip_cause == rps_status_t.timeout then
self.trip_cause = rps_status_t.ok
if self.trip_cause == RPS_TRIP_CAUSE.AUTOMATIC or self.trip_cause == RPS_TRIP_CAUSE.TIMEOUT then
self.trip_cause = RPS_TRIP_CAUSE.OK
self.tripped = false
log.info("RPS: auto reset")
@ -693,7 +693,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
end
-- send reactor protection system alarm
---@param cause rps_status_t reactor protection system status
---@param cause rps_trip_cause reactor protection system status
function public.send_rps_alarm(cause)
if self.linked then
local rps_alarm = {

View File

@ -231,8 +231,8 @@ types.rtu_t = {
---| "dmg_crit"
---| "high_temp"
---| "no_coolant"
---| "full_waste"
---| "heated_coolant_backup"
---| "ex_waste"
---| "ex_heated_coolant"
---| "no_fuel"
---| "fault"
---| "timeout"
@ -241,21 +241,20 @@ types.rtu_t = {
---| "sys_fail"
---| "force_disabled"
---@alias rps_status_t rps_trip_cause
types.rps_status_t = {
ok = "ok",
dmg_crit = "dmg_crit",
high_temp = "high_temp",
no_coolant = "no_coolant",
ex_waste = "full_waste",
ex_hcoolant = "heated_coolant_backup",
no_fuel = "no_fuel",
fault = "fault",
timeout = "timeout",
manual = "manual",
automatic = "automatic",
sys_fail = "sys_fail",
force_disabled = "force_disabled"
types.RPS_TRIP_CAUSE = {
OK = "ok",
DMG_CRIT = "dmg_crit",
HIGH_TEMP = "high_temp",
NO_COOLANT = "no_coolant",
EX_WASTE = "ex_waste",
EX_HCOOLANT = "ex_heated_coolant",
NO_FUEL = "no_fuel",
FAULT = "fault",
TIMEOUT = "timeout",
MANUAL = "manual",
AUTOMATIC = "automatic",
SYS_FAIL = "sys_fail",
FORCE_DISABLED = "force_disabled"
}
---@alias DUMPING_MODE

View File

@ -108,8 +108,8 @@ function logic.update_annunciator(self)
-- update other annunciator fields
self.db.annunciator.ReactorSCRAM = plc_db.rps_tripped
self.db.annunciator.ManualReactorSCRAM = plc_db.rps_trip_cause == types.rps_status_t.manual
self.db.annunciator.AutoReactorSCRAM = plc_db.rps_trip_cause == types.rps_status_t.automatic
self.db.annunciator.ManualReactorSCRAM = plc_db.rps_trip_cause == types.RPS_TRIP_CAUSE.MANUAL
self.db.annunciator.AutoReactorSCRAM = plc_db.rps_trip_cause == types.RPS_TRIP_CAUSE.AUTOMATIC
self.db.annunciator.RCPTrip = plc_db.rps_tripped and (plc_db.rps_status.ex_hcool or plc_db.rps_status.no_cool)
self.db.annunciator.RCSFlowLow = _get_dt(DT_KEYS.ReactorCCool) < -2.0
self.db.annunciator.CoolantLevelLow = plc_db.mek_status.ccool_fill < 0.4
@ -636,9 +636,9 @@ function logic.update_status_text(self)
cause = "core temperature high"
elseif plc_db.rps_trip_cause == "no_coolant" then
cause = "insufficient coolant"
elseif plc_db.rps_trip_cause == "full_waste" then
elseif plc_db.rps_trip_cause == "ex_waste" then
cause = "excess waste"
elseif plc_db.rps_trip_cause == "heated_coolant_backup" then
elseif plc_db.rps_trip_cause == "ex_heated_coolant" then
cause = "excess heated coolant"
elseif plc_db.rps_trip_cause == "no_fuel" then
cause = "insufficient fuel"