#201 functional pocket comms with supervisor and coordinator, adjusted some UI element positioning, bugfixes with apisessions and svsessions

This commit is contained in:
Mikayla Fischler
2023-04-19 20:35:42 -04:00
parent b48c956354
commit 7929318096
13 changed files with 84 additions and 49 deletions

View File

@@ -152,6 +152,8 @@ function pocket.comms(version, modem, local_port, sv_port, api_port, range, sv_w
-- attempt to re-link if any of the dependent links aren't active
function public.link_update()
if not self.sv.linked then
coreio.report_link_state(util.trinary(self.api.linked, LINK_STATE.API_LINK_ONLY, LINK_STATE.UNLINKED))
if self.establish_delay_counter <= 0 then
_send_sv_establish()
self.establish_delay_counter = 4
@@ -159,6 +161,8 @@ function pocket.comms(version, modem, local_port, sv_port, api_port, range, sv_w
self.establish_delay_counter = self.establish_delay_counter - 1
end
elseif not self.api.linked then
coreio.report_link_state(LINK_STATE.SV_LINK_ONLY)
if self.establish_delay_counter <= 0 then
_send_api_establish()
self.establish_delay_counter = 4
@@ -167,6 +171,7 @@ function pocket.comms(version, modem, local_port, sv_port, api_port, range, sv_w
end
else
-- linked, all good!
coreio.report_link_state(LINK_STATE.LINKED)
end
end

View File

@@ -17,7 +17,7 @@ local coreio = require("pocket.coreio")
local pocket = require("pocket.pocket")
local renderer = require("pocket.renderer")
local POCKET_VERSION = "alpha-v0.2.1"
local POCKET_VERSION = "alpha-v0.2.2"
local println = util.println
local println_ts = util.println_ts
@@ -89,8 +89,8 @@ local function main()
log.debug("startup> conn watchdogs created")
-- start comms, open all channels
local pocket_comms = pocket.comms(POCKET_VERSION, modem, config.SCADA_SV_PORT, config.SCADA_API_PORT,
config.LISTEN_PORT, config.TRUSTED_RANGE, conn_wd.sv, conn_wd.api)
local pocket_comms = pocket.comms(POCKET_VERSION, modem, config.LISTEN_PORT, config.SCADA_SV_PORT,
config.SCADA_API_PORT, config.TRUSTED_RANGE, conn_wd.sv, conn_wd.api)
log.debug("startup> comms init")
-- base loop clock (2Hz, 10 ticks)

View File

@@ -19,17 +19,20 @@ local cpair = core.graphics.cpair
---@param parent graphics_element parent
---@param y integer y offset
local function init(parent, y, is_api)
-- root div
local root = Div{parent=parent,x=1,y=1}
-- bounding box div
local root = Div{parent=parent,x=1,y=y,height=5}
local box = Div{parent=root,x=1,y=y,height=5}
local waiting_x = math.floor(parent.width() / 2) - 1
if is_api then
WaitingAnim{parent=root,x=waiting_x,y=1,fg_bg=cpair(colors.blue,style.root.bkg)}
TextBox{parent=root,text="Connecting to API",alignment=TEXT_ALIGN.CENTER,y=5,height=1,fg_bg=cpair(colors.white,style.root.bkg)}
WaitingAnim{parent=box,x=waiting_x,y=1,fg_bg=cpair(colors.blue,style.root.bkg)}
TextBox{parent=box,text="Connecting to API",alignment=TEXT_ALIGN.CENTER,y=5,height=1,fg_bg=cpair(colors.white,style.root.bkg)}
else
WaitingAnim{parent=root,x=waiting_x,y=1,fg_bg=cpair(colors.green,style.root.bkg)}
TextBox{parent=root,text="Connecting to Supervisor",alignment=TEXT_ALIGN.CENTER,y=5,height=1,fg_bg=cpair(colors.white,style.root.bkg)}
WaitingAnim{parent=box,x=waiting_x,y=1,fg_bg=cpair(colors.green,style.root.bkg)}
TextBox{parent=box,text="Connecting to Supervisor",alignment=TEXT_ALIGN.CENTER,y=5,height=1,fg_bg=cpair(colors.white,style.root.bkg)}
end
return root

View File

@@ -69,7 +69,7 @@ local function init(monitor)
-- main page panel panes & sidebar
--
local page_div = Div{parent=main_pane,x=4,y=2}
local page_div = Div{parent=main_pane,x=4,y=1}
local sidebar_tabs = {
{
@@ -103,7 +103,7 @@ local function init(monitor)
local page_pane = MultiPane{parent=page_div,x=1,y=1,panes=panes}
Sidebar{parent=main_pane,x=1,y=2,tabs=sidebar_tabs,fg_bg=cpair(colors.white,colors.gray),callback=page_pane.set_value}
Sidebar{parent=main_pane,x=1,y=1,tabs=sidebar_tabs,fg_bg=cpair(colors.white,colors.gray),callback=page_pane.set_value}
return main
end