#643 self check and backplane checks for multiple fission reactor logic adapters

This commit is contained in:
Mikayla
2025-11-13 21:54:56 +00:00
parent 4dabc3f0aa
commit d43112bdeb
4 changed files with 35 additions and 11 deletions

View File

@@ -118,6 +118,14 @@ function backplane.init(config, __shared_memory)
plc_state.reactor_formed = false
end
end
-- detect and warn about multiple reactors
if #ppm.get_all_devices("fissionReactorLogicAdapter") > 1 then
println("startup> !! DANGER !! more than one reactor was detected! do not share reactor connections between multiple PLCs! they may not all be protected and used as configured")
log.warning("BKPLN: !! DANGER !! more than one reactor was detected on startup!")
log.warning("BKPLN: do NOT share reactor connections between multiple PLCs! they may not all be protected and used as configured")
end
end
-- get the active NIC
@@ -139,7 +147,13 @@ function backplane.attach(iface, type, device, print_no_fp)
local sys = _bp.smem.plc_sys
if type ~= nil and device ~= nil then
if state.no_reactor and (type == "fissionReactorLogicAdapter") then
if type == "fissionReactorLogicAdapter" then
if not state.no_reactor then
log.warning("BKPLN: !! DANGER !! an additional reactor (" .. iface .. ") was connected and will not be used!")
log.warning("BKPLN: do NOT share reactor connections between multiple PLCs! they may not all be protected and used as configured")
return
end
-- reconnected reactor
log.info("BKPLN: REACTOR LINK_UP " .. iface)
@@ -250,6 +264,14 @@ function backplane.detach(iface, type, device, print_no_fp)
state.no_reactor = true
state.degraded = true
-- try to find another reactor (this should not work unless multiple were incorrectly connected)
local reactor, r_iface = ppm.get_fission_reactor()
if reactor and r_iface then
log.info("BKPLN: found another fission reactor logic adapter")
backplane.attach(r_iface, type, reactor, print_no_fp)
end
elseif _bp.smem.networked and type == "modem" then
---@cast device Modem

View File

@@ -141,6 +141,7 @@ local function self_check()
self.self_check_msg("> check fission reactor formed...")
-- this consumes events, but that is fine here
self.self_check_msg(nil, reactor and reactor.isFormed(), "ensure the fission reactor multiblock is formed")
self.self_check_msg("> check for no more than one reactor...", #ppm.get_all_devices("fissionReactorLogicAdapter") <= 1, "there MUST be no more than one reactor connected, as a PLC uses the first one it finds, which may not always be the same one")
self.self_check_msg("> check configuration...", valid_cfg, "go through Configure System and apply settings to set any missing settings and repair any corrupted ones")

View File

@@ -425,26 +425,27 @@ end
-- get a mounted peripheral by type (if multiple, returns the first)
---@nodiscard
---@param name string type name
---@return table|nil device function table
function ppm.get_device(name)
local device = nil
---@param type string type name
---@return table|nil device, string|nil iface device and interface
function ppm.get_device(type)
local device, d_iface = nil, nil
for _, data in pairs(_ppm.mounts) do
if data.type == name then
for iface, data in pairs(_ppm.mounts) do
if data.type == type then
device = data.dev
d_iface = iface
break
end
end
return device
return device, d_iface
end
-- SPECIFIC DEVICE ACCESSORS --
-- get the fission reactor (if multiple, returns the first)
---@nodiscard
---@return table|nil reactor function table
---@return table|nil reactor, string|nil iface reactor and interface
function ppm.get_fission_reactor() return ppm.get_device("fissionReactorLogicAdapter") end
-- get a modem by name
@@ -470,8 +471,8 @@ function ppm.get_wireless_modem()
for iface, device in pairs(_ppm.mounts) do
if device.type == "modem" and (emulated_env or device.dev.isWireless()) then
w_iface = iface
w_modem = device.dev
w_iface = iface
break
end
end

View File

@@ -24,7 +24,7 @@ local t_pack = table.pack
local util = {}
-- scada-common version
util.version = "1.6.0"
util.version = "1.6.1"
util.TICK_TIME_S = 0.05
util.TICK_TIME_MS = 50