From a02529b9f703dd00d5fe9c085edad58e9c8a36bf Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 18 Jun 2023 15:19:01 -0400 Subject: [PATCH] #263 fixed bug with supervisor group map length not matching number of reactors --- .gitignore | 2 +- supervisor/facility.lua | 5 +++-- supervisor/startup.lua | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 17ae161..0688a64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ _notes/ -program.sh \ No newline at end of file +/*program.sh \ No newline at end of file diff --git a/supervisor/facility.lua b/supervisor/facility.lua index e3b8059..5864ea5 100644 --- a/supervisor/facility.lua +++ b/supervisor/facility.lua @@ -75,7 +75,7 @@ function facility.new(num_reactors, cooling_conf) burn_target = 0.1, -- burn rate target for aggregate burn mode charge_setpoint = 0, -- FE charge 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) at_max_burn = false, ascram = false, @@ -109,6 +109,7 @@ function facility.new(num_reactors, cooling_conf) -- create units for i = 1, num_reactors do table.insert(self.units, unit.new(i, cooling_conf[i].BOILERS, cooling_conf[i].TURBINES)) + table.insert(self.group_map, 0) end -- init redstone RTU I/O controller @@ -790,7 +791,7 @@ function facility.new(num_reactors, cooling_conf) ---@param unit_id integer unit ID ---@param group integer group ID or 0 for independent 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 local old_group = self.group_map[unit_id] if old_group ~= 0 then diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 3ec55cc..0949573 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -20,7 +20,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v0.17.8" +local SUPERVISOR_VERSION = "v0.17.9" local println = util.println local println_ts = util.println_ts