#78 linked up unit overview using psil

This commit is contained in:
Mikayla Fischler
2022-09-03 13:10:51 -04:00
parent 17fce01ff5
commit 564b89d19c
7 changed files with 169 additions and 71 deletions

View File

@@ -1,6 +1,8 @@
local core = require("graphics.core")
local util = require("scada-common.util")
local style = require("coordinator.ui.style")
local core = require("graphics.core")
local style = require("coordinator.ui.style")
local HorizontalBar = require("graphics.elements.indicators.hbar")
local DataIndicator = require("graphics.elements.indicators.data")
@@ -16,19 +18,20 @@ local border = core.graphics.border
---@param root graphics_element
---@param x integer
---@param y integer
---@param data reactor_db
---@param ps psil
local function new_view(root, x, y, ps)
local function new_view(root, x, y, data, ps)
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 Temp:",unit="K",format="%10.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 Rate:",unit="mB/t",format="%10.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 status = StateIndicator{parent=reactor,x=8,y=1,states=style.reactor.states,value=1,min_width=14}
local core_temp = DataIndicator{parent=reactor,x=2,y=3,lu_colors=lu_col,label="Core Temp:",unit="K",format="%10.2f",value=data.mek_status.temp,width=26,fg_bg=text_fg_bg}
local burn_r = DataIndicator{parent=reactor,x=2,y=4,lu_colors=lu_col,label="Burn Rate:",unit="mB/t",format="%10.1f",value=data.mek_status.act_burn_rate,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=data.mek_status.heating_rate,commas=true,width=26,fg_bg=text_fg_bg}
ps.subscribe("status", status.update)
ps.subscribe("computed_status", status.update)
ps.subscribe("temp", core_temp.update)
ps.subscribe("burn_rate", burn_r.update)
ps.subscribe("heating_rate", heating_r.update)
@@ -40,21 +43,23 @@ local function new_view(root, x, y, ps)
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 ccool_color = util.trinary(data.mek_status.ccool_type == "sodium", cpair(colors.lightBlue,colors.gray), cpair(colors.blue,colors.gray))
local hcool_color = util.trinary(data.mek_status.hcool_type == "superheated_sodium", cpair(colors.orange,colors.gray), cpair(colors.white,colors.gray))
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 ccool = 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 ccool = HorizontalBar{parent=reactor_fills,x=8,y=2,show_percent=true,bar_fg_bg=ccool_color,height=1,width=14}
local hcool = HorizontalBar{parent=reactor_fills,x=8,y=4,show_percent=true,bar_fg_bg=hcool_color,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}
ps.subscribe("fuel", fuel.update)
ps.subscribe("ccool", ccool.update)
ps.subscribe("hcool", hcool.update)
ps.subscribe("waste", waste.update)
ps.subscribe("fuel_fill", fuel.update)
ps.subscribe("ccool_fill", ccool.update)
ps.subscribe("hcool_fill", hcool.update)
ps.subscribe("waste_fill", waste.update)
---@fixme test code
fuel.update(1)
ccool.update(0.85)
hcool.update(0.08)
waste.update(0.32)
fuel.update(data.mek_status.fuel_fill)
ccool.update(data.mek_status.ccool_fill)
hcool.update(data.mek_status.hcool_fill)
waste.update(data.mek_status.waste_fill)
end
return new_view