supervisor comment cleanup

This commit is contained in:
Mikayla Fischler 2024-03-05 21:47:14 -05:00
parent 4e789ab92d
commit d1e4ea586e
4 changed files with 63 additions and 39 deletions

View File

@ -152,6 +152,8 @@ function facility.new(num_reactors, cooling_conf)
table.insert(self.test_tone_states, false) table.insert(self.test_tone_states, false)
end end
-- PRIVATE FUNCTIONS --
-- check if all auto-controlled units completed ramping -- check if all auto-controlled units completed ramping
---@nodiscard ---@nodiscard
local function _all_units_ramped() local function _all_units_ramped()
@ -228,7 +230,7 @@ function facility.new(num_reactors, cooling_conf)
---@class facility ---@class facility
local public = {} local public = {}
-- ADD/LINK DEVICES -- --#region Add/Link Devices
-- link a redstone RTU session -- link a redstone RTU session
---@param rs_unit unit_session ---@param rs_unit unit_session
@ -268,11 +270,9 @@ function facility.new(num_reactors, cooling_conf)
for _, v in pairs(self.rtu_list) do util.filter_table(v, function (s) return s.get_session_id() ~= session end) end for _, v in pairs(self.rtu_list) do util.filter_table(v, function (s) return s.get_session_id() ~= session end) end
end end
-- UPDATE -- --#endregion
-- supervisor sessions reporting the list of active RTU sessions --#region Update
---@param rtu_sessions table session list of all connected RTUs
function public.report_rtus(rtu_sessions) self.rtu_conn_count = #rtu_sessions end
-- update (iterate) the facility management -- update (iterate) the facility management
function public.update() function public.update()
@ -323,7 +323,7 @@ function facility.new(num_reactors, cooling_conf)
-- Run Process Control -- -- Run Process Control --
------------------------- -------------------------
--#region Process Control --#region
local avg_charge = self.avg_charge.compute() local avg_charge = self.avg_charge.compute()
local avg_inflow = self.avg_inflow.compute() local avg_inflow = self.avg_inflow.compute()
@ -597,7 +597,7 @@ function facility.new(num_reactors, cooling_conf)
-- Evaluate Automatic SCRAM -- -- Evaluate Automatic SCRAM --
------------------------------ ------------------------------
--#region Automatic SCRAM --#region
local astatus = self.ascram_status local astatus = self.ascram_status
@ -727,6 +727,8 @@ function facility.new(num_reactors, cooling_conf)
-- Handle Redstone I/O -- -- Handle Redstone I/O --
------------------------- -------------------------
--#region
if #self.redstone > 0 then if #self.redstone > 0 then
-- handle facility SCRAM -- handle facility SCRAM
if self.io_ctl.digital_read(IO.F_SCRAM) then if self.io_ctl.digital_read(IO.F_SCRAM) then
@ -756,10 +758,14 @@ function facility.new(num_reactors, cooling_conf)
self.io_ctl.digital_write(IO.F_ALARM_ANY, has_any_alarm) self.io_ctl.digital_write(IO.F_ALARM_ANY, has_any_alarm)
end end
--#endregion
---------------- ----------------
-- Unit Tasks -- -- Unit Tasks --
---------------- ----------------
--#region
local insufficent_po_rate = false local insufficent_po_rate = false
local need_emcool = false local need_emcool = false
@ -798,10 +804,14 @@ function facility.new(num_reactors, cooling_conf)
end end
end end
--#endregion
------------------------ ------------------------
-- Update Alarm Tones -- -- Update Alarm Tones --
------------------------ ------------------------
--#region
local allow_test = self.allow_testing and self.test_tone_set local allow_test = self.allow_testing and self.test_tone_set
local alarms = { false, false, false, false, false, false, false, false, false, false, false, false } local alarms = { false, false, false, false, false, false, false, false, false, false, false, false }
@ -888,6 +898,8 @@ function facility.new(num_reactors, cooling_conf)
self.test_tone_set = false self.test_tone_set = false
self.test_tone_reset = true self.test_tone_reset = true
end end
--#endregion
end end
-- call the update function of all units in the facility<br> -- call the update function of all units in the facility<br>
@ -900,7 +912,9 @@ function facility.new(num_reactors, cooling_conf)
end end
end end
-- COMMANDS -- --#endregion
--#region Commands
-- SCRAM all reactor units -- SCRAM all reactor units
function public.scram_all() function public.scram_all()
@ -988,7 +1002,9 @@ function facility.new(num_reactors, cooling_conf)
} }
end end
-- SETTINGS -- --#endregion
--#region Settings
-- set the automatic control group of a unit -- set the automatic control group of a unit
---@param unit_id integer unit ID ---@param unit_id integer unit ID
@ -1029,7 +1045,9 @@ function facility.new(num_reactors, cooling_conf)
return self.pu_fallback return self.pu_fallback
end end
-- DIAGNOSTIC TESTING -- --#endregion
--#region Diagnostic Testing
-- attempt to set a test tone state -- attempt to set a test tone state
---@param id TONE|0 tone ID or 0 to disable all ---@param id TONE|0 tone ID or 0 to disable all
@ -1069,7 +1087,9 @@ function facility.new(num_reactors, cooling_conf)
return self.allow_testing, self.test_alarm_states return self.allow_testing, self.test_alarm_states
end end
-- READ STATES/PROPERTIES -- --#endregion
--#region Read States/Properties
-- get current alarm tone on/off states -- get current alarm tone on/off states
---@nodiscard ---@nodiscard
@ -1183,6 +1203,12 @@ function facility.new(num_reactors, cooling_conf)
return status return status
end end
--#endregion
-- supervisor sessions reporting the list of active RTU sessions
---@param rtu_sessions table session list of all connected RTUs
function public.report_rtus(rtu_sessions) self.rtu_conn_count = #rtu_sessions end
-- get the units in this facility -- get the units in this facility
---@nodiscard ---@nodiscard
function public.get_units() return self.units end function public.get_units() return self.units end

