diff --git a/coordinator/ui/components/unit_flow.lua b/coordinator/ui/components/unit_flow.lua index aa13e49..a3b17f5 100644 --- a/coordinator/ui/components/unit_flow.lua +++ b/coordinator/ui/components/unit_flow.lua @@ -70,7 +70,7 @@ local function make(parent, x, y, wide, unit) -- COOLING LOOP -- ------------------ - local reactor = Rectangle{parent=root,x=1,y=1,border=border(1, colors.gray, true),width=19,height=5,fg_bg=wh_gray} + local reactor = Rectangle{parent=root,x=1,y=1,border=border(1,colors.gray,true),width=19,height=5,fg_bg=wh_gray} TextBox{parent=reactor,y=1,text="FISSION REACTOR",alignment=TEXT_ALIGN.CENTER,height=1} TextBox{parent=reactor,y=3,text="UNIT #"..unit.unit_id,alignment=TEXT_ALIGN.CENTER,height=1} TextBox{parent=root,x=19,y=2,text="\x1b \x80 \x1a",width=1,height=3,fg_bg=lg_gray} @@ -206,12 +206,12 @@ local function make(parent, x, y, wide, unit) _machine(_wide(116, 94), 6, "SPENT WASTE \x1b") TextBox{parent=waste,x=_wide(30,25),y=3,text="SNAs [Po]",alignment=TEXT_ALIGN.CENTER,width=19,height=1,fg_bg=wh_gray} - local sna_po = Rectangle{parent=waste,x=_wide(30,25),y=4,border=border(1, colors.gray, true),width=19,height=7,thin=true,fg_bg=bw_fg_bg} + local sna_po = Rectangle{parent=waste,x=_wide(30,25),y=4,border=border(1,colors.gray,true),width=19,height=7,thin=true,fg_bg=bw_fg_bg} local sna_act = IndicatorLight{parent=sna_po,label="ACTIVE",colors=ind_grn} local sna_cnt = DataIndicator{parent=sna_po,x=12,y=1,lu_colors=lu_c,label="CNT",unit="",format="%2d",value=0,width=7} local sna_pk = DataIndicator{parent=sna_po,y=3,lu_colors=lu_c,label="PEAK",unit="mB/t",format="%7.2f",value=0,width=17} - local sna_max = DataIndicator{parent=sna_po,lu_colors=lu_c,label="MAX ",unit="mB/t",format="%7.2f",value=0,width=17} - local sna_in = DataIndicator{parent=sna_po,lu_colors=lu_c,label="IN ",unit="mB/t",format="%7.2f",value=0,width=17} + local sna_max = DataIndicator{parent=sna_po,lu_colors=lu_c,label="MAX",unit="mB/t",format="%8.2f",value=0,width=17} + local sna_in = DataIndicator{parent=sna_po,lu_colors=lu_c,label="IN",unit="mB/t",format="%9.2f",value=0,width=17} sna_act.register(unit.unit_ps, "po_rate", function (r) sna_act.update(r > 0) end) sna_cnt.register(unit.unit_ps, "sna_count", sna_cnt.update) diff --git a/coordinator/ui/layout/flow_view.lua b/coordinator/ui/layout/flow_view.lua index 5fa1cbd..5577604 100644 --- a/coordinator/ui/layout/flow_view.lua +++ b/coordinator/ui/layout/flow_view.lua @@ -2,6 +2,7 @@ -- Flow Monitor GUI -- +local types = require("scada-common.types") local util = require("scada-common.util") local iocontrol = require("coordinator.iocontrol") @@ -22,6 +23,8 @@ local HorizontalBar = require("graphics.elements.indicators.hbar") local IndicatorLight = require("graphics.elements.indicators.light") local StateIndicator = require("graphics.elements.indicators.state") +local CONTAINER_MODE = types.CONTAINER_MODE + local TEXT_ALIGN = core.TEXT_ALIGN local cpair = core.cpair @@ -71,7 +74,7 @@ local function init(main) for i = 1, facility.num_units do if units[i].has_tank then local y = y_ofs(i) - table.insert(water_pipes, pipe(2, y, 2, y + 5, colors.blue, true)) + table.insert(water_pipes, pipe(2, y, 2, y + 3, colors.blue, true)) table.insert(water_pipes, pipe(2, y, 21, y, colors.blue, true)) local u = units[i] ---@type ioctl_unit @@ -88,7 +91,7 @@ local function init(main) if tank_defs[i] == 2 then table.insert(water_pipes, pipe(1, y, 21, y, colors.blue, true)) else - table.insert(water_pipes, pipe(2, y, 2, y + 5, colors.blue, true)) + table.insert(water_pipes, pipe(2, y, 2, y + 3, colors.blue, true)) table.insert(water_pipes, pipe(2, y, 21, y, colors.blue, true)) end @@ -105,12 +108,12 @@ local function init(main) for i = 1, #tank_defs do local y = y_ofs(i) if i == first_fdef then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) elseif i > first_fdef then if i == last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y, colors.blue, true)) elseif i < last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y + 5, colors.blue, true)) end end end @@ -122,15 +125,15 @@ local function init(main) local y = y_ofs(i) if i == 4 then if tank_defs[i] == 2 then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) end elseif i == first_fdef then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) elseif i > first_fdef then if i == last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y, colors.blue, true)) elseif i < last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y + 5, colors.blue, true)) end end end @@ -155,15 +158,15 @@ local function init(main) local y = y_ofs(i) if i == 1 then if tank_defs[i] == 2 then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) end elseif i == first_fdef then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) elseif i > first_fdef then if i == last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y, colors.blue, true)) elseif i < last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y + 5, colors.blue, true)) end end end @@ -175,15 +178,15 @@ local function init(main) local y = y_ofs(i) if i == 3 or i == 4 then if tank_defs[i] == 2 then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) end elseif i == first_fdef then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) elseif i > first_fdef then if i == last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y, colors.blue, true)) elseif i < last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y + 5, colors.blue, true)) end end end @@ -195,15 +198,15 @@ local function init(main) local y = y_ofs(i) if i == 1 or i == 4 then if tank_defs[i] == 2 then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) end elseif i == first_fdef then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) elseif i > first_fdef then if i == last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y, colors.blue, true)) elseif i < last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y + 5, colors.blue, true)) end end end @@ -215,15 +218,15 @@ local function init(main) local y = y_ofs(i) if i == 1 or i == 2 then if tank_defs[i] == 2 then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) end elseif i == first_fdef then - table.insert(water_pipes, pipe(0, y, 1, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y, 1, y + 5, colors.blue, true)) elseif i > first_fdef then if i == last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y, colors.blue, true)) elseif i < last_fdef then - table.insert(water_pipes, pipe(0, y - 13, 0, y + 6, colors.blue, true)) + table.insert(water_pipes, pipe(0, y - 14, 0, y + 5, colors.blue, true)) end end end @@ -275,12 +278,12 @@ local function init(main) local y_offset = y_ofs(i) - local tank = Div{parent=main,x=3,y=8+y_offset,width=20,height=12} + local tank = Div{parent=main,x=3,y=7+y_offset,width=20,height=14} TextBox{parent=tank,text=" ",height=1,x=1,y=1,fg_bg=cpair(colors.lightGray,colors.gray)} TextBox{parent=tank,text="DYNAMIC TANK "..id,alignment=TEXT_ALIGN.CENTER,height=1,fg_bg=cpair(colors.white,colors.gray)} - local tank_box = Rectangle{parent=tank,border=border(1, colors.gray, true),width=20,height=10} + local tank_box = Rectangle{parent=tank,border=border(1,colors.gray,true),width=20,height=12} local status = StateIndicator{parent=tank_box,x=3,y=1,states=style.dtank.states,value=1,min_width=14} @@ -291,16 +294,32 @@ local function init(main) TextBox{parent=tank_box,x=2,y=6,text="Water Level",height=1,width=11,fg_bg=style.label} local level = HorizontalBar{parent=tank_box,x=2,y=7,bar_fg_bg=cpair(colors.blue,colors.gray),height=1,width=16} + TextBox{parent=tank_box,x=2,y=9,text="In/Out Mode",height=1,width=11,fg_bg=style.label} + local can_fill = IndicatorLight{parent=tank_box,x=2,y=10,label="FILL",colors=style.ind_wht} + local can_empty = IndicatorLight{parent=tank_box,x=10,y=10,label="EMPTY",colors=style.ind_wht} + + local function _can_fill(mode) + can_fill.update((mode == CONTAINER_MODE.BOTH) or (mode == CONTAINER_MODE.FILL)) + end + + local function _can_empty(mode) + can_empty.update((mode == CONTAINER_MODE.BOTH) or (mode == CONTAINER_MODE.EMPTY)) + end + if tank_list[i] == 1 then status.register(units[i].tank_ps_tbl[1], "computed_status", status.update) tank_pcnt.register(units[i].tank_ps_tbl[1], "fill", function (f) tank_pcnt.update(f * 100) end) tank_amnt.register(units[i].tank_ps_tbl[1], "stored", function (sto) tank_amnt.update(sto.amount) end) level.register(units[i].tank_ps_tbl[1], "fill", level.update) + can_fill.register(units[i].tank_ps_tbl[1], "container_mode", _can_fill) + can_empty.register(units[i].tank_ps_tbl[1], "container_mode", _can_empty) else status.register(facility.tank_ps_tbl[f_id], "computed_status", status.update) tank_pcnt.register(facility.tank_ps_tbl[f_id], "fill", function (f) tank_pcnt.update(f * 100) end) tank_amnt.register(facility.tank_ps_tbl[f_id], "stored", function (sto) tank_amnt.update(sto.amount) end) level.register(facility.tank_ps_tbl[f_id], "fill", level.update) + can_fill.register(facility.tank_ps_tbl[f_id], "container_mode", _can_fill) + can_empty.register(facility.tank_ps_tbl[f_id], "container_mode", _can_empty) end end end @@ -312,7 +331,7 @@ local function init(main) TextBox{parent=sps,text=" ",width=24,height=1,x=1,y=1,fg_bg=cpair(colors.lightGray,colors.gray)} TextBox{parent=sps,text="SPS",alignment=TEXT_ALIGN.CENTER,width=24,height=1,fg_bg=wh_gray} - local sps_box = Rectangle{parent=sps,border=border(1, colors.gray, true),width=24,height=10} + local sps_box = Rectangle{parent=sps,border=border(1,colors.gray,true),width=24,height=10} local status = StateIndicator{parent=sps_box,x=5,y=1,states=style.sps.states,value=1,min_width=14} @@ -331,7 +350,7 @@ local function init(main) -- statistics -- TextBox{parent=main,x=145,y=16,text="PROC. WASTE",alignment=TEXT_ALIGN.CENTER,width=19,height=1,fg_bg=wh_gray} - local pr_waste = Rectangle{parent=main,x=145,y=17,border=border(1, colors.gray, true),width=19,height=5,thin=true,fg_bg=bw_fg_bg} + local pr_waste = Rectangle{parent=main,x=145,y=17,border=border(1,colors.gray,true),width=19,height=5,thin=true,fg_bg=bw_fg_bg} local pu = DataIndicator{parent=pr_waste,lu_colors=lu_col,label="Pu",unit="mB/t",format="%9.3f",value=0,width=17} local po = DataIndicator{parent=pr_waste,lu_colors=lu_col,label="Po",unit="mB/t",format="%9.3f",value=0,width=17} local popl = DataIndicator{parent=pr_waste,lu_colors=lu_col,label="PoPl",unit="mB/t",format="%7.3f",value=0,width=17} @@ -341,7 +360,7 @@ local function init(main) popl.register(facility.ps, "po_pl_rate", popl.update) TextBox{parent=main,x=145,y=23,text="SPENT WASTE",alignment=TEXT_ALIGN.CENTER,width=19,height=1,fg_bg=wh_gray} - local sp_waste = Rectangle{parent=main,x=145,y=24,border=border(1, colors.gray, true),width=19,height=3,thin=true,fg_bg=bw_fg_bg} + local sp_waste = Rectangle{parent=main,x=145,y=24,border=border(1,colors.gray,true),width=19,height=3,thin=true,fg_bg=bw_fg_bg} local sum_sp_waste = DataIndicator{parent=sp_waste,lu_colors=lu_col,label="SUM",unit="mB/t",format="%8.3f",value=0,width=17} sum_sp_waste.register(facility.ps, "spent_waste_rate", sum_sp_waste.update)