diff --git a/coordinator/ui/components/unit_flow.lua b/coordinator/ui/components/unit_flow.lua index f0813f7..2c1ed35 100644 --- a/coordinator/ui/components/unit_flow.lua +++ b/coordinator/ui/components/unit_flow.lua @@ -56,7 +56,6 @@ local function make(parent, x, y, wide, unit_id) local facility = iocontrol.get_db().facility local unit = iocontrol.get_db().units[unit_id] - local tank_defs = facility.tank_defs local tank_conns = facility.tank_conns local tank_types = facility.tank_fluid_types diff --git a/coordinator/ui/layout/flow_view.lua b/coordinator/ui/layout/flow_view.lua index bf90a9c..75972e9 100644 --- a/coordinator/ui/layout/flow_view.lua +++ b/coordinator/ui/layout/flow_view.lua @@ -122,10 +122,9 @@ local function init(main) for i = 1, #tank_defs do local y = y_ofs(i) - local color = c_clr(i) if i == first_fdef then - table.insert(emcool_pipes, pipe(0, y, 1, y + 5, color, true)) + table.insert(emcool_pipes, pipe(0, y, 1, y + 5, c_clr(i), true)) elseif i > first_fdef then if i == last_fdef then table.insert(emcool_pipes, pipe(0, y - 14, 0, y, c_clr(first_fdef), true)) @@ -140,11 +139,11 @@ local function init(main) for i = 1, #tank_defs do local y = y_ofs(i) - local color = c_clr(i) + local color = c_clr(first_fdef) if i == 4 then if tank_defs[i] == 2 then - table.insert(emcool_pipes, pipe(0, y, 1, y + 5, color, true)) + table.insert(emcool_pipes, pipe(0, y, 1, y + 5, c_clr(i), true)) end elseif i == first_fdef then table.insert(emcool_pipes, pipe(0, y, 1, y + 5, color, true)) @@ -163,7 +162,7 @@ local function init(main) if tank_defs[a] == 2 then table.insert(emcool_pipes, pipe(0, y_ofs(a), 1, y_ofs(a) + 6, c_clr(a), true)) if tank_defs[b] == 2 then - table.insert(emcool_pipes, pipe(0, y_ofs(b) - 13, 1, y_ofs(b), c_clr(b), true)) + table.insert(emcool_pipes, pipe(0, y_ofs(b) - 13, 1, y_ofs(b), c_clr(a), true)) end elseif tank_defs[b] == 2 then table.insert(emcool_pipes, pipe(0, y_ofs(b), 1, y_ofs(b) + 6, c_clr(b), true)) diff --git a/supervisor/config/facility.lua b/supervisor/config/facility.lua index 7e64f97..225c758 100644 --- a/supervisor/config/facility.lua +++ b/supervisor/config/facility.lua @@ -34,7 +34,7 @@ local facility = {} ---@param defs table facility tank definitions ---@return table tank_list ---@return table tank_conns -local function generate_tank_list_and_conns(mode, defs) +function facility.generate_tank_list_and_conns(mode, defs) local tank_mode = mode local tank_defs = defs local tank_list = { table.unpack(tank_defs) } @@ -313,7 +313,7 @@ function facility.create(tool_ctl, main_pane, cfg_sys, fac_cfg, style) tmp_cfg.FacilityTankDefs[i] = tri(tmp_cfg.CoolingConfig[i].TankConnection, 1, 0) end - tmp_cfg.FacilityTankList, tmp_cfg.FacilityTankConns = generate_tank_list_and_conns(tmp_cfg.FacilityTankMode, tmp_cfg.FacilityTankDefs) + tmp_cfg.FacilityTankList, tmp_cfg.FacilityTankConns = facility.generate_tank_list_and_conns(tmp_cfg.FacilityTankMode, tmp_cfg.FacilityTankDefs) self.draw_fluid_ops() @@ -563,7 +563,7 @@ function facility.create(tool_ctl, main_pane, cfg_sys, fac_cfg, style) local function next_from_tank_mode() -- determine tank list and connections - tmp_cfg.FacilityTankList, tmp_cfg.FacilityTankConns = generate_tank_list_and_conns(tmp_cfg.FacilityTankMode, tmp_cfg.FacilityTankDefs) + tmp_cfg.FacilityTankList, tmp_cfg.FacilityTankConns = facility.generate_tank_list_and_conns(tmp_cfg.FacilityTankMode, tmp_cfg.FacilityTankDefs) self.draw_fluid_ops() diff --git a/supervisor/config/system.lua b/supervisor/config/system.lua index cb5bacd..7518210 100644 --- a/supervisor/config/system.lua +++ b/supervisor/config/system.lua @@ -1,6 +1,9 @@ local log = require("scada-common.log") +local types = require("scada-common.types") local util = require("scada-common.util") +local facility = require("supervisor.config.facility") + local core = require("graphics.core") local themes = require("graphics.themes") @@ -508,8 +511,15 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, fac_pane, style, exit else tmp_cfg.FacilityTankMode = 0 tmp_cfg.FacilityTankDefs = {} + + -- on facility tank mode 0, setup tank defs to match unit tank option + for i = 1, tmp_cfg.UnitCount do + tmp_cfg.FacilityTankDefs[i] = tri(tmp_cfg.CoolingConfig[i].TankConnection, 1, 0) + end end + tmp_cfg.FacilityTankList, tmp_cfg.FacilityTankConns = facility.generate_tank_list_and_conns(tmp_cfg.FacilityTankMode, tmp_cfg.FacilityTankDefs) + tmp_cfg.SVR_Channel = config.SVR_CHANNEL tmp_cfg.PLC_Channel = config.PLC_CHANNEL tmp_cfg.RTU_Channel = config.RTU_CHANNEL @@ -580,14 +590,26 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, fac_pane, style, exit if val == "" then val = "no facility tanks" end elseif f[1] == "FacilityTankMode" and raw == 0 then val = "0 (n/a, unit mode)" elseif f[1] == "FacilityTankDefs" and type(cfg.FacilityTankDefs) == "table" then + local tank_name_list = { table.unpack(cfg.FacilityTankList) } ---@type (string|integer)[] + local next_f = 1 + val = "" + for idx = 1, #tank_name_list do + if tank_name_list[i] == 1 then + tank_name_list[i] = "U" .. idx + elseif tank_name_list[i] == 2 then + tank_name_list[i] = "F" .. next_f + next_f = next_f + 1 + end + end + for idx = 1, #cfg.FacilityTankDefs do local t_mode = "not connected to a tank" if cfg.FacilityTankDefs[idx] == 1 then - t_mode = "connected to its unit tank" + t_mode = "connected to its unit tank (" .. tank_name_list[cfg.FacilityTankConns[i]] .. ")" elseif cfg.FacilityTankDefs[idx] == 2 then - t_mode = "connected to a facility tank" + t_mode = "connected to facility tank " .. tank_name_list[cfg.FacilityTankConns[i]] end val = val .. tri(idx == 1, "", "\n") .. util.sprintf(" \x07 unit %d - %s", idx, t_mode) @@ -595,20 +617,33 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, fac_pane, style, exit if val == "" then val = "no facility tanks" end elseif f[1] == "FacilityTankList" or f[1] == "FacilityTankConns" then - -- hide + -- hide these since this info is available in the FacilityTankDefs list (connections) and TankFluidTypes list (list of tanks) skip = true - elseif f[1] == "TankFluidTypes" and type(cfg.TankFluidTypes) == "table" and type(cfg.FacilityTankDefs) == "table" then + elseif f[1] == "TankFluidTypes" and type(cfg.TankFluidTypes) == "table" and type(cfg.FacilityTankList) == "table" then + local tank_list = cfg.FacilityTankList + local next_f = 1 + val = "" - for idx = 1, #cfg.FacilityTankDefs do - local t_mode = "not connected to a tank" - if cfg.FacilityTankDefs[idx] == 1 then - t_mode = "connected to its unit tank" - elseif cfg.FacilityTankDefs[idx] == 2 then - t_mode = "connected to a facility tank" - end + for idx = 1, #tank_list do + local prefix = "?" + local fluid = "water" + local type = tmp_cfg.TankFluidTypes[idx] - val = val .. tri(idx == 1, "", "\n") .. util.sprintf(" \x07 unit %d - %s", idx, t_mode) + if tank_list[i] > 0 then + if tank_list[i] == 1 then + prefix = "U" .. idx + elseif tank_list[i] == 2 then + prefix = "F" .. next_f + next_f = next_f + 1 + end + + if type == types.COOLANT_TYPE.SODIUM then + fluid = "sodium" + end + + val = val .. tri(val == "", "", "\n") .. util.sprintf(" \x07 tank %s - %s", prefix, fluid) + end end if val == "" then val = "no emergency coolant tanks" end