#118 type cleanup

This commit is contained in:
Mikayla Fischler 2023-02-21 12:40:34 -05:00
parent 424097973d
commit 82ea35168b
5 changed files with 49 additions and 35 deletions

View File

@ -287,7 +287,7 @@ local function init(parent, id)
end
local t1_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=colors.gray,c2=colors.yellow,c3=colors.red}
t_ps[1].subscribe("SteamDumpOpen", function (val) t1_sdo.update(val + 1) end)
t_ps[1].subscribe("SteamDumpOpen", t1_sdo.update)
TextBox{parent=rcs_tags,text="T1",width=2,height=1,fg_bg=bw_fg_bg}
local t1_tos = IndicatorLight{parent=rcs_annunc,label="Turbine Over Speed",colors=cpair(colors.red,colors.gray)}
@ -300,7 +300,7 @@ local function init(parent, id)
if unit.num_turbines > 1 then
TextBox{parent=rcs_tags,text="T2",width=2,height=1,fg_bg=bw_fg_bg}
local t2_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=colors.gray,c2=colors.yellow,c3=colors.red}
t_ps[2].subscribe("SteamDumpOpen", function (val) t2_sdo.update(val + 1) end)
t_ps[2].subscribe("SteamDumpOpen", t2_sdo.update)
TextBox{parent=rcs_tags,text="T2",width=2,height=1,fg_bg=bw_fg_bg}
local t2_tos = IndicatorLight{parent=rcs_annunc,label="Turbine Over Speed",colors=cpair(colors.red,colors.gray)}
@ -314,7 +314,7 @@ local function init(parent, id)
if unit.num_turbines > 2 then
TextBox{parent=rcs_tags,text="T3",width=2,height=1,fg_bg=bw_fg_bg}
local t3_sdo = TriIndicatorLight{parent=rcs_annunc,label="Steam Relief Valve Open",c1=colors.gray,c2=colors.yellow,c3=colors.red}
t_ps[3].subscribe("SteamDumpOpen", function (val) t3_sdo.update(val + 1) end)
t_ps[3].subscribe("SteamDumpOpen", t3_sdo.update)
TextBox{parent=rcs_tags,text="T3",width=2,height=1,fg_bg=bw_fg_bg}
local t3_tos = IndicatorLight{parent=rcs_annunc,label="Turbine Over Speed",colors=cpair(colors.red,colors.gray)}

View File

