#224 fix for RTU unit indexing on supervisor when virtual units were present

This commit is contained in:
Mikayla Fischler 2023-05-11 20:54:43 -04:00
parent a81fd49604
commit f6610489c2
3 changed files with 5 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -171,7 +171,7 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
end
if unit ~= nil then
table.insert(self.units, unit)
self.units[i] = unit
elseif u_type ~= RTU_UNIT_TYPE.VIRTUAL then
_reset_config()
log.error(util.c(log_header, "bad advertisement: error occured while creating a unit (type is ", type_string, ")"))
@ -186,9 +186,7 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
self.connected = false
-- mark all RTU unit sessions as closed so the reactor unit knows
for i = 1, #self.units do
self.units[i].close()
end
for _, unit in pairs(self.units) do unit.close() end
end
-- send a MODBUS packet
@ -351,9 +349,7 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
local time_now = util.time()
for i = 1, #self.units do
self.units[i].update(time_now)
end
for _, unit in pairs(self.units) do unit.update(time_now) end
----------------------
-- update periodics --

View File

@ -14,7 +14,7 @@ local supervisor = require("supervisor.supervisor")
local svsessions = require("supervisor.session.svsessions")
local SUPERVISOR_VERSION = "v0.15.7"
local SUPERVISOR_VERSION = "v0.15.8"
local println = util.println
local println_ts = util.println_ts