|
|
|
|
@@ -33,6 +33,8 @@ local APP_ID = pocket.APP_ID
|
|
|
|
|
local label_fg_bg = style.label
|
|
|
|
|
local lu_col = style.label_unit_pair
|
|
|
|
|
|
|
|
|
|
local box_label = cpair(colors.lightGray, colors.gray)
|
|
|
|
|
|
|
|
|
|
-- nominal RTT is ping (0ms to 10ms usually) + 150ms for SV main loop tick
|
|
|
|
|
-- ensure in sync with supervisor databus file
|
|
|
|
|
local WARN_RTT = 300 -- 2x as long as expected w/ 0 ping
|
|
|
|
|
@@ -61,7 +63,7 @@ local function new_view(root)
|
|
|
|
|
|
|
|
|
|
-- load the app (create the elements)
|
|
|
|
|
local function load()
|
|
|
|
|
local f_ps = db.facility.ps
|
|
|
|
|
local ps = db.ps
|
|
|
|
|
|
|
|
|
|
page_div = Div{parent=main,y=2,width=main.get_width()}
|
|
|
|
|
|
|
|
|
|
@@ -86,20 +88,24 @@ local function new_view(root)
|
|
|
|
|
---@param pfx string
|
|
|
|
|
---@param rect Rectangle
|
|
|
|
|
local function create_common_indicators(pfx, rect)
|
|
|
|
|
TextBox{parent=rect,text="Computer ID",fg_bg=label_fg_bg}
|
|
|
|
|
TextBox{parent=rect,text="Firmware",fg_bg=label_fg_bg}
|
|
|
|
|
TextBox{parent=rect,text="Round-Trip Time",fg_bg=label_fg_bg}
|
|
|
|
|
local addr = TextBox{parent=rect,x=13,y=2,text="---"}
|
|
|
|
|
local fw = TextBox{parent=rect,x=13,y=3,text="---"}
|
|
|
|
|
local rtt = TextBox{parent=rect,x=13,y=3,text="---"}
|
|
|
|
|
local first = TextBox{parent=rect,text="Computer",fg_bg=box_label}
|
|
|
|
|
TextBox{parent=rect,text="Firmware",fg_bg=box_label}
|
|
|
|
|
TextBox{parent=rect,text="RTT",fg_bg=box_label}
|
|
|
|
|
|
|
|
|
|
addr.register(f_ps, pfx .. "_addr", addr.set_value)
|
|
|
|
|
fw.register(f_ps, pfx .. "_fw", fw.set_value)
|
|
|
|
|
local y = first.get_y()
|
|
|
|
|
local addr = TextBox{parent=rect,x=10,y=y,text="---"}
|
|
|
|
|
local fw = TextBox{parent=rect,x=10,y=y+1,text="---"}
|
|
|
|
|
local rtt = TextBox{parent=rect,x=10,y=y+2,text="---"}
|
|
|
|
|
|
|
|
|
|
rtt.register(f_ps, pfx.. "_rtt", function (value)
|
|
|
|
|
rtt.set_value(rtt)
|
|
|
|
|
addr.register(ps, pfx .. "_addr", function (v) addr.set_value(util.strval(v)) end)
|
|
|
|
|
fw.register(ps, pfx .. "_fw", function (v) fw.set_value(util.strval(v)) end)
|
|
|
|
|
|
|
|
|
|
if value > HIGH_RTT then
|
|
|
|
|
rtt.register(ps, pfx .. "_rtt", function (value)
|
|
|
|
|
rtt.set_value(util.strval(value))
|
|
|
|
|
|
|
|
|
|
if value == "---" then
|
|
|
|
|
rtt.recolor(colors.white)
|
|
|
|
|
elseif value > HIGH_RTT then
|
|
|
|
|
rtt.recolor(colors.red)
|
|
|
|
|
elseif value > WARN_RTT then
|
|
|
|
|
rtt.recolor(colors.yellow)
|
|
|
|
|
@@ -118,37 +124,39 @@ local function new_view(root)
|
|
|
|
|
|
|
|
|
|
TextBox{parent=m_div,y=1,text="Connected Computers",alignment=ALIGN.CENTER}
|
|
|
|
|
|
|
|
|
|
local conns = DataIndicator{parent=m_div,x=10,y=3,lu_colors=lu_col,label="Online",unit="",format="%3d",value=0,commas=true,width=21}
|
|
|
|
|
conns.register(f_ps, "comp_online", conns.update)
|
|
|
|
|
local conns = DataIndicator{parent=m_div,y=3,lu_colors=lu_col,label="Total Online",unit="",format="%8d",value=0,commas=true,width=21}
|
|
|
|
|
conns.register(ps, "comp_online", conns.update)
|
|
|
|
|
|
|
|
|
|
local svr_div = Div{parent=m_div,y=5,height=5}
|
|
|
|
|
local svr_rect = Rectangle{parent=svr_div,height=5,x=2,width=21,border=border(1,colors.gray,true),thin=true,fg_bg=cpair(colors.black,colors.lightGray)}
|
|
|
|
|
local svr_div = Div{parent=m_div,y=4,height=6}
|
|
|
|
|
local svr_rect = Rectangle{parent=svr_div,height=6,width=22,border=border(1,colors.white,true),thin=true,fg_bg=cpair(colors.white,colors.gray)}
|
|
|
|
|
|
|
|
|
|
TextBox{parent=svr_rect,text="Supervisor"}
|
|
|
|
|
TextBox{parent=svr_rect,x=12,y=1,width=6,text="Online",fg_bg=cpair(colors.green,colors._INHERIT)}
|
|
|
|
|
TextBox{parent=svr_rect,text="Computer ID",fg_bg=label_fg_bg}
|
|
|
|
|
TextBox{parent=svr_rect,text="Firmware",fg_bg=label_fg_bg}
|
|
|
|
|
local svr_addr = TextBox{parent=svr_rect,x=13,y=2,text="---"}
|
|
|
|
|
local svr_fw = TextBox{parent=svr_rect,x=13,y=3,text="---"}
|
|
|
|
|
TextBox{parent=svr_rect,text="Status",fg_bg=box_label}
|
|
|
|
|
TextBox{parent=svr_rect,x=10,y=2,text="Online",fg_bg=cpair(colors.green,colors._INHERIT)}
|
|
|
|
|
TextBox{parent=svr_rect,text="Computer",fg_bg=box_label}
|
|
|
|
|
TextBox{parent=svr_rect,text="Firmware",fg_bg=box_label}
|
|
|
|
|
local svr_addr = TextBox{parent=svr_rect,x=10,y=3,text="?"}
|
|
|
|
|
local svr_fw = TextBox{parent=svr_rect,x=10,y=4,text="?"}
|
|
|
|
|
|
|
|
|
|
svr_addr.register(f_ps, "comp_svr_addr", svr_addr.set_value)
|
|
|
|
|
svr_fw.register(f_ps, "comp_svr_fw", svr_fw.set_value)
|
|
|
|
|
svr_addr.register(ps, "comp_svr_addr", function (v) svr_addr.set_value(util.strval(v)) end)
|
|
|
|
|
svr_fw.register(ps, "comp_svr_fw", function (v) svr_fw.set_value(util.strval(v)) end)
|
|
|
|
|
|
|
|
|
|
local crd_div = Div{parent=m_div,y=5,height=5}
|
|
|
|
|
local crd_rect = Rectangle{parent=crd_div,height=6,x=2,width=21,border=border(1,colors.gray,true),thin=true,fg_bg=cpair(colors.black,colors.lightGray)}
|
|
|
|
|
local crd_div = Div{parent=m_div,y=11,height=9}
|
|
|
|
|
local crd_rect = Rectangle{parent=crd_div,height=7,width=21,border=border(1,colors.white,true),thin=true,fg_bg=cpair(colors.white,colors.gray)}
|
|
|
|
|
|
|
|
|
|
TextBox{parent=crd_rect,text="Coordinator"}
|
|
|
|
|
local crd_online = TextBox{parent=crd_rect,x=12,y=1,width=7,text="Online",fg_bg=cpair(colors.green,colors._INHERIT)}
|
|
|
|
|
TextBox{parent=crd_rect,text="Status",fg_bg=box_label}
|
|
|
|
|
local crd_online = TextBox{parent=crd_rect,x=10,y=2,width=8,text="Off-line",fg_bg=cpair(colors.red,colors._INHERIT)}
|
|
|
|
|
|
|
|
|
|
create_common_indicators("comp_crd", crd_rect)
|
|
|
|
|
|
|
|
|
|
crd_online.register(f_ps, "comp_crd_online", function (online)
|
|
|
|
|
crd_online.register(ps, "comp_crd_online", function (online)
|
|
|
|
|
if online then
|
|
|
|
|
crd_online.set_value("Online")
|
|
|
|
|
crd_online.recolor(colors.green)
|
|
|
|
|
crd_online.set_value("Online")
|
|
|
|
|
else
|
|
|
|
|
crd_online.set_value("Off-line")
|
|
|
|
|
crd_online.recolor(colors.red)
|
|
|
|
|
crd_online.set_value("Off-line")
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
@@ -198,16 +206,18 @@ local function new_view(root)
|
|
|
|
|
|
|
|
|
|
--#region connect/disconnect management
|
|
|
|
|
|
|
|
|
|
f_ps.subscribe("comp_connect", function (id)
|
|
|
|
|
ps.subscribe("comp_connect", function (id)
|
|
|
|
|
if id == false then return end
|
|
|
|
|
|
|
|
|
|
local pfx = "comp_" .. id
|
|
|
|
|
local type = f_ps.get(pfx .. "_type")
|
|
|
|
|
local type = ps.get(pfx .. "_type")
|
|
|
|
|
|
|
|
|
|
if type == DEV_TYPE.PLC then
|
|
|
|
|
plc_elems[id] = Div{parent=plc_list,height=5}
|
|
|
|
|
local rect = Rectangle{parent=plc_elems[id],height=6,x=2,width=20,border=border(1,colors.gray,true),thin=true,fg_bg=cpair(colors.black,colors.lightGray)}
|
|
|
|
|
|
|
|
|
|
local title = TextBox{parent=rect,text="PLC (Unit ?) @ "..id}
|
|
|
|
|
title.register(f_ps, pfx .. "_unit", function (unit) title.set_value("PLC (Unit " .. unit .. ") @ " .. id) end)
|
|
|
|
|
title.register(ps, pfx .. "_unit", function (unit) title.set_value("PLC (Unit " .. unit .. ") @ " .. id) end)
|
|
|
|
|
|
|
|
|
|
create_common_indicators(pfx, rect)
|
|
|
|
|
elseif type == DEV_TYPE.RTU then
|
|
|
|
|
@@ -227,8 +237,10 @@ local function new_view(root)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
f_ps.subscribe("comp_disconnect", function (id)
|
|
|
|
|
local type = f_ps.get("comp_" ..id .. "_type")
|
|
|
|
|
ps.subscribe("comp_disconnect", function (id)
|
|
|
|
|
if id == false then return end
|
|
|
|
|
|
|
|
|
|
local type = ps.get("comp_" ..id .. "_type")
|
|
|
|
|
|
|
|
|
|
if type == DEV_TYPE.PLC then
|
|
|
|
|
if plc_elems[id] then plc_elems[id].delete() end
|
|
|
|
|
@@ -252,7 +264,7 @@ local function new_view(root)
|
|
|
|
|
|
|
|
|
|
local list = {
|
|
|
|
|
{ label = " # ", tall = true, color = core.cpair(colors.black, colors.green), callback = db.nav.go_home },
|
|
|
|
|
{ label = " \x1e ", color = core.cpair(colors.black, colors.blue), callback = main_page.nav_to },
|
|
|
|
|
{ label = " @ ", color = core.cpair(colors.black, colors.blue), callback = main_page.nav_to },
|
|
|
|
|
{ label = "PLC", color = core.cpair(colors.black, colors.red), callback = plc_page.nav_to },
|
|
|
|
|
{ label = "RTU", color = core.cpair(colors.black, colors.orange), callback = rtu_page.nav_to },
|
|
|
|
|
{ label = "PKT", color = core.cpair(colors.black, colors.gray), callback = pkt_page.nav_to }
|
|
|
|
|
|