#72 work on main layout, reactor and boiler views exist now

This commit is contained in:
Mikayla Fischler 2022-06-25 16:21:57 -04:00
parent e137953f93
commit 1188d2f7df
6 changed files with 132 additions and 15 deletions

View File

@ -82,11 +82,21 @@ end
log.dmesg("wireless modem connected", "COMMS", colors.purple)
-- start the UI
log.dmesg("starting UI...", "GRAPHICS", colors.green)
util.psleep(3)
-- util.psleep(3)
local ui_ok, message = pcall(renderer.start_ui)
if not ui_ok then
renderer.close_ui()
log.dmesg("UI draw failed: " .. message, "GRAPHICS", colors.green)
println_ts("UI crashed")
log.dmesg(util.c("UI crashed: ", message), "GRAPHICS", colors.green)
log.fatal(util.c("ui crashed with error ", message))
end
-- renderer.close_ui()
-- log.dmesg("system shutdown", "SYSTEM", colors.cyan)
println_ts("exited")
log.info("exited")

View File

@ -0,0 +1,43 @@
local core = require("graphics.core")
local style = require("coordinator.ui.style")
local Div = require("graphics.elements.div")
local DataIndicator = require("graphics.elements.indicators.data")
local StateIndicator = require("graphics.elements.indicators.state")
local Rectangle = require("graphics.elements.rectangle")
local TextBox = require("graphics.elements.textbox")
local VerticalBar = require("graphics.elements.indicators.vbar")
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
local cpair = core.graphics.cpair
local border = core.graphics.border
local function new_view(root, x, y)
local boiler = Rectangle{parent=root,border=border(1, colors.gray, true),width=31,height=8,x=x,y=y}
local text_fg_bg = cpair(colors.black, colors.lightGray)
local lu_col = cpair(colors.gray, colors.gray)
local status = StateIndicator{parent=boiler,x=10,y=1,states=style.boiler.states,value=3,min_width=10}
local temp = DataIndicator{parent=boiler,x=5,y=3,lu_colors=lu_col,label="Temp:",unit="K",format="%10.2f",value=1900,width=22,fg_bg=text_fg_bg}
local boil_r = DataIndicator{parent=boiler,x=5,y=4,lu_colors=lu_col,label="Boil:",unit="mB/t",format="%10.0f",value=801523,commas=true,width=22,fg_bg=text_fg_bg}
TextBox{parent=boiler,text="H",x=2,y=6,height=1,width=1,fg_bg=text_fg_bg}
TextBox{parent=boiler,text="W",x=3,y=6,height=1,width=1,fg_bg=text_fg_bg}
TextBox{parent=boiler,text="S",x=27,y=6,height=1,width=1,fg_bg=text_fg_bg}
TextBox{parent=boiler,text="C",x=28,y=6,height=1,width=1,fg_bg=text_fg_bg}
local hcool = VerticalBar{parent=boiler,x=2,y=1,fg_bg=cpair(colors.orange,colors.gray),height=4,width=1}
local water = VerticalBar{parent=boiler,x=3,y=1,fg_bg=cpair(colors.blue,colors.gray),height=4,width=1}
local steam = VerticalBar{parent=boiler,x=27,y=1,fg_bg=cpair(colors.white,colors.gray),height=4,width=1}
local cool = VerticalBar{parent=boiler,x=28,y=1,fg_bg=cpair(colors.lightBlue,colors.gray),height=4,width=1}
hcool.update(0.22)
water.update(1)
steam.update(0.05)
cool.update(0.13)
end
return new_view

View File

