#401 supervisor and coordinator computer display
This commit is contained in:
parent
1ce0bbfc65
commit
f4d4de659c
@ -2,10 +2,13 @@
|
|||||||
-- I/O Control's Data Receive (Rx) Handlers
|
-- I/O Control's Data Receive (Rx) Handlers
|
||||||
--
|
--
|
||||||
|
|
||||||
|
local comms = require("scada-common.comms")
|
||||||
local const = require("scada-common.constants")
|
local const = require("scada-common.constants")
|
||||||
local types = require("scada-common.types")
|
local types = require("scada-common.types")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
|
local DEV_TYPE = comms.DEVICE_TYPE
|
||||||
|
|
||||||
local ALARM = types.ALARM
|
local ALARM = types.ALARM
|
||||||
local ALARM_STATE = types.ALARM_STATE
|
local ALARM_STATE = types.ALARM_STATE
|
||||||
|
|
||||||
@ -878,28 +881,51 @@ local comp_record = {}
|
|||||||
function iorx.record_network_data(data)
|
function iorx.record_network_data(data)
|
||||||
local ps = io.facility.ps
|
local ps = io.facility.ps
|
||||||
local connected = {}
|
local connected = {}
|
||||||
|
local crd_online = false
|
||||||
|
|
||||||
|
ps.publish("comp_online", #data)
|
||||||
|
|
||||||
-- add/update connected computers
|
-- add/update connected computers
|
||||||
for i = 1, #data do
|
for i = 1, #data do
|
||||||
local entry = data[i]
|
local entry = data[i]
|
||||||
|
local type = entry[1]
|
||||||
local id = entry[2]
|
local id = entry[2]
|
||||||
local pfx = "comp_" .. id
|
local pfx = "comp_" .. id
|
||||||
|
|
||||||
connected[id] = true
|
connected[id] = true
|
||||||
|
|
||||||
ps.publish(pfx .. "_type", entry[1])
|
if type == DEV_TYPE.SVR then
|
||||||
ps.publish(pfx .. "_addr", id)
|
ps.publish("comp_svr_addr", id)
|
||||||
ps.publish(pfx .. "_fw", entry[3])
|
ps.publish("comp_svr_fw", entry[3])
|
||||||
ps.publish(pfx .. "_rtt", entry[4])
|
elseif type == DEV_TYPE.CRD then
|
||||||
|
crd_online = true
|
||||||
|
ps.publish("comp_crd_addr", id)
|
||||||
|
ps.publish("comp_crd_fw", entry[3])
|
||||||
|
ps.publish("comp_crd_rtt", entry[4])
|
||||||
|
else
|
||||||
|
ps.publish(pfx .. "_type", entry[1])
|
||||||
|
ps.publish(pfx .. "_addr", id)
|
||||||
|
ps.publish(pfx .. "_fw", entry[3])
|
||||||
|
ps.publish(pfx .. "_rtt", entry[4])
|
||||||
|
|
||||||
if not comp_record[id] then
|
if not comp_record[id] then
|
||||||
comp_record[id] = true
|
comp_record[id] = true
|
||||||
|
|
||||||
-- trigger the app to create the new element
|
-- trigger the app to create the new element
|
||||||
ps.publish("comp_connect", id)
|
ps.publish("comp_connect", id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- handle the coordinator being online or not
|
||||||
|
-- no need to worry about the supervisor since this data is from the supervisor, so it has to be 'online' if received
|
||||||
|
ps.publish("comp_crd_online", crd_online)
|
||||||
|
if not crd_online then
|
||||||
|
ps.publish("comp_crd_addr", "---")
|
||||||
|
ps.publish("comp_crd_fw", "---")
|
||||||
|
ps.publish("comp_crd_rtt", "---")
|
||||||
|
end
|
||||||
|
|
||||||
-- reset the published value
|
-- reset the published value
|
||||||
ps.publish("comp_connect", false)
|
ps.publish("comp_connect", false)
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ local TextBox = require("graphics.elements.TextBox")
|
|||||||
|
|
||||||
local WaitingAnim = require("graphics.elements.animations.Waiting")
|
local WaitingAnim = require("graphics.elements.animations.Waiting")
|
||||||
|
|
||||||
local RadIndicator = require("graphics.elements.indicators.RadIndicator")
|
local DataIndicator = require("graphics.elements.indicators.DataIndicator")
|
||||||
|
|
||||||
local ALIGN = core.ALIGN
|
local ALIGN = core.ALIGN
|
||||||
local cpair = core.cpair
|
local cpair = core.cpair
|
||||||
@ -30,6 +30,11 @@ local APP_ID = pocket.APP_ID
|
|||||||
local label_fg_bg = style.label
|
local label_fg_bg = style.label
|
||||||
local lu_col = style.label_unit_pair
|
local lu_col = style.label_unit_pair
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
local HIGH_RTT = 500 -- 3.33x as long as expected w/ 0 ping
|
||||||
|
|
||||||
-- new computer list page view
|
-- new computer list page view
|
||||||
---@param root Container parent
|
---@param root Container parent
|
||||||
local function new_view(root)
|
local function new_view(root)
|
||||||
@ -107,7 +112,7 @@ local function new_view(root)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
--#region overview page
|
--#region main computer page
|
||||||
|
|
||||||
local m_pane = panes[1]
|
local m_pane = panes[1]
|
||||||
local m_div = Div{parent=m_pane,x=2,width=main.get_width()-2}
|
local m_div = Div{parent=m_pane,x=2,width=main.get_width()-2}
|
||||||
@ -117,9 +122,62 @@ local function new_view(root)
|
|||||||
|
|
||||||
TextBox{parent=m_div,y=1,text="Connected Computers",alignment=ALIGN.CENTER}
|
TextBox{parent=m_div,y=1,text="Connected Computers",alignment=ALIGN.CENTER}
|
||||||
|
|
||||||
TextBox{parent=m_div,y=3,text="Networked Computers",fg_bg=label_fg_bg}
|
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}
|
||||||
local s_f_rad = RadIndicator{parent=m_div,label="",format="%17.3f",lu_colors=lu_col,width=21}
|
conns.register(f_ps, "comp_online", conns.update)
|
||||||
s_f_rad.register(f_ps, "radiation", s_f_rad.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)}
|
||||||
|
|
||||||
|
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="---"}
|
||||||
|
|
||||||
|
svr_addr.register(f_ps, "comp_svr_addr", svr_addr.set_value)
|
||||||
|
svr_fw.register(f_ps, "comp_svr_fw", svr_fw.set_value)
|
||||||
|
|
||||||
|
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)}
|
||||||
|
|
||||||
|
TextBox{parent=crd_rect,text="Coordinator"}
|
||||||
|
local crd_online = TextBox{parent=svr_rect,x=12,y=1,width=7,text="Online",fg_bg=cpair(colors.green,colors._INHERIT)}
|
||||||
|
TextBox{parent=crd_rect,text="Computer ID",fg_bg=label_fg_bg}
|
||||||
|
TextBox{parent=crd_rect,text="Firmware",fg_bg=label_fg_bg}
|
||||||
|
TextBox{parent=crd_rect,text="Round-Trip Time",fg_bg=label_fg_bg}
|
||||||
|
local crd_addr = TextBox{parent=svr_rect,x=13,y=2,text="---"}
|
||||||
|
local crd_fw = TextBox{parent=svr_rect,x=13,y=3,text="---"}
|
||||||
|
local crd_rtt = TextBox{parent=svr_rect,x=13,y=3,text="---"}
|
||||||
|
|
||||||
|
crd_addr.register(f_ps, "comp_crd_addr", crd_addr.set_value)
|
||||||
|
crd_fw.register(f_ps, "comp_crd_fw", crd_fw.set_value)
|
||||||
|
|
||||||
|
crd_online.register(f_ps, "comp_crd_online", function (online)
|
||||||
|
if online then
|
||||||
|
crd_online.set_value("Online")
|
||||||
|
crd_online.recolor(colors.green)
|
||||||
|
else
|
||||||
|
crd_online.set_value("Off-line")
|
||||||
|
crd_online.recolor(colors.red)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
crd_rtt.register(f_ps, "comp_crd_rtt", function (rtt)
|
||||||
|
crd_rtt.set_value(rtt)
|
||||||
|
|
||||||
|
if type(rtt) ~= "number" then
|
||||||
|
crd_rtt.recolor(label_fg_bg.fgd)
|
||||||
|
else
|
||||||
|
if rtt > HIGH_RTT then
|
||||||
|
crd_rtt.recolor(colors.red)
|
||||||
|
elseif rtt > WARN_RTT then
|
||||||
|
crd_rtt.recolor(colors.yellow)
|
||||||
|
else
|
||||||
|
crd_rtt.recolor(colors.green)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
--#endregion
|
--#endregion
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ local util = require("scada-common.util")
|
|||||||
local pgi = require("supervisor.panel.pgi")
|
local pgi = require("supervisor.panel.pgi")
|
||||||
|
|
||||||
-- nominal RTT is ping (0ms to 10ms usually) + 150ms for SV main loop tick
|
-- nominal RTT is ping (0ms to 10ms usually) + 150ms for SV main loop tick
|
||||||
|
-- ensure in sync with pocket computer list app
|
||||||
local WARN_RTT = 300 -- 2x as long as expected w/ 0 ping
|
local WARN_RTT = 300 -- 2x as long as expected w/ 0 ping
|
||||||
local HIGH_RTT = 500 -- 3.33x as long as expected w/ 0 ping
|
local HIGH_RTT = 500 -- 3.33x as long as expected w/ 0 ping
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user