2022-07-14 17:47:39 +00:00
|
|
|
--
|
|
|
|
-- Basic Unit Overview
|
|
|
|
--
|
|
|
|
|
2022-12-18 18:56:04 +00:00
|
|
|
local core = require("graphics.core")
|
2022-06-16 15:24:35 +00:00
|
|
|
|
2022-12-18 18:56:04 +00:00
|
|
|
local style = require("coordinator.ui.style")
|
2022-06-16 15:24:35 +00:00
|
|
|
|
2022-06-25 20:21:57 +00:00
|
|
|
local reactor_view = require("coordinator.ui.components.reactor")
|
|
|
|
local boiler_view = require("coordinator.ui.components.boiler")
|
2022-07-02 21:24:52 +00:00
|
|
|
local turbine_view = require("coordinator.ui.components.turbine")
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2022-12-18 18:56:04 +00:00
|
|
|
local Div = require("graphics.elements.div")
|
|
|
|
local PipeNetwork = require("graphics.elements.pipenet")
|
|
|
|
local TextBox = require("graphics.elements.textbox")
|
2022-06-16 15:24:35 +00:00
|
|
|
|
|
|
|
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
|
|
|
|
|
2022-06-29 21:40:46 +00:00
|
|
|
local pipe = core.graphics.pipe
|
2022-06-16 15:24:35 +00:00
|
|
|
|
2022-09-07 02:38:27 +00:00
|
|
|
-- make a new unit overview window
|
|
|
|
---@param parent graphics_element parent
|
|
|
|
---@param x integer top left x
|
|
|
|
---@param y integer top left y
|
2023-01-23 20:10:41 +00:00
|
|
|
---@param unit ioctl_unit unit database entry
|
2022-07-10 20:15:30 +00:00
|
|
|
local function make(parent, x, y, unit)
|
2022-07-14 17:47:39 +00:00
|
|
|
local height = 0
|
|
|
|
local num_boilers = #unit.boiler_data_tbl
|
|
|
|
local num_turbines = #unit.turbine_data_tbl
|
|
|
|
|
|
|
|
assert(num_boilers >= 0 and num_boilers <= 2, "minimum 0 boilers, maximum 2 boilers")
|
|
|
|
assert(num_turbines >= 1 and num_turbines <= 3, "minimum 1 turbine, maximum 3 turbines")
|
|
|
|
|
|
|
|
if num_boilers == 0 and num_turbines == 1 then
|
|
|
|
height = 9
|
|
|
|
elseif num_boilers == 1 and num_turbines <= 2 then
|
|
|
|
height = 17
|
|
|
|
else
|
|
|
|
height = 25
|
|
|
|
end
|
|
|
|
|
2023-02-03 20:19:00 +00:00
|
|
|
assert(parent.height() >= (y + height), "main display not of sufficient vertical resolution (add an additional row of monitors)")
|
|
|
|
|
2022-06-16 15:24:35 +00:00
|
|
|
-- bounding box div
|
2022-07-14 18:29:48 +00:00
|
|
|
local root = Div{parent=parent,x=x,y=y,width=80,height=height}
|
2022-06-16 15:24:35 +00:00
|
|
|
|
|
|
|
-- unit header message
|
2023-02-03 04:07:09 +00:00
|
|
|
TextBox{parent=root,text="Unit #"..unit.unit_id,alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-06-25 20:21:57 +00:00
|
|
|
-------------
|
|
|
|
-- REACTOR --
|
|
|
|
-------------
|
2022-06-16 15:24:35 +00:00
|
|
|
|
2023-02-23 04:20:59 +00:00
|
|
|
reactor_view(root, 1, 3, unit.reactor_data, unit.unit_ps)
|
2022-06-16 15:24:35 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if num_boilers > 0 then
|
|
|
|
local coolant_pipes = {}
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if num_boilers >= 2 then
|
|
|
|
table.insert(coolant_pipes, pipe(0, 0, 11, 12, colors.lightBlue))
|
|
|
|
end
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
table.insert(coolant_pipes, pipe(0, 0, 11, 3, colors.lightBlue))
|
|
|
|
table.insert(coolant_pipes, pipe(2, 0, 11, 2, colors.orange))
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if num_boilers >= 2 then
|
|
|
|
table.insert(coolant_pipes, pipe(2, 0, 11, 11, colors.orange))
|
|
|
|
end
|
2022-06-29 21:40:46 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
PipeNetwork{parent=root,x=4,y=10,pipes=coolant_pipes,bg=colors.lightGray}
|
|
|
|
end
|
2022-06-29 21:40:46 +00:00
|
|
|
|
2022-06-25 20:21:57 +00:00
|
|
|
-------------
|
|
|
|
-- BOILERS --
|
|
|
|
-------------
|
2022-06-16 15:24:35 +00:00
|
|
|
|
2022-09-07 14:25:22 +00:00
|
|
|
if num_boilers >= 1 then boiler_view(root, 16, 11, unit.boiler_ps_tbl[1]) end
|
|
|
|
if num_boilers >= 2 then boiler_view(root, 16, 19, unit.boiler_ps_tbl[2]) end
|
2022-07-02 21:24:52 +00:00
|
|
|
|
|
|
|
--------------
|
|
|
|
-- TURBINES --
|
|
|
|
--------------
|
|
|
|
|
2022-07-10 20:15:30 +00:00
|
|
|
local t_idx = 1
|
2022-07-14 17:47:39 +00:00
|
|
|
local no_boilers = num_boilers == 0
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if (num_turbines >= 3) or no_boilers or (num_boilers == 1 and num_turbines >= 2) then
|
2022-09-07 14:25:22 +00:00
|
|
|
turbine_view(root, 58, 3, unit.turbine_ps_tbl[t_idx])
|
2022-07-10 20:15:30 +00:00
|
|
|
t_idx = t_idx + 1
|
|
|
|
end
|
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if (num_turbines >= 1 and not no_boilers) or num_turbines >= 2 then
|
2022-09-07 14:25:22 +00:00
|
|
|
turbine_view(root, 58, 11, unit.turbine_ps_tbl[t_idx])
|
2022-07-10 20:15:30 +00:00
|
|
|
t_idx = t_idx + 1
|
|
|
|
end
|
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if (num_turbines >= 2 and num_boilers >= 2) or num_turbines >= 3 then
|
2022-09-07 14:25:22 +00:00
|
|
|
turbine_view(root, 58, 19, unit.turbine_ps_tbl[t_idx])
|
2022-07-10 20:15:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local steam_pipes_b = {}
|
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if no_boilers then
|
2023-02-23 04:09:47 +00:00
|
|
|
table.insert(steam_pipes_b, pipe(0, 1, 3, 1, colors.white)) -- steam to turbine 1
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 2, 3, 2, colors.blue)) -- water to turbine 1
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if num_turbines >= 2 then
|
2023-02-23 04:09:47 +00:00
|
|
|
table.insert(steam_pipes_b, pipe(1, 2, 3, 9, colors.white)) -- steam to turbine 2
|
|
|
|
table.insert(steam_pipes_b, pipe(2, 3, 3, 10, colors.blue)) -- water to turbine 2
|
2022-07-14 17:47:39 +00:00
|
|
|
end
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if num_turbines >= 3 then
|
2023-02-23 04:09:47 +00:00
|
|
|
table.insert(steam_pipes_b, pipe(1, 9, 3, 17, colors.white)) -- steam boiler 1 to turbine 1 junction end
|
2022-07-14 17:47:39 +00:00
|
|
|
table.insert(steam_pipes_b, pipe(2, 10, 3, 18, colors.blue)) -- water boiler 1 to turbine 1 junction start
|
|
|
|
end
|
|
|
|
else
|
|
|
|
-- boiler side pipes
|
|
|
|
local steam_pipes_a = {
|
|
|
|
-- boiler 1 steam/water pipes
|
|
|
|
pipe(0, 1, 6, 1, colors.white, false, true), -- steam boiler 1 to turbine junction
|
|
|
|
pipe(0, 2, 6, 2, colors.blue, false, true) -- water boiler 1 to turbine junction
|
|
|
|
}
|
|
|
|
|
|
|
|
if num_boilers >= 2 then
|
|
|
|
-- boiler 2 steam/water pipes
|
|
|
|
table.insert(steam_pipes_a, pipe(0, 9, 6, 9, colors.white, false, true)) -- steam boiler 2 to turbine junction
|
|
|
|
table.insert(steam_pipes_a, pipe(0, 10, 6, 10, colors.blue, false, true)) -- water boiler 2 to turbine junction
|
|
|
|
end
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
-- turbine side pipes
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
if num_turbines >= 3 or (num_boilers == 1 and num_turbines == 2) then
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 9, 1, 2, colors.white, false, true)) -- steam boiler 1 to turbine 1 junction start
|
|
|
|
table.insert(steam_pipes_b, pipe(1, 1, 3, 1, colors.white, false, false)) -- steam boiler 1 to turbine 1 junction end
|
2022-07-10 20:15:30 +00:00
|
|
|
end
|
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
table.insert(steam_pipes_b, pipe(0, 9, 3, 9, colors.white, false, true)) -- steam boiler 1 to turbine 2
|
|
|
|
|
|
|
|
if num_turbines >= 3 or (num_boilers == 1 and num_turbines == 2) then
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 10, 2, 3, colors.blue, false, true)) -- water boiler 1 to turbine 1 junction start
|
|
|
|
table.insert(steam_pipes_b, pipe(2, 2, 3, 2, colors.blue, false, false)) -- water boiler 1 to turbine 1 junction end
|
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 10, 3, 10, colors.blue, false, true)) -- water boiler 1 to turbine 2
|
|
|
|
|
|
|
|
if num_turbines >= 3 or (num_turbines >= 2 and num_boilers >= 2) then
|
|
|
|
if num_boilers >= 2 then
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 17, 1, 9, colors.white, false, true)) -- steam boiler 2 to turbine 2 junction
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 17, 3, 17, colors.white, false, true)) -- steam boiler 2 to turbine 3
|
|
|
|
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 18, 2, 10, colors.blue, false, true)) -- water boiler 2 to turbine 3
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 18, 3, 18, colors.blue, false, true)) -- water boiler 2 to turbine 2 junction
|
|
|
|
else
|
|
|
|
table.insert(steam_pipes_b, pipe(1, 17, 1, 9, colors.white, false, true)) -- steam boiler 2 to turbine 2 junction
|
|
|
|
table.insert(steam_pipes_b, pipe(1, 17, 3, 17, colors.white, false, true)) -- steam boiler 2 to turbine 3
|
|
|
|
|
|
|
|
table.insert(steam_pipes_b, pipe(2, 18, 2, 10, colors.blue, false, true)) -- water boiler 2 to turbine 3
|
|
|
|
table.insert(steam_pipes_b, pipe(2, 18, 3, 18, colors.blue, false, true)) -- water boiler 2 to turbine 2 junction
|
|
|
|
end
|
|
|
|
elseif num_turbines == 1 and num_boilers >= 2 then
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 17, 1, 9, colors.white, false, true)) -- steam boiler 2 to turbine 2 junction
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 17, 1, 17, colors.white, false, true)) -- steam boiler 2 to turbine 3
|
|
|
|
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 18, 2, 10, colors.blue, false, true)) -- water boiler 2 to turbine 3
|
|
|
|
table.insert(steam_pipes_b, pipe(0, 18, 2, 18, colors.blue, false, true)) -- water boiler 2 to turbine 2 junction
|
2022-07-10 20:15:30 +00:00
|
|
|
end
|
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
PipeNetwork{parent=root,x=47,y=11,pipes=steam_pipes_a,bg=colors.lightGray}
|
2022-07-10 20:15:30 +00:00
|
|
|
end
|
2022-07-02 21:24:52 +00:00
|
|
|
|
|
|
|
PipeNetwork{parent=root,x=54,y=3,pipes=steam_pipes_b,bg=colors.lightGray}
|
2022-06-16 15:24:35 +00:00
|
|
|
|
2022-07-14 17:47:39 +00:00
|
|
|
return root
|
2022-06-16 15:24:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return make
|