2022-09-03 17:10:51 +00:00
|
|
|
local core = require("graphics.core")
|
2022-07-02 21:24:52 +00:00
|
|
|
|
2022-09-03 17:10:51 +00:00
|
|
|
local style = require("coordinator.ui.style")
|
2022-07-02 21:24:52 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-07-10 20:15:30 +00:00
|
|
|
-- new turbine view
|
|
|
|
---@param root graphics_element
|
|
|
|
---@param x integer
|
|
|
|
---@param y integer
|
2022-09-03 17:10:51 +00:00
|
|
|
---@param id integer
|
2022-07-10 20:15:30 +00:00
|
|
|
---@param ps psil
|
2022-09-05 20:04:32 +00:00
|
|
|
local function new_view(root, x, y, id, ps)
|
2022-09-03 17:10:51 +00:00
|
|
|
local tag = id .. "_"
|
|
|
|
|
2022-07-02 21:24:52 +00:00
|
|
|
local turbine = Rectangle{parent=root,border=border(1, colors.gray, true),width=23,height=7,x=x,y=y}
|
|
|
|
|
|
|
|
local text_fg_bg = cpair(colors.black, colors.lightGray)
|
|
|
|
local lu_col = cpair(colors.gray, colors.gray)
|
|
|
|
|
2022-09-03 17:10:51 +00:00
|
|
|
local status = StateIndicator{parent=turbine,x=8,y=1,states=style.turbine.states,value=1,min_width=10}
|
2022-09-05 20:04:32 +00:00
|
|
|
local prod_rate = DataIndicator{parent=turbine,x=5,y=3,lu_colors=lu_col,label="",unit="MFE",format="%10.2f",value=0,width=16,fg_bg=text_fg_bg}
|
|
|
|
local flow_rate = DataIndicator{parent=turbine,x=5,y=4,lu_colors=lu_col,label="",unit="mB/t",format="%10.0f",value=0,commas=true,width=16,fg_bg=text_fg_bg}
|
2022-07-02 21:24:52 +00:00
|
|
|
|
2022-09-03 17:10:51 +00:00
|
|
|
ps.subscribe(tag .. "computed_status", status.update)
|
|
|
|
ps.subscribe(tag .. "prod_rate", prod_rate.update)
|
|
|
|
ps.subscribe(tag .. "flow_rate", flow_rate.update)
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-07-02 21:24:52 +00:00
|
|
|
local steam = VerticalBar{parent=turbine,x=2,y=1,fg_bg=cpair(colors.white,colors.gray),height=5,width=2}
|
|
|
|
|
2022-09-03 17:10:51 +00:00
|
|
|
ps.subscribe(tag .. "steam_fill", steam.update)
|
2022-07-02 21:24:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return new_view
|