fix(level): pass timestamp on level samples for level-rate fallback
MeasurementRouter.onLevelMeasurement was writing level samples via .value(value).unit(context.unit), which dropped the timestamp. The level-rate fallback in FlowAggregator derives netFlow from dlevel/dt, so without a timestamp on each sample it had nothing to differentiate. Switch to the positional .value(value, timestamp, unit) form so the fallback works. Add a basic test that drives two level samples 2 s apart and asserts the aggregator produces direction=filling with a finite dlevel/dt-derived netFlow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ class MeasurementRouter {
|
||||
|
||||
onLevelMeasurement(position, value, context = {}) {
|
||||
this.measurements.type('level').variant('measured').position(position)
|
||||
.value(value).unit(context.unit);
|
||||
.value(value, context.timestamp, context.unit);
|
||||
|
||||
const series = this.measurements.type('level').variant('measured').position(position);
|
||||
const levelMeters = series.getCurrentValue('m');
|
||||
|
||||
Reference in New Issue
Block a user