#263 fixed bug with supervisor group map length not matching number of reactors

This commit is contained in:
Mikayla Fischler 2023-06-18 15:19:01 -04:00
parent af38025f50
commit a02529b9f7
3 changed files with 5 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
_notes/ _notes/
program.sh /*program.sh

View File

@ -75,7 +75,7 @@ function facility.new(num_reactors, cooling_conf)
burn_target = 0.1, -- burn rate target for aggregate burn mode burn_target = 0.1, -- burn rate target for aggregate burn mode
charge_setpoint = 0, -- FE charge target setpoint charge_setpoint = 0, -- FE charge target setpoint
gen_rate_setpoint = 0, -- FE/t charge rate target setpoint gen_rate_setpoint = 0, -- FE/t charge rate target setpoint
group_map = { 0, 0, 0, 0 }, -- units -> group IDs group_map = {}, -- units -> group IDs
prio_defs = { {}, {}, {}, {} }, -- priority definitions (each level is a table of units) prio_defs = { {}, {}, {}, {} }, -- priority definitions (each level is a table of units)
at_max_burn = false, at_max_burn = false,
ascram = false, ascram = false,
@ -109,6 +109,7 @@ function facility.new(num_reactors, cooling_conf)
-- create units -- create units
for i = 1, num_reactors do for i = 1, num_reactors do
table.insert(self.units, unit.new(i, cooling_conf[i].BOILERS, cooling_conf[i].TURBINES)) table.insert(self.units, unit.new(i, cooling_conf[i].BOILERS, cooling_conf[i].TURBINES))
table.insert(self.group_map, 0)
end end
-- init redstone RTU I/O controller -- init redstone RTU I/O controller
@ -790,7 +791,7 @@ function facility.new(num_reactors, cooling_conf)
---@param unit_id integer unit ID ---@param unit_id integer unit ID
---@param group integer group ID or 0 for independent ---@param group integer group ID or 0 for independent
function public.set_group(unit_id, group) function public.set_group(unit_id, group)
if group >= 0 and group <= 4 and self.mode == PROCESS.INACTIVE then if (group >= 0 and group <= 4) and (unit_id > 0 and unit_id <= num_reactors) and self.mode == PROCESS.INACTIVE then
-- remove from old group if previously assigned -- remove from old group if previously assigned
local old_group = self.group_map[unit_id] local old_group = self.group_map[unit_id]
if old_group ~= 0 then if old_group ~= 0 then

View File

@ -20,7 +20,7 @@ local supervisor = require("supervisor.supervisor")
local svsessions = require("supervisor.session.svsessions") local svsessions = require("supervisor.session.svsessions")
local SUPERVISOR_VERSION = "v0.17.8" local SUPERVISOR_VERSION = "v0.17.9"
local println = util.println local println = util.println
local println_ts = util.println_ts local println_ts = util.println_ts