added network details to about app

This commit is contained in:
Mikayla Fischler 2024-05-11 15:03:14 -04:00
parent 0cb964a177
commit c181142f75
3 changed files with 60 additions and 10 deletions

View File

@ -501,7 +501,9 @@ end
-- set network link state -- set network link state
---@param state POCKET_LINK_STATE ---@param state POCKET_LINK_STATE
function iocontrol.report_link_state(state) ---@param sv_addr integer? supervisor address if linked
---@param api_addr integer? coordinator address if linked
function iocontrol.report_link_state(state, sv_addr, api_addr)
io.ps.publish("link_state", state) io.ps.publish("link_state", state)
if state == LINK_STATE.API_LINK_ONLY or state == LINK_STATE.UNLINKED then if state == LINK_STATE.API_LINK_ONLY or state == LINK_STATE.UNLINKED then
@ -511,6 +513,11 @@ function iocontrol.report_link_state(state)
if state == LINK_STATE.SV_LINK_ONLY or state == LINK_STATE.UNLINKED then if state == LINK_STATE.SV_LINK_ONLY or state == LINK_STATE.UNLINKED then
io.ps.publish("crd_conn_quality", 0) io.ps.publish("crd_conn_quality", 0)
end end
if state == LINK_STATE.LINKED then
io.ps.publish("sv_addr", sv_addr)
io.ps.publish("api_addr", api_addr)
end
end end
-- determine supervisor connection quality (trip time) -- determine supervisor connection quality (trip time)

View File

@ -192,7 +192,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog)
end end
else else
-- linked, all good! -- linked, all good!
iocontrol.report_link_state(LINK_STATE.LINKED) iocontrol.report_link_state(LINK_STATE.LINKED, self.sv.addr, self.api.addr)
end end
end end
@ -358,7 +358,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog)
self.api.addr = src_addr self.api.addr = src_addr
if self.sv.linked then if self.sv.linked then
iocontrol.report_link_state(LINK_STATE.LINKED) iocontrol.report_link_state(LINK_STATE.LINKED, self.sv.addr, self.api.addr)
else else
iocontrol.report_link_state(LINK_STATE.API_LINK_ONLY) iocontrol.report_link_state(LINK_STATE.API_LINK_ONLY)
end end
@ -497,7 +497,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog)
self.sv.addr = src_addr self.sv.addr = src_addr
if self.api.linked then if self.api.linked then
iocontrol.report_link_state(LINK_STATE.LINKED) iocontrol.report_link_state(LINK_STATE.LINKED, self.sv.addr, self.api.addr)
else else
iocontrol.report_link_state(LINK_STATE.SV_LINK_ONLY) iocontrol.report_link_state(LINK_STATE.SV_LINK_ONLY)
end end

View File

