Skip to content

Commit 832bd47

Browse files
committed
Add consumer formula generator excluding phantom loads
Meters with successors can still have loads not represented in the component graph. These are called phantom loads. Tracking phantom loads requires larger formulas and expects all meters to be available. This commit implements the consumer formula generator as it is implemented in the SDK - exclude producer and battery powers from the grid power, or when there is no grid meter, add all the non battery and producer meters. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent f296103 commit 832bd47

File tree

3 files changed

+230
-15
lines changed

3 files changed

+230
-15
lines changed

src/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ pub struct ComponentGraphConfig {
2424
/// is `true`, the formulas will not include fallback components.
2525
pub disable_fallback_components: bool,
2626

27+
/// Meters with successors can still have loads not represented in the
28+
/// component graph. These are called phantom loads.
29+
///
30+
/// When this is `true`, phantom loads are included in formulas by excluding
31+
/// the measurements of successor meters from the measurements of their
32+
/// predecessor meters.
33+
///
34+
/// When `false`, consumer formula is generated by excluding production
35+
/// and battery components from the grid measurements.
36+
pub include_phantom_loads_in_consumer_formula: bool,
37+
2738
/// Whether to prefer PV inverters when generating PV formulas. When this
2839
/// is `true`, PV inverters will be the primary source and PV meters will be
2940
/// the fallback. When `false`, PV meters will be the primary source.

src/graph/formulas/formula.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
// evaluator.
4444
#[derive(Debug, Clone, PartialEq)]
4545
pub struct AggregationFormula {
46-
expr: Expr,
46+
pub(crate) expr: Expr,
4747
}
4848

4949
impl From<Expr> for AggregationFormula {

0 commit comments

Comments
 (0)