mirror of
https://github.com/nasa/openmct.git
synced 2024-12-22 14:32:22 +00:00
ensure derived DERIVED telemetry loads in the proper order. also have telemetry collections prioritize request options over clock
This commit is contained in:
parent
dfcfa47237
commit
4a301a15d2
@ -216,12 +216,20 @@ export default class TelemetryCollection extends EventEmitter {
|
|||||||
let hasDataBeforeStartBound = false;
|
let hasDataBeforeStartBound = false;
|
||||||
let size = this.options.size;
|
let size = this.options.size;
|
||||||
let enforceSize = size !== undefined && this.options.enforceSize;
|
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
|
// loop through, sort and dedupe
|
||||||
for (let datum of data) {
|
for (let datum of data) {
|
||||||
parsedValue = this.parseTime(datum);
|
parsedValue = this.parseTime(datum);
|
||||||
beforeStartOfBounds = parsedValue < this.lastBounds.start;
|
beforeStartOfBounds = parsedValue < boundsToUse.start;
|
||||||
afterEndOfBounds = parsedValue > this.lastBounds.end;
|
afterEndOfBounds = parsedValue > boundsToUse.end;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!afterEndOfBounds &&
|
!afterEndOfBounds &&
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
export default class CompsManager extends EventEmitter {
|
export default class CompsManager extends EventEmitter {
|
||||||
#openmct;
|
#openmct;
|
||||||
@ -112,20 +113,23 @@ export default class CompsManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async load(telemetryOptions) {
|
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) {
|
if (!this.#compositionLoaded) {
|
||||||
this.#telemetryOptions = telemetryOptions;
|
|
||||||
await this.#loadComposition();
|
await this.#loadComposition();
|
||||||
this.#compositionLoaded = true;
|
this.#compositionLoaded = true;
|
||||||
}
|
}
|
||||||
if (!this.#loaded) {
|
if (!this.#loaded) {
|
||||||
await Promise.all(this.#telemetryLoadedPromises);
|
await this.startListeningToUnderlyingTelemetry();
|
||||||
this.#telemetryLoadedPromises = [];
|
this.#telemetryLoadedPromises = [];
|
||||||
this.#loaded = true;
|
this.#loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async startListeningToUnderlyingTelemetry() {
|
async startListeningToUnderlyingTelemetry() {
|
||||||
this.#loaded = false;
|
|
||||||
Object.keys(this.#telemetryCollections).forEach((keyString) => {
|
Object.keys(this.#telemetryCollections).forEach((keyString) => {
|
||||||
if (!this.#telemetryCollections[keyString].loaded) {
|
if (!this.#telemetryCollections[keyString].loaded) {
|
||||||
this.#telemetryCollections[keyString].on('add', this.#getTelemetryProcessor(keyString));
|
this.#telemetryCollections[keyString].on('add', this.#getTelemetryProcessor(keyString));
|
||||||
@ -136,7 +140,15 @@ export default class CompsManager extends EventEmitter {
|
|||||||
});
|
});
|
||||||
await Promise.all(this.#telemetryLoadedPromises);
|
await Promise.all(this.#telemetryLoadedPromises);
|
||||||
this.#telemetryLoadedPromises = [];
|
this.#telemetryLoadedPromises = [];
|
||||||
this.#loaded = true;
|
}
|
||||||
|
|
||||||
|
#destroy() {
|
||||||
|
this.stopListeningToUnderlyingTelemetry();
|
||||||
|
this.#composition = null;
|
||||||
|
this.#telemetryCollections = {};
|
||||||
|
this.#compositionLoaded = false;
|
||||||
|
this.#loaded = false;
|
||||||
|
this.#telemetryObjects = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
stopListeningToUnderlyingTelemetry() {
|
stopListeningToUnderlyingTelemetry() {
|
||||||
@ -208,7 +220,7 @@ export default class CompsManager extends EventEmitter {
|
|||||||
this.deleteParameter(keyString);
|
this.deleteParameter(keyString);
|
||||||
};
|
};
|
||||||
|
|
||||||
requestUnderlyingTelemetry(options) {
|
requestUnderlyingTelemetry() {
|
||||||
const underlyingTelemetry = {};
|
const underlyingTelemetry = {};
|
||||||
Object.keys(this.#telemetryCollections).forEach((collectionKey) => {
|
Object.keys(this.#telemetryCollections).forEach((collectionKey) => {
|
||||||
const collection = this.#telemetryCollections[collectionKey];
|
const collection = this.#telemetryCollections[collectionKey];
|
||||||
@ -259,11 +271,6 @@ export default class CompsManager extends EventEmitter {
|
|||||||
this.#telemetryOptions
|
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
|
// check to see if we have a corresponding parameter
|
||||||
// if not, add one
|
// if not, add one
|
||||||
const parameterExists = this.#domainObject.configuration.comps.parameters.some(
|
const parameterExists = this.#domainObject.configuration.comps.parameters.some(
|
||||||
|
@ -117,7 +117,7 @@ export default class CompsTelemetryProvider {
|
|||||||
callbackID
|
callbackID
|
||||||
);
|
);
|
||||||
specificCompsManager.on('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
specificCompsManager.on('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
||||||
specificCompsManager.startListeningToUnderlyingTelemetry();
|
specificCompsManager.load();
|
||||||
return () => {
|
return () => {
|
||||||
specificCompsManager.off('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
specificCompsManager.off('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
||||||
delete this.#subscriptionCallbacks[callbackID];
|
delete this.#subscriptionCallbacks[callbackID];
|
||||||
|
Loading…
Reference in New Issue
Block a user