ENH modularize module geometries

This commit is contained in:
Nathan Dwarshuis 2022-08-16 00:14:04 -04:00
parent 99ce64bbb6
commit fb79ea899d
5 changed files with 59 additions and 52 deletions

View File

@ -6,9 +6,45 @@ let Margin = Vector2 Natural
let FSPath = { name : Text, path : Text }
let TextGeo = { Type = { text_spacing : Natural }, default.text_spacing = 20 }
let SepGeo = { Type = { sep_spacing : Natural }, default.sep_spacing = 20 }
let PlotGeo_ =
{ Type = { sec_break : Natural, height : Natural }
, default = { sec_break = 20, height = 56 }
}
let PlotGeo = { Type = { plot : PlotGeo_.Type }, default.plot = PlotGeo_::{=} }
let TableGeo_ = { Type = { sec_break : Natural }, default.sec_break = 20 }
let TableGeo =
{ Type = { table : TableGeo_.Type }, default.table = TableGeo_::{=} }
let FSGeo =
{ Type = { spacing : Natural, bar_pad : Natural, sep_spacing : Natural }
, default = { spacing = 20, bar_pad = 100, sep_spacing = 20 }
{ Type = { bar_spacing : Natural, bar_pad : Natural } //\\ SepGeo.Type
, default = { bar_spacing = 20, bar_pad = 100 } /\ SepGeo::{=}
}
let GfxGeo =
{ Type = SepGeo.Type //\\ PlotGeo.Type //\\ TextGeo.Type
, default = SepGeo::{=} /\ PlotGeo::{=} /\ TextGeo::{=}
}
let MemGeo =
{ Type = TextGeo.Type //\\ PlotGeo.Type //\\ TableGeo.Type
, default = TextGeo::{=} /\ PlotGeo::{=} /\ TableGeo::{=}
}
let ProcGeo =
{ Type = GfxGeo.Type //\\ TableGeo.Type
, default = GfxGeo::{=} /\ TableGeo::{=}
}
let PwrGeo =
{ Type = TextGeo.Type //\\ PlotGeo.Type
, default = TextGeo::{=} /\ PlotGeo::{=}
}
let FileSystem =
@ -17,17 +53,6 @@ let FileSystem =
, default.geometry = FSGeo::{=}
}
let PlotGeo =
{ Type = { sec_break : Natural, height : Natural }
, default = { sec_break = 20, height = 56 }
}
let GfxGeo =
{ Type =
{ sep_spacing : Natural, text_spacing : Natural, plot : PlotGeo.Type }
, default = { sep_spacing = 20, text_spacing = 20, plot = PlotGeo::{=} }
}
let Graphics =
{ Type =
{ dev_power : Text
@ -41,11 +66,6 @@ let Graphics =
, default.geometry = GfxGeo::{=}
}
let MemGeo =
{ Type = { text_spacing : Natural, plot : PlotGeo.Type }
, default = { plot = PlotGeo::{=}, text_spacing = 20 }
}
let Memory =
{ Type =
{ show_stats : Bool
@ -58,11 +78,7 @@ let Memory =
}
let Network =
{ Type = { geometry : { plot : PlotGeo.Type } }
, default.geometry.plot = PlotGeo::{=}
}
let ProcGeo = { Type = { plot : PlotGeo.Type }, default.plot = PlotGeo::{=} }
{ Type = { geometry : PlotGeo.Type }, default.geometry = PlotGeo::{=} }
let Processor =
{ Type =
@ -78,15 +94,8 @@ let Processor =
let RaplSpec = { name : Text, address : Text }
let PwrGeo =
{ Type = { text_spacing : Natural, plot : PlotGeo.Type }
, default = { text_spacing = 20, plot = PlotGeo::{=} }
}
let Pacman =
{ Type = { geometry : { text_spacing : Natural } }
, default.geometry.text_spacing = 20
}
{ Type = { geometry : TextGeo.Type }, default.geometry = TextGeo::{=} }
let Power =
{ Type =
@ -94,11 +103,9 @@ let Power =
, default.geometry = PwrGeo::{=}
}
let RWGeo = { Type = { plot : PlotGeo.Type }, default.plot = PlotGeo::{=} }
let ReadWrite =
{ Type = { devices : List Text, geometry : RWGeo.Type }
, default.geometry = RWGeo::{=}
{ Type = { devices : List Text, geometry : PlotGeo.Type }
, default.geometry = PlotGeo::{=}
}
let System = Pacman

View File

@ -4,8 +4,7 @@ local impure = require 'impure'
return function(main_state, config, common, width, point)
local geo = config.geometry
local SPACING = geo.spacing
local BAR_PAD = geo.bar_pad
local SPACING = geo.bar_spacing
local SEPARATOR_SPACING = geo.sep_spacing
-----------------------------------------------------------------------------
@ -47,7 +46,9 @@ return function(main_state, config, common, width, point)
point.x,
y,
width,
BAR_PAD,
-- TODO this isn't actually padding, it would be padding if it was
-- relative to the right edge of the text column
geo.bar_pad,
names,
SPACING,
12,

View File

@ -11,10 +11,9 @@ return function(update_freq, config, common, width, point)
local DIAL_X_SPACING = 40
local CACHE_Y_OFFSET = 7
local CACHE_X_OFFSET = 50
local TEXT_SPACING = geo.text_spacing
local PLOT_SECTION_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
local TABLE_SECTION_BREAK = 20
local TABLE_SECTION_BREAK = geo.table.sec_break
local __math_floor = math.floor
local __string_format = string.format
@ -77,7 +76,7 @@ return function(update_freq, config, common, width, point)
CACHE_X,
y + CACHE_Y_OFFSET,
CACHE_WIDTH,
TEXT_SPACING,
geo.text_spacing,
{'Page Cache', 'Buffers', 'Shared', 'Kernel Slab'},
'%.1f%%'
)

View File

@ -4,7 +4,6 @@ local sys = require 'sys'
return function(update_freq, config, common, width, point)
local geo = config.geometry
local TEXT_SPACING = geo.text_spacing
local PLOT_SEC_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
@ -51,7 +50,7 @@ return function(update_freq, config, common, width, point)
local mk_rate_blockspec = function(spec)
local f = pure.partial(mk_rate_plot, spec.name, spec.address)
return {f, true, TEXT_SPACING}
return {f, true, geo.text_spacing}
end
-----------------------------------------------------------------------------

View File

@ -7,15 +7,16 @@ local pure = require 'pure'
local __math_floor = math.floor
return function(update_freq, main_state, config, common, width, point)
local geo = config.geometry
local DIAL_INNER_RADIUS = 30
local DIAL_OUTER_RADIUS = 42
local DIAL_THICKNESS = 5.5
local DIAL_SPACING = 20
local SEPARATOR_SPACING = 20
local TEXT_SPACING = 22
local PLOT_SECTION_BREAK = 23
local PLOT_HEIGHT = 56
local TABLE_SECTION_BREAK = 20
local DIAL_Y_SPACING = 20
local SEPARATOR_SPACING = geo.sep_spacing
local TEXT_SPACING = geo.text_spacing
local PLOT_SECTION_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
local TABLE_SECTION_BREAK = geo.table.sec_break
-----------------------------------------------------------------------------
-- processor state
@ -55,7 +56,7 @@ return function(update_freq, main_state, config, common, width, point)
(width - 2 * (DIAL_OUTER_RADIUS + config.core_padding))
* math.fmod(c - 1, core_cols) / (core_cols - 1)))
local dial_y = y + DIAL_OUTER_RADIUS +
(2 * DIAL_OUTER_RADIUS + DIAL_SPACING)
(2 * DIAL_OUTER_RADIUS + DIAL_Y_SPACING)
* math.floor((c - 1) / core_cols)
return {
loads = common.make_compound_dial(
@ -115,8 +116,8 @@ return function(update_freq, main_state, config, common, width, point)
end
return common.mk_acc(
width,
(DIAL_OUTER_RADIUS * 2 + DIAL_SPACING) * config.core_rows
- DIAL_SPACING,
(DIAL_OUTER_RADIUS * 2 + DIAL_Y_SPACING) * config.core_rows
- DIAL_Y_SPACING,
update,
static,
dynamic