From 4a1730ec47b43404d18180fb63b4b295fdc87489 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 19 Aug 2025 18:43:43 -0400 Subject: [PATCH] #401 cleanup and global RTT limit constants --- pocket/ui/apps/comps.lua | 39 +++++++++++++++++--------------------- scada-common/constants.lua | 6 ++++++ scada-common/util.lua | 2 +- supervisor/databus.lua | 26 +++++++++++-------------- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/pocket/ui/apps/comps.lua b/pocket/ui/apps/comps.lua index 63e885a..cc1240e 100644 --- a/pocket/ui/apps/comps.lua +++ b/pocket/ui/apps/comps.lua @@ -2,23 +2,24 @@ -- Computer List App -- -local comms = require("scada-common.comms") -local util = require("scada-common.util") +local comms = require("scada-common.comms") +local const = require("scada-common.constants") +local util = require("scada-common.util") -local iocontrol = require("pocket.iocontrol") -local pocket = require("pocket.pocket") +local iocontrol = require("pocket.iocontrol") +local pocket = require("pocket.pocket") -local style = require("pocket.ui.style") +local style = require("pocket.ui.style") -local core = require("graphics.core") +local core = require("graphics.core") -local Div = require("graphics.elements.Div") -local ListBox = require("graphics.elements.ListBox") -local MultiPane = require("graphics.elements.MultiPane") -local Rectangle = require("graphics.elements.Rectangle") -local TextBox = require("graphics.elements.TextBox") +local Div = require("graphics.elements.Div") +local ListBox = require("graphics.elements.ListBox") +local MultiPane = require("graphics.elements.MultiPane") +local Rectangle = require("graphics.elements.Rectangle") +local TextBox = require("graphics.elements.TextBox") -local WaitingAnim = require("graphics.elements.animations.Waiting") +local WaitingAnim = require("graphics.elements.animations.Waiting") local DataIndicator = require("graphics.elements.indicators.DataIndicator") @@ -30,15 +31,9 @@ local border = core.border local APP_ID = pocket.APP_ID -local label_fg_bg = style.label -local lu_col = style.label_unit_pair +local lu_col = style.label_unit_pair -local box_label = cpair(colors.lightGray, colors.gray) - --- nominal RTT is ping (0ms to 10ms usually) + 150ms for SV main loop tick --- ensure in sync with supervisor databus file -local WARN_RTT = 300 -- 2x as long as expected w/ 0 ping -local HIGH_RTT = 500 -- 3.33x as long as expected w/ 0 ping +local box_label = cpair(colors.lightGray, colors.gray) -- new computer list page view ---@param root Container parent @@ -105,9 +100,9 @@ local function new_view(root) if value == "---" then rtt.recolor(colors.white) - elseif value > HIGH_RTT then + elseif value > const.HIGH_RTT then rtt.recolor(colors.red) - elseif value > WARN_RTT then + elseif value > const.WARN_RTT then rtt.recolor(colors.yellow) else rtt.recolor(colors.green) diff --git a/scada-common/constants.lua b/scada-common/constants.lua index 11a8929..02841e1 100644 --- a/scada-common/constants.lua +++ b/scada-common/constants.lua @@ -88,6 +88,7 @@ constants.FLOW_STABILITY_DELAY_MS = 10000 -- - background radiation 0.0000001 Sv/h (99.99 nSv/h) -- - "green tint" radiation 0.00001 Sv/h (10 uSv/h) -- - damaging radiation 0.00006 Sv/h (60 uSv/h) + constants.LOW_RADIATION = 0.00001 constants.HAZARD_RADIATION = 0.00006 constants.HIGH_RADIATION = 0.001 @@ -95,6 +96,11 @@ constants.VERY_HIGH_RADIATION = 0.1 constants.SEVERE_RADIATION = 8.0 constants.EXTREME_RADIATION = 100.0 +-- nominal RTT is ping (0ms to 10ms usually) + 150ms for SV main loop tick + +constants.WARN_RTT = 300 -- 2x as long as expected w/ 0 ping +constants.HIGH_RTT = 500 -- 3.33x as long as expected w/ 0 ping + --#endregion --#region Mekanism Configuration Constants diff --git a/scada-common/util.lua b/scada-common/util.lua index 8230fca..031eaa0 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -24,7 +24,7 @@ local t_pack = table.pack local util = {} -- scada-common version -util.version = "1.5.3" +util.version = "1.5.4" util.TICK_TIME_S = 0.05 util.TICK_TIME_MS = 50 diff --git a/supervisor/databus.lua b/supervisor/databus.lua index eef99e7..94d67d1 100644 --- a/supervisor/databus.lua +++ b/supervisor/databus.lua @@ -2,16 +2,12 @@ -- Data Bus - Central Communication Linking for Supervisor Front Panel -- -local psil = require("scada-common.psil") -local util = require("scada-common.util") +local const = require("scada-common.constants") +local psil = require("scada-common.psil") +local util = require("scada-common.util") local pgi = require("supervisor.panel.pgi") --- nominal RTT is ping (0ms to 10ms usually) + 150ms for SV main loop tick --- ensure in sync with pocket computer list app -local WARN_RTT = 300 -- 2x as long as expected w/ 0 ping -local HIGH_RTT = 500 -- 3.33x as long as expected w/ 0 ping - local databus = {} -- databus PSIL @@ -60,9 +56,9 @@ end function databus.tx_plc_rtt(reactor_id, rtt) databus.ps.publish("plc_" .. reactor_id .. "_rtt", rtt) - if rtt > HIGH_RTT then + if rtt > const.HIGH_RTT then databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.red) - elseif rtt > WARN_RTT then + elseif rtt > const.WARN_RTT then databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.yellow_hc) else databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.green_hc) @@ -91,9 +87,9 @@ end function databus.tx_rtu_rtt(session_id, rtt) databus.ps.publish("rtu_" .. session_id .. "_rtt", rtt) - if rtt > HIGH_RTT then + if rtt > const.HIGH_RTT then databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.red) - elseif rtt > WARN_RTT then + elseif rtt > const.WARN_RTT then databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.yellow_hc) else databus.ps.publish("rtu_" .. session_id .. "_rtt_color", colors.green_hc) @@ -130,9 +126,9 @@ end function databus.tx_crd_rtt(rtt) databus.ps.publish("crd_rtt", rtt) - if rtt > HIGH_RTT then + if rtt > const.HIGH_RTT then databus.ps.publish("crd_rtt_color", colors.red) - elseif rtt > WARN_RTT then + elseif rtt > const.WARN_RTT then databus.ps.publish("crd_rtt_color", colors.yellow_hc) else databus.ps.publish("crd_rtt_color", colors.green_hc) @@ -161,9 +157,9 @@ end function databus.tx_pdg_rtt(session_id, rtt) databus.ps.publish("pdg_" .. session_id .. "_rtt", rtt) - if rtt > HIGH_RTT then + if rtt > const.HIGH_RTT then databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.red) - elseif rtt > WARN_RTT then + elseif rtt > const.WARN_RTT then databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.yellow_hc) else databus.ps.publish("pdg_" .. session_id .. "_rtt_color", colors.green_hc)