Merge branch 'telemetry-comps' into combined-rodap-stuff

This commit is contained in:
Scott Bell 2024-10-03 14:47:27 +02:00
commit 6c48ad50ca
2 changed files with 27 additions and 16 deletions

View File

@ -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;

View File

@ -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));