#647 rtu gateway status light functionality
This commit is contained in:
@@ -7,6 +7,25 @@ local util = require("scada-common.util")
|
||||
|
||||
local databus = {}
|
||||
|
||||
local _dbus = {
|
||||
wd_modem = true,
|
||||
wl_modem = true,
|
||||
coroutines = {}
|
||||
}
|
||||
|
||||
-- evaluate and publish system health status
|
||||
local function eval_status()
|
||||
local ok = _dbus.wd_modem and _dbus.wl_modem
|
||||
|
||||
if ok then
|
||||
for _, v in pairs(_dbus.coroutines) do
|
||||
ok = ok and v
|
||||
end
|
||||
end
|
||||
|
||||
databus.ps.publish("status", ok)
|
||||
end
|
||||
|
||||
-- databus PSIL
|
||||
databus.ps = psil.create()
|
||||
|
||||
@@ -35,12 +54,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 the number of speakers connected
|
||||
@@ -67,7 +92,12 @@ end
|
||||
---@param thread string thread name
|
||||
---@param ok boolean thread state
|
||||
function databus.tx_rt_status(thread, ok)
|
||||
databus.ps.publish(util.c("routine__", thread), ok)
|
||||
local name = util.c("routine__", thread)
|
||||
|
||||
databus.ps.publish(name, ok)
|
||||
|
||||
_dbus.coroutines[name] = ok
|
||||
eval_status()
|
||||
end
|
||||
|
||||
-- transmit supervisor link state
|
||||
|
||||
@@ -51,11 +51,11 @@ local function init(panel, config, units)
|
||||
|
||||
local system = Div{parent=panel,width=14,height=term_h-5,x=2,y=3}
|
||||
|
||||
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
|
||||
|
||||
@@ -21,7 +21,7 @@ local rtu = require("rtu.rtu")
|
||||
local threads = require("rtu.threads")
|
||||
local uinit = require("rtu.uinit")
|
||||
|
||||
local RTU_VERSION = "v1.13.0"
|
||||
local RTU_VERSION = "v1.13.1"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
||||
Reference in New Issue
Block a user