2023-04-12 16:40:13 +00:00
|
|
|
--
|
|
|
|
-- Pocket GUI Root
|
|
|
|
--
|
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local util = require("scada-common.util")
|
2024-06-04 00:52:59 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local iocontrol = require("pocket.iocontrol")
|
|
|
|
local pocket = require("pocket.pocket")
|
2023-04-18 17:47:06 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local diag_apps = require("pocket.ui.apps.diag_apps")
|
|
|
|
local dummy_app = require("pocket.ui.apps.dummy_app")
|
|
|
|
local guide_app = require("pocket.ui.apps.guide")
|
|
|
|
local loader_app = require("pocket.ui.apps.loader")
|
|
|
|
local sys_apps = require("pocket.ui.apps.sys_apps")
|
|
|
|
local unit_app = require("pocket.ui.apps.unit")
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local home_page = require("pocket.ui.pages.home_page")
|
2023-04-16 19:05:28 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local style = require("pocket.ui.style")
|
2024-04-13 18:47:20 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local core = require("graphics.core")
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local Div = require("graphics.elements.div")
|
|
|
|
local MultiPane = require("graphics.elements.multipane")
|
|
|
|
local TextBox = require("graphics.elements.textbox")
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local WaitingAnim = require("graphics.elements.animations.waiting")
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local PushButton = require("graphics.elements.controls.push_button")
|
|
|
|
local Sidebar = require("graphics.elements.controls.sidebar")
|
|
|
|
|
|
|
|
local SignalBar = require("graphics.elements.indicators.signal")
|
2024-01-14 19:20:59 +00:00
|
|
|
|
2023-10-04 03:16:46 +00:00
|
|
|
local ALIGN = core.ALIGN
|
2023-05-07 01:27:36 +00:00
|
|
|
local cpair = core.cpair
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2024-06-14 01:43:56 +00:00
|
|
|
local APP_ID = pocket.APP_ID
|
|
|
|
|
2023-04-12 16:40:13 +00:00
|
|
|
-- create new main view
|
2023-04-21 18:53:28 +00:00
|
|
|
---@param main graphics_element main displaybox
|
|
|
|
local function init(main)
|
2023-12-31 17:58:24 +00:00
|
|
|
local db = iocontrol.get_db()
|
2023-07-29 22:16:59 +00:00
|
|
|
|
2024-06-28 00:01:53 +00:00
|
|
|
-- window header message and connection status
|
2024-08-26 02:45:41 +00:00
|
|
|
TextBox{parent=main,y=1,text="EARLY ACCESS ALPHA S C ",fg_bg=style.header}
|
2024-04-13 20:15:20 +00:00
|
|
|
local svr_conn = SignalBar{parent=main,y=1,x=22,compact=true,colors_low_med=cpair(colors.red,colors.yellow),disconnect_color=colors.lightGray,fg_bg=cpair(colors.green,colors.gray)}
|
|
|
|
local crd_conn = SignalBar{parent=main,y=1,x=26,compact=true,colors_low_med=cpair(colors.red,colors.yellow),disconnect_color=colors.lightGray,fg_bg=cpair(colors.green,colors.gray)}
|
2024-01-14 19:20:59 +00:00
|
|
|
|
|
|
|
db.ps.subscribe("svr_conn_quality", svr_conn.set_value)
|
|
|
|
db.ps.subscribe("crd_conn_quality", crd_conn.set_value)
|
2023-04-18 17:47:06 +00:00
|
|
|
|
2024-06-29 16:29:28 +00:00
|
|
|
local start_pane = Div{parent=main,x=1,y=2}
|
|
|
|
local main_pane = Div{parent=main,x=1,y=2}
|
|
|
|
|
|
|
|
WaitingAnim{parent=start_pane,x=12,y=7,fg_bg=cpair(colors.lightBlue,style.root.bkg)}
|
|
|
|
TextBox{parent=start_pane,y=11,text="starting up...",alignment=ALIGN.CENTER,fg_bg=cpair(colors.lightGray,style.root.bkg)}
|
|
|
|
|
|
|
|
local root_pane = MultiPane{parent=main,x=1,y=2,panes={start_pane,main_pane}}
|
|
|
|
|
2023-04-20 00:35:42 +00:00
|
|
|
local page_div = Div{parent=main_pane,x=4,y=1}
|
2023-04-12 16:40:13 +00:00
|
|
|
|
2024-06-28 00:01:53 +00:00
|
|
|
-- create all the apps & pages
|
2024-04-13 18:47:20 +00:00
|
|
|
home_page(page_div)
|
2024-05-30 02:08:36 +00:00
|
|
|
unit_app(page_div)
|
2024-06-04 00:52:59 +00:00
|
|
|
guide_app(page_div)
|
2024-06-27 23:57:43 +00:00
|
|
|
loader_app(page_div)
|
2024-04-13 20:18:27 +00:00
|
|
|
sys_apps(page_div)
|
2024-06-04 00:52:59 +00:00
|
|
|
diag_apps(page_div)
|
2024-04-13 18:47:20 +00:00
|
|
|
dummy_app(page_div)
|
|
|
|
|
2024-06-28 00:01:53 +00:00
|
|
|
-- verify all apps were created
|
2024-06-14 01:43:56 +00:00
|
|
|
assert(util.table_len(db.nav.get_containers()) == APP_ID.NUM_APPS, "app IDs were not sequential or some apps weren't registered")
|
2023-12-22 16:12:47 +00:00
|
|
|
|
2024-05-10 03:05:55 +00:00
|
|
|
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)})
|
2023-07-29 22:16:59 +00:00
|
|
|
|
2023-12-31 17:58:24 +00:00
|
|
|
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}
|
|
|
|
|
2024-06-14 01:43:56 +00:00
|
|
|
db.nav.open_app(APP_ID.ROOT)
|
2024-06-29 16:29:28 +00:00
|
|
|
|
|
|
|
-- done with initial render, lets go!
|
|
|
|
root_pane.set_value(2)
|
2023-04-12 16:40:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return init
|