#72, #78 updated main view to adapt to facility configuration, initial use of pub/sub for main view

This commit is contained in:
Mikayla Fischler
2022-07-10 16:15:30 -04:00
parent 5a96818c97
commit 6f61203db3
6 changed files with 145 additions and 50 deletions

View File

@@ -14,7 +14,12 @@ local TEXT_ALIGN = core.graphics.TEXT_ALIGN
local cpair = core.graphics.cpair
local border = core.graphics.border
local function new_view(root, x, y)
-- new boiler view
---@param root graphics_element
---@param x integer
---@param y integer
---@param ps psil
local function new_view(root, x, y, ps)
local boiler = Rectangle{parent=root,border=border(1, colors.gray, true),width=31,height=7,x=x,y=y}
local text_fg_bg = cpair(colors.black, colors.lightGray)
@@ -24,6 +29,10 @@ local function new_view(root, x, y)
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}
ps.subscribe("status", status.update)
ps.subscribe("temp", temp.update)
ps.subscribe("boil_rate", boil_r.update)
TextBox{parent=boiler,text="H",x=2,y=5,height=1,width=1,fg_bg=text_fg_bg}
TextBox{parent=boiler,text="W",x=3,y=5,height=1,width=1,fg_bg=text_fg_bg}
TextBox{parent=boiler,text="S",x=27,y=5,height=1,width=1,fg_bg=text_fg_bg}
@@ -32,12 +41,17 @@ local function new_view(root, x, y)
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}
local ccool = VerticalBar{parent=boiler,x=28,y=1,fg_bg=cpair(colors.lightBlue,colors.gray),height=4,width=1}
ps.subscribe("hcool", hcool.update)
ps.subscribe("water", water.update)
ps.subscribe("steam", steam.update)
ps.subscribe("ccool", ccool.update)
hcool.update(0.22)
water.update(1)
steam.update(0.05)
cool.update(0.13)
ccool.update(0.13)
end
return new_view