#604 fixed supervisor bugs with new redstone

This commit is contained in:
Mikayla Fischler 2025-05-07 20:04:39 -04:00
parent 069a7ce0ad
commit 8f6425b814
2 changed files with 16 additions and 13 deletions

View File

@ -140,16 +140,18 @@ function rtu.new_session(id, s_addr, i_seq_num, in_queue, out_queue, timeout, ad
-- link this to any subsystems this RTU provides connections for -- link this to any subsystems this RTU provides connections for
if type(unit) ~= "nil" then if type(unit) ~= "nil" then
for assignment, _ in pairs(unit_advert.rs_conns) do for assignment, conns in pairs(unit_advert.rs_conns) do
if #conns > 0 then
if assignment == 0 then if assignment == 0 then
facility.add_redstone(unit) facility.add_redstone(unit)
elseif assignment > 0 and assignment < #self.fac_units then elseif assignment > 0 and assignment <= #self.fac_units then
self.fac_units[assignment].add_redstone(unit) self.fac_units[assignment].add_redstone(unit)
else else
log.warning(util.c(log_tag, "_handle_advertisement(): unrecognized redstone RTU assignment ", assignment, " ", type_string)) log.warning(util.c(log_tag, "_handle_advertisement(): unrecognized redstone RTU assignment ", assignment, " ", type_string))
end end
end end
end end
end
else else
log.warning(util.c(log_tag, "_handle_advertisement(): encountered unsupported multi-assignment RTU type ", type_string)) log.warning(util.c(log_tag, "_handle_advertisement(): encountered unsupported multi-assignment RTU type ", type_string))
end end

View File

@ -127,7 +127,7 @@ function redstone.new(session_id, unit_id, advert, out_queue)
write = function () end write = function () end
} }
self.db.io[port] = io_f self.db.io[bank][port] = io_f
elseif mode == IO_MODE.DIGITAL_OUT then elseif mode == IO_MODE.DIGITAL_OUT then
self.has_do = true self.has_do = true
table.insert(self.io_map.digital_out, io_entry) table.insert(self.io_map.digital_out, io_entry)
@ -145,7 +145,7 @@ function redstone.new(session_id, unit_id, advert, out_queue)
end end
} }
self.db.io[port] = io_f self.db.io[bank][port] = io_f
elseif mode == IO_MODE.ANALOG_IN then elseif mode == IO_MODE.ANALOG_IN then
self.has_ai = true self.has_ai = true
table.insert(self.io_map.analog_in, io_entry) table.insert(self.io_map.analog_in, io_entry)
@ -160,7 +160,7 @@ function redstone.new(session_id, unit_id, advert, out_queue)
write = function () end write = function () end
} }
self.db.io[port] = io_f self.db.io[bank][port] = io_f
elseif mode == IO_MODE.ANALOG_OUT then elseif mode == IO_MODE.ANALOG_OUT then
self.has_ao = true self.has_ao = true
table.insert(self.io_map.analog_out, io_entry) table.insert(self.io_map.analog_out, io_entry)
@ -180,7 +180,7 @@ function redstone.new(session_id, unit_id, advert, out_queue)
end end
} }
self.db.io[port] = io_f self.db.io[bank][port] = io_f
else else
-- should be unreachable code, we already validated ports -- should be unreachable code, we already validated ports
log.error(util.c(log_tag, "failed to identify advertisement port IO mode (", bank, ":", port, ")"), true) log.error(util.c(log_tag, "failed to identify advertisement port IO mode (", bank, ":", port, ")"), true)
@ -396,9 +396,10 @@ function redstone.new(session_id, unit_id, advert, out_queue)
self.session.post_update() self.session.post_update()
end end
-- invalidate build cache -- force a re-read of cached outputs
function public.invalidate_cache() function public.invalidate_cache()
-- no build cache for this device _read_coils()
_read_holding_registers()
end end
-- get the unit session database -- get the unit session database