2022-09-03 17:10:51 +00:00
|
|
|
local style = require("coordinator.ui.style")
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2024-02-23 00:25:16 +00:00
|
|
|
local iocontrol = require("coordinator.iocontrol")
|
|
|
|
|
2023-02-03 04:07:09 +00:00
|
|
|
local core = require("graphics.core")
|
|
|
|
|
2022-06-25 20:21:57 +00:00
|
|
|
local Rectangle = require("graphics.elements.rectangle")
|
|
|
|
local TextBox = require("graphics.elements.textbox")
|
2022-12-10 20:44:11 +00:00
|
|
|
|
|
|
|
local DataIndicator = require("graphics.elements.indicators.data")
|
|
|
|
local StateIndicator = require("graphics.elements.indicators.state")
|
2022-06-25 20:21:57 +00:00
|
|
|
local VerticalBar = require("graphics.elements.indicators.vbar")
|
|
|
|
|
2023-05-07 01:27:36 +00:00
|
|
|
local cpair = core.cpair
|
|
|
|
local border = core.border
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2024-02-24 19:35:04 +00:00
|
|
|
local text_fg = style.theme.text_fg
|
2024-02-23 00:25:16 +00:00
|
|
|
local lu_col = style.lu_colors
|
2023-09-02 02:24:31 +00:00
|
|
|
|
2022-07-10 20:15:30 +00:00
|
|
|
-- new boiler view
|
2022-09-07 02:38:27 +00:00
|
|
|
---@param root graphics_element parent
|
|
|
|
---@param x integer top left x
|
|
|
|
---@param y integer top left y
|
|
|
|
---@param ps psil ps interface
|
2022-09-07 14:25:22 +00:00
|
|
|
local function new_view(root, x, y, ps)
|
2024-02-23 00:25:16 +00:00
|
|
|
local db = iocontrol.get_db()
|
|
|
|
|
2023-09-02 02:24:31 +00:00
|
|
|
local boiler = Rectangle{parent=root,border=border(1,colors.gray,true),width=31,height=7,x=x,y=y}
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2022-11-11 19:59:53 +00:00
|
|
|
local status = StateIndicator{parent=boiler,x=9,y=1,states=style.boiler.states,value=1,min_width=12}
|
2024-02-24 19:35:04 +00:00
|
|
|
local temp = DataIndicator{parent=boiler,x=5,y=3,lu_colors=lu_col,label="Temp:",unit=db.temp_label,format="%10.2f",value=0,commas=true,width=22,fg_bg=text_fg}
|
|
|
|
local boil_r = DataIndicator{parent=boiler,x=5,y=4,lu_colors=lu_col,label="Boil:",unit="mB/t",format="%10.0f",value=0,commas=true,width=22,fg_bg=text_fg}
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2023-05-14 23:13:12 +00:00
|
|
|
status.register(ps, "computed_status", status.update)
|
2024-02-23 00:25:16 +00:00
|
|
|
temp.register(ps, "temperature", function (t) temp.update(db.temp_convert(t)) end)
|
2023-05-14 23:13:12 +00:00
|
|
|
boil_r.register(ps, "boil_rate", boil_r.update)
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2024-02-24 19:35:04 +00:00
|
|
|
TextBox{parent=boiler,text="H",x=2,y=5,height=1,width=1,fg_bg=text_fg}
|
|
|
|
TextBox{parent=boiler,text="W",x=3,y=5,height=1,width=1,fg_bg=text_fg}
|
|
|
|
TextBox{parent=boiler,text="S",x=27,y=5,height=1,width=1,fg_bg=text_fg}
|
|
|
|
TextBox{parent=boiler,text="C",x=28,y=5,height=1,width=1,fg_bg=text_fg}
|
2022-06-25 20:21:57 +00:00
|
|
|
|
|
|
|
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}
|
2022-07-10 20:15:30 +00:00
|
|
|
local ccool = VerticalBar{parent=boiler,x=28,y=1,fg_bg=cpair(colors.lightBlue,colors.gray),height=4,width=1}
|
|
|
|
|
2023-05-14 23:13:12 +00:00
|
|
|
hcool.register(ps, "hcool_fill", hcool.update)
|
|
|
|
water.register(ps, "water_fill", water.update)
|
|
|
|
steam.register(ps, "steam_fill", steam.update)
|
|
|
|
ccool.register(ps, "ccool_fill", ccool.update)
|
2022-06-25 20:21:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return new_view
|