mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#118 refactored rps_status_t
This commit is contained in:
parent
6e0dde3f30
commit
7c64a66dd3
@ -6,7 +6,7 @@ local util = require("scada-common.util")
|
|||||||
|
|
||||||
local plc = {}
|
local plc = {}
|
||||||
|
|
||||||
local rps_status_t = types.rps_status_t
|
local RPS_TRIP_CAUSE = types.RPS_TRIP_CAUSE
|
||||||
|
|
||||||
local PROTOCOL = comms.PROTOCOL
|
local PROTOCOL = comms.PROTOCOL
|
||||||
local DEVICE_TYPE = comms.DEVICE_TYPE
|
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
|
-- clear automatic SCRAM if it was the cause
|
||||||
if self.tripped and self.trip_cause == "automatic" then
|
if self.tripped and self.trip_cause == "automatic" then
|
||||||
self.state[state_keys.automatic] = true
|
self.state[state_keys.automatic] = true
|
||||||
self.trip_cause = rps_status_t.ok
|
self.trip_cause = RPS_TRIP_CAUSE.OK
|
||||||
self.tripped = false
|
self.tripped = false
|
||||||
|
|
||||||
log.debug("RPS: cleared automatic SCRAM for re-activation")
|
log.debug("RPS: cleared automatic SCRAM for re-activation")
|
||||||
@ -270,9 +270,9 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- check all safety conditions
|
-- 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()
|
function public.check()
|
||||||
local status = rps_status_t.ok
|
local status = RPS_TRIP_CAUSE.OK
|
||||||
local was_tripped = self.tripped
|
local was_tripped = self.tripped
|
||||||
local first_trip = false
|
local first_trip = false
|
||||||
|
|
||||||
@ -298,47 +298,47 @@ function plc.rps_init(reactor, is_formed)
|
|||||||
status = self.trip_cause
|
status = self.trip_cause
|
||||||
elseif self.state[state_keys.sys_fail] then
|
elseif self.state[state_keys.sys_fail] then
|
||||||
log.warning("RPS: system failure, reactor not formed")
|
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
|
elseif self.state[state_keys.force_disabled] then
|
||||||
log.warning("RPS: reactor was force disabled")
|
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
|
elseif self.state[state_keys.dmg_crit] then
|
||||||
log.warning("RPS: damage critical")
|
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
|
elseif self.state[state_keys.high_temp] then
|
||||||
log.warning("RPS: high temperature")
|
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
|
elseif self.state[state_keys.no_coolant] then
|
||||||
log.warning("RPS: no coolant")
|
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
|
elseif self.state[state_keys.ex_waste] then
|
||||||
log.warning("RPS: full waste")
|
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
|
elseif self.state[state_keys.ex_hcoolant] then
|
||||||
log.warning("RPS: heated coolant backup")
|
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
|
elseif self.state[state_keys.no_fuel] then
|
||||||
log.warning("RPS: no fuel")
|
log.warning("RPS: no fuel")
|
||||||
status = rps_status_t.no_fuel
|
status = RPS_TRIP_CAUSE.NO_FUEL
|
||||||
elseif self.state[state_keys.fault] then
|
elseif self.state[state_keys.fault] then
|
||||||
log.warning("RPS: reactor access fault")
|
log.warning("RPS: reactor access fault")
|
||||||
status = rps_status_t.fault
|
status = RPS_TRIP_CAUSE.FAULT
|
||||||
elseif self.state[state_keys.timeout] then
|
elseif self.state[state_keys.timeout] then
|
||||||
log.warning("RPS: supervisor connection timeout")
|
log.warning("RPS: supervisor connection timeout")
|
||||||
status = rps_status_t.timeout
|
status = RPS_TRIP_CAUSE.TIMEOUT
|
||||||
elseif self.state[state_keys.manual] then
|
elseif self.state[state_keys.manual] then
|
||||||
log.warning("RPS: manual SCRAM requested")
|
log.warning("RPS: manual SCRAM requested")
|
||||||
status = rps_status_t.manual
|
status = RPS_TRIP_CAUSE.MANUAL
|
||||||
elseif self.state[state_keys.automatic] then
|
elseif self.state[state_keys.automatic] then
|
||||||
log.warning("RPS: automatic SCRAM requested")
|
log.warning("RPS: automatic SCRAM requested")
|
||||||
status = rps_status_t.automatic
|
status = RPS_TRIP_CAUSE.AUTOMATIC
|
||||||
else
|
else
|
||||||
self.tripped = false
|
self.tripped = false
|
||||||
self.trip_cause = rps_status_t.ok
|
self.trip_cause = RPS_TRIP_CAUSE.OK
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if a new trip occured...
|
-- 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
|
first_trip = true
|
||||||
self.tripped = true
|
self.tripped = true
|
||||||
self.trip_cause = status
|
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
|
---@param quiet? boolean true to suppress the info log message
|
||||||
function public.reset(quiet)
|
function public.reset(quiet)
|
||||||
self.tripped = false
|
self.tripped = false
|
||||||
self.trip_cause = rps_status_t.ok
|
self.trip_cause = RPS_TRIP_CAUSE.OK
|
||||||
|
|
||||||
for i = 1, #self.state do
|
for i = 1, #self.state do
|
||||||
self.state[i] = false
|
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.automatic] = false
|
||||||
self.state[state_keys.timeout] = false
|
self.state[state_keys.timeout] = false
|
||||||
|
|
||||||
if self.trip_cause == rps_status_t.automatic or self.trip_cause == rps_status_t.timeout then
|
if self.trip_cause == RPS_TRIP_CAUSE.AUTOMATIC or self.trip_cause == RPS_TRIP_CAUSE.TIMEOUT then
|
||||||
self.trip_cause = rps_status_t.ok
|
self.trip_cause = RPS_TRIP_CAUSE.OK
|
||||||
self.tripped = false
|
self.tripped = false
|
||||||
|
|
||||||
log.info("RPS: auto reset")
|
log.info("RPS: auto reset")
|
||||||
@ -693,7 +693,7 @@ function plc.comms(id, version, modem, local_port, server_port, range, reactor,
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- send reactor protection system alarm
|
-- 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)
|
function public.send_rps_alarm(cause)
|
||||||
if self.linked then
|
if self.linked then
|
||||||
local rps_alarm = {
|
local rps_alarm = {
|
||||||
|
@ -231,8 +231,8 @@ types.rtu_t = {
|
|||||||
---| "dmg_crit"
|
---| "dmg_crit"
|
||||||
---| "high_temp"
|
---| "high_temp"
|
||||||
---| "no_coolant"
|
---| "no_coolant"
|
||||||
---| "full_waste"
|
---| "ex_waste"
|
||||||
---| "heated_coolant_backup"
|
---| "ex_heated_coolant"
|
||||||
---| "no_fuel"
|
---| "no_fuel"
|
||||||
---| "fault"
|
---| "fault"
|
||||||
---| "timeout"
|
---| "timeout"
|
||||||
@ -241,21 +241,20 @@ types.rtu_t = {
|
|||||||
---| "sys_fail"
|
---| "sys_fail"
|
||||||
---| "force_disabled"
|
---| "force_disabled"
|
||||||
|
|
||||||
---@alias rps_status_t rps_trip_cause
|
types.RPS_TRIP_CAUSE = {
|
||||||
types.rps_status_t = {
|
OK = "ok",
|
||||||
ok = "ok",
|
DMG_CRIT = "dmg_crit",
|
||||||
dmg_crit = "dmg_crit",
|
HIGH_TEMP = "high_temp",
|
||||||
high_temp = "high_temp",
|
NO_COOLANT = "no_coolant",
|
||||||
no_coolant = "no_coolant",
|
EX_WASTE = "ex_waste",
|
||||||
ex_waste = "full_waste",
|
EX_HCOOLANT = "ex_heated_coolant",
|
||||||
ex_hcoolant = "heated_coolant_backup",
|
NO_FUEL = "no_fuel",
|
||||||
no_fuel = "no_fuel",
|
FAULT = "fault",
|
||||||
fault = "fault",
|
TIMEOUT = "timeout",
|
||||||
timeout = "timeout",
|
MANUAL = "manual",
|
||||||
manual = "manual",
|
AUTOMATIC = "automatic",
|
||||||
automatic = "automatic",
|
SYS_FAIL = "sys_fail",
|
||||||
sys_fail = "sys_fail",
|
FORCE_DISABLED = "force_disabled"
|
||||||
force_disabled = "force_disabled"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
---@alias DUMPING_MODE
|
---@alias DUMPING_MODE
|
||||||
|
@ -108,8 +108,8 @@ function logic.update_annunciator(self)
|
|||||||
|
|
||||||
-- update other annunciator fields
|
-- update other annunciator fields
|
||||||
self.db.annunciator.ReactorSCRAM = plc_db.rps_tripped
|
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.ManualReactorSCRAM = plc_db.rps_trip_cause == types.RPS_TRIP_CAUSE.MANUAL
|
||||||
self.db.annunciator.AutoReactorSCRAM = plc_db.rps_trip_cause == types.rps_status_t.automatic
|
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.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.RCSFlowLow = _get_dt(DT_KEYS.ReactorCCool) < -2.0
|
||||||
self.db.annunciator.CoolantLevelLow = plc_db.mek_status.ccool_fill < 0.4
|
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"
|
cause = "core temperature high"
|
||||||
elseif plc_db.rps_trip_cause == "no_coolant" then
|
elseif plc_db.rps_trip_cause == "no_coolant" then
|
||||||
cause = "insufficient coolant"
|
cause = "insufficient coolant"
|
||||||
elseif plc_db.rps_trip_cause == "full_waste" then
|
elseif plc_db.rps_trip_cause == "ex_waste" then
|
||||||
cause = "excess waste"
|
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"
|
cause = "excess heated coolant"
|
||||||
elseif plc_db.rps_trip_cause == "no_fuel" then
|
elseif plc_db.rps_trip_cause == "no_fuel" then
|
||||||
cause = "insufficient fuel"
|
cause = "insufficient fuel"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user