Merge branch 'devel' into front-panels
This commit is contained in:
@@ -28,5 +28,7 @@ config.LOG_PATH = "/log.txt"
|
||||
-- 0 = APPEND (adds to existing file on start)
|
||||
-- 1 = NEW (replaces existing file on start)
|
||||
config.LOG_MODE = 0
|
||||
-- true to log verbose debug messages
|
||||
config.LOG_DEBUG = false
|
||||
|
||||
return config
|
||||
|
||||
@@ -119,26 +119,31 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
||||
if unit_advert.reactor > 0 then
|
||||
local target_unit = self.fac_units[unit_advert.reactor] ---@type reactor_unit
|
||||
|
||||
-- unit RTUs
|
||||
if u_type == RTU_UNIT_TYPE.REDSTONE then
|
||||
-- redstone
|
||||
unit = svrs_redstone.new(id, i, unit_advert, self.modbus_q)
|
||||
if type(unit) ~= "nil" then target_unit.add_redstone(unit) end
|
||||
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)
|
||||
if type(unit) ~= "nil" then target_unit.add_boiler(unit) end
|
||||
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)
|
||||
if type(unit) ~= "nil" then target_unit.add_turbine(unit) end
|
||||
elseif u_type == RTU_UNIT_TYPE.ENV_DETECTOR then
|
||||
-- environment detector
|
||||
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
|
||||
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
|
||||
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-specific RTU type ", type_string))
|
||||
end
|
||||
else
|
||||
-- facility RTUs
|
||||
if u_type == RTU_UNIT_TYPE.REDSTONE then
|
||||
-- redstone
|
||||
unit = svrs_redstone.new(id, i, unit_advert, self.modbus_q)
|
||||
@@ -157,6 +162,9 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
||||
-- environment detector
|
||||
unit = svrs_envd.new(id, i, unit_advert, self.modbus_q)
|
||||
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
|
||||
log.error(util.c(log_header, "bad advertisement: encountered unsupported reactor-independent RTU type ", type_string))
|
||||
end
|
||||
@@ -165,7 +173,7 @@ function rtu.new_session(id, in_queue, out_queue, timeout, advertisement, facili
|
||||
|
||||
if unit ~= nil then
|
||||
table.insert(self.units, unit)
|
||||
else
|
||||
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, ")"))
|
||||
break
|
||||
|
||||
@@ -120,9 +120,7 @@ function redstone.new(session_id, unit_id, advert, out_queue)
|
||||
local io_f = {
|
||||
---@nodiscard
|
||||
read = function () return rsio.digital_is_active(port, self.phy_io.digital_in[port].phy) end,
|
||||
---@param active boolean
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
write = function (active) end
|
||||
write = function () end
|
||||
}
|
||||
|
||||
self.db.io[port] = io_f
|
||||
@@ -155,9 +153,7 @@ function redstone.new(session_id, unit_id, advert, out_queue)
|
||||
---@nodiscard
|
||||
---@return integer
|
||||
read = function () return self.phy_io.analog_in[port].phy end,
|
||||
---@param value integer
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
write = function (value) end
|
||||
write = function () end
|
||||
}
|
||||
|
||||
self.db.io[port] = io_f
|
||||
|
||||
@@ -166,6 +166,8 @@ function unit_session.new(session_id, unit_id, advert, out_queue, log_tag, txn_t
|
||||
|
||||
-- PUBLIC TEMPLATE FUNCTIONS --
|
||||
|
||||
-- luacheck: no unused args
|
||||
|
||||
-- handle a packet
|
||||
---@param m_pkt modbus_frame
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
@@ -180,6 +182,8 @@ function unit_session.new(session_id, unit_id, advert, out_queue, log_tag, txn_t
|
||||
log.debug("template unit_session.update() called", true)
|
||||
end
|
||||
|
||||
-- luacheck: unused args
|
||||
|
||||
-- invalidate build cache
|
||||
function public.invalidate_cache()
|
||||
log.debug("template unit_session.invalidate_cache() called", true)
|
||||
|
||||
@@ -45,6 +45,7 @@ cfv.assert_type_int(config.NUM_REACTORS)
|
||||
cfv.assert_type_table(config.REACTOR_COOLING)
|
||||
cfv.assert_type_str(config.LOG_PATH)
|
||||
cfv.assert_type_int(config.LOG_MODE)
|
||||
cfv.assert_type_bool(config.LOG_DEBUG)
|
||||
|
||||
assert(cfv.valid(), "bad config file: missing/invalid fields")
|
||||
|
||||
@@ -66,7 +67,7 @@ end
|
||||
-- log init
|
||||
----------------------------------------
|
||||
|
||||
log.init(config.LOG_PATH, config.LOG_MODE)
|
||||
log.init(config.LOG_PATH, config.LOG_MODE, config.LOG_DEBUG)
|
||||
|
||||
log.info("========================================")
|
||||
log.info("BOOTING supervisor.startup " .. SUPERVISOR_VERSION)
|
||||
|
||||
@@ -16,7 +16,7 @@ local println = function (str) end
|
||||
|
||||
-- supervisory controller communications
|
||||
---@nodiscard
|
||||
---@param version string supervisor version
|
||||
---@param _version string supervisor version
|
||||
---@param num_reactors integer number of reactors
|
||||
---@param cooling_conf table cooling configuration table
|
||||
---@param modem table modem device
|
||||
@@ -24,7 +24,7 @@ local println = function (str) end
|
||||
---@param svctl_listen integer listening port for supervisor access
|
||||
---@param range integer trusted device connection range
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
function supervisor.comms(version, num_reactors, cooling_conf, modem, dev_listen, svctl_listen, range)
|
||||
function supervisor.comms(_version, num_reactors, cooling_conf, modem, dev_listen, svctl_listen, range)
|
||||
local self = {
|
||||
last_est_acks = {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user