#479 work on sodium emergency coolant config and ui
This commit is contained in:
parent
bc4228d4eb
commit
ffd4bae2d5
@ -56,7 +56,6 @@ local function make(parent, x, y, wide, unit_id)
|
|||||||
local facility = iocontrol.get_db().facility
|
local facility = iocontrol.get_db().facility
|
||||||
local unit = iocontrol.get_db().units[unit_id]
|
local unit = iocontrol.get_db().units[unit_id]
|
||||||
|
|
||||||
local tank_defs = facility.tank_defs
|
|
||||||
local tank_conns = facility.tank_conns
|
local tank_conns = facility.tank_conns
|
||||||
local tank_types = facility.tank_fluid_types
|
local tank_types = facility.tank_fluid_types
|
||||||
|
|
||||||
|
|||||||
@ -122,10 +122,9 @@ local function init(main)
|
|||||||
|
|
||||||
for i = 1, #tank_defs do
|
for i = 1, #tank_defs do
|
||||||
local y = y_ofs(i)
|
local y = y_ofs(i)
|
||||||
local color = c_clr(i)
|
|
||||||
|
|
||||||
if i == first_fdef then
|
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
|
elseif i > first_fdef then
|
||||||
if i == last_fdef then
|
if i == last_fdef then
|
||||||
table.insert(emcool_pipes, pipe(0, y - 14, 0, y, c_clr(first_fdef), true))
|
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
|
for i = 1, #tank_defs do
|
||||||
local y = y_ofs(i)
|
local y = y_ofs(i)
|
||||||
local color = c_clr(i)
|
local color = c_clr(first_fdef)
|
||||||
|
|
||||||
if i == 4 then
|
if i == 4 then
|
||||||
if tank_defs[i] == 2 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
|
end
|
||||||
elseif i == first_fdef then
|
elseif 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, color, true))
|
||||||
@ -163,7 +162,7 @@ local function init(main)
|
|||||||
if tank_defs[a] == 2 then
|
if tank_defs[a] == 2 then
|
||||||
table.insert(emcool_pipes, pipe(0, y_ofs(a), 1, y_ofs(a) + 6, c_clr(a), true))
|
table.insert(emcool_pipes, pipe(0, y_ofs(a), 1, y_ofs(a) + 6, c_clr(a), true))
|
||||||
if tank_defs[b] == 2 then
|
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
|
end
|
||||||
elseif tank_defs[b] == 2 then
|
elseif tank_defs[b] == 2 then
|
||||||
table.insert(emcool_pipes, pipe(0, y_ofs(b), 1, y_ofs(b) + 6, c_clr(b), true))
|
table.insert(emcool_pipes, pipe(0, y_ofs(b), 1, y_ofs(b) + 6, c_clr(b), true))
|
||||||
|
|||||||
@ -34,7 +34,7 @@ local facility = {}
|
|||||||
---@param defs table facility tank definitions
|
---@param defs table facility tank definitions
|
||||||
---@return table tank_list
|
---@return table tank_list
|
||||||
---@return table tank_conns
|
---@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_mode = mode
|
||||||
local tank_defs = defs
|
local tank_defs = defs
|
||||||
local tank_list = { table.unpack(tank_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)
|
tmp_cfg.FacilityTankDefs[i] = tri(tmp_cfg.CoolingConfig[i].TankConnection, 1, 0)
|
||||||
end
|
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()
|
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()
|
local function next_from_tank_mode()
|
||||||
-- determine tank list and connections
|
-- 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()
|
self.draw_fluid_ops()
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
local log = require("scada-common.log")
|
local log = require("scada-common.log")
|
||||||
|
local types = require("scada-common.types")
|
||||||
local util = require("scada-common.util")
|
local util = require("scada-common.util")
|
||||||
|
|
||||||
|
local facility = require("supervisor.config.facility")
|
||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
local themes = require("graphics.themes")
|
local themes = require("graphics.themes")
|
||||||
|
|
||||||
@ -508,8 +511,15 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, fac_pane, style, exit
|
|||||||
else
|
else
|
||||||
tmp_cfg.FacilityTankMode = 0
|
tmp_cfg.FacilityTankMode = 0
|
||||||
tmp_cfg.FacilityTankDefs = {}
|
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
|
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.SVR_Channel = config.SVR_CHANNEL
|
||||||
tmp_cfg.PLC_Channel = config.PLC_CHANNEL
|
tmp_cfg.PLC_Channel = config.PLC_CHANNEL
|
||||||
tmp_cfg.RTU_Channel = config.RTU_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
|
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] == "FacilityTankMode" and raw == 0 then val = "0 (n/a, unit mode)"
|
||||||
elseif f[1] == "FacilityTankDefs" and type(cfg.FacilityTankDefs) == "table" then
|
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 = ""
|
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
|
for idx = 1, #cfg.FacilityTankDefs do
|
||||||
local t_mode = "not connected to a tank"
|
local t_mode = "not connected to a tank"
|
||||||
if cfg.FacilityTankDefs[idx] == 1 then
|
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
|
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
|
end
|
||||||
|
|
||||||
val = val .. tri(idx == 1, "", "\n") .. util.sprintf(" \x07 unit %d - %s", idx, t_mode)
|
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
|
if val == "" then val = "no facility tanks" end
|
||||||
elseif f[1] == "FacilityTankList" or f[1] == "FacilityTankConns" then
|
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
|
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 = ""
|
val = ""
|
||||||
|
|
||||||
for idx = 1, #cfg.FacilityTankDefs do
|
for idx = 1, #tank_list do
|
||||||
local t_mode = "not connected to a tank"
|
local prefix = "?"
|
||||||
if cfg.FacilityTankDefs[idx] == 1 then
|
local fluid = "water"
|
||||||
t_mode = "connected to its unit tank"
|
local type = tmp_cfg.TankFluidTypes[idx]
|
||||||
elseif cfg.FacilityTankDefs[idx] == 2 then
|
|
||||||
t_mode = "connected to a facility tank"
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
end
|
||||||
|
|
||||||
if val == "" then val = "no emergency coolant tanks" end
|
if val == "" then val = "no emergency coolant tanks" end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user