From b9030d6bed192bb8f8a43831e2e20c8532840b2f Mon Sep 17 00:00:00 2001 From: Mikayla Date: Wed, 5 Jun 2024 00:31:29 +0000 Subject: [PATCH] #403 work on guide app --- pocket/ui/apps/guide.lua | 40 ++++++++++++++++++++++++++++++++--- pocket/ui/{docs => }/docs.lua | 15 ++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) rename pocket/ui/{docs => }/docs.lua (89%) diff --git a/pocket/ui/apps/guide.lua b/pocket/ui/apps/guide.lua index 9fd9628..a6edc87 100644 --- a/pocket/ui/apps/guide.lua +++ b/pocket/ui/apps/guide.lua @@ -7,10 +7,13 @@ local iocontrol = require("pocket.iocontrol") +local docs = require("pocket.ui.docs") +local style = require("pocket.ui.style") + local core = require("graphics.core") local Div = require("graphics.elements.div") --- local ListBox = require("graphics.elements.listbox") +local ListBox = require("graphics.elements.listbox") local MultiPane = require("graphics.elements.multipane") local TextBox = require("graphics.elements.textbox") @@ -19,6 +22,10 @@ local PushButton = require("graphics.elements.controls.push_button") 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 + -- new system guide view ---@param root graphics_element parent local function new_view(root) @@ -51,18 +58,23 @@ local function new_view(root) local use_page = app.new_page(main_page, 2) local uis_page = app.new_page(main_page, 3) local fps_page = app.new_page(main_page, 4) + local gls_page = app.new_page(main_page, 5) local home = Div{parent=page_div,x=2,width=p_width} local use = Div{parent=page_div,x=2,width=p_width} local uis = Div{parent=page_div,x=2,width=p_width} local fps = Div{parent=page_div,x=2,width=p_width} - local panes = { home, use, uis, fps } + local gls = Div{parent=page_div,x=2} + local panes = { home, use, uis, fps, gls } + + local doc_map = {} TextBox{parent=home,y=1,text="cc-mek-scada Guide",height=1,alignment=ALIGN.CENTER} PushButton{parent=home,y=3,text="System Usage >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=use_page.nav_to} PushButton{parent=home,text="Operator UIs >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=uis_page.nav_to} PushButton{parent=home,text="Front Panels >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=fps_page.nav_to} + PushButton{parent=home,text="Glossary >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=gls_page.nav_to} TextBox{parent=use,y=1,text="System Usage",height=1,alignment=ALIGN.CENTER} @@ -78,7 +90,16 @@ local function new_view(root) PushButton{parent=uis,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=main_page.nav_to} - PushButton{parent=uis,y=3,text="Annunciators >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} + local alarms_page = app.new_page(uis_page, #panes + 1) + local alarms_div = Div{parent=page_div,x=2} + table.insert(panes, alarms_div) + + local annunc_page = app.new_page(uis_page, #panes + 1) + local annunc_div = Div{parent=page_div,x=2} + table.insert(panes, annunc_div) + + PushButton{parent=uis,y=3,text="Alarms >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=alarms_page.nav_to} + PushButton{parent=uis,text="Annunciators >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=annunc_page.nav_to} PushButton{parent=uis,text="Pocket UI >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} PushButton{parent=uis,text="Coordinator UI >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} @@ -92,6 +113,19 @@ local function new_view(root) PushButton{parent=fps,text="Supervisor >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} PushButton{parent=fps,text="Coordinator >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=function()end} + TextBox{parent=gls,y=1,text="Glossary",height=1,alignment=ALIGN.CENTER} + + PushButton{parent=gls,x=3,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=main_page.nav_to} + + local gls_list_box = ListBox{parent=gls,x=2,y=3,scroll_height=100,nav_fg_bg=cpair(colors.lightGray,colors.gray),nav_active=cpair(colors.white,colors.gray)} + + for i = 1, #docs.glossary do + local item = docs.glossary[i] ---@type pocket_doc_item + doc_map[item.key] = TextBox{parent=gls_list_box,text=item.name,anchor=true} + TextBox{parent=gls_list_box,text=item.desc,fg_bg=label} + gls_list_box.line_break() + end + -- setup multipane local u_pane = MultiPane{parent=page_div,x=1,y=1,panes=panes} app.set_root_pane(u_pane) diff --git a/pocket/ui/docs/docs.lua b/pocket/ui/docs.lua similarity index 89% rename from pocket/ui/docs/docs.lua rename to pocket/ui/docs.lua index b51c1ef..69b31d9 100644 --- a/pocket/ui/docs/docs.lua +++ b/pocket/ui/docs.lua @@ -3,7 +3,9 @@ local docs = {} local target local function doc(key, name, desc) - table.insert(target, { key = key, name = name, desc = desc }) + ---@class pocket_doc_item + local item = { key = key, name = name, desc = desc } + table.insert(target, item) end docs.alarms = {} @@ -52,4 +54,15 @@ target = docs.annunc.unit.rps_section doc("rps_tripped", "RPS Trip", "Indicates if the reactor protection system has caused a SCRAM.") doc("high_dmg", "Damage Level High", "Indicates if the RPS tripped due to significant reactor damage.") +docs.glossary = {} + +target = docs.glossary +doc("G_Nominal", "Nominal", "") +doc("G_RCS", "RCS", "Reactor Cooling System: the combination of all machines used to cool the reactor.") +doc("G_RPS", "RPS", "Reactor Protection System: a component of the reactor PLC responsible for keeping the reactor safe.") +doc("G_Transient", "Transient", "") +doc("G_Trip", "Trip", "A checked condition has occurred, also known as 'tripped'.") + +target = docs.annunc.unit.main_section + return docs