@ -0,0 +1,46 @@
local core = require("graphics.core")
local style = require("coordinator.ui.style")
local Div = require("graphics.elements.div")
local HorizontalBar = require("graphics.elements.indicators.hbar")
local DataIndicator = require("graphics.elements.indicators.data")
local StateIndicator = require("graphics.elements.indicators.state")
local Rectangle = require("graphics.elements.rectangle")
local TextBox = require("graphics.elements.textbox")
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
local cpair = core.graphics.cpair
local border = core.graphics.border
local function new_view(root, x, y)
local reactor = Rectangle{parent=root,border=border(1, colors.gray, true),width=30,height=7,x=x,y=y}
local text_fg_bg = cpair(colors.black, colors.lightGray)
local lu_col = cpair(colors.gray, colors.gray)
local status = StateIndicator{parent=reactor,x=8,y=1,states=style.reactor.states,value=3,min_width=14}
local core_temp = DataIndicator{parent=reactor,x=2,y=3,lu_colors=lu_col,label="Core: ",unit="K",format="%12.2f",value=451.12,width=26,fg_bg=text_fg_bg}
local burn_r = DataIndicator{parent=reactor,x=2,y=4,lu_colors=lu_col,label="Burn: ",unit="mB/t",format="%12.1f",value=40.1,width=26,fg_bg=text_fg_bg}
local heating_r = DataIndicator{parent=reactor,x=2,y=5,lu_colors=lu_col,label="Heating:",unit="mB/t",format="%12.0f",value=8015342,commas=true,width=26,fg_bg=text_fg_bg}
local reactor_fills = Rectangle{parent=root,border=border(1, colors.gray, true),width=24,height=7,x=(x + 29),y=y}
TextBox{parent=reactor_fills,text="FUEL",x=2,y=1,height=1,fg_bg=text_fg_bg}
TextBox{parent=reactor_fills,text="COOL",x=2,y=2,height=1,fg_bg=text_fg_bg}
TextBox{parent=reactor_fills,text="HCOOL",x=2,y=4,height=1,fg_bg=text_fg_bg}
TextBox{parent=reactor_fills,text="WASTE",x=2,y=5,height=1,fg_bg=text_fg_bg}
local fuel = HorizontalBar{parent=reactor_fills,x=8,y=1,show_percent=true,bar_fg_bg=cpair(colors.black,colors.gray),height=1,width=14}
local cool = HorizontalBar{parent=reactor_fills,x=8,y=2,show_percent=true,bar_fg_bg=cpair(colors.lightBlue,colors.gray),height=1,width=14}
local hcool = HorizontalBar{parent=reactor_fills,x=8,y=4,show_percent=true,bar_fg_bg=cpair(colors.orange,colors.gray),height=1,width=14}
local waste = HorizontalBar{parent=reactor_fills,x=8,y=5,show_percent=true,bar_fg_bg=cpair(colors.brown,colors.gray),height=1,width=14}
fuel.update(1)
cool.update(0.85)
hcool.update(0.08)
waste.update(0.32)
end
return new_view

View File

@ -2,6 +2,9 @@ local core = require("graphics.core")
local style = require("coordinator.ui.style")
local reactor_view = require("coordinator.ui.components.reactor")
local boiler_view = require("coordinator.ui.components.boiler")
local Div = require("graphics.elements.div")
local HorizontalBar = require("graphics.elements.indicators.hbar")
local DataIndicator = require("graphics.elements.indicators.data")
@ -22,22 +25,19 @@ local function make(parent, x, y, unit_id)
-- unit header message
TextBox{parent=root,text="Unit #" .. unit_id,alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
-- reactor
local reactor = Rectangle{parent=root,border=border(1, colors.gray),width=30,height=10,x=1,y=3}
-------------
-- REACTOR --
-------------
local text_fg_bg = cpair(colors.black, colors.lightGray)
local lu_col = cpair(colors.gray, colors.gray)
reactor_view(root, 1, 3)
local status = StateIndicator{parent=reactor,x=9,y=2,states=style.reactor.states,value=1,min_width=14}
local core_temp = DataIndicator{parent=reactor,x=3,y=4,lu_colors=lu_col,label="Core: ",unit="K",format="%7.0f",value=295,width=26,fg_bg=text_fg_bg}
local heating_r = DataIndicator{parent=reactor,x=3,y=5,lu_colors=lu_col,label="Heating:",unit="mB/t",format="%7.0f",value=359999,width=26,fg_bg=text_fg_bg}
local burn_r = DataIndicator{parent=reactor,x=3,y=6,lu_colors=lu_col,label="Burn: ",unit="mB/t",format="%7.1f",value=40.1,width=26,fg_bg=text_fg_bg}
-------------
-- BOILERS --
-------------
local fuel = HorizontalBar{parent=root,x=34,y=4,show_percent=true,bar_fg_bg=cpair(colors.brown,colors.white),height=1,width=14}
local coolant = HorizontalBar{parent=root,x=34,y=5,show_percent=true,bar_fg_bg=cpair(colors.lightBlue,colors.white),height=1,width=14}
boiler_view(root, 23, 11)
boiler_view(root, 23, 20)
fuel.update(0.85)
coolant.update(0.75)
end
return make

View File

@ -21,7 +21,7 @@ local function init(monitor)
TextBox{parent=main,text="Nuclear Generation Facility SCADA Coordinator",alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=style.header}
-- unit overviews
unit_overview(main, 5, 5, 1)
unit_overview(main, 3, 3, 1)
return main
end

View File

@ -32,4 +32,22 @@ style.reactor = {
}
}
style.boiler = {
-- boiler states
states = {
{
color = cpair(colors.black, colors.yellow),
text = "OFF-LINE"
},
{
color = cpair(colors.white, colors.gray),
text = "IDLE"
},
{
color = cpair(colors.black, colors.green),
text = "ACTIVE"
}
}
}
return style