ensure derived DERIVED telemetry loads in the proper order. also have telemetry collections prioritize request options over clock

This commit is contained in:
Scott Bell 2024-09-25 13:19:00 +02:00
parent dfcfa47237
commit 4a301a15d2
3 changed files with 28 additions and 13 deletions

View File

@ -216,12 +216,20 @@ 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;
}
// loop through, sort and dedupe
for (let datum of data) {
parsedValue = this.parseTime(datum);
beforeStartOfBounds = parsedValue < this.lastBounds.start;
afterEndOfBounds = parsedValue > this.lastBounds.end;
beforeStartOfBounds = parsedValue < boundsToUse.start;
afterEndOfBounds = parsedValue > boundsToUse.end;
if (
!afterEndOfBounds &&

View File

@ -1,4 +1,5 @@
import { EventEmitter } from 'eventemitter3';
import _ from 'lodash';
export default class CompsManager extends EventEmitter {
#openmct;
@ -112,20 +113,23 @@ 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) {
this.#destroy();
}
this.#telemetryOptions = telemetryOptions;
if (!this.#compositionLoaded) {
this.#telemetryOptions = telemetryOptions;
await this.#loadComposition();
this.#compositionLoaded = true;
}
if (!this.#loaded) {
await Promise.all(this.#telemetryLoadedPromises);
await this.startListeningToUnderlyingTelemetry();
this.#telemetryLoadedPromises = [];
this.#loaded = true;
}
}
async startListeningToUnderlyingTelemetry() {
this.#loaded = false;
Object.keys(this.#telemetryCollections).forEach((keyString) => {
if (!this.#telemetryCollections[keyString].loaded) {
this.#telemetryCollections[keyString].on('add', this.#getTelemetryProcessor(keyString));
@ -136,7 +140,15 @@ export default class CompsManager extends EventEmitter {
});
await Promise.all(this.#telemetryLoadedPromises);
this.#telemetryLoadedPromises = [];
this.#loaded = true;
}
#destroy() {
this.stopListeningToUnderlyingTelemetry();
this.#composition = null;
this.#telemetryCollections = {};
this.#compositionLoaded = false;
this.#loaded = false;
this.#telemetryObjects = {};
}
stopListeningToUnderlyingTelemetry() {
@ -208,7 +220,7 @@ export default class CompsManager extends EventEmitter {
this.deleteParameter(keyString);
};
requestUnderlyingTelemetry(options) {
requestUnderlyingTelemetry() {
const underlyingTelemetry = {};
Object.keys(this.#telemetryCollections).forEach((collectionKey) => {
const collection = this.#telemetryCollections[collectionKey];
@ -259,11 +271,6 @@ export default class CompsManager extends EventEmitter {
this.#telemetryOptions
);
this.#telemetryCollections[keyString].on('add', this.#getTelemetryProcessor(keyString));
this.#telemetryCollections[keyString].on('clear', this.clearData);
const telemetryLoadedPromise = this.#telemetryCollections[keyString].load();
this.#telemetryLoadedPromises.push(telemetryLoadedPromise);
// check to see if we have a corresponding parameter
// if not, add one
const parameterExists = this.#domainObject.configuration.comps.parameters.some(

View File

@ -117,7 +117,7 @@ export default class CompsTelemetryProvider {
callbackID
);
specificCompsManager.on('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
specificCompsManager.startListeningToUnderlyingTelemetry();
specificCompsManager.load();
return () => {
specificCompsManager.off('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
delete this.#subscriptionCallbacks[callbackID];