This commit is contained in:
Mikayla Fischler 2024-04-08 23:59:16 -04:00
parent cc50e4a020
commit 98c37caecd
3 changed files with 21 additions and 21 deletions

View File

@ -23,11 +23,13 @@ local MAIN_CLOCK = 0.5 -- (2Hz, 10 ticks)
local RENDER_SLEEP = 100 -- (100ms, 2 ticks) local RENDER_SLEEP = 100 -- (100ms, 2 ticks)
local MQ__RENDER_CMD = { local MQ__RENDER_CMD = {
START_MAIN_UI = 1, START_MAIN_UI = 1
MON_CONNECT = 2, }
MON_DISCONNECT = 3,
MON_RESIZE = 4, local MQ__RENDER_DATA = {
UPDATE = 5 MON_CONNECT = 1,
MON_DISCONNECT = 2,
MON_RESIZE = 3
} }
-- main thread -- main thread
@ -88,7 +90,7 @@ function threads.thread__main(smem)
log_sys("non-comms modem disconnected") log_sys("non-comms modem disconnected")
end end
elseif type == "monitor" then elseif type == "monitor" then
smem.q.mq_render.push_data(MQ__RENDER_CMD.MON_DISCONNECT, device) smem.q.mq_render.push_data(MQ__RENDER_DATA.MON_DISCONNECT, device)
elseif type == "speaker" then elseif type == "speaker" then
log_sys("lost alarm sounder speaker") log_sys("lost alarm sounder speaker")
iocontrol.fp_has_speaker(false) iocontrol.fp_has_speaker(false)
@ -110,7 +112,7 @@ function threads.thread__main(smem)
log_sys("wired modem reconnected") log_sys("wired modem reconnected")
end end
elseif type == "monitor" then elseif type == "monitor" then
smem.q.mq_render.push_data(MQ__RENDER_CMD.MON_CONNECT, { name = param1, device = device }) smem.q.mq_render.push_data(MQ__RENDER_DATA.MON_CONNECT, { name = param1, device = device })
elseif type == "speaker" then elseif type == "speaker" then
log_sys("alarm sounder speaker reconnected") log_sys("alarm sounder speaker reconnected")
sounder.reconnect(device) sounder.reconnect(device)
@ -118,7 +120,7 @@ function threads.thread__main(smem)
end end
end end
elseif event == "monitor_resize" then elseif event == "monitor_resize" then
smem.q.mq_render.push_data(MQ__RENDER_CMD.MON_RESIZE, param1) smem.q.mq_render.push_data(MQ__RENDER_DATA.MON_RESIZE, param1)
elseif event == "timer" then elseif event == "timer" then
if loop_clock.is_clock(param1) then if loop_clock.is_clock(param1) then
-- main loop tick -- main loop tick
@ -137,7 +139,6 @@ function threads.thread__main(smem)
elseif start_ui then elseif start_ui then
log_sys("supervisor connected, dispatching main UI start") log_sys("supervisor connected, dispatching main UI start")
smem.q.mq_render.push_command(MQ__RENDER_CMD.START_MAIN_UI) smem.q.mq_render.push_command(MQ__RENDER_CMD.START_MAIN_UI)
--@todo if not ui_ok then break end
end end
end end
@ -284,28 +285,26 @@ function threads.thread__render(smem)
else else
log_render("main UI draw took " .. (util.time_ms() - draw_start) .. "ms") log_render("main UI draw took " .. (util.time_ms() - draw_start) .. "ms")
end end
elseif msg.message == MQ__RENDER_CMD.UPDATE then
-- new data
end end
elseif msg.qtype == mqueue.TYPE.DATA then elseif msg.qtype == mqueue.TYPE.DATA then
-- received data -- received data
local cmd = msg.message ---@type queue_data local cmd = msg.message ---@type queue_data
if cmd.key == MQ__RENDER_CMD.MON_CONNECT then if cmd.key == MQ__RENDER_DATA.MON_CONNECT then
-- monitor connected -- monitor connected
if renderer.handle_reconnect(cmd.val.name, cmd.val.device) then if renderer.handle_reconnect(cmd.val.name, cmd.val.device) then
log_sys(util.c("configured monitor ", cmd.val.name, " reconnected")) log_sys(util.c("configured monitor ", cmd.val.name, " reconnected"))
else else
log_sys(util.c("unused monitor ", cmd.val.name, " connected")) log_sys(util.c("unused monitor ", cmd.val.name, " connected"))
end end
elseif cmd.key == MQ__RENDER_CMD.MON_DISCONNECT then elseif cmd.key == MQ__RENDER_DATA.MON_DISCONNECT then
-- monitor disconnected -- monitor disconnected
if renderer.handle_disconnect(cmd.val) then if renderer.handle_disconnect(cmd.val) then
log_sys("lost a configured monitor") log_sys("lost a configured monitor")
else else
log_sys("lost an unused monitor") log_sys("lost an unused monitor")
end end
elseif cmd.key == MQ__RENDER_CMD.MON_RESIZE then elseif cmd.key == MQ__RENDER_DATA.MON_RESIZE then
-- monitor resized -- monitor resized
local is_used, is_ok = renderer.handle_resize(cmd.val) local is_used, is_ok = renderer.handle_resize(cmd.val)
if is_used then if is_used then

View File

@ -2,9 +2,10 @@
-- Main SCADA Coordinator GUI -- Main SCADA Coordinator GUI
-- --
local iocontrol = require("coordinator.iocontrol")
local util = require("scada-common.util") local util = require("scada-common.util")
local iocontrol = require("coordinator.iocontrol")
local style = require("coordinator.ui.style") local style = require("coordinator.ui.style")
local imatrix = require("coordinator.ui.components.imatrix") local imatrix = require("coordinator.ui.components.imatrix")