still display supervisor/coordinator address info if not linked to both

This commit is contained in:
Mikayla Fischler 2024-07-27 13:17:56 -04:00
parent d58a6a3369
commit f00751edeb
4 changed files with 38 additions and 21 deletions

View File

@ -38,10 +38,15 @@ local io = {
ps = psil.create() ps = psil.create()
} }
local config = nil ---@type pkt_config
-- initialize facility-independent components of pocket iocontrol -- initialize facility-independent components of pocket iocontrol
---@param comms pocket_comms ---@param comms pocket_comms
---@param nav pocket_nav ---@param nav pocket_nav
function iocontrol.init_core(comms, nav) ---@param cfg pkt_config
function iocontrol.init_core(comms, nav, cfg)
config = cfg
io.nav = nav io.nav = nav
---@class pocket_ioctl_diag ---@class pocket_ioctl_diag
@ -89,10 +94,9 @@ function iocontrol.init_core(comms, nav)
end end
-- initialize facility-dependent components of pocket iocontrol -- initialize facility-dependent components of pocket iocontrol
---@param conf facility_conf configuration ---@param conf facility_conf facility configuration
---@param temp_scale TEMP_SCALE temperature unit function iocontrol.init_fac(conf)
---@param energy_scale ENERGY_SCALE energy unit local temp_scale, energy_scale = config.TempScale, config.EnergyScale
function iocontrol.init_fac(conf, temp_scale, energy_scale)
io.temp_label = TEMP_UNITS[temp_scale] io.temp_label = TEMP_UNITS[temp_scale]
io.energy_label = ENERGY_UNITS[energy_scale] io.energy_label = ENERGY_UNITS[energy_scale]
@ -346,8 +350,8 @@ end
-- set network link state -- set network link state
---@param state POCKET_LINK_STATE ---@param state POCKET_LINK_STATE
---@param sv_addr integer? supervisor address if linked ---@param sv_addr integer|false|nil supervisor address if linked, nil if unchanged, false if unlinked
---@param api_addr integer? coordinator address if linked ---@param api_addr integer|false|nil coordinator address if linked, nil if unchanged, false if unlinked
function iocontrol.report_link_state(state, sv_addr, api_addr) function iocontrol.report_link_state(state, sv_addr, api_addr)
io.ps.publish("link_state", state) io.ps.publish("link_state", state)
@ -359,8 +363,17 @@ function iocontrol.report_link_state(state, sv_addr, api_addr)
io.ps.publish("crd_conn_quality", 0) io.ps.publish("crd_conn_quality", 0)
end end
if sv_addr then io.ps.publish("sv_addr", sv_addr) end if sv_addr then
if api_addr then io.ps.publish("api_addr", api_addr) end io.ps.publish("sv_addr", util.c(sv_addr, ":", config.SVR_Channel))
elseif sv_addr == false then
io.ps.publish("sv_addr", "unknown (not linked)")
end
if api_addr then
io.ps.publish("api_addr", util.c(api_addr, ":", config.CRD_Channel))
elseif api_addr == false then
io.ps.publish("api_addr", "unknown (not linked)")
end
end end
-- determine supervisor connection quality (trip time) -- determine supervisor connection quality (trip time)

View File