View File

@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
local svsessions = require("supervisor.session.svsessions") local svsessions = require("supervisor.session.svsessions")
local SUPERVISOR_VERSION = "v1.2.10" local SUPERVISOR_VERSION = "v1.2.11"
local println = util.println local println = util.println
local println_ts = util.println_ts local println_ts = util.println_ts

View File

@ -255,7 +255,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
-- PRIVATE FUNCTIONS -- -- PRIVATE FUNCTIONS --
--#region time derivative utility functions --#region Time Derivative Utility Functions
-- compute a change with respect to time of the given value -- compute a change with respect to time of the given value
---@param key string value key ---@param key string value key
@ -330,7 +330,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
--#endregion --#endregion
--#region redstone I/O --#region Redstone I/O
-- create a generic valve interface -- create a generic valve interface
---@nodiscard ---@nodiscard
@ -397,8 +397,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
---@class reactor_unit ---@class reactor_unit
local public = {} local public = {}
-- ADD/LINK DEVICES -- --#region Add/Link Devices
--#region
-- link the PLC -- link the PLC
---@param plc_session plc_session_struct ---@param plc_session plc_session_struct
@ -488,7 +487,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
--#endregion --#endregion
-- UPDATE SESSION -- --#region Update Session
-- update (iterate) this unit -- update (iterate) this unit
function public.update() function public.update()
@ -556,8 +555,9 @@ function unit.new(reactor_id, num_boilers, num_turbines)
end end
end end
-- AUTO CONTROL OPERATIONS -- --#endregion
--#region
--#region Auto Control Operations
-- engage automatic control -- engage automatic control
function public.auto_engage() function public.auto_engage()
@ -644,8 +644,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
--#endregion --#endregion
-- OPERATIONS -- --#region Operations
--#region
-- queue a command to disable the reactor -- queue a command to disable the reactor
function public.disable() function public.disable()
@ -725,8 +724,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
--#endregion --#endregion
-- READ STATES/PROPERTIES -- --#region Read States/Properties
--#region
-- check if an alarm of at least a certain priority level is tripped -- check if an alarm of at least a certain priority level is tripped
---@nodiscard ---@nodiscard
@ -877,7 +875,7 @@ function unit.new(reactor_id, num_boilers, num_turbines)
return status return status
end end
-- get the current total [max] production rate is -- get the current total max production rate
---@nodiscard ---@nodiscard
---@return number total_avail_rate ---@return number total_avail_rate
function public.get_sna_rate() function public.get_sna_rate()

View File

@ -54,9 +54,7 @@ function logic.update_annunciator(self)
-- variables for boiler, or reactor if no boilers used -- variables for boiler, or reactor if no boilers used
local total_boil_rate = 0.0 local total_boil_rate = 0.0
------------- --#region Reactor
-- REACTOR --
-------------
annunc.AutoControl = self.auto_engaged annunc.AutoControl = self.auto_engaged
@ -143,9 +141,9 @@ function logic.update_annunciator(self)
self.plc_cache.ok = false self.plc_cache.ok = false
end end
--------------- --#endregion
-- MISC RTUs --
--------------- --#region Misc RTUs
local max_rad, any_faulted = 0, false local max_rad, any_faulted = 0, false
@ -170,9 +168,9 @@ function logic.update_annunciator(self)
end end
end end
------------- --#endregion
-- BOILERS --
------------- --#region Boilers
local boilers_ready = num_boilers == #self.boilers local boilers_ready = num_boilers == #self.boilers
@ -230,9 +228,9 @@ function logic.update_annunciator(self)
boiler_water_dt_sum = _get_dt(DT_KEYS.ReactorCCool) boiler_water_dt_sum = _get_dt(DT_KEYS.ReactorCCool)
end end
--------------------------- --#endregion
-- COOLANT FEED MISMATCH --
--------------------------- --#region Coolant Feed Mismatch
-- check coolant feed mismatch if using boilers, otherwise calculate with reactor -- check coolant feed mismatch if using boilers, otherwise calculate with reactor
local cfmismatch = false local cfmismatch = false
@ -263,9 +261,9 @@ function logic.update_annunciator(self)
annunc.CoolantFeedMismatch = cfmismatch annunc.CoolantFeedMismatch = cfmismatch
-------------- --#endregion
-- TURBINES --
-------------- --#region Turbines
local turbines_ready = num_turbines == #self.turbines local turbines_ready = num_turbines == #self.turbines
@ -340,6 +338,8 @@ function logic.update_annunciator(self)
annunc.TurbineTrip[idx] = has_steam and db.state.flow_rate == 0 annunc.TurbineTrip[idx] = has_steam and db.state.flow_rate == 0
end end
--#endregion
-- update auto control ready state for this unit -- update auto control ready state for this unit
self.db.control.ready = plc_ready and boilers_ready and turbines_ready self.db.control.ready = plc_ready and boilers_ready and turbines_ready
end end