#629 rework of alarm testing app and other cleanup
This commit is contained in:
parent
afc89ac727
commit
a1bb5ce50b
@ -85,10 +85,8 @@ function iocontrol.init_core(pkt_comms, nav, cfg)
|
|||||||
|
|
||||||
get_tone_states = function () comms.diag__get_alarm_tones() end,
|
get_tone_states = function () comms.diag__get_alarm_tones() end,
|
||||||
|
|
||||||
ready_warn = nil, ---@type TextBox
|
tone_buttons = {}, ---@type SwitchButton[]
|
||||||
tone_buttons = {}, ---@type SwitchButton[]
|
alarm_buttons = {} ---@type Checkbox[]
|
||||||
alarm_buttons = {}, ---@type Checkbox[]
|
|
||||||
tone_indicators = {} ---@type IndicatorLight[] indicators to update from supervisor tone states
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- computer list
|
-- computer list
|
||||||
|
|||||||
@ -676,6 +676,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
|||||||
---@param packet mgmt_frame|crdn_frame|nil
|
---@param packet mgmt_frame|crdn_frame|nil
|
||||||
function public.handle_packet(packet)
|
function public.handle_packet(packet)
|
||||||
local diag = iocontrol.get_db().diag
|
local diag = iocontrol.get_db().diag
|
||||||
|
local ps = iocontrol.get_db().ps
|
||||||
|
|
||||||
if packet ~= nil then
|
if packet ~= nil then
|
||||||
local l_chan = packet.scada_frame.local_channel()
|
local l_chan = packet.scada_frame.local_channel()
|
||||||
@ -927,23 +928,23 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
|||||||
elseif packet.type == MGMT_TYPE.DIAG_TONE_GET then
|
elseif packet.type == MGMT_TYPE.DIAG_TONE_GET then
|
||||||
if _check_length(packet, 8) then
|
if _check_length(packet, 8) then
|
||||||
for i = 1, #packet.data do
|
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
|
||||||
end
|
end
|
||||||
elseif packet.type == MGMT_TYPE.DIAG_TONE_SET then
|
elseif packet.type == MGMT_TYPE.DIAG_TONE_SET then
|
||||||
if packet.length == 1 and packet.data[1] == false 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")
|
log.debug("supervisor SCADA diag tone set failed")
|
||||||
elseif packet.length == 2 and type(packet.data[2]) == "table" then
|
elseif packet.length == 2 and type(packet.data[2]) == "table" then
|
||||||
local ready = packet.data[1]
|
local ready = packet.data[1]
|
||||||
local states = packet.data[2]
|
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
|
for i = 1, #states do
|
||||||
if diag.tone_test.tone_buttons[i] ~= nil then
|
if diag.tone_test.tone_buttons[i] ~= nil then
|
||||||
diag.tone_test.tone_buttons[i].set_value(states[i] == true)
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -951,13 +952,13 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
|
|||||||
end
|
end
|
||||||
elseif packet.type == MGMT_TYPE.DIAG_ALARM_SET then
|
elseif packet.type == MGMT_TYPE.DIAG_ALARM_SET then
|
||||||
if packet.length == 1 and packet.data[1] == false 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")
|
log.debug("supervisor SCADA diag alarm set failed")
|
||||||
elseif packet.length == 2 and type(packet.data[2]) == "table" then
|
elseif packet.length == 2 and type(packet.data[2]) == "table" then
|
||||||
local ready = packet.data[1]
|
local ready = packet.data[1]
|
||||||
local states = packet.data[2]
|
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
|
for i = 1, #states do
|
||||||
if diag.tone_test.alarm_buttons[i] ~= nil then
|
if diag.tone_test.alarm_buttons[i] ~= nil then
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
--
|
--
|
||||||
-- System Apps
|
-- About Page
|
||||||
--
|
--
|
||||||
|
|
||||||
local comms = require("scada-common.comms")
|
local comms = require("scada-common.comms")
|
||||||
@ -24,25 +24,21 @@ local cpair = core.cpair
|
|||||||
|
|
||||||
local APP_ID = pocket.APP_ID
|
local APP_ID = pocket.APP_ID
|
||||||
|
|
||||||
-- create system app pages
|
-- create about page view
|
||||||
---@param root Container parent
|
---@param root Container parent
|
||||||
local function create_pages(root)
|
local function create_pages(root)
|
||||||
local db = iocontrol.get_db()
|
local db = iocontrol.get_db()
|
||||||
|
|
||||||
----------------
|
local frame = Div{parent=root,x=1,y=1}
|
||||||
-- About Page --
|
|
||||||
----------------
|
|
||||||
|
|
||||||
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 about = Div{parent=frame,x=1,y=2}
|
||||||
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}
|
|
||||||
|
|
||||||
TextBox{parent=about,y=1,text="System Information",alignment=ALIGN.CENTER}
|
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 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}
|
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}
|
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
|
--#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}
|
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}
|
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
|
--#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}
|
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}
|
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
|
--#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
|
end
|
||||||
|
|
||||||
return create_pages
|
return create_pages
|
||||||
171
pocket/ui/apps/alarm.lua
Normal file
171
pocket/ui/apps/alarm.lua
Normal file
@ -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
|
||||||
@ -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
|
|
||||||
@ -7,15 +7,15 @@ local util = require("scada-common.util")
|
|||||||
local iocontrol = require("pocket.iocontrol")
|
local iocontrol = require("pocket.iocontrol")
|
||||||
local pocket = require("pocket.pocket")
|
local pocket = require("pocket.pocket")
|
||||||
|
|
||||||
|
local alarm_app = require("pocket.ui.apps.alarm")
|
||||||
local comps_app = require("pocket.ui.apps.comps")
|
local comps_app = require("pocket.ui.apps.comps")
|
||||||
local control_app = require("pocket.ui.apps.control")
|
local control_app = require("pocket.ui.apps.control")
|
||||||
local diag_apps = require("pocket.ui.apps.diag_apps")
|
|
||||||
local facil_app = require("pocket.ui.apps.facility")
|
local facil_app = require("pocket.ui.apps.facility")
|
||||||
local guide_app = require("pocket.ui.apps.guide")
|
local guide_app = require("pocket.ui.apps.guide")
|
||||||
local loader_app = require("pocket.ui.apps.loader")
|
local loader_app = require("pocket.ui.apps.loader")
|
||||||
local process_app = require("pocket.ui.apps.process")
|
local process_app = require("pocket.ui.apps.process")
|
||||||
local rad_app = require("pocket.ui.apps.radiation")
|
local rad_app = require("pocket.ui.apps.radiation")
|
||||||
local sys_apps = require("pocket.ui.apps.sys_apps")
|
local about_app = require("pocket.ui.apps.about")
|
||||||
local unit_app = require("pocket.ui.apps.unit")
|
local unit_app = require("pocket.ui.apps.unit")
|
||||||
local waste_app = require("pocket.ui.apps.waste")
|
local waste_app = require("pocket.ui.apps.waste")
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ local function init(main)
|
|||||||
guide_app(page_div)
|
guide_app(page_div)
|
||||||
rad_app(page_div)
|
rad_app(page_div)
|
||||||
loader_app(page_div)
|
loader_app(page_div)
|
||||||
sys_apps(page_div)
|
about_app(page_div)
|
||||||
diag_apps(page_div)
|
alarm_app(page_div)
|
||||||
comps_app(page_div)
|
comps_app(page_div)
|
||||||
|
|
||||||
-- verify all apps were created
|
-- verify all apps were created
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user