#545 supervisor type annotation updates

This commit is contained in:
Mikayla
2024-09-13 02:23:16 +00:00
parent 3003e57531
commit a1dbc15d16
14 changed files with 178 additions and 163 deletions

View File

@@ -40,7 +40,7 @@ local facility = {}
function facility.new(config)
---@class _facility_self
local self = {
units = {},
units = {}, ---@type reactor_unit[]
types = { AUTO_SCRAM = AUTO_SCRAM, START_STATUS = START_STATUS },
status_text = { "START UP", "initializing..." },
all_sys_ok = false,
@@ -51,16 +51,16 @@ function facility.new(config)
r_cool = config.CoolingConfig,
fac_tank_mode = config.FacilityTankMode,
fac_tank_defs = config.FacilityTankDefs,
fac_tank_list = {}
fac_tank_list = {} ---@type integer[]
},
-- rtus
rtu_conn_count = 0,
rtu_list = {},
redstone = {},
induction = {},
sps = {},
tanks = {},
envd = {},
rtu_list = {}, ---@type unit_session[][]
redstone = {}, ---@type unit_session[]
induction = {}, ---@type unit_session[]
sps = {}, ---@type unit_session[]
tanks = {}, ---@type unit_session[]
envd = {}, ---@type unit_session[]
-- redstone I/O control
io_ctl = nil, ---@type rs_controller
-- process control
@@ -105,11 +105,11 @@ function facility.new(config)
sps_low_power = false,
disabled_sps = false,
-- alarm tones
tone_states = {},
tone_states = {}, ---@type boolean[]
test_tone_set = false,
test_tone_reset = false,
test_tone_states = {},
test_alarm_states = {},
test_tone_states = {}, ---@type boolean[]
test_alarm_states = {}, ---@type boolean[]
-- statistics
im_stat_init = false,
avg_charge = util.mov_avg(3), -- 3 seconds
@@ -350,7 +350,7 @@ function facility.new(config)
-- additionally sets the requested auto waste mode if applicable
function public.update_units()
for i = 1, #self.units do
local u = self.units[i] ---@type reactor_unit
local u = self.units[i]
u.auto_set_waste(self.current_waste_product)
u.update()
end
@@ -363,16 +363,14 @@ function facility.new(config)
-- SCRAM all reactor units
function public.scram_all()
for i = 1, #self.units do
local u = self.units[i] ---@type reactor_unit
u.scram()
self.units[i].scram()
end
end
-- ack all alarms on all reactor units
function public.ack_all()
for i = 1, #self.units do
local u = self.units[i] ---@type reactor_unit
u.ack_all()
local u = self.units[i].ack_all()
end
end
@@ -393,8 +391,7 @@ function facility.new(config)
-- load up current limits
local limits = {}
for i = 1, config.UnitCount do
local u = self.units[i] ---@type reactor_unit
limits[i] = u.get_control_inf().lim_br100 * 100
limits[i] = self.units[i].get_control_inf().lim_br100 * 100
end
-- only allow changes if not running
@@ -565,7 +562,7 @@ function facility.new(config)
if all or type == RTU_UNIT_TYPE.IMATRIX then
build.induction = {}
for i = 1, #self.induction do
local matrix = self.induction[i] ---@type unit_session
local matrix = self.induction[i]
build.induction[i] = { matrix.get_db().formed, matrix.get_db().build }
end
end
@@ -573,7 +570,7 @@ function facility.new(config)
if all or type == RTU_UNIT_TYPE.SPS then
build.sps = {}
for i = 1, #self.sps do
local sps = self.sps[i] ---@type unit_session
local sps = self.sps[i]
build.sps[i] = { sps.get_db().formed, sps.get_db().build }
end
end
@@ -581,7 +578,7 @@ function facility.new(config)
if all or type == RTU_UNIT_TYPE.DYNAMIC_VALVE then
build.tanks = {}
for i = 1, #self.tanks do
local tank = self.tanks[i] ---@type unit_session
local tank = self.tanks[i]
build.tanks[tank.get_device_idx()] = { tank.get_db().formed, tank.get_db().build }
end
end
@@ -649,8 +646,8 @@ function facility.new(config)
-- status of induction matricies (including tanks)
status.induction = {}
for i = 1, #self.induction do
local matrix = self.induction[i] ---@type unit_session
local db = matrix.get_db() ---@type imatrix_session_db
local matrix = self.induction[i]
local db = matrix.get_db() ---@type imatrix_session_db
status.induction[i] = { matrix.is_faulted(), db.formed, db.state, db.tanks }
@@ -662,24 +659,24 @@ function facility.new(config)
-- status of sps
status.sps = {}
for i = 1, #self.sps do
local sps = self.sps[i] ---@type unit_session
local db = sps.get_db() ---@type sps_session_db
local sps = self.sps[i]
local db = sps.get_db() ---@type sps_session_db
status.sps[i] = { sps.is_faulted(), db.formed, db.state, db.tanks }
end
-- status of dynamic tanks
status.tanks = {}
for i = 1, #self.tanks do
local tank = self.tanks[i] ---@type unit_session
local db = tank.get_db() ---@type dynamicv_session_db
local tank = self.tanks[i]
local db = tank.get_db() ---@type dynamicv_session_db
status.tanks[tank.get_device_idx()] = { tank.is_faulted(), db.formed, db.state, db.tanks }
end
-- radiation monitors (environment detectors)
status.envds = {}
for i = 1, #self.envd do
local envd = self.envd[i] ---@type unit_session
local db = envd.get_db() ---@type envd_session_db
local envd = self.envd[i]
local db = envd.get_db() ---@type envd_session_db
status.envds[envd.get_device_idx()] = { envd.is_faulted(), db.radiation, db.radiation_raw }
end