2023-05-05 17:04:13 +00:00
|
|
|
--
|
2023-07-10 03:22:24 +00:00
|
|
|
-- Supervisor Front Panel GUI
|
2023-05-05 17:04:13 +00:00
|
|
|
--
|
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
local util = require("scada-common.util")
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
local databus = require("supervisor.databus")
|
2023-12-31 19:04:22 +00:00
|
|
|
local supervisor = require("supervisor.supervisor")
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-06-03 18:33:08 +00:00
|
|
|
local pgi = require("supervisor.panel.pgi")
|
2023-05-23 23:22:22 +00:00
|
|
|
local style = require("supervisor.panel.style")
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
local chk_entry = require("supervisor.panel.components.chk_entry")
|
2023-06-03 18:33:08 +00:00
|
|
|
local pdg_entry = require("supervisor.panel.components.pdg_entry")
|
|
|
|
local rtu_entry = require("supervisor.panel.components.rtu_entry")
|
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
local core = require("graphics.core")
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
local Div = require("graphics.elements.div")
|
|
|
|
local ListBox = require("graphics.elements.listbox")
|
|
|
|
local MultiPane = require("graphics.elements.multipane")
|
|
|
|
local TextBox = require("graphics.elements.textbox")
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
local TabBar = require("graphics.elements.controls.tabbar")
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
local LED = require("graphics.elements.indicators.led")
|
|
|
|
local DataIndicator = require("graphics.elements.indicators.data")
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-10-04 03:16:46 +00:00
|
|
|
local ALIGN = core.ALIGN
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-05-12 00:06:41 +00:00
|
|
|
local cpair = core.cpair
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-09-02 02:24:31 +00:00
|
|
|
local ind_grn = style.ind_grn
|
|
|
|
|
2023-07-10 03:22:24 +00:00
|
|
|
-- create new front panel view
|
2023-05-05 17:04:13 +00:00
|
|
|
---@param panel graphics_element main displaybox
|
|
|
|
local function init(panel)
|
2024-03-08 00:23:46 +00:00
|
|
|
local s_hi_box = style.theme.highlight_box
|
|
|
|
local s_hi_bright = style.theme.highlight_box_bright
|
|
|
|
|
|
|
|
local label_fg = style.fp.label_fg
|
|
|
|
local label_d_fg = style.fp.label_d_fg
|
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=panel,y=1,text="SCADA SUPERVISOR",alignment=ALIGN.CENTER,fg_bg=style.theme.header}
|
2023-05-05 17:04:13 +00:00
|
|
|
|
|
|
|
local page_div = Div{parent=panel,x=1,y=3}
|
|
|
|
|
|
|
|
--
|
|
|
|
-- system indicators
|
|
|
|
--
|
|
|
|
|
|
|
|
local main_page = Div{parent=page_div,x=1,y=1}
|
|
|
|
|
|
|
|
local system = Div{parent=main_page,width=14,height=17,x=2,y=2}
|
|
|
|
|
2023-06-03 18:33:08 +00:00
|
|
|
local on = LED{parent=system,label="STATUS",colors=cpair(colors.green,colors.red)}
|
2023-09-02 02:24:31 +00:00
|
|
|
local heartbeat = LED{parent=system,label="HEARTBEAT",colors=ind_grn}
|
2023-05-05 17:04:13 +00:00
|
|
|
on.update(true)
|
|
|
|
system.line_break()
|
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
heartbeat.register(databus.ps, "heartbeat", heartbeat.update)
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-09-02 02:24:31 +00:00
|
|
|
local modem = LED{parent=system,label="MODEM",colors=ind_grn}
|
2023-05-05 17:04:13 +00:00
|
|
|
system.line_break()
|
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
modem.register(databus.ps, "has_modem", modem.update)
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-06-05 22:10:53 +00:00
|
|
|
---@diagnostic disable-next-line: undefined-field
|
|
|
|
local comp_id = util.sprintf("(%d)", os.getComputerID())
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=system,x=9,y=4,width=6,text=comp_id,fg_bg=style.fp.disabled_fg}
|
2023-06-05 22:10:53 +00:00
|
|
|
|
2023-06-03 19:50:44 +00:00
|
|
|
--
|
2023-05-05 17:04:13 +00:00
|
|
|
-- about footer
|
|
|
|
--
|
|
|
|
|
2024-03-06 16:43:31 +00:00
|
|
|
local about = Div{parent=main_page,width=15,height=3,x=1,y=16,fg_bg=style.fp.disabled_fg}
|
2024-06-30 17:55:13 +00:00
|
|
|
local fw_v = TextBox{parent=about,x=1,y=1,text="FW: v00.00.00",alignment=ALIGN.LEFT}
|
|
|
|
local comms_v = TextBox{parent=about,x=1,y=2,text="NT: v00.00.00",alignment=ALIGN.LEFT}
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-05-23 23:22:22 +00:00
|
|
|
fw_v.register(databus.ps, "version", function (version) fw_v.set_value(util.c("FW: ", version)) end)
|
|
|
|
comms_v.register(databus.ps, "comms_version", function (version) comms_v.set_value(util.c("NT: v", version)) end)
|
2023-05-05 17:04:13 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- page handling
|
|
|
|
--
|
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
-- plc sessions page
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-05-31 15:44:41 +00:00
|
|
|
local plc_page = Div{parent=page_div,x=1,y=1,hidden=true}
|
2023-05-23 23:22:22 +00:00
|
|
|
local plc_list = Div{parent=plc_page,x=2,y=2,width=49}
|
2023-05-05 17:04:13 +00:00
|
|
|
|
2023-12-31 19:04:22 +00:00
|
|
|
for i = 1, supervisor.config.UnitCount do
|
2023-05-23 23:22:22 +00:00
|
|
|
local ps_prefix = "plc_" .. i .. "_"
|
2024-03-06 16:43:31 +00:00
|
|
|
local plc_entry = Div{parent=plc_list,height=3,fg_bg=s_hi_bright}
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=plc_entry,x=1,y=1,text="",width=8,fg_bg=s_hi_box}
|
|
|
|
TextBox{parent=plc_entry,x=1,y=2,text="UNIT "..i,alignment=ALIGN.CENTER,width=8,fg_bg=s_hi_box}
|
|
|
|
TextBox{parent=plc_entry,x=1,y=3,text="",width=8,fg_bg=s_hi_box}
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2024-03-12 01:25:34 +00:00
|
|
|
local conn = LED{parent=plc_entry,x=10,y=2,label="LINK",colors=cpair(colors.green_hc,colors.green_off)}
|
2023-05-23 23:22:22 +00:00
|
|
|
conn.register(databus.ps, ps_prefix .. "conn", conn.update)
|
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
local plc_addr = TextBox{parent=plc_entry,x=17,y=2,text=" --- ",width=5,fg_bg=label_d_fg}
|
2023-06-05 22:10:53 +00:00
|
|
|
plc_addr.register(databus.ps, ps_prefix .. "addr", plc_addr.set_value)
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=plc_entry,x=23,y=2,text="FW:",width=3}
|
|
|
|
local plc_fw_v = TextBox{parent=plc_entry,x=27,y=2,text=" ------- ",width=9,fg_bg=label_fg}
|
2023-05-23 23:22:22 +00:00
|
|
|
plc_fw_v.register(databus.ps, ps_prefix .. "fw", plc_fw_v.set_value)
|
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=plc_entry,x=37,y=2,text="RTT:",width=4}
|
2024-03-06 16:43:31 +00:00
|
|
|
local plc_rtt = DataIndicator{parent=plc_entry,x=42,y=2,label="",unit="",format="%4d",value=0,width=4,fg_bg=label_fg}
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=plc_entry,x=47,y=2,text="ms",width=4,fg_bg=label_fg}
|
2023-05-23 23:22:22 +00:00
|
|
|
plc_rtt.register(databus.ps, ps_prefix .. "rtt", plc_rtt.update)
|
|
|
|
plc_rtt.register(databus.ps, ps_prefix .. "rtt_color", plc_rtt.recolor)
|
|
|
|
|
|
|
|
plc_list.line_break()
|
|
|
|
end
|
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
-- rtu sessions page
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2023-05-31 15:44:41 +00:00
|
|
|
local rtu_page = Div{parent=page_div,x=1,y=1,hidden=true}
|
2023-06-03 18:33:08 +00:00
|
|
|
local rtu_list = ListBox{parent=rtu_page,x=1,y=1,height=17,width=51,scroll_height=1000,fg_bg=cpair(colors.black,colors.ivory),nav_fg_bg=cpair(colors.gray,colors.lightGray),nav_active=cpair(colors.black,colors.gray)}
|
|
|
|
local _ = Div{parent=rtu_list,height=1,hidden=true} -- padding
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
-- coordinator session page
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2023-05-31 15:44:41 +00:00
|
|
|
local crd_page = Div{parent=page_div,x=1,y=1,hidden=true}
|
2024-03-06 16:43:31 +00:00
|
|
|
local crd_box = Div{parent=crd_page,x=2,y=2,width=49,height=4,fg_bg=s_hi_bright}
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2024-03-12 01:25:34 +00:00
|
|
|
local crd_conn = LED{parent=crd_box,x=2,y=2,label="CONNECTION",colors=cpair(colors.green_hc,colors.green_off)}
|
2023-05-23 23:22:22 +00:00
|
|
|
crd_conn.register(databus.ps, "crd_conn", crd_conn.update)
|
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=crd_box,x=4,y=3,text="COMPUTER",width=8,fg_bg=label_d_fg}
|
|
|
|
local crd_addr = TextBox{parent=crd_box,x=13,y=3,text="---",width=5,fg_bg=label_d_fg}
|
2023-06-05 22:10:53 +00:00
|
|
|
crd_addr.register(databus.ps, "crd_addr", crd_addr.set_value)
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=crd_box,x=22,y=2,text="FW:",width=3}
|
|
|
|
local crd_fw_v = TextBox{parent=crd_box,x=26,y=2,text=" ------- ",width=9,fg_bg=label_fg}
|
2023-05-23 23:22:22 +00:00
|
|
|
crd_fw_v.register(databus.ps, "crd_fw", crd_fw_v.set_value)
|
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=crd_box,x=36,y=2,text="RTT:",width=4}
|
2024-03-06 16:43:31 +00:00
|
|
|
local crd_rtt = DataIndicator{parent=crd_box,x=41,y=2,label="",unit="",format="%5d",value=0,width=5,fg_bg=label_fg}
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=crd_box,x=47,y=2,text="ms",width=4,fg_bg=label_fg}
|
2023-05-23 23:22:22 +00:00
|
|
|
crd_rtt.register(databus.ps, "crd_rtt", crd_rtt.update)
|
|
|
|
crd_rtt.register(databus.ps, "crd_rtt_color", crd_rtt.recolor)
|
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
-- pocket sessions page
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2023-05-31 15:44:41 +00:00
|
|
|
local pkt_page = Div{parent=page_div,x=1,y=1,hidden=true}
|
2024-03-06 16:43:31 +00:00
|
|
|
local pdg_list = ListBox{parent=pkt_page,x=1,y=1,height=17,width=51,scroll_height=1000,fg_bg=style.fp.text_fg,nav_fg_bg=cpair(colors.gray,colors.lightGray),nav_active=cpair(colors.black,colors.gray)}
|
2023-06-03 18:33:08 +00:00
|
|
|
local _ = Div{parent=pdg_list,height=1,hidden=true} -- padding
|
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
-- RTU device ID check/diagnostics page
|
|
|
|
|
|
|
|
local chk_page = Div{parent=page_div,x=1,y=1,hidden=true}
|
|
|
|
local chk_list = ListBox{parent=chk_page,x=1,y=1,height=17,width=51,scroll_height=1000,fg_bg=style.fp.text_fg,nav_fg_bg=cpair(colors.gray,colors.lightGray),nav_active=cpair(colors.black,colors.gray)}
|
|
|
|
local _ = Div{parent=chk_list,height=1,hidden=true} -- padding
|
|
|
|
|
2023-06-03 18:33:08 +00:00
|
|
|
-- assemble page panes
|
2023-05-23 23:22:22 +00:00
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
local panes = { main_page, plc_page, rtu_page, crd_page, pkt_page, chk_page }
|
2023-05-05 17:04:13 +00:00
|
|
|
|
|
|
|
local page_pane = MultiPane{parent=page_div,x=1,y=1,panes=panes}
|
|
|
|
|
|
|
|
local tabs = {
|
2024-03-06 16:43:31 +00:00
|
|
|
{ name = "SVR", color = style.fp.text },
|
|
|
|
{ name = "PLC", color = style.fp.text },
|
|
|
|
{ name = "RTU", color = style.fp.text },
|
|
|
|
{ name = "CRD", color = style.fp.text },
|
|
|
|
{ name = "PKT", color = style.fp.text },
|
2024-08-16 21:19:25 +00:00
|
|
|
{ name = "CHECK", color = style.fp.text }
|
2023-05-05 17:04:13 +00:00
|
|
|
}
|
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
TabBar{parent=panel,y=2,tabs=tabs,min_width=7,callback=page_pane.set_value,fg_bg=style.theme.highlight_box_bright}
|
2023-06-03 18:33:08 +00:00
|
|
|
|
2024-08-16 21:19:25 +00:00
|
|
|
-- link RTU/PDG/CHK list management to PGI
|
|
|
|
pgi.link_elements(rtu_list, rtu_entry, pdg_list, pdg_entry, chk_list, chk_entry)
|
2023-05-05 17:04:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return init
|