@ -114,21 +114,21 @@ end
---@enum TRI_FAIL
types.TRI_FAIL = {
OK = 0,
PARTIAL = 1,
FULL = 2
OK = 1,
PARTIAL = 2,
FULL = 3
}
---@enum PROCESS
types.PROCESS = {
INACTIVE = 0,
MAX_BURN = 1,
BURN_RATE = 2,
CHARGE = 3,
GEN_RATE = 4,
MATRIX_FAULT_IDLE = 5,
SYSTEM_ALARM_IDLE = 6,
GEN_RATE_FAULT_IDLE = 7
INACTIVE = 1,
MAX_BURN = 2,
BURN_RATE = 3,
CHARGE = 4,
GEN_RATE = 5,
MATRIX_FAULT_IDLE = 6,
SYSTEM_ALARM_IDLE = 7,
GEN_RATE_FAULT_IDLE = 8
}
types.PROCESS_NAMES = {
@ -150,6 +150,13 @@ types.WASTE_MODE = {
ANTI_MATTER = 4
}
types.WASTE_MODE_NAMES = {
"AUTO",
"PLUTONIUM",
"POLONIUM",
"ANTI_MATTER"
}
---@enum ALARM
types.ALARM = {
ContainmentBreach = 1,
@ -183,10 +190,10 @@ types.ALARM_NAMES = {
---@enum ALARM_PRIORITY
types.ALARM_PRIORITY = {
CRITICAL = 0,
EMERGENCY = 1,
URGENT = 2,
TIMELY = 3
CRITICAL = 1,
EMERGENCY = 2,
URGENT = 3,
TIMELY = 4
}
types.ALARM_PRIORITY_NAMES = {
@ -198,10 +205,17 @@ types.ALARM_PRIORITY_NAMES = {
---@enum ALARM_STATE
types.ALARM_STATE = {
INACTIVE = 0,
TRIPPED = 1,
ACKED = 2,
RING_BACK = 3
INACTIVE = 1,
TRIPPED = 2,
ACKED = 3,
RING_BACK = 4
}
types.ALARM_STATE_NAMES = {
"INACTIVE",
"TRIPPED",
"ACKED",
"RING_BACK"
}
--#endregion

View File

@ -293,7 +293,7 @@ function facility.new(num_reactors, cooling_conf)
if state_changed then
self.saturated = false
log.debug("FAC: state changed from " .. PROCESS_NAMES[self.last_mode + 1] .. " to " .. PROCESS_NAMES[self.mode + 1])
log.debug("FAC: state changed from " .. PROCESS_NAMES[self.last_mode] .. " to " .. PROCESS_NAMES[self.mode])
if (self.last_mode == PROCESS.INACTIVE) or (self.last_mode == PROCESS.GEN_RATE_FAULT_IDLE) then
self.start_fail = START_STATUS.OK

View File

@ -41,14 +41,14 @@ local DT_KEYS = {
TurbinePower = "TPR"
}
---@alias ALARM_INT_STATE integer
---@enum ALARM_INT_STATE
local AISTATE = {
INACTIVE = 0,
TRIPPING = 1,
TRIPPED = 2,
ACKED = 3,
RING_BACK = 4,
RING_BACK_TRIPPING = 5
INACTIVE = 1,
TRIPPING = 2,
TRIPPED = 3,
ACKED = 4,
RING_BACK = 5,
RING_BACK_TRIPPING = 6
}
unit.FLOW_STABILITY_DELAY_MS = FLOW_STABILITY_DELAY_MS

View File

@ -15,7 +15,7 @@ local IO = rsio.IO
local PLC_S_CMDS = plc.PLC_S_CMDS
local aistate_string = {
local AISTATE_NAMES = {
"INACTIVE",
"TRIPPING",
"TRIPPED",
@ -368,7 +368,7 @@ local function _update_alarm_state(self, tripped, alarm)
alarm.state = AISTATE.TRIPPED
self.db.alarm_states[alarm.id] = ALARM_STATE.TRIPPED
log.info(util.c("UNIT ", self.r_id, " ALARM ", alarm.id, " (", types.ALARM_NAMES[alarm.id], "): TRIPPED [PRIORITY ",
types.ALARM_PRIORITY_NAMES[alarm.tier + 1],"]"))
types.ALARM_PRIORITY_NAMES[alarm.tier],"]"))
end
else
alarm.trip_time = util.time_ms()
@ -382,7 +382,7 @@ local function _update_alarm_state(self, tripped, alarm)
alarm.state = AISTATE.TRIPPED
self.db.alarm_states[alarm.id] = ALARM_STATE.TRIPPED
log.info(util.c("UNIT ", self.r_id, " ALARM ", alarm.id, " (", types.ALARM_NAMES[alarm.id], "): TRIPPED [PRIORITY ",
types.ALARM_PRIORITY_NAMES[alarm.tier + 1],"]"))
types.ALARM_PRIORITY_NAMES[alarm.tier],"]"))
end
elseif int_state == AISTATE.RING_BACK_TRIPPING then
alarm.trip_time = 0
@ -431,7 +431,7 @@ local function _update_alarm_state(self, tripped, alarm)
-- check for state change
if alarm.state ~= int_state then
local change_str = util.c(aistate_string[int_state + 1], " -> ", aistate_string[alarm.state + 1])
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
end
@ -531,7 +531,7 @@ function logic.update_auto_safety(public, self)
if alarm.tier <= PRIO.URGENT and (alarm.state == AISTATE.TRIPPED or alarm.state == AISTATE.ACKED) then
if not self.auto_was_alarmed then
log.info(util.c("UNIT ", self.r_id, " AUTO SCRAM due to ALARM ", alarm.id, " (", types.ALARM_NAMES[alarm.id], ") [PRIORITY ",
types.ALARM_PRIORITY_NAMES[alarm.tier + 1],"]"))
types.ALARM_PRIORITY_NAMES[alarm.tier],"]"))
end
alarmed = true