From 983724f45f929d7d45c06434a8cf2bc854c03683 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 15 Nov 2025 17:11:28 -0500 Subject: [PATCH] #643 warn about report multiple logic adapters on the front panel --- reactor-plc/backplane.lua | 9 +++++++++ reactor-plc/databus.lua | 6 ++++++ reactor-plc/panel/front_panel.lua | 29 +++++++++++++++++++++++++++++ reactor-plc/startup.lua | 2 +- 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/reactor-plc/backplane.lua b/reactor-plc/backplane.lua index 57dce67..f5ee23c 100644 --- a/reactor-plc/backplane.lua +++ b/reactor-plc/backplane.lua @@ -7,6 +7,8 @@ local network = require("scada-common.network") local ppm = require("scada-common.ppm") local util = require("scada-common.util") +local databus = require("reactor-plc.databus") + local println = util.println ---@class plc_backplane @@ -125,6 +127,8 @@ function backplane.init(config, __shared_memory) 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") + + databus.tx_multi_reactor(true) end end @@ -151,6 +155,8 @@ function backplane.attach(iface, type, device, print_no_fp) 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") + + databus.tx_multi_reactor(true) return end @@ -265,6 +271,9 @@ function backplane.detach(iface, type, device, print_no_fp) state.no_reactor = true state.degraded = true + -- clear this tentatively, so then if there is >1, that will be reported in backplane.attach in the following if statement + databus.tx_multi_reactor(false) + -- 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 diff --git a/reactor-plc/databus.lua b/reactor-plc/databus.lua index 9975dac..1bc8d8b 100644 --- a/reactor-plc/databus.lua +++ b/reactor-plc/databus.lua @@ -56,6 +56,12 @@ function databus.tx_hw_status(plc_state) databus.ps.publish("has_wl_modem", plc_state.wl_modem) end +-- transmiti f the reactor dangerously has multiple fission reactor logic adapters +---@param multi boolean has multiple reactors +function databus.tx_multi_reactor(multi) + databus.ps.publish("has_multi_reactor", multi) +end + -- transmit thread (routine) statuses ---@param thread string thread name ---@param ok boolean thread state diff --git a/reactor-plc/panel/front_panel.lua b/reactor-plc/panel/front_panel.lua index 95004d2..fd6e8a5 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -2,6 +2,7 @@ -- Reactor PLC Front Panel GUI -- +local tcd = require("scada-common.tcd") local types = require("scada-common.types") local util = require("scada-common.util") @@ -161,6 +162,34 @@ local function init(panel, config) TextBox{parent=hw_labels,text="NT v"..databus.ps.get("comms_version"),fg_bg=s_hi_box} TextBox{parent=hw_labels,text="SN "..comp_id.."-PLC",fg_bg=s_hi_box} + -- warning about multiple reactors connected + + local warn_strings = { "!! DANGER !!\n>1 REACTOR\nLOGIC ADAPTER", "REMOVE\nALL BUT ONE\nLOGIC ADAPTER" } + local multi_warn = TextBox{parent=status,text=warn_strings[1],width=status.get_width()-2,alignment=ALIGN.CENTER,fg_bg=cpair(colors.yellow,colors.red),hidden=true} + + local warn_toggle = true + local function flash_warn() + multi_warn.recolor(util.trinary(warn_toggle, colors.black, colors.yellow)) + multi_warn.set_value(util.trinary(warn_toggle, warn_strings[2], warn_strings[1])) + warn_toggle = not warn_toggle + + if databus.ps.get("has_multi_reactor") then tcd.dispatch_unique(2, flash_warn) end + end + + multi_warn.register(databus.ps, "has_multi_reactor", function (v) + if v then + multi_warn.show(true) + + warn_toggle = false + flash_warn() + + tcd.dispatch_unique(2, flash_warn) + else + tcd.abort(flash_warn) + multi_warn.hide(true) + end + end) + -- -- rps list -- diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 324cb68..3ce6eb2 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -19,7 +19,7 @@ local plc = require("reactor-plc.plc") local renderer = require("reactor-plc.renderer") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v1.10.0" +local R_PLC_VERSION = "v1.10.1" local println = util.println local println_ts = util.println_ts