mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#496 threaded app loading
This commit is contained in:
parent
38457cfbbc
commit
def5b49327
@ -29,225 +29,17 @@ local LINK_STATE = {
|
||||
|
||||
iocontrol.LINK_STATE = LINK_STATE
|
||||
|
||||
---@enum POCKET_APP_ID
|
||||
local APP_ID = {
|
||||
ROOT = 1,
|
||||
-- main app page
|
||||
UNITS = 2,
|
||||
GUIDE = 3,
|
||||
ABOUT = 4,
|
||||
-- diag app page
|
||||
ALARMS = 5,
|
||||
-- other
|
||||
DUMMY = 6,
|
||||
NUM_APPS = 6
|
||||
}
|
||||
|
||||
iocontrol.APP_ID = APP_ID
|
||||
|
||||
---@class pocket_ioctl
|
||||
local io = {
|
||||
version = "unknown",
|
||||
ps = psil.create()
|
||||
}
|
||||
|
||||
---@class nav_tree_page
|
||||
---@field _p nav_tree_page|nil page's parent
|
||||
---@field _c table page's children
|
||||
---@field nav_to function function to navigate to this page
|
||||
---@field switcher function|nil function to switch between children
|
||||
---@field tasks table tasks to run while viewing this page
|
||||
|
||||
-- allocate the page navigation system
|
||||
function iocontrol.alloc_nav()
|
||||
local self = {
|
||||
pane = nil, ---@type graphics_element
|
||||
apps = {},
|
||||
containers = {},
|
||||
help_map = {},
|
||||
help_return = nil,
|
||||
cur_app = APP_ID.ROOT
|
||||
}
|
||||
|
||||
self.cur_page = self.root
|
||||
|
||||
---@class pocket_nav
|
||||
io.nav = {}
|
||||
|
||||
-- set the root pane element to switch between apps with
|
||||
---@param root_pane graphics_element
|
||||
function io.nav.set_pane(root_pane)
|
||||
self.pane = root_pane
|
||||
end
|
||||
|
||||
function io.nav.set_sidebar(sidebar)
|
||||
self.sidebar = sidebar
|
||||
end
|
||||
|
||||
-- register an app
|
||||
---@param app_id POCKET_APP_ID app ID
|
||||
---@param container graphics_element element that contains this app (usually a Div)
|
||||
---@param pane graphics_element? multipane if this is a simple paned app, then nav_to must be a number
|
||||
function io.nav.register_app(app_id, container, pane)
|
||||
---@class pocket_app
|
||||
local app = {
|
||||
loaded = false,
|
||||
load = nil,
|
||||
cur_page = nil, ---@type nav_tree_page
|
||||
pane = pane,
|
||||
paned_pages = {},
|
||||
sidebar_items = {}
|
||||
}
|
||||
|
||||
app.load = function () app.loaded = true end
|
||||
|
||||
-- delayed set of the pane if it wasn't ready at the start
|
||||
---@param root_pane graphics_element multipane
|
||||
function app.set_root_pane(root_pane)
|
||||
app.pane = root_pane
|
||||
end
|
||||
|
||||
function app.set_sidebar(items)
|
||||
app.sidebar_items = items
|
||||
if self.sidebar then self.sidebar.update(items) end
|
||||
end
|
||||
|
||||
-- function to run on initial load into memory
|
||||
---@param on_load function callback
|
||||
function app.set_on_load(on_load)
|
||||
app.load = function ()
|
||||
on_load()
|
||||
app.loaded = true
|
||||
end
|
||||
end
|
||||
|
||||
-- if a pane was provided, this will switch between numbered pages
|
||||
---@param idx integer page index
|
||||
function app.switcher(idx)
|
||||
if app.paned_pages[idx] then
|
||||
app.paned_pages[idx].nav_to()
|
||||
end
|
||||
end
|
||||
|
||||
-- create a new page entry in the app's page navigation tree
|
||||
---@param parent nav_tree_page? a parent page or nil to set this as the root
|
||||
---@param nav_to function|integer function to navigate to this page or pane index
|
||||
---@return nav_tree_page new_page this new page
|
||||
function app.new_page(parent, nav_to)
|
||||
---@type nav_tree_page
|
||||
local page = { _p = parent, _c = {}, nav_to = function () end, switcher = function () end, tasks = {} }
|
||||
|
||||
if parent == nil and app.cur_page == nil then
|
||||
app.cur_page = page
|
||||
end
|
||||
|
||||
if type(nav_to) == "number" then
|
||||
app.paned_pages[nav_to] = page
|
||||
|
||||
function page.nav_to()
|
||||
app.cur_page = page
|
||||
if app.pane then app.pane.set_value(nav_to) end
|
||||
end
|
||||
else
|
||||
function page.nav_to()
|
||||
app.cur_page = page
|
||||
nav_to()
|
||||
end
|
||||
end
|
||||
|
||||
-- switch between children
|
||||
---@param id integer child ID
|
||||
function page.switcher(id) if page._c[id] then page._c[id].nav_to() end end
|
||||
|
||||
if parent ~= nil then
|
||||
table.insert(page._p._c, page)
|
||||
end
|
||||
|
||||
return page
|
||||
end
|
||||
|
||||
-- get the currently active page
|
||||
function app.get_current_page() return app.cur_page end
|
||||
|
||||
-- attempt to navigate up the tree
|
||||
---@return boolean success true if successfully navigated up
|
||||
function app.nav_up()
|
||||
local parent = app.cur_page._p
|
||||
if parent then parent.nav_to() end
|
||||
return parent ~= nil
|
||||
end
|
||||
|
||||
self.apps[app_id] = app
|
||||
self.containers[app_id] = container
|
||||
|
||||
return app
|
||||
end
|
||||
|
||||
-- open a given app
|
||||
---@param app_id POCKET_APP_ID
|
||||
function io.nav.open_app(app_id)
|
||||
-- reset help return on navigating out of an app
|
||||
if app_id == APP_ID.ROOT then self.help_return = nil end
|
||||
|
||||
local app = self.apps[app_id] ---@type pocket_app
|
||||
if app then
|
||||
if not app.loaded then app.load() end
|
||||
|
||||
self.cur_app = app_id
|
||||
self.pane.set_value(app_id)
|
||||
|
||||
if #app.sidebar_items > 0 then
|
||||
self.sidebar.update(app.sidebar_items)
|
||||
end
|
||||
else
|
||||
log.debug("tried to open unknown app")
|
||||
end
|
||||
end
|
||||
|
||||
-- get a list of the app containers (usually Div elements)
|
||||
function io.nav.get_containers() return self.containers end
|
||||
|
||||
-- get the currently active page
|
||||
---@return nav_tree_page
|
||||
function io.nav.get_current_page()
|
||||
return self.apps[self.cur_app].get_current_page()
|
||||
end
|
||||
|
||||
-- attempt to navigate up
|
||||
function io.nav.nav_up()
|
||||
-- return out of help if opened with open_help
|
||||
if self.help_return then
|
||||
io.nav.open_app(self.help_return)
|
||||
self.help_return = nil
|
||||
return
|
||||
end
|
||||
|
||||
local app = self.apps[self.cur_app] ---@type pocket_app
|
||||
log.debug("attempting app nav up for app " .. self.cur_app)
|
||||
|
||||
if not app.nav_up() then
|
||||
log.debug("internal app nav up failed, going to home screen")
|
||||
io.nav.open_app(APP_ID.ROOT)
|
||||
end
|
||||
end
|
||||
|
||||
-- open the help app, to show the reference for a key
|
||||
function io.nav.open_help(key)
|
||||
self.help_return = self.cur_app
|
||||
|
||||
io.nav.open_app(APP_ID.GUIDE)
|
||||
|
||||
local load = self.help_map[key]
|
||||
if load then load() end
|
||||
end
|
||||
|
||||
function io.nav.link_help(map) self.help_map = map end
|
||||
end
|
||||
|
||||
-- initialize facility-independent components of pocket iocontrol
|
||||
---@param comms pocket_comms
|
||||
function iocontrol.init_core(comms)
|
||||
iocontrol.alloc_nav()
|
||||
---@param nav pocket_nav
|
||||
function iocontrol.init_core(comms, nav)
|
||||
io.nav = nav
|
||||
|
||||
---@class pocket_ioctl_diag
|
||||
io.diag = {}
|
||||
@ -858,7 +650,7 @@ function iocontrol.record_unit_data(data)
|
||||
|
||||
--#endregion
|
||||
|
||||
--#region Advanced Alarm Information Display
|
||||
--#region Status Information Display
|
||||
|
||||
local ecam = {} -- aviation reference :) back to VATSIM I go...
|
||||
|
||||
|
@ -14,6 +14,18 @@ local LINK_STATE = iocontrol.LINK_STATE
|
||||
|
||||
local pocket = {}
|
||||
|
||||
local MQ__RENDER_CMD = {
|
||||
UNLOAD_SV_APPS = 1,
|
||||
UNLOAD_API_APPS = 2
|
||||
}
|
||||
|
||||
local MQ__RENDER_DATA = {
|
||||
LOAD_APP = 1
|
||||
}
|
||||
|
||||
pocket.MQ__RENDER_CMD = MQ__RENDER_CMD
|
||||
pocket.MQ__RENDER_DATA = MQ__RENDER_DATA
|
||||
|
||||
---@type pkt_config
|
||||
local config = {}
|
||||
|
||||
@ -63,6 +75,225 @@ function pocket.load_config()
|
||||
return cfv.valid()
|
||||
end
|
||||
|
||||
---@enum POCKET_APP_ID
|
||||
local APP_ID = {
|
||||
ROOT = 1,
|
||||
-- main app pages
|
||||
UNITS = 2,
|
||||
GUIDE = 3,
|
||||
ABOUT = 4,
|
||||
-- diag app page
|
||||
ALARMS = 5,
|
||||
-- other
|
||||
DUMMY = 6,
|
||||
NUM_APPS = 6
|
||||
}
|
||||
|
||||
pocket.APP_ID = APP_ID
|
||||
|
||||
---@class nav_tree_page
|
||||
---@field _p nav_tree_page|nil page's parent
|
||||
---@field _c table page's children
|
||||
---@field nav_to function function to navigate to this page
|
||||
---@field switcher function|nil function to switch between children
|
||||
---@field tasks table tasks to run while viewing this page
|
||||
|
||||
-- allocate the page navigation system
|
||||
---@param render_queue mqueue
|
||||
function pocket.init_nav(render_queue)
|
||||
local self = {
|
||||
pane = nil, ---@type graphics_element
|
||||
apps = {},
|
||||
containers = {},
|
||||
help_map = {},
|
||||
help_return = nil,
|
||||
cur_app = APP_ID.ROOT
|
||||
}
|
||||
|
||||
self.cur_page = self.root
|
||||
|
||||
---@class pocket_nav
|
||||
local nav = {}
|
||||
|
||||
-- set the root pane element to switch between apps with
|
||||
---@param root_pane graphics_element
|
||||
function nav.set_pane(root_pane)
|
||||
self.pane = root_pane
|
||||
end
|
||||
|
||||
function nav.set_sidebar(sidebar)
|
||||
self.sidebar = sidebar
|
||||
end
|
||||
|
||||
-- register an app
|
||||
---@param app_id POCKET_APP_ID app ID
|
||||
---@param container graphics_element element that contains this app (usually a Div)
|
||||
---@param pane graphics_element? multipane if this is a simple paned app, then nav_to must be a number
|
||||
function nav.register_app(app_id, container, pane)
|
||||
---@class pocket_app
|
||||
local app = {
|
||||
loaded = false,
|
||||
load = nil,
|
||||
cur_page = nil, ---@type nav_tree_page
|
||||
pane = pane,
|
||||
paned_pages = {},
|
||||
sidebar_items = {}
|
||||
}
|
||||
|
||||
app.load = function () app.loaded = true end
|
||||
|
||||
-- delayed set of the pane if it wasn't ready at the start
|
||||
---@param root_pane graphics_element multipane
|
||||
function app.set_root_pane(root_pane)
|
||||
app.pane = root_pane
|
||||
end
|
||||
|
||||
function app.set_sidebar(items)
|
||||
app.sidebar_items = items
|
||||
if self.sidebar then self.sidebar.update(items) end
|
||||
end
|
||||
|
||||
-- function to run on initial load into memory
|
||||
---@param on_load function callback
|
||||
function app.set_on_load(on_load)
|
||||
app.load = function ()
|
||||
on_load()
|
||||
app.loaded = true
|
||||
end
|
||||
end
|
||||
|
||||
-- if a pane was provided, this will switch between numbered pages
|
||||
---@param idx integer page index
|
||||
function app.switcher(idx)
|
||||
if app.paned_pages[idx] then
|
||||
app.paned_pages[idx].nav_to()
|
||||
end
|
||||
end
|
||||
|
||||
-- create a new page entry in the app's page navigation tree
|
||||
---@param parent nav_tree_page? a parent page or nil to set this as the root
|
||||
---@param nav_to function|integer function to navigate to this page or pane index
|
||||
---@return nav_tree_page new_page this new page
|
||||
function app.new_page(parent, nav_to)
|
||||
---@type nav_tree_page
|
||||
local page = { _p = parent, _c = {}, nav_to = function () end, switcher = function () end, tasks = {} }
|
||||
|
||||
if parent == nil and app.cur_page == nil then
|
||||
app.cur_page = page
|
||||
end
|
||||
|
||||
if type(nav_to) == "number" then
|
||||
app.paned_pages[nav_to] = page
|
||||
|
||||
function page.nav_to()
|
||||
app.cur_page = page
|
||||
if app.pane then app.pane.set_value(nav_to) end
|
||||
end
|
||||
else
|
||||
function page.nav_to()
|
||||
app.cur_page = page
|
||||
nav_to()
|
||||
end
|
||||
end
|
||||
|
||||
-- switch between children
|
||||
---@param id integer child ID
|
||||
function page.switcher(id) if page._c[id] then page._c[id].nav_to() end end
|
||||
|
||||
if parent ~= nil then
|
||||
table.insert(page._p._c, page)
|
||||
end
|
||||
|
||||
return page
|
||||
end
|
||||
|
||||
-- get the currently active page
|
||||
function app.get_current_page() return app.cur_page end
|
||||
|
||||
-- attempt to navigate up the tree
|
||||
---@return boolean success true if successfully navigated up
|
||||
function app.nav_up()
|
||||
local parent = app.cur_page._p
|
||||
if parent then parent.nav_to() end
|
||||
return parent ~= nil
|
||||
end
|
||||
|
||||
self.apps[app_id] = app
|
||||
self.containers[app_id] = container
|
||||
|
||||
return app
|
||||
end
|
||||
|
||||
-- open a given app
|
||||
---@param app_id POCKET_APP_ID
|
||||
function nav.open_app(app_id)
|
||||
-- reset help return on navigating out of an app
|
||||
if app_id == APP_ID.ROOT then self.help_return = nil end
|
||||
|
||||
local app = self.apps[app_id] ---@type pocket_app
|
||||
if app then
|
||||
if not app.loaded then render_queue.push_data(MQ__RENDER_DATA.LOAD_APP, app_id) end
|
||||
|
||||
self.cur_app = app_id
|
||||
self.pane.set_value(app_id)
|
||||
|
||||
if #app.sidebar_items > 0 then
|
||||
self.sidebar.update(app.sidebar_items)
|
||||
end
|
||||
else
|
||||
log.debug("tried to open unknown app")
|
||||
end
|
||||
end
|
||||
|
||||
-- load a given app
|
||||
---@param app_id POCKET_APP_ID
|
||||
function nav.load_app(app_id)
|
||||
self.apps[app_id].load()
|
||||
end
|
||||
|
||||
-- get a list of the app containers (usually Div elements)
|
||||
function nav.get_containers() return self.containers end
|
||||
|
||||
-- get the currently active page
|
||||
---@return nav_tree_page
|
||||
function nav.get_current_page()
|
||||
return self.apps[self.cur_app].get_current_page()
|
||||
end
|
||||
|
||||
-- attempt to navigate up
|
||||
function nav.nav_up()
|
||||
-- return out of help if opened with open_help
|
||||
if self.help_return then
|
||||
nav.open_app(self.help_return)
|
||||
self.help_return = nil
|
||||
return
|
||||
end
|
||||
|
||||
local app = self.apps[self.cur_app] ---@type pocket_app
|
||||
log.debug("attempting app nav up for app " .. self.cur_app)
|
||||
|
||||
if not app.nav_up() then
|
||||
log.debug("internal app nav up failed, going to home screen")
|
||||
nav.open_app(APP_ID.ROOT)
|
||||
end
|
||||
end
|
||||
|
||||
-- open the help app, to show the reference for a key
|
||||
function nav.open_help(key)
|
||||
self.help_return = self.cur_app
|
||||
|
||||
nav.open_app(APP_ID.GUIDE)
|
||||
|
||||
local load = self.help_map[key]
|
||||
if load then load() end
|
||||
end
|
||||
|
||||
-- link the help map from the guide app
|
||||
function nav.link_help(map) self.help_map = map end
|
||||
|
||||
return nav
|
||||
end
|
||||
|
||||
-- pocket coordinator + supervisor communications
|
||||
---@nodiscard
|
||||
---@param version string pocket version
|
||||
|
@ -103,7 +103,8 @@ local function main()
|
||||
nic = nil, ---@type nic
|
||||
pocket_comms = nil, ---@type pocket_comms
|
||||
sv_wd = nil, ---@type watchdog
|
||||
api_wd = nil ---@type watchdog
|
||||
api_wd = nil, ---@type watchdog
|
||||
nav = nil ---@type pocket_nav
|
||||
},
|
||||
|
||||
-- message queues
|
||||
@ -118,7 +119,7 @@ local function main()
|
||||
local pkt_state = __shared_memory.pkt_state
|
||||
|
||||
----------------------------------------
|
||||
-- setup communications & clocks
|
||||
-- setup system
|
||||
----------------------------------------
|
||||
|
||||
-- message authentication init
|
||||
@ -147,8 +148,9 @@ local function main()
|
||||
smem_sys.pocket_comms = pocket.comms(POCKET_VERSION, smem_sys.nic, smem_sys.sv_wd, smem_sys.api_wd)
|
||||
log.debug("startup> comms init")
|
||||
|
||||
-- init I/O control
|
||||
iocontrol.init_core(smem_sys.pocket_comms)
|
||||
-- init nav and I/O handler
|
||||
smem_sys.nav = pocket.init_nav(__shared_memory.q.mq_render)
|
||||
iocontrol.init_core(smem_sys.pocket_comms, smem_sys.nav)
|
||||
|
||||
----------------------------------------
|
||||
-- start the UI
|
||||
|
@ -4,7 +4,7 @@ local ppm = require("scada-common.ppm")
|
||||
local tcd = require("scada-common.tcd")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local pocket = require("pocket.pocket")
|
||||
local renderer = require("pocket.renderer")
|
||||
|
||||
local core = require("graphics.core")
|
||||
@ -14,14 +14,8 @@ local threads = {}
|
||||
local MAIN_CLOCK = 0.5 -- (2Hz, 10 ticks)
|
||||
local RENDER_SLEEP = 100 -- (100ms, 2 ticks)
|
||||
|
||||
local MQ__RENDER_CMD = {
|
||||
UNLOAD_SV_APPS = 1,
|
||||
UNLOAD_API_APPS = 2
|
||||
}
|
||||
|
||||
local MQ__RENDER_DATA = {
|
||||
LOAD_APP = 1
|
||||
}
|
||||
local MQ__RENDER_CMD = pocket.MQ__RENDER_CMD
|
||||
local MQ__RENDER_DATA = pocket.MQ__RENDER_DATA
|
||||
|
||||
-- main thread
|
||||
---@nodiscard
|
||||
@ -44,15 +38,13 @@ function threads.thread__main(smem)
|
||||
local pocket_comms = smem.pkt_sys.pocket_comms
|
||||
local sv_wd = smem.pkt_sys.sv_wd
|
||||
local api_wd = smem.pkt_sys.api_wd
|
||||
local nav = smem.pkt_sys.nav
|
||||
|
||||
-- start connection watchdogs
|
||||
sv_wd.feed()
|
||||
api_wd.feed()
|
||||
log.debug("startup> conn watchdogs started")
|
||||
|
||||
local io_db = iocontrol.get_db()
|
||||
local nav = io_db.nav
|
||||
|
||||
-- event loop
|
||||
while true do
|
||||
local event, param1, param2, param3, param4, param5 = util.pull_event()
|
||||
@ -152,9 +144,12 @@ function threads.thread__render(smem)
|
||||
-- load in from shared memory
|
||||
local pkt_state = smem.pkt_state
|
||||
local render_queue = smem.q.mq_render
|
||||
local nav = smem.pkt_sys.nav
|
||||
|
||||
local last_update = util.time()
|
||||
|
||||
local ui_message
|
||||
|
||||
-- thread loop
|
||||
while true do
|
||||
-- check for messages in the message queue
|
||||
@ -172,6 +167,16 @@ function threads.thread__render(smem)
|
||||
local cmd = msg.message ---@type queue_data
|
||||
|
||||
if cmd.key == MQ__RENDER_DATA.LOAD_APP then
|
||||
log.debug("RENDER: load app " .. cmd.val)
|
||||
|
||||
local draw_start = util.time_ms()
|
||||
|
||||
pkt_state.ui_ok, ui_message = pcall(function () nav.load_app(cmd.val) end)
|
||||
if not pkt_state.ui_ok then
|
||||
log.fatal(util.c("RENDER: app load failed with error ", ui_message))
|
||||
else
|
||||
log.debug("RENDER: app loaded in " .. (util.time_ms() - draw_start) .. "ms")
|
||||
end
|
||||
end
|
||||
elseif msg.qtype == mqueue.TYPE.PACKET then
|
||||
-- received a packet
|
||||
|
@ -3,6 +3,7 @@
|
||||
--
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local pocket = require("pocket.pocket")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
@ -15,9 +16,10 @@ local Checkbox = require("graphics.elements.controls.checkbox")
|
||||
local PushButton = require("graphics.elements.controls.push_button")
|
||||
local SwitchButton = require("graphics.elements.controls.switch_button")
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local cpair = core.cpair
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local APP_ID = pocket.APP_ID
|
||||
|
||||
-- create diagnostic app pages
|
||||
---@param root graphics_element parent
|
||||
@ -30,7 +32,7 @@ local function create_pages(root)
|
||||
|
||||
local alarm_test = Div{parent=root,x=1,y=1}
|
||||
|
||||
local alarm_app = db.nav.register_app(iocontrol.APP_ID.ALARMS, alarm_test)
|
||||
local alarm_app = db.nav.register_app(APP_ID.ALARMS, alarm_test)
|
||||
|
||||
local page = alarm_app.new_page(nil, function () end)
|
||||
page.tasks = { db.diag.tone_test.get_tone_states }
|
||||
|
@ -3,12 +3,15 @@
|
||||
--
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local pocket = require("pocket.pocket")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local APP_ID = pocket.APP_ID
|
||||
|
||||
-- create placeholder app page
|
||||
---@param root graphics_element parent
|
||||
local function create_pages(root)
|
||||
@ -16,7 +19,7 @@ local function create_pages(root)
|
||||
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
|
||||
db.nav.register_app(iocontrol.APP_ID.DUMMY, main).new_page(nil, function () end)
|
||||
db.nav.register_app(APP_ID.DUMMY, main).new_page(nil, function () end)
|
||||
|
||||
TextBox{parent=main,text="This app is not implemented yet.",x=1,y=2,alignment=core.ALIGN.CENTER}
|
||||
|
||||
|
@ -3,13 +3,12 @@
|
||||
--
|
||||
|
||||
local util = require("scada-common.util")
|
||||
-- local log = require("scada-common.log")
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local TextField = require("graphics.elements.form.text_field")
|
||||
local pocket = require("pocket.pocket")
|
||||
|
||||
local docs = require("pocket.ui.docs")
|
||||
local style = require("pocket.ui.style")
|
||||
-- local style = require("pocket.ui.style")
|
||||
|
||||
local guide_section = require("pocket.ui.pages.guide_section")
|
||||
|
||||
@ -20,33 +19,44 @@ local ListBox = require("graphics.elements.listbox")
|
||||
local MultiPane = require("graphics.elements.multipane")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local WaitingAnim = require("graphics.elements.animations.waiting")
|
||||
|
||||
local PushButton = require("graphics.elements.controls.push_button")
|
||||
|
||||
local TextField = require("graphics.elements.form.text_field")
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local cpair = core.cpair
|
||||
|
||||
local label = style.label
|
||||
-- local lu_col = style.label_unit_pair
|
||||
local text_fg = style.text_fg
|
||||
local APP_ID = pocket.APP_ID
|
||||
|
||||
-- local label = style.label
|
||||
-- local lu_col = style.label_unit_pair
|
||||
-- local text_fg = style.text_fg
|
||||
|
||||
-- new system guide view
|
||||
---@param root graphics_element parent
|
||||
local function new_view(root)
|
||||
local db = iocontrol.get_db()
|
||||
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
local frame = Div{parent=root,x=1,y=1}
|
||||
|
||||
local app = db.nav.register_app(iocontrol.APP_ID.GUIDE, main)
|
||||
local app = db.nav.register_app(APP_ID.GUIDE, frame)
|
||||
|
||||
TextBox{parent=main,y=2,text="Guide",height=1,alignment=ALIGN.CENTER}
|
||||
TextBox{parent=main,y=4,text="Loading...",height=1,alignment=ALIGN.CENTER}
|
||||
local load_div = Div{parent=frame,x=1,y=1}
|
||||
local main = Div{parent=frame,x=1,y=1}
|
||||
|
||||
TextBox{parent=load_div,y=12,text="Loading...",height=1,alignment=ALIGN.CENTER}
|
||||
WaitingAnim{parent=load_div,x=math.floor(main.get_width()/2)-1,y=8,fg_bg=cpair(colors.cyan,colors._INHERIT)}
|
||||
|
||||
local load_pane = MultiPane{parent=main,x=1,y=1,panes={load_div,main}}
|
||||
|
||||
local btn_fg_bg = cpair(colors.cyan, colors.black)
|
||||
local btn_active = cpair(colors.white, colors.black)
|
||||
local btn_disable = cpair(colors.gray, colors.black)
|
||||
|
||||
local list = {
|
||||
{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(iocontrol.APP_ID.ROOT) end },
|
||||
{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end },
|
||||
{ label = " \x14 ", color = core.cpair(colors.black, colors.cyan), callback = function () app.switcher(1) end },
|
||||
{ label = "__?", color = core.cpair(colors.black, colors.lightGray), callback = function () app.switcher(2) end }
|
||||
}
|
||||
@ -142,6 +152,8 @@ local function new_view(root)
|
||||
|
||||
TextBox{parent=search_results,text="Click 'GO' to search..."}
|
||||
|
||||
util.nop()
|
||||
|
||||
TextBox{parent=use,y=1,text="System Usage",height=1,alignment=ALIGN.CENTER}
|
||||
PushButton{parent=use,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=main_page.nav_to}
|
||||
|
||||
@ -202,6 +214,9 @@ local function new_view(root)
|
||||
|
||||
-- link help resources
|
||||
db.nav.link_help(doc_map)
|
||||
|
||||
-- done, show the app
|
||||
load_pane.set_value(2)
|
||||
end
|
||||
|
||||
app.set_on_load(load)
|
||||
|
@ -19,9 +19,10 @@ local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local PushButton = require("graphics.elements.controls.push_button")
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local cpair = core.cpair
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local APP_ID = pocket.APP_ID
|
||||
|
||||
-- create system app pages
|
||||
---@param root graphics_element parent
|
||||
@ -34,7 +35,7 @@ local function create_pages(root)
|
||||
|
||||
local about_root = Div{parent=root,x=1,y=1}
|
||||
|
||||
local about_app = db.nav.register_app(iocontrol.APP_ID.ABOUT, about_root)
|
||||
local about_app = db.nav.register_app(APP_ID.ABOUT, about_root)
|
||||
|
||||
local about_page = about_app.new_page(nil, 1)
|
||||
local nt_page = about_app.new_page(about_page, 2)
|
||||
|
@ -2,34 +2,39 @@
|
||||
-- Unit Overview Page
|
||||
--
|
||||
|
||||
local util = require("scada-common.util")
|
||||
-- local log = require("scada-common.log")
|
||||
local util = require("scada-common.util")
|
||||
-- local log = require("scada-common.log")
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local pocket = require("pocket.pocket")
|
||||
|
||||
local style = require("pocket.ui.style")
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
local boiler = require("pocket.ui.pages.unit_boiler")
|
||||
local reactor = require("pocket.ui.pages.unit_reactor")
|
||||
local turbine = require("pocket.ui.pages.unit_turbine")
|
||||
local boiler = require("pocket.ui.pages.unit_boiler")
|
||||
local reactor = require("pocket.ui.pages.unit_reactor")
|
||||
local turbine = require("pocket.ui.pages.unit_turbine")
|
||||
|
||||
local core = require("graphics.core")
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
local ListBox = require("graphics.elements.listbox")
|
||||
local MultiPane = require("graphics.elements.multipane")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
local Div = require("graphics.elements.div")
|
||||
local ListBox = require("graphics.elements.listbox")
|
||||
local MultiPane = require("graphics.elements.multipane")
|
||||
local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local DataIndicator = require("graphics.elements.indicators.data")
|
||||
local IconIndicator = require("graphics.elements.indicators.icon")
|
||||
-- local RadIndicator = require("graphics.elements.indicators.rad")
|
||||
-- local VerticalBar = require("graphics.elements.indicators.vbar")
|
||||
local WaitingAnim = require("graphics.elements.animations.waiting")
|
||||
|
||||
local PushButton = require("graphics.elements.controls.push_button")
|
||||
local DataIndicator = require("graphics.elements.indicators.data")
|
||||
local IconIndicator = require("graphics.elements.indicators.icon")
|
||||
-- local RadIndicator = require("graphics.elements.indicators.rad")
|
||||
-- local VerticalBar = require("graphics.elements.indicators.vbar")
|
||||
|
||||
local PushButton = require("graphics.elements.controls.push_button")
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local cpair = core.cpair
|
||||
|
||||
local APP_ID = pocket.APP_ID
|
||||
|
||||
-- local label = style.label
|
||||
local lu_col = style.label_unit_pair
|
||||
local text_fg = style.text_fg
|
||||
@ -49,11 +54,17 @@ local emc_ind_s = {
|
||||
local function new_view(root)
|
||||
local db = iocontrol.get_db()
|
||||
|
||||
local main = Div{parent=root,x=1,y=1}
|
||||
local frame = Div{parent=root,x=1,y=1}
|
||||
|
||||
local app = db.nav.register_app(iocontrol.APP_ID.UNITS, main)
|
||||
local app = db.nav.register_app(APP_ID.UNITS, frame)
|
||||
|
||||
TextBox{parent=main,y=2,text="Units App",height=1,alignment=ALIGN.CENTER}
|
||||
local load_div = Div{parent=frame,x=1,y=1}
|
||||
local main = Div{parent=frame,x=1,y=1}
|
||||
|
||||
TextBox{parent=load_div,y=12,text="Loading...",height=1,alignment=ALIGN.CENTER}
|
||||
WaitingAnim{parent=load_div,x=math.floor(main.get_width()/2)-1,y=8,fg_bg=cpair(colors.yellow,colors._INHERIT)}
|
||||
|
||||
local load_pane = MultiPane{parent=main,x=1,y=1,panes={load_div,main}}
|
||||
|
||||
TextBox{parent=main,y=4,text="Loading...",height=1,alignment=ALIGN.CENTER}
|
||||
|
||||
@ -66,7 +77,7 @@ local function new_view(root)
|
||||
local unit = db.units[id] ---@type pioctl_unit
|
||||
|
||||
local list = {
|
||||
{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(iocontrol.APP_ID.ROOT) end },
|
||||
{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = function () db.nav.open_app(APP_ID.ROOT) end },
|
||||
{ label = "U-" .. id, color = core.cpair(colors.black, colors.yellow), callback = function () app.switcher(id) end },
|
||||
{ label = " \x13 ", color = core.cpair(colors.black, colors.red), callback = nav_links[id].alarm },
|
||||
{ label = "RPS", tall = true, color = core.cpair(colors.black, colors.cyan), callback = nav_links[id].rps },
|
||||
@ -174,6 +185,8 @@ local function new_view(root)
|
||||
|
||||
--#endregion
|
||||
|
||||
util.nop()
|
||||
|
||||
--#region Alarms Tab
|
||||
|
||||
local alm_div = Div{parent=page_div}
|
||||
@ -349,6 +362,8 @@ local function new_view(root)
|
||||
end
|
||||
|
||||
--#endregion
|
||||
|
||||
util.nop()
|
||||
end
|
||||
|
||||
-- setup multipane
|
||||
@ -356,6 +371,9 @@ local function new_view(root)
|
||||
app.set_root_pane(u_pane)
|
||||
|
||||
set_sidebar(active_unit)
|
||||
|
||||
-- done, show the app
|
||||
load_pane.set_value(2)
|
||||
end
|
||||
|
||||
app.set_on_load(load)
|
||||
|
@ -102,7 +102,7 @@ doc("G_Fault", "Fault", "Something has gone wrong and/or failed to function.")
|
||||
doc("G_FrontPanel", "Front Panel", "A basic interface on the front of a device for viewing and sometimes modifying its state. This is what you see when looking at a computer running one of the SCADA applications.")
|
||||
doc("G_Nominal", "Nominal", "Normal operation. Everything operating as intended.")
|
||||
doc("G_Ringback", "Ringback", "An indication that an alarm had gone off so that you are aware, even if the alarm condition is no longer met.")
|
||||
doc("G_SCRAM", "SCRAM", "[Emergency] shut-down of a reactor by stopping the fission reactor. In Mekanism and here, it isn't always for an emergency.")
|
||||
doc("G_SCRAM", "SCRAM", "[Emergency] shut-down of a reactor by stopping the fission. In Mekanism and here, it isn't always for an emergency.")
|
||||
doc("G_Transient", "Transient", "A temporary change in state from normal operation. Coolant levels dropping or core temperature rising above nominal values would be examples of transients.")
|
||||
doc("G_Trip", "Trip", "A checked condition has occurred, also known as 'tripped'.")
|
||||
doc("G_Tripped", "Tripped", "An alarm condition has been met and is still met.")
|
||||
|
@ -5,6 +5,7 @@
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local pocket = require("pocket.pocket")
|
||||
|
||||
local diag_apps = require("pocket.ui.apps.diag_apps")
|
||||
local dummy_app = require("pocket.ui.apps.dummy_app")
|
||||
@ -29,11 +30,12 @@ local Sidebar = require("graphics.elements.controls.sidebar")
|
||||
|
||||
local SignalBar = require("graphics.elements.indicators.signal")
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local cpair = core.cpair
|
||||
|
||||
local LINK_STATE = iocontrol.LINK_STATE
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
|
||||
local cpair = core.cpair
|
||||
local APP_ID = pocket.APP_ID
|
||||
|
||||
-- create new main view
|
||||
---@param main graphics_element main displaybox
|
||||
@ -82,14 +84,14 @@ local function init(main)
|
||||
diag_apps(page_div)
|
||||
dummy_app(page_div)
|
||||
|
||||
assert(util.table_len(db.nav.get_containers()) == iocontrol.APP_ID.NUM_APPS, "app IDs were not sequential or some apps weren't registered")
|
||||
assert(util.table_len(db.nav.get_containers()) == APP_ID.NUM_APPS, "app IDs were not sequential or some apps weren't registered")
|
||||
|
||||
db.nav.set_pane(MultiPane{parent=page_div,x=1,y=1,panes=db.nav.get_containers()})
|
||||
db.nav.set_sidebar(Sidebar{parent=main_pane,x=1,y=1,height=18,fg_bg=cpair(colors.white,colors.gray)})
|
||||
|
||||
PushButton{parent=main_pane,x=1,y=19,text="\x1b",min_width=3,fg_bg=cpair(colors.white,colors.gray),active_fg_bg=cpair(colors.gray,colors.black),callback=db.nav.nav_up}
|
||||
|
||||
db.nav.open_app(iocontrol.APP_ID.ROOT)
|
||||
db.nav.open_app(APP_ID.ROOT)
|
||||
|
||||
--#endregion
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
local Div = require("graphics.elements.div")
|
||||
@ -53,7 +55,11 @@ return function (data, base_page, title, items, scroll_height)
|
||||
table.insert(search_db, { string.lower(item.name), item.name, title, view })
|
||||
|
||||
PushButton{parent=name_list,text=item.name,alignment=ALIGN.LEFT,fg_bg=cpair(colors.blue,colors.black),active_fg_bg=btn_active,callback=view}
|
||||
|
||||
if i % 12 == 0 then util.nop() end
|
||||
end
|
||||
|
||||
util.nop()
|
||||
|
||||
return section_page
|
||||
end
|
||||
|
@ -3,6 +3,7 @@
|
||||
--
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local pocket = require("pocket.pocket")
|
||||
|
||||
local core = require("graphics.core")
|
||||
|
||||
@ -12,11 +13,10 @@ local TextBox = require("graphics.elements.textbox")
|
||||
|
||||
local App = require("graphics.elements.controls.app")
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local cpair = core.cpair
|
||||
|
||||
local APP_ID = iocontrol.APP_ID
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local APP_ID = pocket.APP_ID
|
||||
|
||||
-- new home page view
|
||||
---@param root graphics_element parent
|
||||
@ -25,7 +25,7 @@ local function new_view(root)
|
||||
|
||||
local main = Div{parent=root,x=1,y=1,height=19}
|
||||
|
||||
local app = db.nav.register_app(iocontrol.APP_ID.ROOT, main)
|
||||
local app = db.nav.register_app(APP_ID.ROOT, main)
|
||||
|
||||
local apps_1 = Div{parent=main,x=1,y=1,height=15}
|
||||
local apps_2 = Div{parent=main,x=1,y=1,height=15}
|
||||
|
Loading…
Reference in New Issue
Block a user