#224 skip virtual RTU units when parsing advertisements instead of aborting
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -118,26 +118,31 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
|||||||
if unit_advert.reactor > 0 then
|
if unit_advert.reactor > 0 then
|
||||||
local target_unit = self.fac_units[unit_advert.reactor] ---@type reactor_unit
|
local target_unit = self.fac_units[unit_advert.reactor] ---@type reactor_unit
|
||||||
|
|
||||||
|
-- unit RTUs
|
||||||
if u_type == RTU_UNIT_TYPE.REDSTONE then
|
if u_type == RTU_UNIT_TYPE.REDSTONE then
|
||||||
-- redstone
|
-- redstone
|
||||||
unit = svrs_redstone.new(id, i, unit_advert, self.modbus_q)
|
unit = svrs_redstone.new(id, i, unit_advert, self.modbus_q)
|
||||||
if type(unit) ~= "nil" then target_unit.add_redstone(unit) end
|
if type(unit) ~= "nil" then target_unit.add_redstone(unit) end
|
||||||
elseif u_type == RTU_UNIT_TYPE.BOILER_VALVE then
|
elseif u_type == RTU_UNIT_TYPE.BOILER_VALVE then
|
||||||
-- boiler (Mekanism 10.1+)
|
-- boiler
|
||||||
unit = svrs_boilerv.new(id, i, unit_advert, self.modbus_q)
|
unit = svrs_boilerv.new(id, i, unit_advert, self.modbus_q)
|
||||||
if type(unit) ~= "nil" then target_unit.add_boiler(unit) end
|
if type(unit) ~= "nil" then target_unit.add_boiler(unit) end
|
||||||
elseif u_type == RTU_UNIT_TYPE.TURBINE_VALVE then
|
elseif u_type == RTU_UNIT_TYPE.TURBINE_VALVE then
|
||||||
-- turbine (Mekanism 10.1+)
|
-- turbine
|
||||||
unit = svrs_turbinev.new(id, i, unit_advert, self.modbus_q)
|
unit = svrs_turbinev.new(id, i, unit_advert, self.modbus_q)
|
||||||
if type(unit) ~= "nil" then target_unit.add_turbine(unit) end
|
if type(unit) ~= "nil" then target_unit.add_turbine(unit) end
|
||||||
elseif u_type == RTU_UNIT_TYPE.ENV_DETECTOR then
|
elseif u_type == RTU_UNIT_TYPE.ENV_DETECTOR then
|
||||||
-- environment detector
|
-- environment detector
|
||||||
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
|
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
|
||||||
if type(unit) ~= "nil" then target_unit.add_envd(unit) end
|
if type(unit) ~= "nil" then target_unit.add_envd(unit) end
|
||||||
|
elseif u_type == RTU_UNIT_TYPE.VIRTUAL then
|
||||||
|
-- skip virtual units
|
||||||
|
log.debug(util.c(log_header, "skipping virtual RTU unit #", i))
|
||||||
else
|
else
|
||||||
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-specific RTU type ", type_string))
|
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-specific RTU type ", type_string))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
-- facility RTUs
|
||||||
if u_type == RTU_UNIT_TYPE.REDSTONE then
|
if u_type == RTU_UNIT_TYPE.REDSTONE then
|
||||||
-- redstone
|
-- redstone
|
||||||
unit = svrs_redstone.new(id, i, unit_advert, self.modbus_q)
|
unit = svrs_redstone.new(id, i, unit_advert, self.modbus_q)
|
||||||
@@ -156,6 +161,9 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
|||||||
-- environment detector
|
-- environment detector
|
||||||
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
|
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
|
||||||
if type(unit) ~= "nil" then facility.add_envd(unit) end
|
if type(unit) ~= "nil" then facility.add_envd(unit) end
|
||||||
|
elseif u_type == RTU_UNIT_TYPE.VIRTUAL then
|
||||||
|
-- skip virtual units
|
||||||
|
log.debug(util.c(log_header, "skipping virtual RTU unit #", i))
|
||||||
else
|
else
|
||||||
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-independent RTU type ", type_string))
|
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-independent RTU type ", type_string))
|
||||||
end
|
end
|
||||||
@@ -164,7 +172,7 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
|||||||
|
|
||||||
if unit ~= nil then
|
if unit ~= nil then
|
||||||
table.insert(self.units, unit)
|
table.insert(self.units, unit)
|
||||||
else
|
elseif u_type ~= RTU_UNIT_TYPE.VIRTUAL then
|
||||||
_reset_config()
|
_reset_config()
|
||||||
log.error(util.c(log_header, "bad advertisement: error occured while creating a unit (type is ", type_string, ")"))
|
log.error(util.c(log_header, "bad advertisement: error occured while creating a unit (type is ", type_string, ")"))
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ local supervisor = require("supervisor.supervisor")
|
|||||||
|
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "v0.15.6"
|
local SUPERVISOR_VERSION = "v0.15.7"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
|
|||||||
Reference in New Issue
Block a user