mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#344 renderer integration with new assertion handling
This commit is contained in:
parent
560d48084a
commit
d38a2dea7c
@ -133,19 +133,30 @@ function renderer.init_dmesg()
|
|||||||
log.direct_dmesg(engine.dmesg_window)
|
log.direct_dmesg(engine.dmesg_window)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- start the coordinator front panel
|
-- try to start the front panel
|
||||||
function renderer.start_fp()
|
---@return boolean success, any error_msg
|
||||||
|
function renderer.try_start_fp()
|
||||||
|
local status, msg = true, nil
|
||||||
|
|
||||||
if not engine.fp_ready then
|
if not engine.fp_ready then
|
||||||
-- show front panel view on terminal
|
-- show front panel view on terminal
|
||||||
|
status, msg = pcall(function ()
|
||||||
engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root}
|
engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root}
|
||||||
panel_view(engine.ui.front_panel, #engine.monitors.unit_displays)
|
panel_view(engine.ui.front_panel, #engine.monitors.unit_displays)
|
||||||
|
end)
|
||||||
|
|
||||||
-- start flasher callback task
|
if status then
|
||||||
|
-- start flasher callback task and report ready
|
||||||
flasher.run()
|
flasher.run()
|
||||||
|
|
||||||
-- report front panel as ready
|
|
||||||
engine.fp_ready = true
|
engine.fp_ready = true
|
||||||
|
else
|
||||||
|
-- report fail and close front panel
|
||||||
|
msg = core.extract_assert_msg(msg)
|
||||||
|
renderer.close_fp()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return status, msg
|
||||||
end
|
end
|
||||||
|
|
||||||
-- close out the front panel
|
-- close out the front panel
|
||||||
@ -178,7 +189,7 @@ function renderer.close_fp()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- start the coordinator GUI
|
-- try to start the main GUI
|
||||||
---@return boolean success, any error_msg
|
---@return boolean success, any error_msg
|
||||||
function renderer.try_start_ui()
|
function renderer.try_start_ui()
|
||||||
local status, msg = true, nil
|
local status, msg = true, nil
|
||||||
|
@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder")
|
|||||||
|
|
||||||
local apisessions = require("coordinator.session.apisessions")
|
local apisessions = require("coordinator.session.apisessions")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "v1.0.15"
|
local COORDINATOR_VERSION = "v1.0.16"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -182,9 +182,8 @@ local function main()
|
|||||||
|
|
||||||
log_graphics("starting front panel UI...")
|
log_graphics("starting front panel UI...")
|
||||||
|
|
||||||
local fp_ok, fp_message = pcall(renderer.start_fp)
|
local fp_ok, fp_message = renderer.try_start_fp()
|
||||||
if not fp_ok then
|
if not fp_ok then
|
||||||
renderer.close_fp()
|
|
||||||
log_graphics(util.c("front panel UI error: ", fp_message))
|
log_graphics(util.c("front panel UI error: ", fp_message))
|
||||||
println_ts("front panel UI creation failed")
|
println_ts("front panel UI creation failed")
|
||||||
log.fatal(util.c("front panel GUI render failed with error ", fp_message))
|
log.fatal(util.c("front panel GUI render failed with error ", fp_message))
|
||||||
|
@ -5,18 +5,23 @@
|
|||||||
local main_view = require("pocket.ui.main")
|
local main_view = require("pocket.ui.main")
|
||||||
local style = require("pocket.ui.style")
|
local style = require("pocket.ui.style")
|
||||||
|
|
||||||
|
local core = require("graphics.core")
|
||||||
local flasher = require("graphics.flasher")
|
local flasher = require("graphics.flasher")
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
|
|
||||||
|
---@class pocket_renderer
|
||||||
local renderer = {}
|
local renderer = {}
|
||||||
|
|
||||||
local ui = {
|
local ui = {
|
||||||
display = nil
|
display = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
-- start the pocket GUI
|
-- try to start the pocket GUI
|
||||||
function renderer.start_ui()
|
---@return boolean success, any error_msg
|
||||||
|
function renderer.try_start_ui()
|
||||||
|
local status, msg = true, nil
|
||||||
|
|
||||||
if ui.display == nil then
|
if ui.display == nil then
|
||||||
-- reset screen
|
-- reset screen
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
@ -30,12 +35,22 @@ function renderer.start_ui()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- init front panel view
|
-- init front panel view
|
||||||
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
||||||
main_view(ui.display)
|
main_view(ui.display)
|
||||||
|
end)
|
||||||
|
|
||||||
|
if status then
|
||||||
-- start flasher callback task
|
-- start flasher callback task
|
||||||
flasher.run()
|
flasher.run()
|
||||||
|
else
|
||||||
|
-- report fail and close ui
|
||||||
|
msg = core.extract_assert_msg(msg)
|
||||||
|
renderer.close_ui()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return status, msg
|
||||||
end
|
end
|
||||||
|
|
||||||
-- close out the UI
|
-- close out the UI
|
||||||
|
@ -18,7 +18,7 @@ local iocontrol = require("pocket.iocontrol")
|
|||||||
local pocket = require("pocket.pocket")
|
local pocket = require("pocket.pocket")
|
||||||
local renderer = require("pocket.renderer")
|
local renderer = require("pocket.renderer")
|
||||||
|
|
||||||
local POCKET_VERSION = "v0.6.2-alpha"
|
local POCKET_VERSION = "v0.6.3-alpha"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -111,9 +111,8 @@ local function main()
|
|||||||
-- start the UI
|
-- start the UI
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
local ui_ok, message = pcall(renderer.start_ui)
|
local ui_ok, message = renderer.try_start_ui()
|
||||||
if not ui_ok then
|
if not ui_ok then
|
||||||
renderer.close_ui()
|
|
||||||
println(util.c("UI error: ", message))
|
println(util.c("UI error: ", message))
|
||||||
log.error(util.c("startup> GUI render failed with error ", message))
|
log.error(util.c("startup> GUI render failed with error ", message))
|
||||||
else
|
else
|
||||||
|
@ -5,18 +5,23 @@
|
|||||||
local panel_view = require("reactor-plc.panel.front_panel")
|
local panel_view = require("reactor-plc.panel.front_panel")
|
||||||
local style = require("reactor-plc.panel.style")
|
local style = require("reactor-plc.panel.style")
|
||||||
|
|
||||||
|
local core = require("graphics.core")
|
||||||
local flasher = require("graphics.flasher")
|
local flasher = require("graphics.flasher")
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
|
|
||||||
|
---@class reactor_plc_renderer
|
||||||
local renderer = {}
|
local renderer = {}
|
||||||
|
|
||||||
local ui = {
|
local ui = {
|
||||||
display = nil
|
display = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
-- start the UI
|
-- try to start the UI
|
||||||
function renderer.start_ui()
|
---@return boolean success, any error_msg
|
||||||
|
function renderer.try_start_ui()
|
||||||
|
local status, msg = true, nil
|
||||||
|
|
||||||
if ui.display == nil then
|
if ui.display == nil then
|
||||||
-- reset terminal
|
-- reset terminal
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
@ -30,12 +35,22 @@ function renderer.start_ui()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- init front panel view
|
-- init front panel view
|
||||||
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
||||||
panel_view(ui.display)
|
panel_view(ui.display)
|
||||||
|
end)
|
||||||
|
|
||||||
|
if status then
|
||||||
-- start flasher callback task
|
-- start flasher callback task
|
||||||
flasher.run()
|
flasher.run()
|
||||||
|
else
|
||||||
|
-- report fail and close ui
|
||||||
|
msg = core.extract_assert_msg(msg)
|
||||||
|
renderer.close_ui()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return status, msg
|
||||||
end
|
end
|
||||||
|
|
||||||
-- close out the UI
|
-- close out the UI
|
||||||
|
@ -19,7 +19,7 @@ local plc = require("reactor-plc.plc")
|
|||||||
local renderer = require("reactor-plc.renderer")
|
local renderer = require("reactor-plc.renderer")
|
||||||
local threads = require("reactor-plc.threads")
|
local threads = require("reactor-plc.threads")
|
||||||
|
|
||||||
local R_PLC_VERSION = "v1.5.9"
|
local R_PLC_VERSION = "v1.5.10"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -184,10 +184,9 @@ local function main()
|
|||||||
-- front panel time!
|
-- front panel time!
|
||||||
if not renderer.ui_ready() then
|
if not renderer.ui_ready() then
|
||||||
local message
|
local message
|
||||||
plc_state.fp_ok, message = pcall(renderer.start_ui)
|
plc_state.fp_ok, message = renderer.try_start_ui()
|
||||||
|
|
||||||
if not plc_state.fp_ok then
|
if not plc_state.fp_ok then
|
||||||
renderer.close_ui()
|
|
||||||
println_ts(util.c("UI error: ", message))
|
println_ts(util.c("UI error: ", message))
|
||||||
println("init> running without front panel")
|
println("init> running without front panel")
|
||||||
log.error(util.c("front panel GUI render failed with error ", message))
|
log.error(util.c("front panel GUI render failed with error ", message))
|
||||||
|
@ -5,19 +5,24 @@
|
|||||||
local panel_view = require("rtu.panel.front_panel")
|
local panel_view = require("rtu.panel.front_panel")
|
||||||
local style = require("rtu.panel.style")
|
local style = require("rtu.panel.style")
|
||||||
|
|
||||||
|
local core = require("graphics.core")
|
||||||
local flasher = require("graphics.flasher")
|
local flasher = require("graphics.flasher")
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
|
|
||||||
|
---@class rtu_renderer
|
||||||
local renderer = {}
|
local renderer = {}
|
||||||
|
|
||||||
local ui = {
|
local ui = {
|
||||||
display = nil
|
display = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
-- start the UI
|
-- try to start the UI
|
||||||
---@param units table RTU units
|
---@param units table RTU units
|
||||||
function renderer.start_ui(units)
|
---@return boolean success, any error_msg
|
||||||
|
function renderer.try_start_ui(units)
|
||||||
|
local status, msg = true, nil
|
||||||
|
|
||||||
if ui.display == nil then
|
if ui.display == nil then
|
||||||
-- reset terminal
|
-- reset terminal
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
@ -30,13 +35,23 @@ function renderer.start_ui(units)
|
|||||||
term.setPaletteColor(style.colors[i].c, style.colors[i].hex)
|
term.setPaletteColor(style.colors[i].c, style.colors[i].hex)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- start flasher callback task
|
|
||||||
flasher.run()
|
|
||||||
|
|
||||||
-- init front panel view
|
-- init front panel view
|
||||||
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
||||||
panel_view(ui.display, units)
|
panel_view(ui.display, units)
|
||||||
|
end)
|
||||||
|
|
||||||
|
if status then
|
||||||
|
-- start flasher callback task
|
||||||
|
flasher.run()
|
||||||
|
else
|
||||||
|
-- report fail and close ui
|
||||||
|
msg = core.extract_assert_msg(msg)
|
||||||
|
renderer.close_ui()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return status, msg
|
||||||
end
|
end
|
||||||
|
|
||||||
-- close out the UI
|
-- close out the UI
|
||||||
|
@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
|||||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||||
|
|
||||||
local RTU_VERSION = "v1.6.5"
|
local RTU_VERSION = "v1.6.6"
|
||||||
|
|
||||||
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
|
||||||
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
|
||||||
@ -480,10 +480,9 @@ local function main()
|
|||||||
if configure() then
|
if configure() then
|
||||||
-- start UI
|
-- start UI
|
||||||
local message
|
local message
|
||||||
rtu_state.fp_ok, message = pcall(renderer.start_ui, units)
|
rtu_state.fp_ok, message = renderer.try_start_ui(units)
|
||||||
|
|
||||||
if not rtu_state.fp_ok then
|
if not rtu_state.fp_ok then
|
||||||
renderer.close_ui()
|
|
||||||
println_ts(util.c("UI error: ", message))
|
println_ts(util.c("UI error: ", message))
|
||||||
println("startup> running without front panel")
|
println("startup> running without front panel")
|
||||||
log.error(util.c("front panel GUI render failed with error ", message))
|
log.error(util.c("front panel GUI render failed with error ", message))
|
||||||
|
@ -6,18 +6,23 @@ local panel_view = require("supervisor.panel.front_panel")
|
|||||||
local pgi = require("supervisor.panel.pgi")
|
local pgi = require("supervisor.panel.pgi")
|
||||||
local style = require("supervisor.panel.style")
|
local style = require("supervisor.panel.style")
|
||||||
|
|
||||||
|
local core = require("graphics.core")
|
||||||
local flasher = require("graphics.flasher")
|
local flasher = require("graphics.flasher")
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
|
|
||||||
|
---@class supervisor_renderer
|
||||||
local renderer = {}
|
local renderer = {}
|
||||||
|
|
||||||
local ui = {
|
local ui = {
|
||||||
display = nil
|
display = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
-- start the UI
|
-- try to start the UI
|
||||||
function renderer.start_ui()
|
---@return boolean success, any error_msg
|
||||||
|
function renderer.try_start_ui()
|
||||||
|
local status, msg = true, nil
|
||||||
|
|
||||||
if ui.display == nil then
|
if ui.display == nil then
|
||||||
-- reset terminal
|
-- reset terminal
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
@ -31,12 +36,22 @@ function renderer.start_ui()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- init front panel view
|
-- init front panel view
|
||||||
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
||||||
panel_view(ui.display)
|
panel_view(ui.display)
|
||||||
|
end)
|
||||||
|
|
||||||
|
if status then
|
||||||
-- start flasher callback task
|
-- start flasher callback task
|
||||||
flasher.run()
|
flasher.run()
|
||||||
|
else
|
||||||
|
-- report fail and close ui
|
||||||
|
msg = core.extract_assert_msg(msg)
|
||||||
|
renderer.close_ui()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return status, msg
|
||||||
end
|
end
|
||||||
|
|
||||||
-- close out the UI
|
-- close out the UI
|
||||||
|
@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor")
|
|||||||
|
|
||||||
local svsessions = require("supervisor.session.svsessions")
|
local svsessions = require("supervisor.session.svsessions")
|
||||||
|
|
||||||
local SUPERVISOR_VERSION = "v1.0.5"
|
local SUPERVISOR_VERSION = "v1.0.6"
|
||||||
|
|
||||||
local println = util.println
|
local println = util.println
|
||||||
local println_ts = util.println_ts
|
local println_ts = util.println_ts
|
||||||
@ -117,10 +117,9 @@ local function main()
|
|||||||
databus.tx_hw_modem(true)
|
databus.tx_hw_modem(true)
|
||||||
|
|
||||||
-- start UI
|
-- start UI
|
||||||
local fp_ok, message = pcall(renderer.start_ui)
|
local fp_ok, message = renderer.try_start_ui()
|
||||||
|
|
||||||
if not fp_ok then
|
if not fp_ok then
|
||||||
renderer.close_ui()
|
|
||||||
println_ts(util.c("UI error: ", message))
|
println_ts(util.c("UI error: ", message))
|
||||||
log.error(util.c("front panel GUI render failed with error ", message))
|
log.error(util.c("front panel GUI render failed with error ", message))
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user