mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#219 fixed PLC renderer crash handling
This commit is contained in:
parent
be077aa1fb
commit
e9788abde7
File diff suppressed because one or more lines are too long
@ -12,7 +12,6 @@ local style = require("reactor-plc.panel.style")
|
||||
local core = require("graphics.core")
|
||||
local flasher = require("graphics.flasher")
|
||||
|
||||
local DisplayBox = require("graphics.elements.displaybox")
|
||||
local Div = require("graphics.elements.div")
|
||||
local Rectangle = require("graphics.elements.rectangle")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
@ -29,10 +28,8 @@ local cpair = core.graphics.cpair
|
||||
local border = core.graphics.border
|
||||
|
||||
-- create new main view
|
||||
---@param monitor table main viewscreen
|
||||
local function init(monitor)
|
||||
local panel = DisplayBox{window=monitor,fg_bg=style.root}
|
||||
|
||||
---@param panel table main displaybox
|
||||
local function init(panel)
|
||||
local header = TextBox{parent=panel,y=1,text="REACTOR PLC - UNIT ?",alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
|
||||
databus.rx_field("unit_id", function (id) header.set_value(util.c("REACTOR PLC - UNIT ", id)) end)
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
local comms = require("scada-common.comms")
|
||||
local const = require("scada-common.constants")
|
||||
local databus = require("reactor-plc.databus")
|
||||
local log = require("scada-common.log")
|
||||
local ppm = require("scada-common.ppm")
|
||||
local rsio = require("scada-common.rsio")
|
||||
local types = require("scada-common.types")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local databus = require("reactor-plc.databus")
|
||||
|
||||
local plc = {}
|
||||
|
||||
local RPS_TRIP_CAUSE = types.RPS_TRIP_CAUSE
|
||||
|
@ -2,20 +2,22 @@
|
||||
-- Graphics Rendering Control
|
||||
--
|
||||
|
||||
local style = require("reactor-plc.panel.style")
|
||||
local panel_view = require("reactor-plc.panel.front_panel")
|
||||
local style = require("reactor-plc.panel.style")
|
||||
|
||||
local flasher = require("graphics.flasher")
|
||||
|
||||
local DisplayBox = require("graphics.elements.displaybox")
|
||||
|
||||
local renderer = {}
|
||||
|
||||
local ui = {
|
||||
view = nil
|
||||
display = nil
|
||||
}
|
||||
|
||||
-- start the UI
|
||||
function renderer.start_ui()
|
||||
if ui.view == nil then
|
||||
if ui.display == nil then
|
||||
-- reset terminal
|
||||
term.setTextColor(colors.white)
|
||||
term.setBackgroundColor(colors.black)
|
||||
@ -31,7 +33,8 @@ function renderer.start_ui()
|
||||
flasher.run()
|
||||
|
||||
-- init front panel view
|
||||
ui.view = panel_view(term.current())
|
||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
|
||||
panel_view(ui.display)
|
||||
end
|
||||
end
|
||||
|
||||
@ -40,13 +43,13 @@ function renderer.close_ui()
|
||||
-- stop blinking indicators
|
||||
flasher.clear()
|
||||
|
||||
if ui.view ~= nil then
|
||||
if ui.display ~= nil then
|
||||
-- hide to stop animation callbacks
|
||||
ui.view.hide()
|
||||
ui.display.hide()
|
||||
end
|
||||
|
||||
-- clear root UI elements
|
||||
ui.view = nil
|
||||
ui.display = nil
|
||||
|
||||
-- restore colors
|
||||
for i = 1, #style.colors do
|
||||
@ -64,12 +67,14 @@ end
|
||||
-- is the UI ready?
|
||||
---@nodiscard
|
||||
---@return boolean ready
|
||||
function renderer.ui_ready() return ui.view ~= nil end
|
||||
function renderer.ui_ready() return ui.display ~= nil end
|
||||
|
||||
-- handle a mouse event
|
||||
---@param event mouse_interaction
|
||||
function renderer.handle_mouse(event)
|
||||
ui.view.handle_mouse(event)
|
||||
if ui.display ~= nil then
|
||||
ui.display.handle_mouse(event)
|
||||
end
|
||||
end
|
||||
|
||||
return renderer
|
||||
|
@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc")
|
||||
local renderer = require("reactor-plc.renderer")
|
||||
local threads = require("reactor-plc.threads")
|
||||
|
||||
local R_PLC_VERSION = "v1.1.11"
|
||||
local R_PLC_VERSION = "v1.1.12"
|
||||
|
||||
local println = util.println
|
||||
local println_ts = util.println_ts
|
||||
|
Loading…
Reference in New Issue
Block a user