fix: break chart line on timestamp gaps caused by packet loss#388
Merged
fix: break chart line on timestamp gaps caused by packet loss#388
Conversation
During WiFi streaming, packet loss produces missing timestamps that the chart previously bridged with a straight line, giving a misleading linear slope. This change detects those gaps in PlotLogger and inserts a DataPoint.Undefined marker so OxyPlot renders a visible break instead of connecting the points. Detection uses an exponential moving average (EMA, alpha=0.1) of per-channel timestamp deltas. Any delta that exceeds 2× the running average is treated as a gap. The EMA adapts automatically to the current sample rate, so no fixed threshold configuration is needed. Closes #291 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extracts the EMA-based gap detection logic from PlotLogger into a standalone TimestampGapDetector class (internal, no WPF dependencies), then adds 11 unit tests covering: - First and second sample never flagged as gaps (EMA bootstrap) - Consistent cadence produces no false positives - Delta exactly at threshold (2×) is not flagged - Delta clearly above threshold is detected - Delta just above threshold is detected - Gap on one channel does not affect another (state isolation) - EMA adapts to a gradually slowing sample rate without false positives - After a detected gap the stream resumes cleanly - Clear() resets all per-channel state PlotLogger now delegates to TimestampGapDetector, keeping the gap logic testable in isolation from WPF rendering infrastructure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📊 Code Coverage ReportSummarySummary
CoverageDAQiFi - 19.9%
Daqifi.Desktop.Common - 39.3%
Daqifi.Desktop.IO - 100%
Coverage report generated by ReportGenerator • View full report in build artifacts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DataPoint.Undefinedmarkers in OxyPlot so the chart renders a visible line break instead of a misleading linear connection across the missing dataClearPlot()to keep channels clean between sessionsHow it works
PlotLoggernow maintains two dictionaries keyed by(deviceSerial, channelName):_lastTimestampMs— thedeltaTimeof the previously logged point_avgDeltaMs— the EMA of observed inter-sample deltasOn each
Log(DataSample)call,InsertGapIfNeededcomputes the current delta, compares it toGapThresholdMultiplier * avgDelta(2×), and if exceeded insertsDataPoint.Undefinedbefore the new real point. OxyPlot treats undefined points as line breaks, leaving a visible gap in the chart.Test plan
ClearPlotfully resets the logger and the next session starts freshCloses #291
🤖 Generated with Claude Code