Skip to content

Adopt component-graph's unified Formula type#52

Draft
shsms wants to merge 3 commits into
frequenz-floss:v0.x.xfrom
shsms:meter-subtraction
Draft

Adopt component-graph's unified Formula type#52
shsms wants to merge 3 commits into
frequenz-floss:v0.x.xfrom
shsms:meter-subtraction

Conversation

@shsms

@shsms shsms commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Port the logical-meter formula layer to component-graph's unified Formula type and build against the meter-subtraction branch.

Changes

  • Repoint the frequenz-microgrid-component-graph dependency at the meter-subtraction branch (temporary — repoint to a release before merge).
  • Replace the removed AggregationFormula/CoalesceFormula graph types and the Formula trait with the single Formula struct: FormulaParams and the formula wrappers hold it directly; the GraphFormulaConnector indirection is dropped.
  • Unify the now-identical wrapper structs into one GraphFormula<M, K> keyed by an Aggregation/Coalesce marker; the two GraphFormulaProvider impls and the public names (via aliases) are preserved.
  • Update pv-pool and formula-display test expectations for the new component-first default and the meter-minus-sibling fallback, and add a numeric round-trip test of the subtraction formula through the engine.

Breaking

  • None to microgrid-rs's own public API. The formulas it emits change (component-first default; a component sharing a meter falls back to meter − siblings), inherited from the component-graph upgrade.

shsms added 3 commits June 24, 2026 19:34
Point the frequenz-microgrid-component-graph dependency at the
meter-subtraction branch of the fork and port the logical-meter formula
layer to the unified component-graph Formula type: the AggregationFormula
and CoalesceFormula graph types and the Formula trait are gone, replaced
by a single Formula struct, so FormulaParams and the formula wrappers
hold it directly and the GraphFormulaConnector indirection is dropped.

Update the pv-pool and logical-meter formula-display tests for the new
component-graph behavior: per-category formulas are component-first by
default (the exact sum leads), and a component sharing a meter with a
sibling now falls back to the meter minus that sibling.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
After the port to the unified component-graph Formula, AggregationFormula
and CoalesceFormula had byte-identical bodies (field, Display,
FormulaSubscriber, From<FormulaParams>); only their GraphFormulaProvider
impls differed. Collapse them into one GraphFormula<M, K> keyed by an
Aggregation/Coalesce marker, keep the two provider impls, and alias the
old names. The dead reverse From<wrapper> for FormulaParams impls are
dropped.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The new component-graph meter-minus-sibling formulas (e.g.
COALESCE(frequenz-floss#8, frequenz-floss#5 - frequenz-floss#6, 0.0)) were only checked by display-string
assertions; add a numeric round-trip through FormulaEngine.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant