#556 ui for dynamic tank view in unit apps
This commit is contained in:
parent
72fcc01acd
commit
0544587d84
@ -372,7 +372,7 @@ local function new_view(root)
|
||||
|
||||
if #unit.tank_data_tbl > 0 then
|
||||
local tank_pane = Div{parent=page_div}
|
||||
nav_links[i].d_tank = dyn_tank(app, u_page, panes, tank_pane, 1, unit.tank_ps_tbl[1], update)
|
||||
nav_links[i].d_tank = dyn_tank(app, u_page, panes, tank_pane, unit.tank_ps_tbl[1], update)
|
||||
end
|
||||
|
||||
--#endregion
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local iocontrol = require("pocket.iocontrol")
|
||||
local types = require("scada-common.types")
|
||||
|
||||
local style = require("pocket.ui.style")
|
||||
|
||||
@ -9,22 +7,23 @@ local core = require("graphics.core")
|
||||
local Div = require("graphics.elements.Div")
|
||||
local TextBox = require("graphics.elements.TextBox")
|
||||
|
||||
local PushButton = require("graphics.elements.controls.PushButton")
|
||||
|
||||
local DataIndicator = require("graphics.elements.indicators.DataIndicator")
|
||||
local HorizontalBar = require("graphics.elements.indicators.HorizontalBar")
|
||||
local IconIndicator = require("graphics.elements.indicators.IconIndicator")
|
||||
local StateIndicator = require("graphics.elements.indicators.StateIndicator")
|
||||
local VerticalBar = require("graphics.elements.indicators.VerticalBar")
|
||||
|
||||
local ALIGN = core.ALIGN
|
||||
local CONTAINER_MODE = types.CONTAINER_MODE
|
||||
|
||||
local cpair = core.cpair
|
||||
|
||||
local label = style.label
|
||||
local lu_col = style.label_unit_pair
|
||||
local text_fg = style.text_fg
|
||||
local tri_ind_s = style.icon_states.tri_ind_s
|
||||
local red_ind_s = style.icon_states.red_ind_s
|
||||
local yel_ind_s = style.icon_states.yel_ind_s
|
||||
|
||||
local mode_ind_s = {
|
||||
{ color = cpair(colors.black, colors.lightGray), symbol = "-" },
|
||||
{ color = cpair(colors.black, colors.white), symbol = "+" }
|
||||
}
|
||||
|
||||
-- create a dynamic tank view for the unit or facility app
|
||||
---@param app pocket_app
|
||||
@ -33,9 +32,7 @@ local yel_ind_s = style.icon_states.yel_ind_s
|
||||
---@param tank_pane Div
|
||||
---@param ps psil
|
||||
---@param update function
|
||||
return function (app, page, panes, tank_pane, u_id, ps, update)
|
||||
local db = iocontrol.get_db()
|
||||
|
||||
return function (app, page, panes, tank_pane, ps, update)
|
||||
local tank_div = Div{parent=tank_pane,x=2,width=tank_pane.get_width()-2}
|
||||
table.insert(panes, tank_div)
|
||||
|
||||
@ -45,4 +42,33 @@ return function (app, page, panes, tank_pane, u_id, ps, update)
|
||||
TextBox{parent=tank_div,y=1,text="Dyn Tank",width=9}
|
||||
local status = StateIndicator{parent=tank_div,x=10,y=1,states=style.dtank.states,value=1,min_width=12}
|
||||
status.register(ps, "DynamicTankStateStatus", status.update)
|
||||
|
||||
TextBox{parent=tank_div,y=3,text="Fill",width=10,fg_bg=label}
|
||||
local tank_pcnt = DataIndicator{parent=tank_div,x=14,y=3,label="",format="%5.2f",value=100,unit="%",lu_colors=lu_col,width=8,fg_bg=text_fg}
|
||||
local tank_amnt = DataIndicator{parent=tank_div,label="",format="%18d",value=0,commas=true,unit="mB",lu_colors=lu_col,width=21,fg_bg=text_fg}
|
||||
|
||||
TextBox{parent=tank_div,y=6,text="Fluid Level",width=11,fg_bg=label}
|
||||
local level = HorizontalBar{parent=tank_div,y=7,bar_fg_bg=cpair(colors.blue,colors.gray),height=1,width=21}
|
||||
|
||||
TextBox{parent=tank_div,y=9,text="Tank Fill Mode",width=14,fg_bg=label}
|
||||
local can_fill = IconIndicator{parent=tank_div,y=10,label="Filling Enabled",states=mode_ind_s}
|
||||
local can_empty = IconIndicator{parent=tank_div,y=11,label="Emptying Enabled",states=mode_ind_s}
|
||||
|
||||
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
|
||||
|
||||
tank_pcnt.register(ps, "fill", function (f) tank_pcnt.update(f * 100) end)
|
||||
tank_amnt.register(ps, "stored", function (sto) tank_amnt.update(sto.amount) end)
|
||||
|
||||
level.register(ps, "fill", level.update)
|
||||
|
||||
can_fill.register(ps, "container_mode", _can_fill)
|
||||
can_empty.register(ps, "container_mode", _can_empty)
|
||||
|
||||
return tank_page.nav_to
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user