From 154e8c695d021c474300f3d18396d7442ffabf07 Mon Sep 17 00:00:00 2001 From: Scott Bell Date: Thu, 3 Oct 2024 14:47:12 +0200 Subject: [PATCH] fix slow loading errors --- src/api/telemetry/TelemetryCollection.js | 31 ++++++++++++++++-------- src/plugins/comps/CompsManager.js | 12 ++++----- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/api/telemetry/TelemetryCollection.js b/src/api/telemetry/TelemetryCollection.js index 7cad1fe8bd..769b2923e4 100644 --- a/src/api/telemetry/TelemetryCollection.js +++ b/src/api/telemetry/TelemetryCollection.js @@ -73,6 +73,10 @@ export default class TelemetryCollection extends EventEmitter { this.isStrategyLatest = this.options.strategy === 'latest'; this.dataOutsideTimeBounds = false; this.modeChanged = false; + + console.debug( + `🫙 Created telemetry for ${this.domainObject.name} with bounds ${options.start} and ${options.end}` + ); } /** @@ -86,6 +90,16 @@ export default class TelemetryCollection extends EventEmitter { this._setTimeSystem(this.options.timeContext.getTimeSystem()); this.lastBounds = this.options.timeContext.getBounds(); + // prioritize passed options over time bounds + if (this.options.start) { + this.lastBounds.start = this.options.start; + } + if (this.options.end) { + this.lastBounds.end = this.options.end; + } + console.debug( + `🫙 Bounds for collection are start ${this.lastBounds.start} and end ${this.lastBounds.end}` + ); this._watchBounds(); this._watchTimeSystem(); this._watchTimeModeChange(); @@ -215,20 +229,13 @@ export default class TelemetryCollection extends EventEmitter { let hasDataBeforeStartBound = false; let size = this.options.size; let enforceSize = size !== undefined && this.options.enforceSize; - // prioritize request bounds over time context bounds - let boundsToUse = this.lastBounds; - if (this.options.start) { - boundsToUse.start = this.options.start; - } - if (this.options.end) { - boundsToUse.end = this.options.end; - } + console.debug(`🫙 Bounds are telemetry are currently`, this.lastBounds); // loop through, sort and dedupe for (let datum of data) { parsedValue = this.parseTime(datum); - beforeStartOfBounds = parsedValue < boundsToUse.start; - afterEndOfBounds = parsedValue > boundsToUse.end; + beforeStartOfBounds = parsedValue < this.lastBounds.start; + afterEndOfBounds = parsedValue > this.lastBounds.end; if ( !afterEndOfBounds && @@ -335,6 +342,10 @@ export default class TelemetryCollection extends EventEmitter { return; } + console.debug( + `🫙 Bounds CHANGED for ${this.domainObject.name} are start ${bounds.start} and end ${bounds.end}` + ); + let startChanged = this.lastBounds.start !== bounds.start; let endChanged = this.lastBounds.end !== bounds.end; diff --git a/src/plugins/comps/CompsManager.js b/src/plugins/comps/CompsManager.js index 7875397078..59ee041c77 100644 --- a/src/plugins/comps/CompsManager.js +++ b/src/plugins/comps/CompsManager.js @@ -7,14 +7,11 @@ export default class CompsManager extends EventEmitter { #composition; #telemetryObjects = {}; #telemetryCollections = {}; - #dataFrame = {}; #telemetryLoadedPromises = []; #telemetryOptions = {}; #loaded = false; #compositionLoaded = false; #telemetryProcessors = {}; - // make id random 4 digit number - #id = Math.floor(Math.random() * 9000) + 1000; constructor(openmct, domainObject) { super(); @@ -111,8 +108,11 @@ export default class CompsManager extends EventEmitter { } async load(telemetryOptions) { - // if our options change, we need to reload the composition if (!_.isEqual(telemetryOptions, this.#telemetryOptions) && this.#loaded) { + console.debug( + `😩 Reloading comps manager ${this.#domainObject.name} due to telemetry options change`, + telemetryOptions + ); this.#destroy(); } this.#telemetryOptions = telemetryOptions; @@ -121,13 +121,13 @@ export default class CompsManager extends EventEmitter { this.#compositionLoaded = true; } if (!this.#loaded) { - await this.startListeningToUnderlyingTelemetry(); + await this.#startListeningToUnderlyingTelemetry(); this.#telemetryLoadedPromises = []; this.#loaded = true; } } - async startListeningToUnderlyingTelemetry() { + async #startListeningToUnderlyingTelemetry() { Object.keys(this.#telemetryCollections).forEach((keyString) => { if (!this.#telemetryCollections[keyString].loaded) { this.#telemetryCollections[keyString].on('add', this.#getTelemetryProcessor(keyString));