#367 fixes and removed computer ID display

This commit is contained in:
Mikayla Fischler 2024-08-21 18:53:52 -04:00
parent 12f187f596
commit 8a5c468606
3 changed files with 15 additions and 32 deletions

View File

@ -17,35 +17,26 @@ local cpair = core.cpair
---@param parent graphics_element parent
---@param msg string message
---@param fail_code integer failure code
local function init(parent, msg, fail_code, cmp_id)
local s_hi_box = style.theme.highlight_box
local label_fg = style.fp.label_fg
local function init(parent, msg, fail_code)
-- root div
local root = Div{parent=parent,x=2,y=2,height=4,width=parent.get_width()-2,hidden=true}
local entry = Div{parent=root,x=2,y=1,height=3,fg_bg=style.theme.highlight_box_bright}
if fail_code == 1 then
TextBox{parent=entry,y=1,text="",width=11,fg_bg=cpair(colors.black,colors.orange)}
TextBox{parent=entry,text="BAD INDEX",alignment=ALIGN.CENTER,width=11,nav_active=cpair(colors.black,colors.orange)}
TextBox{parent=entry,text="BAD INDEX",alignment=ALIGN.CENTER,width=11,fg_bg=cpair(colors.black,colors.orange)}
TextBox{parent=entry,text="",width=11,fg_bg=cpair(colors.black,colors.orange)}
elseif fail_code == 2 then
TextBox{parent=entry,y=1,text="",width=11,fg_bg=cpair(colors.black,colors.red)}
TextBox{parent=entry,text="DUPLICATE",alignment=ALIGN.CENTER,width=11,nav_active=cpair(colors.black,colors.red)}
TextBox{parent=entry,text="DUPLICATE",alignment=ALIGN.CENTER,width=11,fg_bg=cpair(colors.black,colors.red)}
TextBox{parent=entry,text="",width=11,fg_bg=cpair(colors.black,colors.red)}
elseif fail_code == 4 then
TextBox{parent=entry,y=1,text="",width=11,fg_bg=cpair(colors.black,colors.yellow)}
TextBox{parent=entry,text="MISSING",alignment=ALIGN.CENTER,width=11,nav_active=cpair(colors.black,colors.yellow)}
TextBox{parent=entry,text="MISSING",alignment=ALIGN.CENTER,width=11,fg_bg=cpair(colors.black,colors.yellow)}
TextBox{parent=entry,text="",width=11,fg_bg=cpair(colors.black,colors.yellow)}
end
if fail_code == 4 then
TextBox{parent=entry,x=13,y=2,text=msg}
else
TextBox{parent=entry,x=13,y=2,text="@ C "..cmp_id,alignment=ALIGN.CENTER,width=8,fg_bg=s_hi_box,nav_active=cpair(colors.gray,colors.black)}
TextBox{parent=entry,x=21,y=2,text=msg}
end
TextBox{parent=entry,x=13,y=2,text=msg}
return root
end

View File

@ -111,15 +111,14 @@ end
-- add a device ID check failure entry to the CHK list
---@param unit unit_session RTU session
---@param fail_code integer failure code
---@param cmp_id integer computer ID
---@param msg string description to show the user
function pgi.create_chk_entry(unit, fail_code, cmp_id, msg)
function pgi.create_chk_entry(unit, fail_code, msg)
local gw_session = unit.get_session_id()
if data.chk_list ~= nil and data.chk_entry ~= nil then
if not data.entries.chk[gw_session] then data.entries.chk[gw_session] = {} end
local success, result = pcall(data.chk_entry, data.chk_list, msg, fail_code, cmp_id)
local success, result = pcall(data.chk_entry, data.chk_list, msg, fail_code)
if success then
data.entries.chk[gw_session][unit.get_unit_id()] = result
@ -154,7 +153,7 @@ end
---@param message string missing device message
function pgi.create_missing_entry(message)
if data.chk_list ~= nil and data.chk_entry ~= nil then
local success, result = pcall(data.chk_entry, data.chk_list, message, 4, -1)
local success, result = pcall(data.chk_entry, data.chk_list, message, 4)
if success then
data.entries.missing[message] = result

View File

@ -300,15 +300,6 @@ function svsessions.check_rtu_id(unit, list, max)
-- add to the list for the user
if fail_code > 0 and fail_code ~= 3 then
local cmp_id = -1
for i = 1, #self.sessions.rtu do
if self.sessions.rtu[i].instance.get_id() == unit.get_session_id() then
cmp_id = self.sessions.rtu[i].s_addr
break
end
end
local r_id = unit.get_reactor()
local idx = unit.get_device_idx()
local type = unit.get_unit_type()
@ -324,7 +315,7 @@ function svsessions.check_rtu_id(unit, list, max)
elseif type == RTU_TYPES.DYNAMIC_VALVE then
msg = util.c(msg, "#", idx, " dynamic tank")
elseif type == RTU_TYPES.ENV_DETECTOR then
msg = util.c(msg, "#", idx, " environment detector")
msg = util.c(msg, "#", idx, " env. detector")
else
msg = msg .. " ? (error)"
end
@ -338,13 +329,13 @@ function svsessions.check_rtu_id(unit, list, max)
elseif type == RTU_TYPES.DYNAMIC_VALVE then
msg = msg .. "dynamic tank"
elseif type == RTU_TYPES.ENV_DETECTOR then
msg = util.c(msg, "#", idx, " environment detector")
msg = util.c(msg, "#", idx, " env. detector")
else
msg = msg .. " ? (error)"
end
end
pgi.create_chk_entry(unit, fail_code, cmp_id, msg)
pgi.create_chk_entry(unit, fail_code, msg)
end
return fail_code, fail_str
@ -369,7 +360,9 @@ function svsessions.init(nic, fp_ok, config, facility)
local cool_conf = facility.get_cooling_conf()
for i = 1, #cool_conf.fac_tank_list do
self.dev_dbg.connected.tanks[i] = true
if cool_conf.fac_tank_list[i] == 2 then
table.insert(self.dev_dbg.connected.tanks, true)
end
end
for i = 1, config.UnitCount do
@ -377,7 +370,7 @@ function svsessions.init(nic, fp_ok, config, facility)
local conns = { boilers = {}, turbines = {}, tanks = {} }
for b = 1, r_cool.BoilerCount do conns.boilers[b] = true end
for t = 1, r_cool.TurbineCount do conns.boilers[t] = true end
for t = 1, r_cool.TurbineCount do conns.turbines[t] = true end
if r_cool.TankConnection and cool_conf.fac_tank_defs[i] == 1 then
conns.tanks[1] = true