#232 continued work on flow monitor, added SPS display

This commit is contained in:
Mikayla Fischler 2023-08-10 23:31:38 -04:00
parent e0809f52a6
commit d85385c1fe
3 changed files with 75 additions and 36 deletions

View File

@ -6,12 +6,6 @@ local util = require("scada-common.util")
local core = require("graphics.core")
local style = require("coordinator.ui.style")
local reactor_view = require("coordinator.ui.components.reactor")
local boiler_view = require("coordinator.ui.components.boiler")
local turbine_view = require("coordinator.ui.components.turbine")
local Div = require("graphics.elements.div")
local PipeNetwork = require("graphics.elements.pipenet")
local TextBox = require("graphics.elements.textbox")
@ -19,18 +13,14 @@ local TextBox = require("graphics.elements.textbox")
local Rectangle = require("graphics.elements.rectangle")
local DataIndicator = require("graphics.elements.indicators.data")
local HorizontalBar = require("graphics.elements.indicators.hbar")
local StateIndicator = require("graphics.elements.indicators.state")
local IndicatorLight = require("graphics.elements.indicators.light")
local TriIndicatorLight = require("graphics.elements.indicators.trilight")
local VerticalBar = require("graphics.elements.indicators.vbar")
local cpair = core.cpair
local border = core.border
local TEXT_ALIGN = core.TEXT_ALIGN
local cpair = core.cpair
local border = core.border
local pipe = core.pipe
-- make a new unit overview window
@ -42,11 +32,15 @@ local function make(parent, x, y, unit)
local height = 16
local v_start = 1 + ((unit.unit_id - 1) * 4)
local prv_start = 1 + ((unit.unit_id - 1) * 3)
local v_names = {
util.sprintf("PV%02d-PU", v_start),
util.sprintf("PV%02d-PO", v_start + 1),
util.sprintf("PV%02d-PL", v_start + 2),
util.sprintf("PV%02d-AM", v_start + 3)
util.sprintf("PV%02d-AM", v_start + 3),
util.sprintf("PRV%02d", prv_start),
util.sprintf("PRV%02d", prv_start + 1),
util.sprintf("PRV%02d", prv_start + 2)
}
assert(parent.get_height() >= (y + height), "flow display not of sufficient vertical resolution (add an additional row of monitors) " .. y .. "," .. parent.get_height())
@ -57,9 +51,9 @@ local function make(parent, x, y, unit)
local text_fg_bg = cpair(colors.black, colors.white)
local lu_col = cpair(colors.gray, colors.gray)
-------------
-- REACTOR --
-------------
------------------
-- COOLING LOOP --
------------------
local reactor = Rectangle{parent=root,x=1,y=1,border=border(1, colors.gray, true),width=19,height=5,fg_bg=cpair(colors.white,colors.gray)}
TextBox{parent=reactor,y=1,text="FISSION REACTOR",alignment=TEXT_ALIGN.CENTER,height=1}
@ -97,11 +91,18 @@ local function make(parent, x, y, unit)
TextBox{parent=turbine,y=3,text="GENERATORS",alignment=TEXT_ALIGN.CENTER,height=1}
TextBox{parent=root,x=79,y=2,text="\x1a \x80 \x1b",width=1,height=3,fg_bg=cpair(colors.lightGray,colors.gray)}
TextBox{parent=root,x=101,y=3,text="\x10\x11",fg_bg=cpair(colors.black,colors.lightGray),width=2,height=1}
TextBox{parent=root,x=103,y=3,text="\x7f",fg_bg=cpair(colors.white,colors.lightGray),width=1,height=1}
local conn = TriIndicatorLight{parent=root,x=106,y=1,label="PRV01",c1=colors.gray,c2=colors.yellow,c3=colors.red}
local conn = TriIndicatorLight{parent=root,x=106,y=3,label="PRV02",c1=colors.gray,c2=colors.yellow,c3=colors.red}
local conn = TriIndicatorLight{parent=root,x=106,y=5,label="PRV03",c1=colors.gray,c2=colors.yellow,c3=colors.red}
local function _relief(rx, ry, name)
TextBox{parent=root,x=rx,y=ry,text="\x10\x11\x7f",fg_bg=cpair(colors.black,colors.lightGray),width=3,height=1}
local conn = TriIndicatorLight{parent=root,x=rx+4,y=ry,label=name,c1=colors.gray,c2=colors.yellow,c3=colors.red}
end
_relief(103, 1, v_names[5])
_relief(103, 3, v_names[6])
_relief(103, 5, v_names[7])
----------------------
-- WASTE PROCESSING --
----------------------
local waste = Div{parent=root,x=3,y=6}
@ -141,13 +142,19 @@ local function make(parent, x, y, unit)
local poam_rate = DataIndicator{parent=waste,x=70,y=10,lu_colors=lu_col,label="",unit="mB/t",format="%7.3f",value=123.456,width=12,fg_bg=text_fg_bg}
local spent_rate = DataIndicator{parent=waste,x=99,y=4,lu_colors=lu_col,label="",unit="mB/t",format="%7.3f",value=123.456,width=12,fg_bg=text_fg_bg}
_valve(18, 2, 1); _valve(18, 6, 2); _valve(62, 5, 3); _valve(62, 9, 4)
_machine(45, 1, "CENTRIFUGE \x1a"); _machine(83, 1, "PRC [Pu] \x1a"); _machine(83, 4, "PRC [Po] \x1a"); _machine(94, 6, "SPENT WASTE \x1b")
_valve(18, 2, 1)
_valve(18, 6, 2)
_valve(62, 5, 3)
_valve(62, 9, 4)
_machine(45, 1, "CENTRIFUGE \x1a");
_machine(83, 1, "PRC [Pu] \x1a");
_machine(83, 4, "PRC [Po] \x1a");
_machine(94, 6, "SPENT WASTE \x1b")
TextBox{parent=waste,x=25,y=3,text="SNAs [Po]",alignment=TEXT_ALIGN.CENTER,width=19,height=1,fg_bg=cpair(colors.white,colors.gray)}
local sna_po = Rectangle{parent=waste,x=25,y=4,border=border(1, colors.gray, true),width=19,height=7,thin=true,fg_bg=cpair(colors.black,colors.white)}
local sna_act = IndicatorLight{parent=sna_po,label="ACTIVE",colors=cpair(colors.green,colors.red)}
local sna_act = IndicatorLight{parent=sna_po,label="ACTIVE",colors=cpair(colors.green,colors.gray)}
local sna_cnt = DataIndicator{parent=sna_po,x=12,y=1,lu_colors=lu_col,label="CNT",unit="",format="%2d",value=99,width=7,fg_bg=text_fg_bg}
local sna_pk = DataIndicator{parent=sna_po,y=3,lu_colors=lu_col,label="PEAK",unit="mB/t",format="%7.2f",value=1000,width=17,fg_bg=text_fg_bg}
local sna_max = DataIndicator{parent=sna_po,lu_colors=lu_col,label="MAX ",unit="mB/t",format="%7.2f",value=1000,width=17,fg_bg=text_fg_bg}

