Fix check for new data in plotter
The previous check was overly sensitive--it failed to account for
situations where there were more data-points than messages (e.g.,
batched IMU measurements or repeated fields).
Change-Id: Id495a702a40b95a322f2244588d6c02423a0fb1c
diff --git a/aos/network/www/aos_plotter.ts b/aos/network/www/aos_plotter.ts
index 35c27a7..59db9d9 100644
--- a/aos/network/www/aos_plotter.ts
+++ b/aos/network/www/aos_plotter.ts
@@ -141,9 +141,15 @@
}
class MessageLine {
+ private _lastNumMessages: number = 0;
constructor(
public readonly messages: MessageHandler, public readonly line: Line,
public readonly field: string[]) {}
+ hasUpdate(): boolean {
+ const updated = this._lastNumMessages != this.messages.numMessages();
+ this._lastNumMessages = this.messages.numMessages();
+ return updated;
+ }
}
class AosPlot {
@@ -172,7 +178,7 @@
// is a relatively expensive call, we don't want to do it any more than
// necessary.
for (const line of this.lines) {
- if (line.messages.numMessages() * 2 != line.line.getPoints().length) {
+ if (line.hasUpdate()) {
line.line.setPoints(line.messages.getField(line.field));
}
}