@ -493,7 +493,11 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
-- attempt to re-link if any of the dependent links aren't active -- attempt to re-link if any of the dependent links aren't active
function public.link_update() function public.link_update()
if not self.sv.linked then if not self.sv.linked then
iocontrol.report_link_state(util.trinary(self.api.linked, LINK_STATE.API_LINK_ONLY, LINK_STATE.UNLINKED)) if self.api.linked then
iocontrol.report_link_state(LINK_STATE.API_LINK_ONLY, false, nil)
else
iocontrol.report_link_state(LINK_STATE.UNLINKED, false, false)
end
if self.establish_delay_counter <= 0 then if self.establish_delay_counter <= 0 then
_send_sv_establish() _send_sv_establish()
@ -502,7 +506,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
self.establish_delay_counter = self.establish_delay_counter - 1 self.establish_delay_counter = self.establish_delay_counter - 1
end end
elseif not self.api.linked then elseif not self.api.linked then
iocontrol.report_link_state(LINK_STATE.SV_LINK_ONLY) iocontrol.report_link_state(LINK_STATE.SV_LINK_ONLY, nil, false)
if self.establish_delay_counter <= 0 then if self.establish_delay_counter <= 0 then
_send_api_establish() _send_api_establish()
@ -512,7 +516,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
end end
else else
-- linked, all good! -- linked, all good!
iocontrol.report_link_state(LINK_STATE.LINKED, self.sv.addr, self.api.addr) iocontrol.report_link_state(LINK_STATE.LINKED)
end end
end end
@ -678,7 +682,7 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
-- get configuration -- get configuration
local conf = { num_units = fac_config[1], cooling = fac_config[2] } local conf = { num_units = fac_config[1], cooling = fac_config[2] }
iocontrol.init_fac(conf, config.TempScale, config.EnergyScale) iocontrol.init_fac(conf)
log.info("coordinator connection established") log.info("coordinator connection established")
self.establish_delay_counter = 0 self.establish_delay_counter = 0
@ -686,9 +690,9 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
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, self.sv.addr, self.api.addr) iocontrol.report_link_state(LINK_STATE.LINKED, nil, self.api.addr)
else else
iocontrol.report_link_state(LINK_STATE.API_LINK_ONLY) iocontrol.report_link_state(LINK_STATE.API_LINK_ONLY, nil, self.api.addr)
end end
else else
log.debug("invalid facility configuration table received from coordinator, establish failed") log.debug("invalid facility configuration table received from coordinator, establish failed")
@ -826,9 +830,9 @@ function pocket.comms(version, nic, sv_watchdog, api_watchdog, nav)
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, self.sv.addr, self.api.addr) iocontrol.report_link_state(LINK_STATE.LINKED, self.sv.addr, nil)
else else
iocontrol.report_link_state(LINK_STATE.SV_LINK_ONLY) iocontrol.report_link_state(LINK_STATE.SV_LINK_ONLY, self.sv.addr, nil)
end end
elseif est_ack == ESTABLISH_ACK.DENY then elseif est_ack == ESTABLISH_ACK.DENY then
if self.sv.last_est_ack ~= est_ack then if self.sv.last_est_ack ~= est_ack then

View File

@ -20,7 +20,7 @@ local pocket = require("pocket.pocket")
local renderer = require("pocket.renderer") local renderer = require("pocket.renderer")
local threads = require("pocket.threads") local threads = require("pocket.threads")
local POCKET_VERSION = "v0.11.3-alpha" local POCKET_VERSION = "v0.11.4-alpha"
local println = util.println local println = util.println
local println_ts = util.println_ts local println_ts = util.println_ts
@ -152,7 +152,7 @@ local function main()
log.debug("startup> comms init") log.debug("startup> comms init")
-- init I/O control -- init I/O control
iocontrol.init_core(smem_sys.pocket_comms, smem_sys.nav) iocontrol.init_core(smem_sys.pocket_comms, smem_sys.nav, config)
---------------------------------------- ----------------------------------------
-- start the UI -- start the UI

View File

@ -75,8 +75,8 @@ local function create_pages(root)
TextBox{parent=nt_div,x=2,text="Coordinator Address",alignment=ALIGN.LEFT,fg_bg=label} TextBox{parent=nt_div,x=2,text="Coordinator Address",alignment=ALIGN.LEFT,fg_bg=label}
local coord = TextBox{parent=nt_div,x=2,text="",alignment=ALIGN.LEFT} local coord = TextBox{parent=nt_div,x=2,text="",alignment=ALIGN.LEFT}
sv.register(db.ps, "sv_addr", function (addr) sv.set_value(util.c(addr, ":", config.SVR_Channel)) end) sv.register(db.ps, "sv_addr", sv.set_value)
coord.register(db.ps, "api_addr", function (addr) coord.set_value(util.c(addr, ":", config.CRD_Channel)) end) coord.register(db.ps, "api_addr", coord.set_value)
nt_div.line_break() nt_div.line_break()
TextBox{parent=nt_div,x=2,text="Message Authentication",alignment=ALIGN.LEFT,fg_bg=label} TextBox{parent=nt_div,x=2,text="Message Authentication",alignment=ALIGN.LEFT,fg_bg=label}