#79 water cooling only support, dynamic height, changed 2 turbine 1 boiler layout

This commit is contained in:
Mikayla Fischler 2022-07-14 13:47:39 -04:00
parent 8704d845bd
commit bd1ab11686
7 changed files with 129 additions and 74 deletions

View File

@ -13,7 +13,7 @@ local config = require("coordinator.config")
local coordinator = require("coordinator.coordinator") local coordinator = require("coordinator.coordinator")
local renderer = require("coordinator.renderer") local renderer = require("coordinator.renderer")
local COORDINATOR_VERSION = "alpha-v0.3.2" local COORDINATOR_VERSION = "alpha-v0.3.3"
local print = util.print local print = util.print
local println = util.println local println = util.println

View File

@ -2,7 +2,6 @@ local core = require("graphics.core")
local style = require("coordinator.ui.style") local style = require("coordinator.ui.style")
local Div = require("graphics.elements.div")
local DataIndicator = require("graphics.elements.indicators.data") local DataIndicator = require("graphics.elements.indicators.data")
local StateIndicator = require("graphics.elements.indicators.state") local StateIndicator = require("graphics.elements.indicators.state")
local Rectangle = require("graphics.elements.rectangle") local Rectangle = require("graphics.elements.rectangle")

View File

@ -2,7 +2,6 @@ local core = require("graphics.core")
local style = require("coordinator.ui.style") local style = require("coordinator.ui.style")
local Div = require("graphics.elements.div")
local HorizontalBar = require("graphics.elements.indicators.hbar") local HorizontalBar = require("graphics.elements.indicators.hbar")
local DataIndicator = require("graphics.elements.indicators.data") local DataIndicator = require("graphics.elements.indicators.data")
local StateIndicator = require("graphics.elements.indicators.state") local StateIndicator = require("graphics.elements.indicators.state")

View File

@ -2,7 +2,6 @@ local core = require("graphics.core")
local style = require("coordinator.ui.style") local style = require("coordinator.ui.style")
local Div = require("graphics.elements.div")
local DataIndicator = require("graphics.elements.indicators.data") local DataIndicator = require("graphics.elements.indicators.data")
local StateIndicator = require("graphics.elements.indicators.state") local StateIndicator = require("graphics.elements.indicators.state")
local Rectangle = require("graphics.elements.rectangle") local Rectangle = require("graphics.elements.rectangle")

View File