@ -3,10 +3,12 @@
-- --
local comms = require("scada-common.comms") local comms = require("scada-common.comms")
local lockbox = require("lockbox")
local util = require("scada-common.util") local util = require("scada-common.util")
local lockbox = require("lockbox")
local iocontrol = require("pocket.iocontrol") local iocontrol = require("pocket.iocontrol")
local pocket = require("pocket.pocket")
local core = require("graphics.core") local core = require("graphics.core")
@ -35,8 +37,9 @@ local function create_pages(root)
local about_app = db.nav.register_app(iocontrol.APP_ID.ABOUT, about_root) local about_app = db.nav.register_app(iocontrol.APP_ID.ABOUT, about_root)
local about_page = about_app.new_page(nil, 1) local about_page = about_app.new_page(nil, 1)
local fw_page = about_app.new_page(about_page, 2) local nt_page = about_app.new_page(about_page, 2)
local hw_page = about_app.new_page(about_page, 3) 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=about_root,x=1,y=2}
@ -46,8 +49,42 @@ local function create_pages(root)
local btn_active = cpair(colors.white, colors.black) local btn_active = cpair(colors.white, colors.black)
local label = cpair(colors.lightGray, colors.black) local label = cpair(colors.lightGray, colors.black)
PushButton{parent=about,x=2,y=3,text="Firmware >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=fw_page.nav_to} PushButton{parent=about,x=2,y=3,text="Network >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=nt_page.nav_to}
PushButton{parent=about,x=2,y=4,text="Host Details >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=hw_page.nav_to} PushButton{parent=about,x=2,y=4,text="Firmware >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=fw_page.nav_to}
PushButton{parent=about,x=2,y=5,text="Host Details >",fg_bg=btn_fg_bg,active_fg_bg=btn_active,callback=hw_page.nav_to}
--#region Network Details
local config = pocket.config
local nt_div = Div{parent=about_root,x=1,y=2}
TextBox{parent=nt_div,y=1,text="Network Details",height=1,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}
TextBox{parent=nt_div,x=2,y=3,text="Pocket Address",height=1,alignment=ALIGN.LEFT,fg_bg=label}
---@diagnostic disable-next-line: undefined-field
TextBox{parent=nt_div,x=2,text=util.c(os.getComputerID(),":",config.PKT_Channel),height=1,alignment=ALIGN.LEFT}
nt_div.line_break()
TextBox{parent=nt_div,x=2,text="Supervisor Address",height=1,alignment=ALIGN.LEFT,fg_bg=label}
local sv = TextBox{parent=nt_div,x=2,text="",height=1,alignment=ALIGN.LEFT}
nt_div.line_break()
TextBox{parent=nt_div,x=2,text="Coordinator Address",height=1,alignment=ALIGN.LEFT,fg_bg=label}
local coord = TextBox{parent=nt_div,x=2,text="",height=1,alignment=ALIGN.LEFT}
sv.register(db.ps, "sv_addr", function (addr) sv.set_value(util.c(addr, ":", config.SVR_Channel)) end)
coord.register(db.ps, "api_addr", function (addr) coord.set_value(util.c(addr, ":", config.CRD_Channel)) end)
nt_div.line_break()
TextBox{parent=nt_div,x=2,text="Message Authentication",height=1,alignment=ALIGN.LEFT,fg_bg=label}
local auth = util.trinary(type(config.AuthKey) == "string" and string.len(config.AuthKey) > 0, "HMAC-MD5", "None")
TextBox{parent=nt_div,x=2,text=auth,height=1,alignment=ALIGN.LEFT}
--#endregion
--#region Firmware Versions
local fw_div = Div{parent=about_root,x=1,y=2} local fw_div = Div{parent=about_root,x=1,y=2}
TextBox{parent=fw_div,y=1,text="Firmware Versions",height=1,alignment=ALIGN.CENTER} TextBox{parent=fw_div,y=1,text="Firmware Versions",height=1,alignment=ALIGN.CENTER}
@ -81,6 +118,10 @@ local function create_pages(root)
TextBox{parent=fw_list,x=2,text="Lockbox Version",height=1,alignment=ALIGN.LEFT,fg_bg=label} TextBox{parent=fw_list,x=2,text="Lockbox Version",height=1,alignment=ALIGN.LEFT,fg_bg=label}
TextBox{parent=fw_list,x=2,text=lockbox.version,height=1,alignment=ALIGN.LEFT} TextBox{parent=fw_list,x=2,text=lockbox.version,height=1,alignment=ALIGN.LEFT}
--#endregion
--#region Host Versions
local hw_div = Div{parent=about_root,x=1,y=2} local hw_div = Div{parent=about_root,x=1,y=2}
TextBox{parent=hw_div,y=1,text="Host Versions",height=1,alignment=ALIGN.CENTER} TextBox{parent=hw_div,y=1,text="Host Versions",height=1,alignment=ALIGN.CENTER}
@ -94,7 +135,9 @@ local function create_pages(root)
TextBox{parent=hw_div,x=2,text="Environment",height=1,alignment=ALIGN.LEFT,fg_bg=label} TextBox{parent=hw_div,x=2,text="Environment",height=1,alignment=ALIGN.LEFT,fg_bg=label}
TextBox{parent=hw_div,x=2,text=_HOST,height=6,alignment=ALIGN.LEFT} TextBox{parent=hw_div,x=2,text=_HOST,height=6,alignment=ALIGN.LEFT}
local root_pane = MultiPane{parent=about_root,x=1,y=1,panes={about,fw_div,hw_div}} --#endregion
local root_pane = MultiPane{parent=about_root,x=1,y=1,panes={about,nt_div,fw_div,hw_div}}
about_app.set_root_pane(root_pane) about_app.set_root_pane(root_pane)
end end