#78 linked up unit overview using psil
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
local core = require("graphics.core")
|
||||
local core = require("graphics.core")
|
||||
|
||||
local style = require("coordinator.ui.style")
|
||||
local style = require("coordinator.ui.style")
|
||||
|
||||
local DataIndicator = require("graphics.elements.indicators.data")
|
||||
local StateIndicator = require("graphics.elements.indicators.state")
|
||||
@@ -17,20 +17,24 @@ local border = core.graphics.border
|
||||
---@param root graphics_element
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param id integer
|
||||
---@param data boiler_session_db|boilerv_session_db
|
||||
---@param ps psil
|
||||
local function new_view(root, x, y, ps)
|
||||
local function new_view(root, x, y, id, data, ps)
|
||||
local tag = id .. "_"
|
||||
|
||||
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)
|
||||
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}
|
||||
local status = StateIndicator{parent=boiler,x=10,y=1,states=style.boiler.states,value=1,min_width=10}
|
||||
local temp = DataIndicator{parent=boiler,x=5,y=3,lu_colors=lu_col,label="Temp:",unit="K",format="%10.2f",value=data.state.temperature,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=data.state.boil_rate,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)
|
||||
ps.subscribe(tag .. "computed_status", status.update)
|
||||
ps.subscribe(tag .. "temperature", temp.update)
|
||||
ps.subscribe(tag .. "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}
|
||||
@@ -42,16 +46,15 @@ local function new_view(root, x, y, ps)
|
||||
local steam = VerticalBar{parent=boiler,x=27,y=1,fg_bg=cpair(colors.white,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)
|
||||
ps.subscribe(tag .. "hcool_fill", hcool.update)
|
||||
ps.subscribe(tag .. "water_fill", water.update)
|
||||
ps.subscribe(tag .. "steam_fill", steam.update)
|
||||
ps.subscribe(tag .. "ccool_fill", ccool.update)
|
||||
|
||||
---@fixme test code
|
||||
hcool.update(0.22)
|
||||
water.update(1)
|
||||
steam.update(0.05)
|
||||
ccool.update(0.13)
|
||||
hcool.update(data.tanks.hcool_fill)
|
||||
water.update(data.tanks.water_fill)
|
||||
steam.update(data.tanks.steam_fill)
|
||||
ccool.update(data.tanks.ccool_fill)
|
||||
end
|
||||
|
||||
return new_view
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local core = require("graphics.core")
|
||||
local core = require("graphics.core")
|
||||
|
||||
local style = require("coordinator.ui.style")
|
||||
local style = require("coordinator.ui.style")
|
||||
|
||||
local DataIndicator = require("graphics.elements.indicators.data")
|
||||
local StateIndicator = require("graphics.elements.indicators.state")
|
||||
@@ -17,27 +17,30 @@ local border = core.graphics.border
|
||||
---@param root graphics_element
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param id integer
|
||||
---@param data turbine_session_db|turbinev_session_db
|
||||
---@param ps psil
|
||||
local function new_view(root, x, y, ps)
|
||||
local function new_view(root, x, y, id, data, ps)
|
||||
local tag = id .. "_"
|
||||
|
||||
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)
|
||||
|
||||
local status = StateIndicator{parent=turbine,x=8,y=1,states=style.turbine.states,value=3,min_width=10}
|
||||
local prod_rate = DataIndicator{parent=turbine,x=5,y=3,lu_colors=lu_col,label="",unit="MFE",format="%10.2f",value=3.2,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=801523,commas=true,width=16,fg_bg=text_fg_bg}
|
||||
local status = StateIndicator{parent=turbine,x=8,y=1,states=style.turbine.states,value=1,min_width=10}
|
||||
local prod_rate = DataIndicator{parent=turbine,x=5,y=3,lu_colors=lu_col,label="",unit="MFE",format="%10.2f",value=data.state.prod_rate,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=data.state.flow_rate,commas=true,width=16,fg_bg=text_fg_bg}
|
||||
|
||||
ps.subscribe("status", status.update)
|
||||
ps.subscribe("prod_rate", prod_rate.update)
|
||||
ps.subscribe("flow_rate", flow_rate.update)
|
||||
ps.subscribe(tag .. "computed_status", status.update)
|
||||
ps.subscribe(tag .. "prod_rate", prod_rate.update)
|
||||
ps.subscribe(tag .. "flow_rate", flow_rate.update)
|
||||
|
||||
local steam = VerticalBar{parent=turbine,x=2,y=1,fg_bg=cpair(colors.white,colors.gray),height=5,width=2}
|
||||
|
||||
ps.subscribe("steam", steam.update)
|
||||
ps.subscribe(tag .. "steam_fill", steam.update)
|
||||
|
||||
---@fixme test code
|
||||
steam.update(0.12)
|
||||
steam.update(data.tanks.steam_fill)
|
||||
end
|
||||
|
||||
return new_view
|
||||
|
||||
@@ -50,7 +50,7 @@ local function make(parent, x, y, unit)
|
||||
-- REACTOR --
|
||||
-------------
|
||||
|
||||
reactor_view(root, 1, 3, unit.reactor_ps)
|
||||
reactor_view(root, 1, 3, unit.reactor_data, unit.reactor_ps)
|
||||
|
||||
if num_boilers > 0 then
|
||||
local coolant_pipes = {}
|
||||
@@ -73,8 +73,8 @@ local function make(parent, x, y, unit)
|
||||
-- BOILERS --
|
||||
-------------
|
||||
|
||||
if num_boilers >= 1 then boiler_view(root, 16, 11, unit.boiler_ps_tbl[1]) end
|
||||
if num_boilers >= 2 then boiler_view(root, 16, 19, unit.boiler_ps_tbl[2]) end
|
||||
if num_boilers >= 1 then boiler_view(root, 16, 11, 1, unit.boiler_data_tbl[1], unit.boiler_ps_tbl[1]) end
|
||||
if num_boilers >= 2 then boiler_view(root, 16, 19, 2, unit.boiler_data_tbl[2], unit.boiler_ps_tbl[2]) end
|
||||
|
||||
--------------
|
||||
-- TURBINES --
|
||||
@@ -84,17 +84,17 @@ local function make(parent, x, y, unit)
|
||||
local no_boilers = num_boilers == 0
|
||||
|
||||
if (num_turbines >= 3) or no_boilers or (num_boilers == 1 and num_turbines >= 2) then
|
||||
turbine_view(root, 58, 3, unit.turbine_ps_tbl[t_idx])
|
||||
turbine_view(root, 58, 3, t_idx, unit.turbine_data_tbl[t_idx], unit.turbine_ps_tbl[t_idx])
|
||||
t_idx = t_idx + 1
|
||||
end
|
||||
|
||||
if (num_turbines >= 1 and not no_boilers) or num_turbines >= 2 then
|
||||
turbine_view(root, 58, 11, unit.turbine_ps_tbl[t_idx])
|
||||
turbine_view(root, 58, 11, t_idx, unit.turbine_data_tbl[t_idx], unit.turbine_ps_tbl[t_idx])
|
||||
t_idx = t_idx + 1
|
||||
end
|
||||
|
||||
if (num_turbines >= 2 and num_boilers >= 2) or num_turbines >= 3 then
|
||||
turbine_view(root, 58, 19, unit.turbine_ps_tbl[t_idx])
|
||||
turbine_view(root, 58, 19, t_idx, unit.turbine_data_tbl[t_idx], unit.turbine_ps_tbl[t_idx])
|
||||
end
|
||||
|
||||
local steam_pipes_b = {}
|
||||
|
||||
@@ -50,6 +50,10 @@ style.reactor = {
|
||||
{
|
||||
color = cpair(colors.black, colors.red),
|
||||
text = "SCRAM!"
|
||||
},
|
||||
{
|
||||
color = cpair(colors.black, colors.orange),
|
||||
text = "PLC FAULT!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user