@ -1,3 +1,7 @@
--
-- Basic Unit Overview
--
local core = require("graphics.core") local core = require("graphics.core")
local style = require("coordinator.ui.style") local style = require("coordinator.ui.style")
@ -21,116 +25,152 @@ local pipe = core.graphics.pipe
---@param y integer ---@param y integer
---@param unit coord_db_entry ---@param unit coord_db_entry
local function make(parent, x, y, unit) local function make(parent, x, y, unit)
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
-- bounding box div -- bounding box div
local root = Div{parent=parent,x=x,y=y,width=80,height=25} local root = Div{parent=parent,x=x,y=y,width=80,height=height,fg_bg=cpair(colors.black,colors.black)}
-- unit header message -- unit header message
TextBox{parent=root,text="Unit #" .. unit.unit_id,alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=style.header} TextBox{parent=root,text="Unit #" .. unit.unit_id,alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
local num_boilers = #unit.boiler_data_tbl
local num_turbines = #unit.turbine_data_tbl
------------- -------------
-- REACTOR -- -- REACTOR --
------------- -------------
reactor_view(root, 1, 3, unit.reactor_ps) reactor_view(root, 1, 3, unit.reactor_ps)
local coolant_pipes = {} if num_boilers > 0 then
local coolant_pipes = {}
if num_boilers == 2 then if num_boilers >= 2 then
table.insert(coolant_pipes, pipe(0, 0, 11, 12, colors.lightBlue)) table.insert(coolant_pipes, pipe(0, 0, 11, 12, colors.lightBlue))
end
table.insert(coolant_pipes, pipe(0, 0, 11, 3, colors.lightBlue))
table.insert(coolant_pipes, pipe(2, 0, 11, 2, colors.orange))
if num_boilers >= 2 then
table.insert(coolant_pipes, pipe(2, 0, 11, 11, colors.orange))
end
PipeNetwork{parent=root,x=4,y=10,pipes=coolant_pipes,bg=colors.lightGray}
end end
table.insert(coolant_pipes, pipe(0, 0, 11, 3, colors.lightBlue))
table.insert(coolant_pipes, pipe(2, 0, 11, 2, colors.orange))
if num_boilers == 2 then
table.insert(coolant_pipes, pipe(2, 0, 11, 11, colors.orange))
end
PipeNetwork{parent=root,x=4,y=10,pipes=coolant_pipes,bg=colors.lightGray}
------------- -------------
-- BOILERS -- -- BOILERS --
------------- -------------
boiler_view(root, 16, 11, unit.boiler_ps_tbl[1]) 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 if num_boilers >= 2 then boiler_view(root, 16, 19, unit.boiler_ps_tbl[2]) end
-------------- --------------
-- TURBINES -- -- TURBINES --
-------------- --------------
local t_idx = 1 local t_idx = 1
local no_boilers = num_boilers == 0
if num_turbines == 3 then if (num_turbines >= 3) or no_boilers or (num_boilers == 1 and num_turbines >= 2) then
turbine_view(root, 58, 3, unit.turbine_ps_tbl[t_idx]) turbine_view(root, 58, 3, unit.turbine_ps_tbl[t_idx])
t_idx = t_idx + 1 t_idx = t_idx + 1
end end
if num_turbines >= 1 then if (num_turbines >= 1 and not no_boilers) or num_turbines >= 2 then
turbine_view(root, 58, 11, unit.turbine_ps_tbl[t_idx]) turbine_view(root, 58, 11, unit.turbine_ps_tbl[t_idx])
t_idx = t_idx + 1 t_idx = t_idx + 1
end end
if num_turbines >= 2 then turbine_view(root, 58, 19, unit.turbine_ps_tbl[t_idx]) end if (num_turbines >= 2 and num_boilers >= 2) or num_turbines >= 3 then
turbine_view(root, 58, 19, unit.turbine_ps_tbl[t_idx])
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 end
local steam_pipes_b = {} local steam_pipes_b = {}
if num_turbines == 3 then if no_boilers 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(0, 1, 3, 1, colors.white)) -- steam to turbine 1
table.insert(steam_pipes_b, pipe(1, 1, 3, 1, colors.white, false, false)) -- steam boiler 1 to turbine 1 junction end table.insert(steam_pipes_b, pipe(0, 2, 3, 2, colors.blue)) -- water to turbine 1
end
table.insert(steam_pipes_b, pipe(0, 9, 3, 9, colors.white, false, true)) -- steam boiler 1 to turbine 2 if num_turbines >= 2 then
table.insert(steam_pipes_b, pipe(1, 2, 3, 9, colors.white)) -- steam to turbine 2
if num_turbines == 3 then table.insert(steam_pipes_b, pipe(2, 3, 3, 10, colors.blue)) -- water to turbine 2
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 >= 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
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
end end
if num_boilers == 2 then if num_turbines >= 3 then
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(1, 9, 3, 17, colors.white)) -- steam boiler 1 to turbine 1 junction end
table.insert(steam_pipes_b, pipe(0, 18, 3, 18, colors.blue, false, true)) -- water boiler 2 to turbine 2 junction table.insert(steam_pipes_b, pipe(2, 10, 3, 18, colors.blue)) -- water boiler 1 to turbine 1 junction start
else
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 end
elseif num_turbines == 1 and num_boilers == 2 then else
table.insert(steam_pipes_b, pipe(0, 17, 1, 9, colors.white, false, true)) -- steam boiler 2 to turbine 2 junction -- boiler side pipes
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 local steam_pipes_a = {
table.insert(steam_pipes_b, pipe(0, 18, 2, 18, colors.blue, false, true)) -- water boiler 2 to turbine 2 junction -- 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
-- turbine side pipes
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
end
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
end
PipeNetwork{parent=root,x=47,y=11,pipes=steam_pipes_a,bg=colors.lightGray}
end end
PipeNetwork{parent=root,x=47,y=11,pipes=steam_pipes_a,bg=colors.lightGray}
PipeNetwork{parent=root,x=54,y=3,pipes=steam_pipes_b,bg=colors.lightGray} PipeNetwork{parent=root,x=54,y=3,pipes=steam_pipes_b,bg=colors.lightGray}
return root
end end
return make return make

View File

@ -2,8 +2,6 @@
-- Main SCADA Coordinator GUI -- Main SCADA Coordinator GUI
-- --
local log = require("scada-common.log")
local database = require("coordinator.database") local database = require("coordinator.database")
local style = require("coordinator.ui.style") local style = require("coordinator.ui.style")
@ -24,11 +22,21 @@ local function init(monitor)
local db = database.get() local db = database.get()
local uo_1, uo_2, uo_3, uo_4 ---@type graphics_element
-- unit overviews -- unit overviews
if db.facility.num_units >= 1 then unit_overview(main, 2, 3, db.units[1]) end if db.facility.num_units >= 1 then uo_1 = unit_overview(main, 2, 3, db.units[1]) end
if db.facility.num_units >= 2 then unit_overview(main, 84, 3, db.units[2]) end if db.facility.num_units >= 2 then uo_2 = unit_overview(main, 84, 3, db.units[2]) end
if db.facility.num_units >= 3 then unit_overview(main, 2, 29, db.units[3]) end
if db.facility.num_units == 4 then unit_overview(main, 84, 29, db.units[4]) end if db.facility.num_units >= 3 then
-- base offset 3, spacing 1, max height of units 1 and 2
local row_2_offset = 3 + 1 + math.max(uo_1.height(), uo_2.height())
uo_3 = unit_overview(main, 2, row_2_offset, db.units[3])
if db.facility.num_units == 4 then uo_4 = unit_overview(main, 84, row_2_offset, db.units[4]) end
end
-- command & control
return main return main
end end

View File

@ -148,6 +148,16 @@ function element.new(args)
return self.child_offset.x, self.child_offset.y return self.child_offset.x, self.child_offset.y
end end
-- get element width
function public.width()
return protected.frame.w
end
-- get element height
function public.height()
return protected.frame.h
end
-- handle a monitor touch -- handle a monitor touch
---@param event monitor_touch monitor touch event ---@param event monitor_touch monitor touch event
function public.handle_touch(event) function public.handle_touch(event)