diff --git a/pocket/iocontrol.lua b/pocket/iocontrol.lua index aeb2cd7..df3fd41 100644 --- a/pocket/iocontrol.lua +++ b/pocket/iocontrol.lua @@ -17,7 +17,6 @@ local ENERGY_UNITS = types.ENERGY_SCALE_UNITS local TEMP_SCALE = types.TEMP_SCALE local TEMP_UNITS = types.TEMP_SCALE_UNITS ----@todo nominal trip time is ping (0ms to 10ms usually) local WARN_TT = 40 local HIGH_TT = 80 @@ -86,10 +85,8 @@ function iocontrol.init_core(pkt_comms, nav, cfg) get_tone_states = function () comms.diag__get_alarm_tones() end, - ready_warn = nil, ---@type TextBox - tone_buttons = {}, ---@type SwitchButton[] - alarm_buttons = {}, ---@type Checkbox[] - tone_indicators = {} ---@type IndicatorLight[] indicators to update from supervisor tone states + tone_buttons = {}, ---@type SwitchButton[] + alarm_buttons = {} ---@type Checkbox[] } -- computer list diff --git a/pocket/iorx.lua b/pocket/iorx.lua index cbb2c01..bfcc1f9 100644 --- a/pocket/iorx.lua +++ b/pocket/iorx.lua @@ -60,7 +60,6 @@ local function _record_multiblock_status(faulted, data, ps) ps.publish("formed", data.formed) ps.publish("faulted", faulted) - ---@todo revisit this if data.build then for key, val in pairs(data.build) do ps.publish(key, val) end end diff --git a/pocket/pocket.lua b/pocket/pocket.lua index 5e227f3..133e26d 100644 --- a/pocket/pocket.lua +++ b/pocket/pocket.lua @@ -88,7 +88,7 @@ local APP_ID = { -- core UI ROOT = 1, LOADER = 2, - -- main app pages + -- main apps UNITS = 3, FACILITY = 4, CONTROL = 5, @@ -97,12 +97,11 @@ local APP_ID = { GUIDE = 8, ABOUT = 9, RADMON = 10, - -- diagnostic app pages + -- diagnostic apps ALARMS = 11, COMPS = 12, - -- other - DUMMY = 13, - NUM_APPS = 13 + -- count + NUM_APPS = 12 } pocket.APP_ID = APP_ID @@ -677,6 +676,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav) ---@param packet mgmt_frame|crdn_frame|nil function public.handle_packet(packet) local diag = iocontrol.get_db().diag + local ps = iocontrol.get_db().ps if packet ~= nil then local l_chan = packet.scada_frame.local_channel() @@ -928,23 +928,23 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav) elseif packet.type == MGMT_TYPE.DIAG_TONE_GET then if _check_length(packet, 8) then for i = 1, #packet.data do - diag.tone_test.tone_indicators[i].update(packet.data[i] == true) + ps.publish("alarm_tone_" .. i, packet.data[i] == true) end end elseif packet.type == MGMT_TYPE.DIAG_TONE_SET then if packet.length == 1 and packet.data[1] == false then - diag.tone_test.ready_warn.set_value("testing denied") + ps.publish("alarm_ready_warn", "testing denied") log.debug("supervisor SCADA diag tone set failed") elseif packet.length == 2 and type(packet.data[2]) == "table" then local ready = packet.data[1] local states = packet.data[2] - diag.tone_test.ready_warn.set_value(util.trinary(ready, "", "system not idle")) + ps.publish("alarm_ready_warn", util.trinary(ready, "", "system not idle")) for i = 1, #states do if diag.tone_test.tone_buttons[i] ~= nil then diag.tone_test.tone_buttons[i].set_value(states[i] == true) - diag.tone_test.tone_indicators[i].update(states[i] == true) + ps.publish("alarm_tone_" .. i, states[i] == true) end end else @@ -952,13 +952,13 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav) end elseif packet.type == MGMT_TYPE.DIAG_ALARM_SET then if packet.length == 1 and packet.data[1] == false then - diag.tone_test.ready_warn.set_value("testing denied") + ps.publish("alarm_ready_warn", "testing denied") log.debug("supervisor SCADA diag alarm set failed") elseif packet.length == 2 and type(packet.data[2]) == "table" then local ready = packet.data[1] local states = packet.data[2] - diag.tone_test.ready_warn.set_value(util.trinary(ready, "", "system not idle")) + ps.publish("alarm_ready_warn", util.trinary(ready, "", "system not idle")) for i = 1, #states do if diag.tone_test.alarm_buttons[i] ~= nil then diff --git a/pocket/ui/apps/sys_apps.lua b/pocket/ui/apps/about.lua similarity index 85% rename from pocket/ui/apps/sys_apps.lua rename to pocket/ui/apps/about.lua index d797caf..08facc5 100644 --- a/pocket/ui/apps/sys_apps.lua +++ b/pocket/ui/apps/about.lua @@ -1,5 +1,5 @@ -- --- System Apps +-- About Page -- local comms = require("scada-common.comms") @@ -24,25 +24,21 @@ local cpair = core.cpair local APP_ID = pocket.APP_ID --- create system app pages +-- create about page view ---@param root Container parent local function create_pages(root) local db = iocontrol.get_db() - ---------------- - -- About Page -- - ---------------- + local frame = Div{parent=root,x=1,y=1} - local about_root = Div{parent=root,x=1,y=1} + local app = db.nav.register_app(APP_ID.ABOUT, frame) - local about_app = db.nav.register_app(APP_ID.ABOUT, about_root) + local about_page = app.new_page(nil, 1) + local nt_page = app.new_page(about_page, 2) + local fw_page = app.new_page(about_page, 3) + local hw_page = app.new_page(about_page, 4) - local about_page = about_app.new_page(nil, 1) - local nt_page = about_app.new_page(about_page, 2) - local fw_page = about_app.new_page(about_page, 3) - local hw_page = about_app.new_page(about_page, 4) - - local about = Div{parent=about_root,x=1,y=2} + local about = Div{parent=frame,x=1,y=2} TextBox{parent=about,y=1,text="System Information",alignment=ALIGN.CENTER} @@ -58,7 +54,7 @@ local function create_pages(root) local config = pocket.config - local nt_div = Div{parent=about_root,x=1,y=2} + local nt_div = Div{parent=frame,x=1,y=2} TextBox{parent=nt_div,y=1,text="Network Details",alignment=ALIGN.CENTER} PushButton{parent=nt_div,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=about_page.nav_to} @@ -87,7 +83,7 @@ local function create_pages(root) --#region Firmware Versions - local fw_div = Div{parent=about_root,x=1,y=2} + local fw_div = Div{parent=frame,x=1,y=2} TextBox{parent=fw_div,y=1,text="Firmware Versions",alignment=ALIGN.CENTER} PushButton{parent=fw_div,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=about_page.nav_to} @@ -123,7 +119,7 @@ local function create_pages(root) --#region Host Versions - local hw_div = Div{parent=about_root,x=1,y=2} + local hw_div = Div{parent=frame,x=1,y=2} TextBox{parent=hw_div,y=1,text="Host Versions",alignment=ALIGN.CENTER} PushButton{parent=hw_div,x=2,y=1,text="<",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=about_page.nav_to} @@ -138,9 +134,9 @@ local function create_pages(root) --#endregion - local root_pane = MultiPane{parent=about_root,x=1,y=1,panes={about,nt_div,fw_div,hw_div}} + local root_pane = MultiPane{parent=frame,x=1,y=1,panes={about,nt_div,fw_div,hw_div}} - about_app.set_root_pane(root_pane) + app.set_root_pane(root_pane) end return create_pages diff --git a/pocket/ui/apps/alarm.lua b/pocket/ui/apps/alarm.lua new file mode 100644 index 0000000..68c69a5 --- /dev/null +++ b/pocket/ui/apps/alarm.lua @@ -0,0 +1,171 @@ +-- +-- Alarm Test App +-- + +local iocontrol = require("pocket.iocontrol") +local pocket = require("pocket.pocket") + +local core = require("graphics.core") + +local Div = require("graphics.elements.Div") +local MultiPane = require("graphics.elements.MultiPane") +local TextBox = require("graphics.elements.TextBox") + +local IndicatorLight = require("graphics.elements.indicators.IndicatorLight") + +local Checkbox = require("graphics.elements.controls.Checkbox") +local PushButton = require("graphics.elements.controls.PushButton") +local SwitchButton = require("graphics.elements.controls.SwitchButton") + +local ALIGN = core.ALIGN +local cpair = core.cpair + +local APP_ID = pocket.APP_ID + +local c_wht_gray = cpair(colors.white, colors.gray) +local c_red_gray = cpair(colors.red, colors.gray) +local c_yel_gray = cpair(colors.yellow, colors.gray) +local c_blue_gray = cpair(colors.blue, colors.gray) + +-- create alarm test page view +---@param root Container parent +local function new_view(root) + local db = iocontrol.get_db() + local ps = db.ps + local ttest = db.diag.tone_test + + local frame = Div{parent=root,x=1,y=1} + + local app = db.nav.register_app(APP_ID.ALARMS, frame, nil, true) + + local main = Div{parent=frame,x=1,y=1} + local page_div = Div{parent=main,y=2,width=main.get_width()} + + --#region alarm testing + + local alarm_page = app.new_page(nil, 1) + alarm_page.tasks = { db.diag.tone_test.get_tone_states } + + local alarms_div = Div{parent=page_div} + + TextBox{parent=alarms_div,text="Alarm Sounder Tests",alignment=ALIGN.CENTER} + + local alarm_ready_warn = TextBox{parent=alarms_div,y=2,text="",alignment=ALIGN.CENTER,fg_bg=cpair(colors.yellow,colors.black)} + alarm_ready_warn.register(ps, "alarm_ready_warn", alarm_ready_warn.set_value) + + local alarm_page_states = Div{parent=alarms_div,x=2,y=3,height=5,width=8} + + TextBox{parent=alarm_page_states,text="States",alignment=ALIGN.CENTER} + local ta_1 = IndicatorLight{parent=alarm_page_states,label="1",colors=c_blue_gray} + local ta_2 = IndicatorLight{parent=alarm_page_states,label="2",colors=c_blue_gray} + local ta_3 = IndicatorLight{parent=alarm_page_states,label="3",colors=c_blue_gray} + local ta_4 = IndicatorLight{parent=alarm_page_states,label="4",colors=c_blue_gray} + local ta_5 = IndicatorLight{parent=alarm_page_states,x=6,y=2,label="5",colors=c_blue_gray} + local ta_6 = IndicatorLight{parent=alarm_page_states,x=6,label="6",colors=c_blue_gray} + local ta_7 = IndicatorLight{parent=alarm_page_states,x=6,label="7",colors=c_blue_gray} + local ta_8 = IndicatorLight{parent=alarm_page_states,x=6,label="8",colors=c_blue_gray} + + local ta = { ta_1, ta_2, ta_3, ta_4, ta_5, ta_6, ta_7, ta_8 } + + for i = 1, #ta do + ta[i].register(ps, "alarm_tone_" .. i, ta[i].update) + end + + local alarms = Div{parent=alarms_div,x=11,y=3,height=15,fg_bg=cpair(colors.lightGray,colors.black)} + + TextBox{parent=alarms,text="Alarms (\x13)",alignment=ALIGN.CENTER,fg_bg=alarms_div.get_fg_bg()} + + local alarm_btns = {} + alarm_btns[1] = Checkbox{parent=alarms,label="BREACH",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_breach} + alarm_btns[2] = Checkbox{parent=alarms,label="RADIATION",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_rad} + alarm_btns[3] = Checkbox{parent=alarms,label="RCT LOST",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_lost} + alarm_btns[4] = Checkbox{parent=alarms,label="CRIT DAMAGE",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_crit} + alarm_btns[5] = Checkbox{parent=alarms,label="DAMAGE",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_dmg} + alarm_btns[6] = Checkbox{parent=alarms,label="OVER TEMP",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_overtemp} + alarm_btns[7] = Checkbox{parent=alarms,label="HIGH TEMP",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_hightemp} + alarm_btns[8] = Checkbox{parent=alarms,label="WASTE LEAK",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_wasteleak} + alarm_btns[9] = Checkbox{parent=alarms,label="WASTE HIGH",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_highwaste} + alarm_btns[10] = Checkbox{parent=alarms,label="RPS TRANS",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_rps} + alarm_btns[11] = Checkbox{parent=alarms,label="RCS TRANS",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_rcs} + alarm_btns[12] = Checkbox{parent=alarms,label="TURBINE TRP",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_turbinet} + + ttest.alarm_buttons = alarm_btns + + local function stop_all_alarms() + for i = 1, #alarm_btns do alarm_btns[i].set_value(false) end + ttest.stop_alarms() + end + + PushButton{parent=alarms,x=3,y=15,text="STOP \x13",min_width=8,fg_bg=cpair(colors.black,colors.red),active_fg_bg=c_wht_gray,callback=stop_all_alarms} + + --#endregion + + --#region direct tone testing + + local tones_page = app.new_page(nil, 2) + tones_page.tasks = { db.diag.tone_test.get_tone_states } + + local tones_div = Div{parent=page_div} + + TextBox{parent=tones_div,text="Alarm Sounder Tests",alignment=ALIGN.CENTER} + + local tone_ready_warn = TextBox{parent=tones_div,y=2,text="",alignment=ALIGN.CENTER,fg_bg=cpair(colors.yellow,colors.black)} + tone_ready_warn.register(ps, "alarm_ready_warn", tone_ready_warn.set_value) + + local tone_page_states = Div{parent=tones_div,x=3,y=3,height=5,width=8} + + TextBox{parent=tone_page_states,text="States",alignment=ALIGN.CENTER} + local tt_1 = IndicatorLight{parent=tone_page_states,label="1",colors=c_blue_gray} + local tt_2 = IndicatorLight{parent=tone_page_states,label="2",colors=c_blue_gray} + local tt_3 = IndicatorLight{parent=tone_page_states,label="3",colors=c_blue_gray} + local tt_4 = IndicatorLight{parent=tone_page_states,label="4",colors=c_blue_gray} + local tt_5 = IndicatorLight{parent=tone_page_states,x=6,y=2,label="5",colors=c_blue_gray} + local tt_6 = IndicatorLight{parent=tone_page_states,x=6,label="6",colors=c_blue_gray} + local tt_7 = IndicatorLight{parent=tone_page_states,x=6,label="7",colors=c_blue_gray} + local tt_8 = IndicatorLight{parent=tone_page_states,x=6,label="8",colors=c_blue_gray} + + local tt = { tt_1, tt_2, tt_3, tt_4, tt_5, tt_6, tt_7, tt_8 } + + for i = 1, #tt do + tt[i].register(ps, "alarm_tone_" .. i, tt[i].update) + end + + local tones = Div{parent=tones_div,x=14,y=3,height=10,width=8,fg_bg=cpair(colors.black,colors.yellow)} + + TextBox{parent=tones,text="Tones",alignment=ALIGN.CENTER,fg_bg=tones_div.get_fg_bg()} + + local test_btns = {} + test_btns[1] = SwitchButton{parent=tones,text="TEST 1",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_1} + test_btns[2] = SwitchButton{parent=tones,text="TEST 2",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_2} + test_btns[3] = SwitchButton{parent=tones,text="TEST 3",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_3} + test_btns[4] = SwitchButton{parent=tones,text="TEST 4",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_4} + test_btns[5] = SwitchButton{parent=tones,text="TEST 5",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_5} + test_btns[6] = SwitchButton{parent=tones,text="TEST 6",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_6} + test_btns[7] = SwitchButton{parent=tones,text="TEST 7",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_7} + test_btns[8] = SwitchButton{parent=tones,text="TEST 8",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_8} + + ttest.tone_buttons = test_btns + + local function stop_all_tones() + for i = 1, #test_btns do test_btns[i].set_value(false) end + ttest.stop_tones() + end + + PushButton{parent=tones,text="STOP",min_width=8,active_fg_bg=c_wht_gray,fg_bg=cpair(colors.black,colors.red),callback=stop_all_tones} + + --#endregion + + -- setup multipane + local u_pane = MultiPane{parent=page_div,x=1,y=1,panes={alarms_div,tones_div}} + app.set_root_pane(u_pane) + + local list = { + { label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home }, + { label = " \x13 ", color = core.cpair(colors.black, colors.red), callback = function () app.switcher(1) end }, + { label = " \x0f ", color = core.cpair(colors.black, colors.yellow), callback = function () app.switcher(2) end } + } + + app.set_sidebar(list) +end + +return new_view diff --git a/pocket/ui/apps/comps.lua b/pocket/ui/apps/comps.lua index 5450118..91a9558 100644 --- a/pocket/ui/apps/comps.lua +++ b/pocket/ui/apps/comps.lua @@ -32,7 +32,6 @@ local border = core.border local APP_ID = pocket.APP_ID local lu_col = style.label_unit_pair - local box_label = cpair(colors.lightGray, colors.gray) -- new computer list page view diff --git a/pocket/ui/apps/diag_apps.lua b/pocket/ui/apps/diag_apps.lua deleted file mode 100644 index ba2bed3..0000000 --- a/pocket/ui/apps/diag_apps.lua +++ /dev/null @@ -1,118 +0,0 @@ --- --- Diagnostic Apps --- - -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 IndicatorLight = require("graphics.elements.indicators.IndicatorLight") - -local Checkbox = require("graphics.elements.controls.Checkbox") -local PushButton = require("graphics.elements.controls.PushButton") -local SwitchButton = require("graphics.elements.controls.SwitchButton") - -local ALIGN = core.ALIGN -local cpair = core.cpair - -local APP_ID = pocket.APP_ID - --- create diagnostic app pages ----@param root Container parent -local function create_pages(root) - local db = iocontrol.get_db() - - ------------------------ - -- Alarm Testing Page -- - ------------------------ - - local alarm_test = Div{parent=root,x=1,y=1} - - local alarm_app = db.nav.register_app(APP_ID.ALARMS, alarm_test, nil, true) - - local page = alarm_app.new_page(nil, function () end) - page.tasks = { db.diag.tone_test.get_tone_states } - - local ttest = db.diag.tone_test - - local c_wht_gray = cpair(colors.white, colors.gray) - local c_red_gray = cpair(colors.red, colors.gray) - local c_yel_gray = cpair(colors.yellow, colors.gray) - local c_blue_gray = cpair(colors.blue, colors.gray) - - local audio = Div{parent=alarm_test,x=1,y=1} - - TextBox{parent=audio,y=1,text="Alarm Sounder Tests",alignment=ALIGN.CENTER} - - ttest.ready_warn = TextBox{parent=audio,y=2,text="",alignment=ALIGN.CENTER,fg_bg=cpair(colors.yellow,colors.black)} - - local tones = Div{parent=audio,x=2,y=3,height=10,width=8,fg_bg=cpair(colors.black,colors.yellow)} - - TextBox{parent=tones,text="Tones",alignment=ALIGN.CENTER,fg_bg=audio.get_fg_bg()} - - local test_btns = {} - test_btns[1] = SwitchButton{parent=tones,text="TEST 1",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_1} - test_btns[2] = SwitchButton{parent=tones,text="TEST 2",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_2} - test_btns[3] = SwitchButton{parent=tones,text="TEST 3",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_3} - test_btns[4] = SwitchButton{parent=tones,text="TEST 4",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_4} - test_btns[5] = SwitchButton{parent=tones,text="TEST 5",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_5} - test_btns[6] = SwitchButton{parent=tones,text="TEST 6",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_6} - test_btns[7] = SwitchButton{parent=tones,text="TEST 7",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_7} - test_btns[8] = SwitchButton{parent=tones,text="TEST 8",min_width=8,active_fg_bg=c_wht_gray,callback=ttest.test_8} - - ttest.tone_buttons = test_btns - - local function stop_all_tones() - for i = 1, #test_btns do test_btns[i].set_value(false) end - ttest.stop_tones() - end - - PushButton{parent=tones,text="STOP",min_width=8,active_fg_bg=c_wht_gray,fg_bg=cpair(colors.black,colors.red),callback=stop_all_tones} - - local alarms = Div{parent=audio,x=11,y=3,height=15,fg_bg=cpair(colors.lightGray,colors.black)} - - TextBox{parent=alarms,text="Alarms (\x13)",alignment=ALIGN.CENTER,fg_bg=audio.get_fg_bg()} - - local alarm_btns = {} - alarm_btns[1] = Checkbox{parent=alarms,label="BREACH",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_breach} - alarm_btns[2] = Checkbox{parent=alarms,label="RADIATION",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_rad} - alarm_btns[3] = Checkbox{parent=alarms,label="RCT LOST",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_lost} - alarm_btns[4] = Checkbox{parent=alarms,label="CRIT DAMAGE",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_crit} - alarm_btns[5] = Checkbox{parent=alarms,label="DAMAGE",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_dmg} - alarm_btns[6] = Checkbox{parent=alarms,label="OVER TEMP",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_overtemp} - alarm_btns[7] = Checkbox{parent=alarms,label="HIGH TEMP",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_hightemp} - alarm_btns[8] = Checkbox{parent=alarms,label="WASTE LEAK",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_wasteleak} - alarm_btns[9] = Checkbox{parent=alarms,label="WASTE HIGH",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_highwaste} - alarm_btns[10] = Checkbox{parent=alarms,label="RPS TRANS",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_rps} - alarm_btns[11] = Checkbox{parent=alarms,label="RCS TRANS",min_width=15,box_fg_bg=c_yel_gray,callback=ttest.test_rcs} - alarm_btns[12] = Checkbox{parent=alarms,label="TURBINE TRP",min_width=15,box_fg_bg=c_red_gray,callback=ttest.test_turbinet} - - ttest.alarm_buttons = alarm_btns - - local function stop_all_alarms() - for i = 1, #alarm_btns do alarm_btns[i].set_value(false) end - ttest.stop_alarms() - end - - PushButton{parent=alarms,x=3,y=15,text="STOP \x13",min_width=8,fg_bg=cpair(colors.black,colors.red),active_fg_bg=c_wht_gray,callback=stop_all_alarms} - - local states = Div{parent=audio,x=2,y=14,height=5,width=8} - - TextBox{parent=states,text="States",alignment=ALIGN.CENTER} - local t_1 = IndicatorLight{parent=states,label="1",colors=c_blue_gray} - local t_2 = IndicatorLight{parent=states,label="2",colors=c_blue_gray} - local t_3 = IndicatorLight{parent=states,label="3",colors=c_blue_gray} - local t_4 = IndicatorLight{parent=states,label="4",colors=c_blue_gray} - local t_5 = IndicatorLight{parent=states,x=6,y=2,label="5",colors=c_blue_gray} - local t_6 = IndicatorLight{parent=states,x=6,label="6",colors=c_blue_gray} - local t_7 = IndicatorLight{parent=states,x=6,label="7",colors=c_blue_gray} - local t_8 = IndicatorLight{parent=states,x=6,label="8",colors=c_blue_gray} - - ttest.tone_indicators = { t_1, t_2, t_3, t_4, t_5, t_6, t_7, t_8 } -end - -return create_pages diff --git a/pocket/ui/apps/dummy_app.lua b/pocket/ui/apps/dummy_app.lua deleted file mode 100644 index a564761..0000000 --- a/pocket/ui/apps/dummy_app.lua +++ /dev/null @@ -1,29 +0,0 @@ --- --- Placeholder App --- - -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 Container parent -local function create_pages(root) - local db = iocontrol.get_db() - - local main = Div{parent=root,x=1,y=1} - - 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} - - TextBox{parent=main,text=" pretend something cool is here \x03",x=1,y=10,alignment=core.ALIGN.CENTER,fg_bg=core.cpair(colors.gray,colors.black)} -end - -return create_pages diff --git a/pocket/ui/apps/facility.lua b/pocket/ui/apps/facility.lua index 65b25e3..9763982 100644 --- a/pocket/ui/apps/facility.lua +++ b/pocket/ui/apps/facility.lua @@ -41,7 +41,7 @@ local grn_ind_s = style.icon_states.grn_ind_s -- new unit page view ---@param root Container parent local function new_view(root) - local db = iocontrol.get_db() + local db = iocontrol.get_db() local frame = Div{parent=root,x=1,y=1} diff --git a/pocket/ui/apps/guide.lua b/pocket/ui/apps/guide.lua index 88bf082..5e627f3 100644 --- a/pocket/ui/apps/guide.lua +++ b/pocket/ui/apps/guide.lua @@ -9,7 +9,6 @@ local iocontrol = require("pocket.iocontrol") local pocket = require("pocket.pocket") local docs = require("pocket.ui.docs") --- local style = require("pocket.ui.style") local guide_section = require("pocket.ui.pages.guide_section") @@ -31,10 +30,6 @@ 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 - -- new system guide view ---@param root Container parent local function new_view(root) diff --git a/pocket/ui/apps/process.lua b/pocket/ui/apps/process.lua index 6f04d60..ed03d71 100644 --- a/pocket/ui/apps/process.lua +++ b/pocket/ui/apps/process.lua @@ -194,7 +194,7 @@ local function new_view(root) TextBox{parent=c_div,y=1,text="Process Control",alignment=ALIGN.CENTER} - local u_stat = Rectangle{parent=c_div,border=border(1,colors.gray,true),thin=true,width=21,height=5,x=1,y=3,fg_bg=cpair(colors.black,colors.lightGray)} + local u_stat = Rectangle{parent=c_div,border=border(1,colors.gray,true),thin=true,width=21,height=5,x=1,y=3,fg_bg=cpair(colors.black,colors.lightGray)} local stat_line_1 = TextBox{parent=u_stat,x=1,y=1,text="UNKNOWN",alignment=ALIGN.CENTER} local stat_line_2 = TextBox{parent=u_stat,x=1,y=2,text="awaiting data...",height=2,alignment=ALIGN.CENTER,trim_whitespace=true,fg_bg=cpair(colors.gray,colors.lightGray)} @@ -210,7 +210,7 @@ local function new_view(root) end local start = HazardButton{parent=c_div,x=2,y=9,text="START",accent=colors.lightBlue,callback=_start_auto,timeout=3,fg_bg=hzd_fg_bg,dis_colors=dis_colors} - local stop = HazardButton{parent=c_div,x=13,y=9,text="STOP",accent=colors.red,callback=process.process_stop,timeout=3,fg_bg=hzd_fg_bg,dis_colors=dis_colors} + local stop = HazardButton{parent=c_div,x=13,y=9,text="STOP",accent=colors.red,callback=process.process_stop,timeout=3,fg_bg=hzd_fg_bg,dis_colors=dis_colors} db.facility.start_ack = start.on_response db.facility.stop_ack = stop.on_response diff --git a/pocket/ui/apps/unit.lua b/pocket/ui/apps/unit.lua index 304608e..6213f6b 100644 --- a/pocket/ui/apps/unit.lua +++ b/pocket/ui/apps/unit.lua @@ -312,8 +312,6 @@ local function new_view(root) c_emg.register(u_ps, "EmergencyCoolant", c_emg.update) c_mwrf.register(u_ps, "MaxWaterReturnFeed", c_mwrf.update) - -- rcs_div.line_break() - -- TextBox{parent=rcs_div,text="Mismatches",alignment=ALIGN.CENTER,fg_bg=label} local c_cfm = IconIndicator{parent=rcs_div,label="Coolant Feed",states=yel_ind_s} local c_brm = IconIndicator{parent=rcs_div,label="Boil Rate",states=yel_ind_s} local c_sfm = IconIndicator{parent=rcs_div,label="Steam Feed",states=yel_ind_s} @@ -323,7 +321,6 @@ local function new_view(root) c_sfm.register(u_ps, "SteamFeedMismatch", c_sfm.update) rcs_div.line_break() - -- TextBox{parent=rcs_div,text="Aggregate Checks",alignment=ALIGN.CENTER,fg_bg=label} if unit.num_boilers > 0 then local wll = IconIndicator{parent=rcs_div,label="Boiler Water Lo",states=red_ind_s} diff --git a/pocket/ui/docs.lua b/pocket/ui/docs.lua index 44219ea..ec395a7 100644 --- a/pocket/ui/docs.lua +++ b/pocket/ui/docs.lua @@ -1,3 +1,7 @@ +-- +-- All the text documentation used in the Guide app is defined in this file. +-- + local const = require("scada-common.constants") local docs = {} diff --git a/pocket/ui/main.lua b/pocket/ui/main.lua index 4ea44e1..001b314 100644 --- a/pocket/ui/main.lua +++ b/pocket/ui/main.lua @@ -7,16 +7,15 @@ local util = require("scada-common.util") local iocontrol = require("pocket.iocontrol") local pocket = require("pocket.pocket") +local about_app = require("pocket.ui.apps.about") +local alarm_app = require("pocket.ui.apps.alarm") local comps_app = require("pocket.ui.apps.comps") local control_app = require("pocket.ui.apps.control") -local diag_apps = require("pocket.ui.apps.diag_apps") -local dummy_app = require("pocket.ui.apps.dummy_app") local facil_app = require("pocket.ui.apps.facility") local guide_app = require("pocket.ui.apps.guide") local loader_app = require("pocket.ui.apps.loader") local process_app = require("pocket.ui.apps.process") local rad_app = require("pocket.ui.apps.radiation") -local sys_apps = require("pocket.ui.apps.sys_apps") local unit_app = require("pocket.ui.apps.unit") local waste_app = require("pocket.ui.apps.waste") @@ -75,10 +74,9 @@ local function init(main) guide_app(page_div) rad_app(page_div) loader_app(page_div) - sys_apps(page_div) - diag_apps(page_div) + about_app(page_div) + alarm_app(page_div) comps_app(page_div) - dummy_app(page_div) -- verify all apps were created assert(util.table_len(db.nav.get_containers()) == APP_ID.NUM_APPS, "app IDs were not sequential or some apps weren't registered") diff --git a/pocket/ui/pages/dynamic_tank.lua b/pocket/ui/pages/dynamic_tank.lua index 17221a6..6604dfd 100644 --- a/pocket/ui/pages/dynamic_tank.lua +++ b/pocket/ui/pages/dynamic_tank.lua @@ -1,3 +1,7 @@ +-- +-- Dynamic Tank View +-- + local types = require("scada-common.types") local util = require("scada-common.util") @@ -16,7 +20,7 @@ local IconIndicator = require("graphics.elements.indicators.IconIndicator") local StateIndicator = require("graphics.elements.indicators.StateIndicator") local CONTAINER_MODE = types.CONTAINER_MODE -local COOLANT_TYPE = types.COOLANT_TYPE +local COOLANT_TYPE = types.COOLANT_TYPE local ALIGN = core.ALIGN local cpair = core.cpair diff --git a/pocket/ui/pages/facility_matrix.lua b/pocket/ui/pages/facility_matrix.lua index 77640b1..1d3c362 100644 --- a/pocket/ui/pages/facility_matrix.lua +++ b/pocket/ui/pages/facility_matrix.lua @@ -1,3 +1,7 @@ +-- +-- Induction Matrix View +-- + local iocontrol = require("pocket.iocontrol") local style = require("pocket.ui.style") diff --git a/pocket/ui/pages/facility_sps.lua b/pocket/ui/pages/facility_sps.lua index 1de23ca..2de3863 100644 --- a/pocket/ui/pages/facility_sps.lua +++ b/pocket/ui/pages/facility_sps.lua @@ -1,3 +1,7 @@ +-- +-- SPS View +-- + local iocontrol = require("pocket.iocontrol") local style = require("pocket.ui.style") diff --git a/pocket/ui/pages/guide_section.lua b/pocket/ui/pages/guide_section.lua index a3ea333..9bb1df2 100644 --- a/pocket/ui/pages/guide_section.lua +++ b/pocket/ui/pages/guide_section.lua @@ -1,3 +1,7 @@ +-- +-- A Guide App Subsection +-- + local log = require("scada-common.log") local util = require("scada-common.util") @@ -17,7 +21,7 @@ local LED = require("graphics.elements.indicators.LED") local ALIGN = core.ALIGN local cpair = core.cpair -local DOC_TYPE = docs.DOC_ITEM_TYPE +local DOC_TYPE = docs.DOC_ITEM_TYPE local LIST_TYPE = docs.DOC_LIST_TYPE -- new guide documentation section diff --git a/pocket/ui/pages/home_page.lua b/pocket/ui/pages/home_page.lua index 2af6f8a..bb962d5 100644 --- a/pocket/ui/pages/home_page.lua +++ b/pocket/ui/pages/home_page.lua @@ -9,11 +9,9 @@ local core = require("graphics.core") local AppMultiPane = require("graphics.elements.AppMultiPane") local Div = require("graphics.elements.Div") -local TextBox = require("graphics.elements.TextBox") local App = require("graphics.elements.controls.App") -local ALIGN = core.ALIGN local cpair = core.cpair local APP_ID = pocket.APP_ID diff --git a/pocket/ui/pages/unit_boiler.lua b/pocket/ui/pages/unit_boiler.lua index 1790268..344451c 100644 --- a/pocket/ui/pages/unit_boiler.lua +++ b/pocket/ui/pages/unit_boiler.lua @@ -1,3 +1,7 @@ +-- +-- Unit Boiler View +-- + local types = require("scada-common.types") local util = require("scada-common.util") @@ -13,8 +17,8 @@ local TextBox = require("graphics.elements.TextBox") local PushButton = require("graphics.elements.controls.PushButton") local DataIndicator = require("graphics.elements.indicators.DataIndicator") -local StateIndicator = require("graphics.elements.indicators.StateIndicator") local IconIndicator = require("graphics.elements.indicators.IconIndicator") +local StateIndicator = require("graphics.elements.indicators.StateIndicator") local VerticalBar = require("graphics.elements.indicators.VerticalBar") local ALIGN = core.ALIGN diff --git a/pocket/ui/pages/unit_reactor.lua b/pocket/ui/pages/unit_reactor.lua index a3333f5..30a8e36 100644 --- a/pocket/ui/pages/unit_reactor.lua +++ b/pocket/ui/pages/unit_reactor.lua @@ -1,3 +1,7 @@ +-- +-- Unit Reactor View +-- + local types = require("scada-common.types") local util = require("scada-common.util") @@ -13,8 +17,8 @@ local TextBox = require("graphics.elements.TextBox") local PushButton = require("graphics.elements.controls.PushButton") local DataIndicator = require("graphics.elements.indicators.DataIndicator") -local StateIndicator = require("graphics.elements.indicators.StateIndicator") local IconIndicator = require("graphics.elements.indicators.IconIndicator") +local StateIndicator = require("graphics.elements.indicators.StateIndicator") local VerticalBar = require("graphics.elements.indicators.VerticalBar") local ALIGN = core.ALIGN diff --git a/pocket/ui/pages/unit_turbine.lua b/pocket/ui/pages/unit_turbine.lua index 94541ad..9e9a79e 100644 --- a/pocket/ui/pages/unit_turbine.lua +++ b/pocket/ui/pages/unit_turbine.lua @@ -1,3 +1,7 @@ +-- +-- Unit Turbine View +-- + local util = require("scada-common.util") local iocontrol = require("pocket.iocontrol")