ENH parameterize power module
This commit is contained in:
parent
5604df2eb6
commit
50809883a3
|
@ -1,5 +1,5 @@
|
||||||
local format = require 'format'
|
local format = require 'format'
|
||||||
-- local i_o = require 'i_o'
|
local pure = require 'pure'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
local sys = require 'sys'
|
local sys = require 'sys'
|
||||||
|
@ -31,8 +31,16 @@ return function(update_freq, battery)
|
||||||
return format.precision_round_to_string(watts, 3)..' W'
|
return format.precision_round_to_string(watts, 3)..' W'
|
||||||
end
|
end
|
||||||
|
|
||||||
local make_rate_plot = function(y, label, init)
|
local mk_static = function(obj)
|
||||||
return common.make_rate_timeseries(
|
return pure.partial(common.tagged_scaled_timeseries_draw_static, obj)
|
||||||
|
end
|
||||||
|
|
||||||
|
local mk_dynamic = function(obj)
|
||||||
|
return pure.partial(common.tagged_scaled_timeseries_draw_dynamic, obj)
|
||||||
|
end
|
||||||
|
|
||||||
|
local mk_rate_plot = function(label, read, y)
|
||||||
|
local obj = common.make_rate_timeseries(
|
||||||
geometry.RIGHT_X,
|
geometry.RIGHT_X,
|
||||||
y,
|
y,
|
||||||
geometry.SECTION_WIDTH,
|
geometry.SECTION_WIDTH,
|
||||||
|
@ -43,30 +51,35 @@ return function(update_freq, battery)
|
||||||
label,
|
label,
|
||||||
0,
|
0,
|
||||||
update_freq,
|
update_freq,
|
||||||
init
|
read()
|
||||||
|
)
|
||||||
|
return common.mk_acc(
|
||||||
|
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||||
|
function(_) common.update_rate_timeseries(obj, read()) end,
|
||||||
|
mk_static(obj),
|
||||||
|
mk_dynamic(obj)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- header
|
-- header
|
||||||
|
|
||||||
local header = common.make_header(
|
local mk_header = pure.partial(
|
||||||
geometry.RIGHT_X,
|
common.mk_header,
|
||||||
MODULE_Y,
|
'POWER',
|
||||||
geometry.SECTION_WIDTH,
|
geometry.SECTION_WIDTH,
|
||||||
'POWER'
|
geometry.RIGHT_X
|
||||||
)
|
)
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- package 0 power plot
|
-- package 0 power plot
|
||||||
|
|
||||||
local pkg0 = make_rate_plot(header.bottom_y, 'PKG0', read_pkg0_joules())
|
local mk_pkg0 = pure.partial(mk_rate_plot, 'PKG0', read_pkg0_joules)
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- DRAM power plot
|
-- DRAM power plot
|
||||||
|
|
||||||
local DRAM_Y = header.bottom_y + TEXT_SPACING + PLOT_SEC_BREAK + PLOT_HEIGHT
|
local mk_dram = pure.partial(mk_rate_plot, 'DRAM', read_dram_joules)
|
||||||
local dram = make_rate_plot(DRAM_Y, 'DRAM', read_dram_joules())
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- battery power plot
|
-- battery power plot
|
||||||
|
@ -79,10 +92,10 @@ return function(update_freq, battery)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local BAT_Y = DRAM_Y + PLOT_SEC_BREAK * 2 + PLOT_HEIGHT
|
local mk_bat = function(y)
|
||||||
local bat = common.make_tagged_scaled_timeseries(
|
local obj = common.make_tagged_scaled_timeseries(
|
||||||
geometry.RIGHT_X,
|
geometry.RIGHT_X,
|
||||||
BAT_Y,
|
y,
|
||||||
geometry.SECTION_WIDTH,
|
geometry.SECTION_WIDTH,
|
||||||
PLOT_HEIGHT,
|
PLOT_HEIGHT,
|
||||||
format_ac,
|
format_ac,
|
||||||
|
@ -92,28 +105,32 @@ return function(update_freq, battery)
|
||||||
0,
|
0,
|
||||||
update_freq
|
update_freq
|
||||||
)
|
)
|
||||||
|
return common.mk_acc(
|
||||||
|
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||||
|
function(ac)
|
||||||
|
common.tagged_scaled_timeseries_set(obj, read_battery_power(ac))
|
||||||
|
end,
|
||||||
|
mk_static(obj),
|
||||||
|
mk_dynamic(obj)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local update = function(is_using_ac)
|
local rbs = common.reduce_blocks_(
|
||||||
common.update_rate_timeseries(pkg0, read_pkg0_joules())
|
MODULE_Y,
|
||||||
common.update_rate_timeseries(dram, read_dram_joules())
|
{
|
||||||
common.tagged_scaled_timeseries_set(bat, read_battery_power(is_using_ac))
|
common.mk_block(mk_header, true, 0),
|
||||||
end
|
common.mk_block(mk_pkg0, true, 0),
|
||||||
|
common.mk_block(mk_dram, true, TEXT_SPACING),
|
||||||
|
common.mk_block(mk_bat, true, TEXT_SPACING),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
local draw_static = function(cr)
|
return {
|
||||||
common.draw_header(cr, header)
|
static = rbs.static_drawer,
|
||||||
common.tagged_scaled_timeseries_draw_static(pkg0, cr)
|
dynamic = rbs.dynamic_drawer,
|
||||||
common.tagged_scaled_timeseries_draw_static(dram, cr)
|
update = rbs.updater
|
||||||
common.tagged_scaled_timeseries_draw_static(bat, cr)
|
}
|
||||||
end
|
|
||||||
|
|
||||||
local draw_dynamic = function(cr)
|
|
||||||
common.tagged_scaled_timeseries_draw_dynamic(pkg0, cr)
|
|
||||||
common.tagged_scaled_timeseries_draw_dynamic(dram, cr)
|
|
||||||
common.tagged_scaled_timeseries_draw_dynamic(bat, cr)
|
|
||||||
end
|
|
||||||
|
|
||||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue