#401 cleanup and global RTT limit constants

This commit is contained in:
Mikayla Fischler 2025-08-19 18:43:43 -04:00
parent 691b781c52
commit 4a1730ec47
4 changed files with 35 additions and 38 deletions

View File

@ -3,6 +3,7 @@
--
local comms = require("scada-common.comms")
local const = require("scada-common.constants")
local util = require("scada-common.util")
local iocontrol = require("pocket.iocontrol")
@ -30,16 +31,10 @@ local border = core.border
local APP_ID = pocket.APP_ID
local label_fg_bg = style.label
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
-- new computer list page view
---@param root Container parent
local function new_view(root)
@ -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)

View File

@ -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

View File

@ -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

View File

@ -2,16 +2,12 @@
-- Data Bus - Central Communication Linking for Supervisor Front Panel
--
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)