View File

@ -83,9 +83,7 @@ local function new_view(root, x, y, data, ps, id)
local function calc_saturation(val)
if (type(data.build) == "table") and (type(data.build.transfer_cap) == "number") and (data.build.transfer_cap > 0) then
return val / data.build.transfer_cap
else
return 0
end
else return 0 end
end
charge.register(ps, "energy_fill", charge.update)

View File

@ -16,9 +16,25 @@ local TextBox = require("graphics.elements.textbox")
local DataIndicator = require("graphics.elements.indicators.data")
local Div = require("graphics.elements.div")
local PipeNetwork = require("graphics.elements.pipenet")
local TextBox = require("graphics.elements.textbox")
local Rectangle = require("graphics.elements.rectangle")
local DataIndicator = require("graphics.elements.indicators.data")
local HorizontalBar = require("graphics.elements.indicators.hbar")
local StateIndicator = require("graphics.elements.indicators.state")
local IndicatorLight = require("graphics.elements.indicators.light")
local TriIndicatorLight = require("graphics.elements.indicators.trilight")
local VerticalBar = require("graphics.elements.indicators.vbar")
local TEXT_ALIGN = core.TEXT_ALIGN
local cpair = core.cpair
local border = core.border
local pipe = core.pipe
-- create new flow view
---@param main graphics_element main displaybox
@ -33,9 +49,27 @@ local function init(main)
datetime.register(facility.ps, "date_time", datetime.set_value)
for i = 1, 4 do
flow_overview(main, 25, 5 + ((i - 1) * 20), units[i])
local po_pipes = {}
for i = 1, facility.num_units do
local y_offset = ((i - 1) * 20)
flow_overview(main, 25, 5 + y_offset, units[i])
table.insert(po_pipes, pipe(0, 6 + y_offset, 8, 0, colors.cyan, true, true))
end
local text_fg_bg = cpair(colors.black, colors.white)
local lu_col = cpair(colors.gray, colors.gray)
PipeNetwork{parent=main,x=139,y=12,pipes=po_pipes,bg=colors.lightGray}
local sps = Div{parent=main,x=142,y=5,height=8}
TextBox{parent=sps,x=1,y=1,text="SPS",alignment=TEXT_ALIGN.CENTER,width=21,height=1,fg_bg=cpair(colors.white,colors.gray)}
local sps_box = Rectangle{parent=sps,x=1,y=2,border=border(1, colors.gray, true),width=21,height=7,thin=true,fg_bg=cpair(colors.black,colors.white)}
local sps_conn = IndicatorLight{parent=sps_box,label="CONNECTED",colors=cpair(colors.green,colors.gray)}
local sps_act = IndicatorLight{parent=sps_box,label="ACTIVE",colors=cpair(colors.green,colors.gray)}
local sps_in = DataIndicator{parent=sps_box,y=4,lu_colors=lu_col,label="IN ",unit="mB/t",format="%9.2f",value=123.456,width=19,fg_bg=text_fg_bg}
local sps_rate = DataIndicator{parent=sps_box,lu_colors=lu_col,label="RATE",unit="\xb5B/t",format="%9.2f",value=123456.78,width=19,fg_bg=text_fg_bg}
end
return init