From 98c37caecd70847048b934de8e4da88c83c20d31 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 8 Apr 2024 23:59:16 -0400 Subject: [PATCH] #460 cleanup --- coordinator/startup.lua | 8 ++++---- coordinator/threads.lua | 31 ++++++++++++++--------------- coordinator/ui/layout/main_view.lua | 3 ++- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 8b42414..236fa79 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -23,13 +23,13 @@ local COORDINATOR_VERSION = "v1.4.0" local CHUNK_LOAD_DELAY_S = 30.0 -local println = util.println +local println = util.println local println_ts = util.println_ts local log_render = coordinator.log_render -local log_sys = coordinator.log_sys -local log_boot = coordinator.log_boot -local log_comms = coordinator.log_comms +local log_sys = coordinator.log_sys +local log_boot = coordinator.log_boot +local log_comms = coordinator.log_comms local log_crypto = coordinator.log_crypto ---------------------------------------- diff --git a/coordinator/threads.lua b/coordinator/threads.lua index 8fac12b..d684fc0 100644 --- a/coordinator/threads.lua +++ b/coordinator/threads.lua @@ -14,8 +14,8 @@ local apisessions = require("coordinator.session.apisessions") local core = require("graphics.core") local log_render = coordinator.log_render -local log_sys = coordinator.log_sys -local log_comms = coordinator.log_comms +local log_sys = coordinator.log_sys +local log_comms = coordinator.log_comms local threads = {} @@ -23,11 +23,13 @@ local MAIN_CLOCK = 0.5 -- (2Hz, 10 ticks) local RENDER_SLEEP = 100 -- (100ms, 2 ticks) local MQ__RENDER_CMD = { - START_MAIN_UI = 1, - MON_CONNECT = 2, - MON_DISCONNECT = 3, - MON_RESIZE = 4, - UPDATE = 5 + START_MAIN_UI = 1 +} + +local MQ__RENDER_DATA = { + MON_CONNECT = 1, + MON_DISCONNECT = 2, + MON_RESIZE = 3 } -- main thread @@ -88,7 +90,7 @@ function threads.thread__main(smem) log_sys("non-comms modem disconnected") end 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 log_sys("lost alarm sounder speaker") iocontrol.fp_has_speaker(false) @@ -110,7 +112,7 @@ function threads.thread__main(smem) log_sys("wired modem reconnected") end 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 log_sys("alarm sounder speaker reconnected") sounder.reconnect(device) @@ -118,7 +120,7 @@ function threads.thread__main(smem) end end 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 if loop_clock.is_clock(param1) then -- main loop tick @@ -137,7 +139,6 @@ function threads.thread__main(smem) elseif start_ui then log_sys("supervisor connected, dispatching main UI start") smem.q.mq_render.push_command(MQ__RENDER_CMD.START_MAIN_UI) - --@todo if not ui_ok then break end end end @@ -284,28 +285,26 @@ function threads.thread__render(smem) else log_render("main UI draw took " .. (util.time_ms() - draw_start) .. "ms") end - elseif msg.message == MQ__RENDER_CMD.UPDATE then - -- new data end elseif msg.qtype == mqueue.TYPE.DATA then -- received 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 if renderer.handle_reconnect(cmd.val.name, cmd.val.device) then log_sys(util.c("configured monitor ", cmd.val.name, " reconnected")) else log_sys(util.c("unused monitor ", cmd.val.name, " connected")) end - elseif cmd.key == MQ__RENDER_CMD.MON_DISCONNECT then + elseif cmd.key == MQ__RENDER_DATA.MON_DISCONNECT then -- monitor disconnected if renderer.handle_disconnect(cmd.val) then log_sys("lost a configured monitor") else log_sys("lost an unused monitor") end - elseif cmd.key == MQ__RENDER_CMD.MON_RESIZE then + elseif cmd.key == MQ__RENDER_DATA.MON_RESIZE then -- monitor resized local is_used, is_ok = renderer.handle_resize(cmd.val) if is_used then diff --git a/coordinator/ui/layout/main_view.lua b/coordinator/ui/layout/main_view.lua index cba1747..5343139 100644 --- a/coordinator/ui/layout/main_view.lua +++ b/coordinator/ui/layout/main_view.lua @@ -2,9 +2,10 @@ -- Main SCADA Coordinator GUI -- -local iocontrol = require("coordinator.iocontrol") local util = require("scada-common.util") +local iocontrol = require("coordinator.iocontrol") + local style = require("coordinator.ui.style") local imatrix = require("coordinator.ui.components.imatrix")