diff --git a/rtu/config/redstone.lua b/rtu/config/redstone.lua index 7592bf9..3227f3f 100644 --- a/rtu/config/redstone.lua +++ b/rtu/config/redstone.lua @@ -413,10 +413,10 @@ function redstone.create(tool_ctl, main_pane, cfg_sys, rs_cfg, style) local def = { unit = tri(PORT_DSGN[port] == 1, u, nil), port = port, + relay = self.rs_cfg_phy, side = side_options_map[side.get_value()], color = tri(self.rs_cfg_bundled.get_value() and rsio.is_digital(port), color_options_map[self.rs_cfg_color.get_value()], nil), - invert = self.rs_cfg_inverted.get_value() or nil, - relay = self.rs_cfg_phy + invert = self.rs_cfg_inverted.get_value() or nil } if self.rs_cfg_editing == false then @@ -442,9 +442,9 @@ function redstone.create(tool_ctl, main_pane, cfg_sys, rs_cfg, style) table.insert(tmp_cfg.Redstone, { unit = tri(PORT_DSGN[IO.WASTE_PU + i] == 1, u, nil), port = IO.WASTE_PU + i, + relay = self.rs_cfg_phy, side = tri(self.rs_cfg_bundled.get_value(), side_options_map[side.get_value()], default_sides[i + 1]), - color = tri(self.rs_cfg_bundled.get_value(), default_colors[i + 1], nil), - relay = self.rs_cfg_phy + color = tri(self.rs_cfg_bundled.get_value(), default_colors[i + 1], nil) }) end end @@ -582,7 +582,7 @@ function redstone.create(tool_ctl, main_pane, cfg_sys, rs_cfg, style) local a = ini_cfg.Redstone[i] local b = tmp_cfg.Redstone[i] - modified = (a.unit ~= b.unit) or (a.port ~= b.port) or (a.side ~= b.side) or (a.color ~= b.color) or (a.invert ~= b.invert) + modified = (a.unit ~= b.unit) or (a.port ~= b.port) or (a.relay ~= b.relay) or (a.side ~= b.side) or (a.color ~= b.color) or (a.invert ~= b.invert) end end end diff --git a/rtu/configure.lua b/rtu/configure.lua index eea6072..022dfbb 100644 --- a/rtu/configure.lua +++ b/rtu/configure.lua @@ -130,7 +130,7 @@ end ---@param data rtu_rs_definition[] function tool_ctl.deep_copy_rs(data) local array = {} - for _, d in ipairs(data) do table.insert(array, { unit = d.unit, port = d.port, side = d.side, color = d.color, invert = d.invert, relay = d.relay }) end + for _, d in ipairs(data) do table.insert(array, { unit = d.unit, port = d.port, relay = d.relay, side = d.side, color = d.color, invert = d.invert }) end return array end diff --git a/rtu/panel/front_panel.lua b/rtu/panel/front_panel.lua index 02f5979..0b9c2ed 100644 --- a/rtu/panel/front_panel.lua +++ b/rtu/panel/front_panel.lua @@ -154,7 +154,7 @@ local function init(panel, units) if is_rs then local is_local = unit.name == "redstone_local" relay_counter = relay_counter + util.trinary(is_local, 0, 1) - return util.c("REDSTONE", util.trinary(is_local, "", " RELAY "..relay_counter)) + return util.c("REDSTONE", util.trinary(is_local, "", " RELAY " .. relay_counter)) else return util.c(UNIT_TYPE_LABELS[unit.type + 1], " ", util.trinary(util.is_int(unit.index), unit.index, "")) end diff --git a/rtu/startup.lua b/rtu/startup.lua index 69e3a56..f4e9eed 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -213,7 +213,6 @@ local function main() valid = util.trinary(entry.color == nil, true, rsio.is_color(entry.color)) end - -- local rs_rtu = rs_rtus[phy].rtu local bank = rs_rtus[phy].banks[for_reactor] local conns = all_conns[for_reactor] diff --git a/supervisor/session/rtu.lua b/supervisor/session/rtu.lua index dea4eb2..094c13d 100644 --- a/supervisor/session/rtu.lua +++ b/supervisor/session/rtu.lua @@ -104,14 +104,11 @@ function rtu.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout, ad advert_validator.assert(util.is_int(unit_advert.index) or (unit_advert.index == false)) advert_validator.assert_type_int(unit_advert.reactor) - if u_type == RTU_UNIT_TYPE.REDSTONE then - advert_validator.assert_type_table(unit_advert.rs_conns) - end - if advert_validator.valid() then if util.is_int(unit_advert.index) then advert_validator.assert_min(unit_advert.index, 1) end - if unit_advert.reactor == -1 then + if (unit_advert.reactor == -1) or (u_type == RTU_UNIT_TYPE.REDSTONE) then + advert_validator.assert((unit_advert.reactor == -1) and (u_type == RTU_UNIT_TYPE.REDSTONE)) advert_validator.assert_type_table(unit_advert.rs_conns) else advert_validator.assert_min(unit_advert.reactor, 0) @@ -147,7 +144,7 @@ function rtu.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout, ad elseif assignment > 0 and assignment <= #self.fac_units then self.fac_units[assignment].add_redstone(unit) else - log.warning(util.c(log_tag, "_handle_advertisement(): unrecognized redstone RTU assignment ", assignment, " ", type_string)) + log.warning(util.c(log_tag, "_handle_advertisement(): invalid redstone RTU assignment ", assignment)) end end end