From 45573be8c76aa6de63ec0bf7c922ed3dd478657d Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 7 Apr 2024 20:47:31 -0400 Subject: [PATCH] #460 renderer logging --- coordinator/coordinator.lua | 4 ++-- coordinator/renderer.lua | 46 ++++++++++++++++++++++--------------- coordinator/startup.lua | 10 ++++---- coordinator/threads.lua | 8 +++---- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/coordinator/coordinator.lua b/coordinator/coordinator.lua index a8d6e5e..40d71d8 100644 --- a/coordinator/coordinator.lua +++ b/coordinator/coordinator.lua @@ -192,7 +192,7 @@ end ---@return function? update, function? done local function log_dmesg(message, dmesg_tag, working) local colors = { - GRAPHICS = colors.green, + RENDER = colors.green, SYSTEM = colors.cyan, BOOT = colors.blue, COMMS = colors.purple, @@ -206,7 +206,7 @@ local function log_dmesg(message, dmesg_tag, working) end end -function coordinator.log_graphics(message) log_dmesg(message, "GRAPHICS") end +function coordinator.log_render(message) log_dmesg(message, "RENDER") end function coordinator.log_sys(message) log_dmesg(message, "SYSTEM") end function coordinator.log_boot(message) log_dmesg(message, "BOOT") end function coordinator.log_comms(message) log_dmesg(message, "COMMS") end diff --git a/coordinator/renderer.lua b/coordinator/renderer.lua index 0e34ee1..6920845 100644 --- a/coordinator/renderer.lua +++ b/coordinator/renderer.lua @@ -2,23 +2,26 @@ -- Graphics Rendering Control -- -local log = require("scada-common.log") -local util = require("scada-common.util") +local log = require("scada-common.log") +local util = require("scada-common.util") -local iocontrol = require("coordinator.iocontrol") +local coordinator = require("coordinator.coordinator") +local iocontrol = require("coordinator.iocontrol") -local style = require("coordinator.ui.style") -local pgi = require("coordinator.ui.pgi") +local style = require("coordinator.ui.style") +local pgi = require("coordinator.ui.pgi") -local flow_view = require("coordinator.ui.layout.flow_view") -local panel_view = require("coordinator.ui.layout.front_panel") -local main_view = require("coordinator.ui.layout.main_view") -local unit_view = require("coordinator.ui.layout.unit_view") +local flow_view = require("coordinator.ui.layout.flow_view") +local panel_view = require("coordinator.ui.layout.front_panel") +local main_view = require("coordinator.ui.layout.main_view") +local unit_view = require("coordinator.ui.layout.unit_view") -local core = require("graphics.core") -local flasher = require("graphics.flasher") +local core = require("graphics.core") +local flasher = require("graphics.flasher") -local DisplayBox = require("graphics.elements.displaybox") +local DisplayBox = require("graphics.elements.displaybox") + +local log_render = coordinator.log_render ---@class coord_renderer local renderer = {} @@ -387,12 +390,15 @@ function renderer.handle_resize(name) engine.dmesg_window.setVisible(not engine.ui_ready) if engine.ui_ready then + local draw_start = util.time_ms() local ok = pcall(function () ui.main_display = DisplayBox{window=device,fg_bg=style.root} main_view(ui.main_display) end) - if not ok then + if ok then + log_render("main view re-draw completed in " .. (util.time_ms() - draw_start) .. "ms") + else if ui.main_display then ui.main_display.delete() ui.main_display = nil @@ -420,14 +426,15 @@ function renderer.handle_resize(name) iocontrol.fp_monitor_state("flow", true) if engine.ui_ready then - engine.dmesg_window.setVisible(false) - + local draw_start = util.time_ms() local ok = pcall(function () ui.flow_display = DisplayBox{window=device,fg_bg=style.root} flow_view(ui.flow_display) end) - if not ok then + if ok then + log_render("flow view re-draw completed in " .. (util.time_ms() - draw_start) .. "ms") + else if ui.flow_display then ui.flow_display.delete() ui.flow_display = nil @@ -457,14 +464,15 @@ function renderer.handle_resize(name) iocontrol.fp_monitor_state(idx, true) if engine.ui_ready then - engine.dmesg_window.setVisible(false) - + local draw_start = util.time_ms() local ok = pcall(function () ui.unit_displays[idx] = DisplayBox{window=device,fg_bg=style.root} unit_view(ui.unit_displays[idx], idx) end) - if not ok then + if ok then + log_render("unit " .. idx .. " view re-draw completed in " .. (util.time_ms() - draw_start) .. "ms") + else if ui.unit_displays[idx] then ui.unit_displays[idx].delete() ui.unit_displays[idx] = nil diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 750dde0..2ed9fdb 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -26,7 +26,7 @@ local CHUNK_LOAD_DELAY_S = 30.0 local println = util.println local println_ts = util.println_ts -local log_graphics = coordinator.log_graphics +local log_render = coordinator.log_render local log_sys = coordinator.log_sys local log_boot = coordinator.log_boot local log_comms = coordinator.log_comms @@ -126,7 +126,7 @@ local function main() -- lets get started! log.info("monitors ready, dmesg output incoming...") - log_graphics("displays connected and reset") + log_render("displays connected and reset") log_sys("system start on " .. os.date("%c")) log_boot("starting " .. COORDINATOR_VERSION) @@ -227,16 +227,16 @@ local function main() -- start front panel ---------------------------------------- - log_graphics("starting front panel UI...") + log_render("starting front panel UI...") local fp_message crd_state.fp_ok, fp_message = renderer.try_start_fp() if not crd_state.fp_ok then - log_graphics(util.c("front panel UI error: ", fp_message)) + log_render(util.c("front panel UI error: ", fp_message)) println_ts("front panel UI creation failed") log.fatal(util.c("front panel GUI render failed with error ", fp_message)) return - else log_graphics("front panel ready") end + else log_render("front panel ready") end ---------------------------------------- -- start system diff --git a/coordinator/threads.lua b/coordinator/threads.lua index 7c849b5..7a433f5 100644 --- a/coordinator/threads.lua +++ b/coordinator/threads.lua @@ -13,7 +13,7 @@ local apisessions = require("coordinator.session.apisessions") local core = require("graphics.core") -local log_graphics = coordinator.log_graphics +local log_render = coordinator.log_render local log_sys = coordinator.log_sys local log_comms = coordinator.log_comms @@ -267,17 +267,17 @@ function threads.thread__render(smem) -- received a command if msg.message == MQ__RENDER_CMD.START_MAIN_UI then -- start up the main UI - log_graphics("starting main UI...") + log_render("starting main UI...") local draw_start = util.time_ms() local ui_message crd_state.ui_ok, ui_message = renderer.try_start_ui() if not crd_state.ui_ok then - log_graphics(util.c("main UI error: ", ui_message)) + log_render(util.c("main UI error: ", ui_message)) log.fatal(util.c("main GUI render failed with error ", ui_message)) else - log_graphics("main UI draw took " .. (util.time_ms() - draw_start) .. "ms") + log_render("main UI draw took " .. (util.time_ms() - draw_start) .. "ms") end elseif msg.message == MQ__RENDER_CMD.UPDATE then -- new data