diff --git a/supervisor/databus.lua b/supervisor/databus.lua index 96e0e80..00185c7 100644 --- a/supervisor/databus.lua +++ b/supervisor/databus.lua @@ -3,6 +3,7 @@ -- local psil = require("scada-common.psil") +local util = require("scada-common.util") local pgi = require("supervisor.panel.pgi") @@ -39,7 +40,7 @@ end 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 .. "_addr", tostring(s_addr)) + databus.ps.publish("plc_" .. reactor_id .. "_addr", util.sprintf("@% 4d", s_addr)) end -- transmit PLC disconnected @@ -73,7 +74,7 @@ end ---@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 .. "_addr", tostring(s_addr)) + databus.ps.publish("rtu_" .. session_id .. "_addr", util.sprintf("@ C% 3d", s_addr)) pgi.create_rtu_entry(session_id) end @@ -143,7 +144,7 @@ end ---@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 .. "_addr", tostring(s_addr)) + databus.ps.publish("pdg_" .. session_id .. "_addr", util.sprintf("@ C% 3d", 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 ea17cfd..2c85d59 100644 --- a/supervisor/panel/components/pdg_entry.lua +++ b/supervisor/panel/components/pdg_entry.lua @@ -2,8 +2,6 @@ -- Pocket Diagnostics Connection Entry -- -local util = require("scada-common.util") - local databus = require("supervisor.databus") local core = require("graphics.core") @@ -30,7 +28,7 @@ local function init(parent, id) TextBox{parent=entry,x=1,y=1,text="",width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} 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_addr.register(databus.ps, ps_prefix .. "addr", function (addr) pdg_addr.set_value(util.sprintf("C #%d", addr)) end) + pdg_addr.register(databus.ps, ps_prefix .. "addr", pdg_addr.set_value) 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 e51b0bf..94900ab 100644 --- a/supervisor/panel/components/rtu_entry.lua +++ b/supervisor/panel/components/rtu_entry.lua @@ -2,8 +2,6 @@ -- RTU Connection Entry -- -local util = require("scada-common.util") - local databus = require("supervisor.databus") local core = require("graphics.core") @@ -30,7 +28,7 @@ local function init(parent, id) TextBox{parent=entry,x=1,y=1,text="",width=8,height=1,fg_bg=cpair(colors.black,colors.lightGray)} 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_addr.register(databus.ps, ps_prefix .. "addr", function (addr) rtu_addr.set_value(util.sprintf("C #%d", addr)) end) + rtu_addr.register(databus.ps, ps_prefix .. "addr", rtu_addr.set_value) 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/startup.lua b/supervisor/startup.lua index bb48cc7..2919f0f 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.3" +local SUPERVISOR_VERSION = "v0.17.4" local println = util.println local println_ts = util.println_ts