cleanup and fixes

This commit is contained in:
Mikayla 2025-05-09 15:41:14 +00:00
parent 41e6d89a4b
commit 5f8c947105
5 changed files with 10 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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