2023-02-23 04:09:47 +00:00
|
|
|
local types = require("scada-common.types")
|
|
|
|
|
2024-02-23 00:25:16 +00:00
|
|
|
local iocontrol = require("coordinator.iocontrol")
|
|
|
|
|
2023-02-03 04:07:09 +00:00
|
|
|
local style = require("coordinator.ui.style")
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2022-09-03 17:10:51 +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 HorizontalBar = require("graphics.elements.indicators.hbar")
|
|
|
|
local StateIndicator = require("graphics.elements.indicators.state")
|
|
|
|
|
2023-05-07 01:27:36 +00:00
|
|
|
local cpair = core.cpair
|
|
|
|
local border = core.border
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2022-09-07 02:38:27 +00:00
|
|
|
-- create new reactor view
|
|
|
|
---@param root graphics_element parent
|
|
|
|
---@param x integer top left x
|
|
|
|
---@param y integer top left y
|
|
|
|
---@param ps psil ps interface
|
2023-04-12 20:02:29 +00:00
|
|
|
local function new_view(root, x, y, ps)
|
2024-03-07 04:35:30 +00:00
|
|
|
local text_fg = style.theme.text_fg
|
|
|
|
local lu_col = style.lu_colors
|
|
|
|
|
2024-02-23 00:25:16 +00:00
|
|
|
local db = iocontrol.get_db()
|
|
|
|
|
2024-02-24 19:35:04 +00:00
|
|
|
local reactor = Rectangle{parent=root,border=border(1,colors.gray,true),width=30,height=7,x=x,y=y}
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2022-11-11 20:45:46 +00:00
|
|
|
local status = StateIndicator{parent=reactor,x=6,y=1,states=style.reactor.states,value=1,min_width=16}
|
2024-02-24 19:35:04 +00:00
|
|
|
local core_temp = DataIndicator{parent=reactor,x=2,y=3,lu_colors=lu_col,label="Core Temp:",unit=db.temp_label,format="%10.2f",value=0,commas=true,width=26,fg_bg=text_fg}
|
|
|
|
local burn_r = DataIndicator{parent=reactor,x=2,y=4,lu_colors=lu_col,label="Burn Rate:",unit="mB/t",format="%10.2f",value=0,width=26,fg_bg=text_fg}
|
|
|
|
local heating_r = DataIndicator{parent=reactor,x=2,y=5,lu_colors=lu_col,label="Heating:",unit="mB/t",format="%12.0f",value=0,commas=true,width=26,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
|
|
|
core_temp.register(ps, "temp", function (t) core_temp.update(db.temp_convert(t)) end)
|
2023-05-14 23:13:12 +00:00
|
|
|
burn_r.register(ps, "act_burn_rate", burn_r.update)
|
|
|
|
heating_r.register(ps, "heating_rate", heating_r.update)
|
2022-07-10 20:15:30 +00:00
|
|
|
|
2022-06-25 20:21:57 +00:00
|
|
|
local reactor_fills = Rectangle{parent=root,border=border(1, colors.gray, true),width=24,height=7,x=(x + 29),y=y}
|
|
|
|
|
2024-06-30 17:55:13 +00:00
|
|
|
TextBox{parent=reactor_fills,text="FUEL",x=2,y=1,fg_bg=text_fg}
|
|
|
|
TextBox{parent=reactor_fills,text="COOL",x=2,y=2,fg_bg=text_fg}
|
|
|
|
TextBox{parent=reactor_fills,text="HCOOL",x=2,y=4,fg_bg=text_fg}
|
|
|
|
TextBox{parent=reactor_fills,text="WASTE",x=2,y=5,fg_bg=text_fg}
|
2022-06-25 20:21:57 +00:00
|
|
|
|
2024-02-24 19:35:04 +00:00
|
|
|
local fuel = HorizontalBar{parent=reactor_fills,x=8,y=1,show_percent=true,bar_fg_bg=cpair(style.theme.fuel_color,colors.gray),height=1,width=14}
|
2022-12-11 15:51:45 +00:00
|
|
|
local ccool = HorizontalBar{parent=reactor_fills,x=8,y=2,show_percent=true,bar_fg_bg=cpair(colors.blue,colors.gray),height=1,width=14}
|
|
|
|
local hcool = HorizontalBar{parent=reactor_fills,x=8,y=4,show_percent=true,bar_fg_bg=cpair(colors.white,colors.gray),height=1,width=14}
|
2022-06-25 20:21:57 +00:00
|
|
|
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}
|
|
|
|
|
2023-05-14 23:13:12 +00:00
|
|
|
ccool.register(ps, "ccool_type", function (type)
|
2023-02-23 04:09:47 +00:00
|
|
|
if type == types.FLUID.SODIUM then
|
2022-12-11 15:51:45 +00:00
|
|
|
ccool.recolor(cpair(colors.lightBlue, colors.gray))
|
|
|
|
else
|
|
|
|
ccool.recolor(cpair(colors.blue, colors.gray))
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-05-14 23:13:12 +00:00
|
|
|
hcool.register(ps, "hcool_type", function (type)
|
2023-02-23 04:09:47 +00:00
|
|
|
if type == types.FLUID.SUPERHEATED_SODIUM then
|
2022-12-11 15:51:45 +00:00
|
|
|
hcool.recolor(cpair(colors.orange, colors.gray))
|
|
|
|
else
|
|
|
|
hcool.recolor(cpair(colors.white, colors.gray))
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-05-14 23:13:12 +00:00
|
|
|
fuel.register(ps, "fuel_fill", fuel.update)
|
|
|
|
ccool.register(ps, "ccool_fill", ccool.update)
|
|
|
|
hcool.register(ps, "hcool_fill", hcool.update)
|
|
|
|
waste.register(ps, "waste_fill", waste.update)
|
2022-06-25 20:21:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return new_view
|