#629 rework of alarm testing app and other cleanup

This commit is contained in:
Mikayla Fischler
2025-09-12 21:46:02 -04:00
parent afc89ac727
commit a1bb5ce50b
6 changed files with 198 additions and 150 deletions

View File

@@ -676,6 +676,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
---@param packet mgmt_frame|crdn_frame|nil
function public.handle_packet(packet)
local diag = iocontrol.get_db().diag
local ps = iocontrol.get_db().ps
if packet ~= nil then
local l_chan = packet.scada_frame.local_channel()
@@ -927,23 +928,23 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
elseif packet.type == MGMT_TYPE.DIAG_TONE_GET then
if _check_length(packet, 8) then
for i = 1, #packet.data do
diag.tone_test.tone_indicators[i].update(packet.data[i] == true)
ps.publish("alarm_tone_" .. i, packet.data[i] == true)
end
end
elseif packet.type == MGMT_TYPE.DIAG_TONE_SET then
if packet.length == 1 and packet.data[1] == false then
diag.tone_test.ready_warn.set_value("testing denied")
ps.publish("alarm_ready_warn", "testing denied")
log.debug("supervisor SCADA diag tone set failed")
elseif packet.length == 2 and type(packet.data[2]) == "table" then
local ready = packet.data[1]
local states = packet.data[2]
diag.tone_test.ready_warn.set_value(util.trinary(ready, "", "system not idle"))
ps.publish("alarm_ready_warn", util.trinary(ready, "", "system not idle"))
for i = 1, #states do
if diag.tone_test.tone_buttons[i] ~= nil then
diag.tone_test.tone_buttons[i].set_value(states[i] == true)
diag.tone_test.tone_indicators[i].update(states[i] == true)
ps.publish("alarm_tone_" .. i, states[i] == true)
end
end
else
@@ -951,13 +952,13 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
end
elseif packet.type == MGMT_TYPE.DIAG_ALARM_SET then
if packet.length == 1 and packet.data[1] == false then
diag.tone_test.ready_warn.set_value("testing denied")
ps.publish("alarm_ready_warn", "testing denied")
log.debug("supervisor SCADA diag alarm set failed")
elseif packet.length == 2 and type(packet.data[2]) == "table" then
local ready = packet.data[1]
local states = packet.data[2]
diag.tone_test.ready_warn.set_value(util.trinary(ready, "", "system not idle"))
ps.publish("alarm_ready_warn", util.trinary(ready, "", "system not idle"))
for i = 1, #states do
if diag.tone_test.alarm_buttons[i] ~= nil then