From b20d42ff38e4b50f245137016c0f34d7d7afde02 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 5 Jun 2023 18:10:53 -0400 Subject: [PATCH] #225 added computer IDs to PLC/RTU front panels, updated supervisor front panel to use computer ID terminology --- pocket/startup.lua | 2 +- reactor-plc/panel/front_panel.lua | 4 ++++ reactor-plc/startup.lua | 2 +- rtu/panel/front_panel.lua | 4 ++++ rtu/startup.lua | 2 +- supervisor/databus.lua | 28 +++++++++++------------ supervisor/panel/components/pdg_entry.lua | 4 ++-- supervisor/panel/components/rtu_entry.lua | 4 ++-- supervisor/panel/front_panel.lua | 16 ++++++++----- supervisor/session/svsessions.lua | 2 +- supervisor/startup.lua | 2 +- 11 files changed, 41 insertions(+), 29 deletions(-) diff --git a/pocket/startup.lua b/pocket/startup.lua index 1ac6a5a..9e55501 100644 --- a/pocket/startup.lua +++ b/pocket/startup.lua @@ -17,7 +17,7 @@ local coreio = require("pocket.coreio") local pocket = require("pocket.pocket") local renderer = require("pocket.renderer") -local POCKET_VERSION = "alpha-v0.3.7" +local POCKET_VERSION = "alpha-v0.4.0" local println = util.println local println_ts = util.println_ts diff --git a/reactor-plc/panel/front_panel.lua b/reactor-plc/panel/front_panel.lua index a8675a0..12c8266 100644 --- a/reactor-plc/panel/front_panel.lua +++ b/reactor-plc/panel/front_panel.lua @@ -70,6 +70,10 @@ local function init(panel) rt_cmrx.register(databus.ps, "routine__comms_rx", rt_cmrx.update) rt_sctl.register(databus.ps, "routine__spctl", rt_sctl.update) +---@diagnostic disable-next-line: undefined-field + local comp_id = util.sprintf("(%d)", os.getComputerID()) + TextBox{parent=system,x=9,y=5,width=6,height=1,text=comp_id,fg_bg=cpair(colors.lightGray,colors.ivory)} + -- -- status & controls -- diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index b5a2e3b..71ebcb2 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc") local renderer = require("reactor-plc.renderer") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v1.4.1" +local R_PLC_VERSION = "v1.4.2" local println = util.println local println_ts = util.println_ts diff --git a/rtu/panel/front_panel.lua b/rtu/panel/front_panel.lua index 09270e9..467386e 100644 --- a/rtu/panel/front_panel.lua +++ b/rtu/panel/front_panel.lua @@ -67,6 +67,10 @@ local function init(panel, units) rt_main.register(databus.ps, "routine__main", rt_main.update) rt_comm.register(databus.ps, "routine__comms", rt_comm.update) +---@diagnostic disable-next-line: undefined-field + local comp_id = util.sprintf("(%d)", os.getComputerID()) + TextBox{parent=system,x=9,y=4,width=6,height=1,text=comp_id,fg_bg=cpair(colors.lightGray,colors.ivory)} + -- -- about label -- diff --git a/rtu/startup.lua b/rtu/startup.lua index d37be78..113b513 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -28,7 +28,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.3.1" +local RTU_VERSION = "v1.3.2" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE diff --git a/supervisor/databus.lua b/supervisor/databus.lua index a1e947e..664b3fe 100644 --- a/supervisor/databus.lua +++ b/supervisor/databus.lua @@ -31,11 +31,11 @@ end -- transmit PLC firmware version and session connection state ---@param reactor_id integer reactor unit ID ---@param fw string firmware version ----@param channel integer PLC remote port -function databus.tx_plc_connected(reactor_id, fw, channel) +---@param s_addr integer PLC computer ID +function databus.tx_plc_connected(reactor_id, fw, s_addr) databus.ps.publish("plc_" .. reactor_id .. "_fw", fw) databus.ps.publish("plc_" .. reactor_id .. "_conn", true) - databus.ps.publish("plc_" .. reactor_id .. "_chan", tostring(channel)) + databus.ps.publish("plc_" .. reactor_id .. "_addr", tostring(s_addr)) end -- transmit PLC disconnected @@ -43,7 +43,7 @@ end function databus.tx_plc_disconnected(reactor_id) databus.ps.publish("plc_" .. reactor_id .. "_fw", " ------- ") databus.ps.publish("plc_" .. reactor_id .. "_conn", false) - databus.ps.publish("plc_" .. reactor_id .. "_chan", " --- ") + databus.ps.publish("plc_" .. reactor_id .. "_addr", " --- ") databus.ps.publish("plc_" .. reactor_id .. "_rtt", 0) databus.ps.publish("plc_" .. reactor_id .. "_rtt_color", colors.lightGray) end @@ -66,10 +66,10 @@ end -- transmit RTU firmware version and session connection state ---@param session_id integer RTU session ---@param fw string firmware version ----@param channel integer RTU remote port -function databus.tx_rtu_connected(session_id, fw, channel) +---@param s_addr integer RTU computer ID +function databus.tx_rtu_connected(session_id, fw, s_addr) databus.ps.publish("rtu_" .. session_id .. "_fw", fw) - databus.ps.publish("rtu_" .. session_id .. "_chan", tostring(channel)) + databus.ps.publish("rtu_" .. session_id .. "_addr", tostring(s_addr)) pgi.create_rtu_entry(session_id) end @@ -103,18 +103,18 @@ end -- transmit coordinator firmware version and session connection state ---@param fw string firmware version ----@param channel integer coordinator remote port -function databus.tx_crd_connected(fw, channel) +---@param s_addr integer coordinator computer ID +function databus.tx_crd_connected(fw, s_addr) databus.ps.publish("crd_fw", fw) databus.ps.publish("crd_conn", true) - databus.ps.publish("crd_chan", tostring(channel)) + databus.ps.publish("crd_addr", tostring(s_addr)) end -- transmit coordinator disconnected function databus.tx_crd_disconnected() databus.ps.publish("crd_fw", " ------- ") databus.ps.publish("crd_conn", false) - databus.ps.publish("crd_chan", "---") + databus.ps.publish("crd_addr", "---") databus.ps.publish("crd_rtt", 0) databus.ps.publish("crd_rtt_color", colors.lightGray) end @@ -136,10 +136,10 @@ end -- transmit PKT firmware version and PDG session connection state ---@param session_id integer PDG session ---@param fw string firmware version ----@param channel integer PDG remote port -function databus.tx_pdg_connected(session_id, fw, channel) +---@param s_addr integer PDG computer ID +function databus.tx_pdg_connected(session_id, fw, s_addr) databus.ps.publish("pdg_" .. session_id .. "_fw", fw) - databus.ps.publish("pdg_" .. session_id .. "_chan", tostring(channel)) + databus.ps.publish("pdg_" .. session_id .. "_addr", tostring(s_addr)) pgi.create_pdg_entry(session_id) end diff --git a/supervisor/panel/components/pdg_entry.lua b/supervisor/panel/components/pdg_entry.lua index 94cd385..ea17cfd 100644 --- a/supervisor/panel/components/pdg_entry.lua +++ b/supervisor/panel/components/pdg_entry.lua @@ -28,9 +28,9 @@ local function init(parent, id) local ps_prefix = "pdg_" .. id .. "_" TextBox{parent=entry,x=1,y=1,text="",width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} - local pdg_chan = TextBox{parent=entry,x=1,y=2,text=" :00000",alignment=TEXT_ALIGN.CENTER,width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray),nav_active=cpair(colors.gray,colors.black)} + local pdg_addr = TextBox{parent=entry,x=1,y=2,text="C #?",alignment=TEXT_ALIGN.CENTER,width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray),nav_active=cpair(colors.gray,colors.black)} TextBox{parent=entry,x=1,y=3,text="",width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} - pdg_chan.register(databus.ps, ps_prefix .. "chan", function (channel) pdg_chan.set_value(util.sprintf(" :%05d", channel)) end) + pdg_addr.register(databus.ps, ps_prefix .. "addr", function (addr) pdg_addr.set_value(util.sprintf("C #%d", addr)) end) TextBox{parent=entry,x=10,y=2,text="FW:",width=3,height=1} local pdg_fw_v = TextBox{parent=entry,x=14,y=2,text=" ------- ",width=20,height=1,fg_bg=cpair(colors.lightGray,colors.white)} diff --git a/supervisor/panel/components/rtu_entry.lua b/supervisor/panel/components/rtu_entry.lua index a4a5a4e..e51b0bf 100644 --- a/supervisor/panel/components/rtu_entry.lua +++ b/supervisor/panel/components/rtu_entry.lua @@ -28,9 +28,9 @@ local function init(parent, id) local ps_prefix = "rtu_" .. id .. "_" TextBox{parent=entry,x=1,y=1,text="",width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} - local rtu_chan = TextBox{parent=entry,x=1,y=2,text=" :00000",alignment=TEXT_ALIGN.CENTER,width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray),nav_active=cpair(colors.gray,colors.black)} + local rtu_addr = TextBox{parent=entry,x=1,y=2,text="C #?",alignment=TEXT_ALIGN.CENTER,width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray),nav_active=cpair(colors.gray,colors.black)} TextBox{parent=entry,x=1,y=3,text="",width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} - rtu_chan.register(databus.ps, ps_prefix .. "chan", function (channel) rtu_chan.set_value(util.sprintf(" :%05d", channel)) end) + rtu_addr.register(databus.ps, ps_prefix .. "addr", function (addr) rtu_addr.set_value(util.sprintf("C #%d", addr)) end) TextBox{parent=entry,x=10,y=2,text="UNITS:",width=7,height=1} local unit_count = DataIndicator{parent=entry,x=17,y=2,label="",unit="",format="%2d",value=0,width=2,fg_bg=cpair(colors.gray,colors.white)} diff --git a/supervisor/panel/front_panel.lua b/supervisor/panel/front_panel.lua index 8cdcf76..b6ee692 100644 --- a/supervisor/panel/front_panel.lua +++ b/supervisor/panel/front_panel.lua @@ -56,6 +56,10 @@ local function init(panel) modem.register(databus.ps, "has_modem", modem.update) +---@diagnostic disable-next-line: undefined-field + local comp_id = util.sprintf("(%d)", os.getComputerID()) + TextBox{parent=system,x=9,y=4,width=6,height=1,text=comp_id,fg_bg=cpair(colors.lightGray,colors.ivory)} + -- -- about footer -- @@ -84,11 +88,11 @@ local function init(panel) TextBox{parent=plc_entry,x=1,y=2,text="UNIT "..i,alignment=TEXT_ALIGN.CENTER,width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} TextBox{parent=plc_entry,x=1,y=3,text="",width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} - local conn = LED{parent=plc_entry,x=10,y=2,label="CONN",colors=cpair(colors.green,colors.green_off)} + local conn = LED{parent=plc_entry,x=10,y=2,label="LINK",colors=cpair(colors.green,colors.green_off)} conn.register(databus.ps, ps_prefix .. "conn", conn.update) - local plc_chan = TextBox{parent=plc_entry,x=17,y=2,text=" --- ",width=5,height=1,fg_bg=cpair(colors.gray,colors.white)} - plc_chan.register(databus.ps, ps_prefix .. "chan", plc_chan.set_value) + local plc_addr = TextBox{parent=plc_entry,x=17,y=2,text=" --- ",width=5,height=1,fg_bg=cpair(colors.gray,colors.white)} + plc_addr.register(databus.ps, ps_prefix .. "addr", plc_addr.set_value) TextBox{parent=plc_entry,x=23,y=2,text="FW:",width=3,height=1} local plc_fw_v = TextBox{parent=plc_entry,x=27,y=2,text=" ------- ",width=9,height=1,fg_bg=cpair(colors.lightGray,colors.white)} @@ -117,9 +121,9 @@ local function init(panel) local crd_conn = LED{parent=crd_box,x=2,y=2,label="CONNECTION",colors=cpair(colors.green,colors.green_off)} crd_conn.register(databus.ps, "crd_conn", crd_conn.update) - TextBox{parent=crd_box,x=4,y=3,text="CHANNEL ",width=8,height=1,fg_bg=cpair(colors.gray,colors.white)} - local crd_chan = TextBox{parent=crd_box,x=12,y=3,text="---",width=5,height=1,fg_bg=cpair(colors.gray,colors.white)} - crd_chan.register(databus.ps, "crd_chan", crd_chan.set_value) + TextBox{parent=crd_box,x=4,y=3,text="COMPUTER",width=8,height=1,fg_bg=cpair(colors.gray,colors.white)} + local crd_addr = TextBox{parent=crd_box,x=13,y=3,text="---",width=5,height=1,fg_bg=cpair(colors.gray,colors.white)} + crd_addr.register(databus.ps, "crd_addr", crd_addr.set_value) TextBox{parent=crd_box,x=22,y=2,text="FW:",width=3,height=1} local crd_fw_v = TextBox{parent=crd_box,x=26,y=2,text=" ------- ",width=9,height=1,fg_bg=cpair(colors.lightGray,colors.white)} diff --git a/supervisor/session/svsessions.lua b/supervisor/session/svsessions.lua index 4d5b0f4..73a4e4f 100644 --- a/supervisor/session/svsessions.lua +++ b/supervisor/session/svsessions.lua @@ -251,7 +251,7 @@ end ---@return pdg_session_struct|nil function svsessions.find_pdg_session(source_addr) -- check diagnostic sessions - local session = _find_session(self.sessions.diag, source_addr) + local session = _find_session(self.sessions.pdg, source_addr) ---@cast session pdg_session_struct|nil return session end diff --git a/supervisor/startup.lua b/supervisor/startup.lua index ba943fe..9fdb517 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -20,7 +20,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v0.17.0" +local SUPERVISOR_VERSION = "v0.17.1" local println = util.println local println_ts = util.println_ts