From 7f951a985b8eabfe503a43d93ab9eea29247c073 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 15 Nov 2025 23:05:36 -0500 Subject: [PATCH] #647 supervisor status light functionality --- supervisor/databus.lua | 18 +++++++++++++++++- supervisor/panel/front_panel.lua | 4 ++-- supervisor/startup.lua | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/supervisor/databus.lua b/supervisor/databus.lua index af90a2c..a474fdb 100644 --- a/supervisor/databus.lua +++ b/supervisor/databus.lua @@ -6,10 +6,20 @@ local const = require("scada-common.constants") local psil = require("scada-common.psil") local util = require("scada-common.util") -local pgi = require("supervisor.panel.pgi") +local pgi = require("supervisor.panel.pgi") local databus = {} +local _dbus = { + wd_modem = true, + wl_modem = true +} + +-- evaluate and publish system health status +local function eval_status() + databus.ps.publish("status", _dbus.wd_modem and _dbus.wl_modem) +end + -- databus PSIL databus.ps = psil.create() @@ -28,12 +38,18 @@ end ---@param has_modem boolean function databus.tx_hw_wd_modem(has_modem) databus.ps.publish("has_wd_modem", has_modem) + + _dbus.wd_modem = has_modem + eval_status() end -- transmit hardware status for the wireless comms modem ---@param has_modem boolean function databus.tx_hw_wl_modem(has_modem) databus.ps.publish("has_wl_modem", has_modem) + + _dbus.wl_modem = has_modem + eval_status() end -- transmit PLC firmware version and session connection state diff --git a/supervisor/panel/front_panel.lua b/supervisor/panel/front_panel.lua index cae6bce..e1afbe1 100644 --- a/supervisor/panel/front_panel.lua +++ b/supervisor/panel/front_panel.lua @@ -58,11 +58,11 @@ local function init(panel, config) local system = Div{parent=main_page,width=18,height=17,x=2,y=2} - local on = LED{parent=system,label="STATUS",colors=cpair(colors.green,colors.red)} + local status = LED{parent=system,label="STATUS",colors=cpair(colors.green,colors.red)} local heartbeat = LED{parent=system,label="HEARTBEAT",colors=ind_grn} - on.update(true) system.line_break() + status.register(databus.ps, "status", status.update) heartbeat.register(databus.ps, "heartbeat", heartbeat.update) if config.WirelessModem and config.WiredModem then diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 1601f20..f6ad4bc 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -24,7 +24,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.8.0" +local SUPERVISOR_VERSION = "v1.8.1" local println = util.println local println_ts = util.println_ts