Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derived Telemetry Prototype #7815

Open
wants to merge 106 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
4316003
skeleton for comps
scottbell Jul 25, 2024
6c74e84
more scaffolding
scottbell Jul 29, 2024
f5d7a33
more drafts
scottbell Jul 30, 2024
0dd0442
add comps manager
scottbell Aug 1, 2024
ff81454
worker ready
scottbell Aug 2, 2024
74c3a95
telemetry is null for some reason
scottbell Aug 2, 2024
ce5e435
can add two sin waves
scottbell Aug 2, 2024
69db534
adding works
scottbell Aug 2, 2024
90a24b3
exact values enabled
scottbell Aug 5, 2024
37d222f
subscriptions work
scottbell Aug 6, 2024
55c8609
Merge remote-tracking branch 'origin/master' into telemetry-comps
scottbell Aug 8, 2024
a94c752
slowing adding gui
scottbell Aug 8, 2024
0113ec0
fix plots
scottbell Aug 12, 2024
a0a2ead
rudimentary expression editor
scottbell Aug 12, 2024
e5719fc
correctly persist
scottbell Aug 13, 2024
0326e38
parameters
scottbell Aug 13, 2024
413338d
can take arbitrary expressions
scottbell Aug 13, 2024
f174515
styles and timing for loading worker
scottbell Aug 14, 2024
9e3e739
ui works kinda
scottbell Aug 14, 2024
dcc8938
need to figure out ranger
scottbell Aug 14, 2024
87dc272
works with time
scottbell Aug 15, 2024
df3ca84
timesystem works
scottbell Aug 15, 2024
484a81b
get rid of batch for now
scottbell Aug 15, 2024
446c811
gui still leaking data
scottbell Aug 15, 2024
aa8750e
memory conserved
scottbell Aug 15, 2024
4d546fb
styles
scottbell Aug 16, 2024
d6c8bee
Merge remote-tracking branch 'origin/master' into telemetry-comps
scottbell Aug 19, 2024
d7d7913
fix initial load
scottbell Aug 19, 2024
d4b2986
expression validator
scottbell Aug 19, 2024
a9d63b9
fix test data
scottbell Aug 20, 2024
e4dcda8
do not persist
scottbell Aug 20, 2024
58568b8
persist after adding
scottbell Aug 20, 2024
d96c3fc
fix editing issues
scottbell Aug 21, 2024
28ec13a
mutate when parameters or expression changes
scottbell Aug 22, 2024
386c3b4
implement output format
scottbell Sep 3, 2024
5af6413
implement output format
scottbell Sep 3, 2024
1c68c7e
be consistent with output key
scottbell Sep 3, 2024
5894363
add icons and fix errant telemetry
scottbell Sep 4, 2024
40a95cf
lint
scottbell Sep 4, 2024
ccc12de
lint
scottbell Sep 4, 2024
3ad21ee
use key instead of name
scottbell Sep 4, 2024
4260cc3
Style enhancements for Derived Telemetry object
charlesh88 Sep 4, 2024
cce3008
Style enhancements for Derived Telemetry object
charlesh88 Sep 4, 2024
2793da4
Enhancements for Derived Telemetry object
charlesh88 Sep 5, 2024
1d686c2
Style enhancements for Derived Telemetry object
charlesh88 Sep 5, 2024
f8ceaa5
Merge branch 'telemetry-comps' of github.com:nasa/openmct into teleme…
charlesh88 Sep 5, 2024
e1f50fe
Enhancements for Derived Telemetry object
charlesh88 Sep 5, 2024
eac4676
do not apply test data when edit mode changes to false
scottbell Sep 5, 2024
02cf701
Revert "do not apply test data when edit mode changes to false"
scottbell Sep 5, 2024
9aeb454
trying this again without blowing away the very pretty styling
scottbell Sep 5, 2024
fb8730c
clean up composition effects
scottbell Sep 5, 2024
06e916e
allow deleting of parameters
scottbell Sep 5, 2024
1996e66
can chain and plot derived data
scottbell Sep 5, 2024
dde0d1a
can delete properly
scottbell Sep 5, 2024
cde34e3
Enhancements for Derived Telemetry object
charlesh88 Sep 5, 2024
fdcece8
Merge branch 'telemetry-comps' of github.com:nasa/openmct into teleme…
charlesh88 Sep 5, 2024
80d8bab
handle arrays and add skeleton tests
scottbell Sep 5, 2024
1615c36
Merge branch 'telemetry-comps' of github.com:nasa/openmct into teleme…
charlesh88 Sep 5, 2024
59461d6
Enhancements for Derived Telemetry object
charlesh88 Sep 6, 2024
1b186d7
add tests
scottbell Sep 6, 2024
b251fde
ensure output format propagates
scottbell Sep 6, 2024
89e18d4
add output format test
scottbell Sep 6, 2024
dd57d78
add some basic object path label tests
scottbell Sep 7, 2024
8b4eed9
good job code scanner. changing to or condition
scottbell Sep 9, 2024
60e07e6
refactor aria labeling
scottbell Sep 10, 2024
e02217a
Merge branch 'master' into telemetry-comps
scottbell Sep 10, 2024
c1a361d
Merge branch 'master' into telemetry-comps
scottbell Sep 11, 2024
ee612a6
resolve conflicts
scottbell Sep 17, 2024
dfcfa47
pass options on request to underlying collections
scottbell Sep 24, 2024
4a301a1
ensure derived DERIVED telemetry loads in the proper order. also have…
scottbell Sep 25, 2024
eb5d32c
fix domains
scottbell Oct 1, 2024
5e013b6
ensure we only ask for latest for comp editor
scottbell Oct 1, 2024
1a94010
Merge remote-tracking branch 'origin/master' into telemetry-comps
scottbell Oct 2, 2024
8e5ac68
improvement in loading
scottbell Oct 3, 2024
154e8c6
fix slow loading errors
scottbell Oct 3, 2024
4bbbd17
more telemetry collection changes to acommodate bound changes
scottbell Oct 3, 2024
38316bd
more debug just in case
scottbell Oct 4, 2024
f718ccd
stacked plots are overriding telemetry object configurations
scottbell Oct 4, 2024
58d6cdb
some changes
scottbell Oct 4, 2024
d859322
add new flag to deal with plots asking for zoomed out data that shoul…
scottbell Oct 4, 2024
395436a
works
scottbell Oct 9, 2024
3f92deb
add sample size
scottbell Oct 9, 2024
c680694
check if sample size greater than zero
scottbell Oct 9, 2024
8e7bfd0
ensure number for sample size
scottbell Oct 9, 2024
2de628a
ensure we have a reference value before we slice
scottbell Oct 9, 2024
ba7f291
can do derived derived accumulated comps now
scottbell Oct 9, 2024
7c01a5e
ensure we are checking for not equal
scottbell Oct 9, 2024
bf9d5ef
add a few more awaits
scottbell Oct 9, 2024
d6f5056
allow blank test values for arrays
scottbell Oct 9, 2024
85a7769
check for blank test values
scottbell Oct 9, 2024
3be414e
Merge remote-tracking branch 'origin/master' into telemetry-comps-wit…
scottbell Oct 9, 2024
3b06c77
change to just value
scottbell Oct 9, 2024
4de0354
impute requested data properly
scottbell Oct 9, 2024
3b78d4d
fix output and add accumulation label
scottbell Oct 10, 2024
d5ee430
update output when comp changes
scottbell Oct 10, 2024
6710ad0
remove unused function
scottbell Oct 10, 2024
7d46afb
add placeholder
scottbell Oct 10, 2024
00c8c0e
Merge remote-tracking branch 'origin/master' into telemetry-comps
scottbell Oct 11, 2024
51f73bb
Merge remote-tracking branch 'origin/master' into telemetry-comps
scottbell Oct 14, 2024
1516524
support lambda values
scottbell Oct 14, 2024
96b1ef0
reduce size
Oct 22, 2024
4a4dabf
Merge remote-tracking branch 'origin/master' into telemetry-comps
scottbell Oct 28, 2024
9ca489c
widen size to accomodate sample size
scottbell Oct 28, 2024
55063a0
removing debug statements for PR review
scottbell Oct 28, 2024
64ae96e
Closes #7823
charlesh88 Nov 14, 2024
5683320
Merge remote-tracking branch 'origin/master' into telemetry-comps
scottbell Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more debug just in case
  • Loading branch information
scottbell committed Oct 4, 2024
commit 38316bd2f54cae9d420fb8ca3abcbb0c766e002a
23 changes: 18 additions & 5 deletions src/api/telemetry/TelemetryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
this.dataOutsideTimeBounds = false;
this.modeChanged = false;

console.debug(

Check warning on line 77 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L77

Added line #L77 was not covered by tests
`🫙 Created telemetry for ${this.domainObject.name} with bounds ${options.start} and ${options.end}`
`🫙 Created telemetry for ${this.domainObject.name} with bounds ${new Date(options.start).toISOString()} and ${new Date(options.end).toISOString()}`
);
}

Expand All @@ -91,25 +91,25 @@
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;

Check warning on line 95 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L94-L95

Added lines #L94 - L95 were not covered by tests
}
if (this.options.end) {
this.lastBounds.end = this.options.end;

Check warning on line 98 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L97-L98

Added lines #L97 - L98 were not covered by tests
}
console.debug(

Check warning on line 100 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L100

Added line #L100 was not covered by tests
`🫙 Bounds for collection are start ${this.lastBounds.start} and end ${this.lastBounds.end}`
`🫙 Bounds for collection are start ${new Date(this.lastBounds.start).toISOString()} and end ${new Date(this.lastBounds.end).toISOString()}`
);
this._watchBounds();
this._watchTimeSystem();
this._watchTimeModeChange();

const historicalTelemetryLoadedPromise = this._requestHistoricalTelemetry();

Check warning on line 107 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L107

Added line #L107 was not covered by tests
this._initiateSubscriptionTelemetry();

this.loaded = true;

return historicalTelemetryLoadedPromise;

Check warning on line 112 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L112

Added line #L112 was not covered by tests
}

/**
Expand All @@ -129,7 +129,7 @@
}

this.removeAllListeners();
this.loaded = false;

Check warning on line 132 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L132

Added line #L132 was not covered by tests
}

/**
Expand All @@ -144,6 +144,9 @@
* @private
*/
async _requestHistoricalTelemetry() {
console.debug(

Check warning on line 147 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L147

Added line #L147 was not covered by tests
`🫙 Requesting historical telemetry with start ${new Date(this.lastBounds.start).toISOString()} and end ${new Date(this.lastBounds.end).toISOString()}}`
);
let options = this.openmct.telemetry.standardizeRequestOptions({ ...this.options });
const historicalProvider = this.openmct.telemetry.findRequestProvider(
this.domainObject,
Expand Down Expand Up @@ -229,14 +232,20 @@
let hasDataBeforeStartBound = false;
let size = this.options.size;
let enforceSize = size !== undefined && this.options.enforceSize;
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 < this.lastBounds.start;
afterEndOfBounds = parsedValue > this.lastBounds.end;

if (beforeStartOfBounds) {
console.debug(

Check warning on line 243 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L242-L243

Added lines #L242 - L243 were not covered by tests
`🫙 Datum is before start of bounds: ${new Date(parsedValue).toISOString()} < ${new Date(this.lastBounds.start).toISOString()}`,
this.options
);
}

if (
!afterEndOfBounds &&
(!beforeStartOfBounds || (this.isStrategyLatest && this.openmct.telemetry.greedyLAD()))
Expand Down Expand Up @@ -348,8 +357,12 @@
this.lastBounds = bounds;

// delete start/end if they are defined in options as we've got new bounds
delete this.options.start;
delete this.options.end;
if (!isTick && startChanged) {
delete this.options.start;

Check warning on line 361 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L360-L361

Added lines #L360 - L361 were not covered by tests
}
if (!isTick && endChanged) {
delete this.options.end;

Check warning on line 364 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L363-L364

Added lines #L363 - L364 were not covered by tests
}

if (isTick) {
if (this.timeKey === undefined) {
Expand Down Expand Up @@ -498,9 +511,9 @@
this.boundedTelemetry = [];
this.futureBuffer = [];

const telemetryLoadPromise = this._requestHistoricalTelemetry();

Check warning on line 514 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L514

Added line #L514 was not covered by tests

this.emit('clear', telemetryLoadPromise);

Check warning on line 516 in src/api/telemetry/TelemetryCollection.js

View check run for this annotation

Codecov / codecov/patch

src/api/telemetry/TelemetryCollection.js#L516

Added line #L516 was not covered by tests
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/comps/CompsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,287 +5,287 @@
#openmct;
#domainObject;
#composition;
#telemetryObjects = {};
#telemetryCollections = {};
#telemetryLoadedPromises = [];
#telemetryOptions = {};
#loaded = false;
#compositionLoaded = false;
#telemetryProcessors = {};

Check warning on line 14 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L8-L14

Added lines #L8 - L14 were not covered by tests

constructor(openmct, domainObject) {
super();
this.#openmct = openmct;
this.#domainObject = domainObject;
this.clearData = this.clearData.bind(this);

Check warning on line 20 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L17-L20

Added lines #L17 - L20 were not covered by tests
}

#getNextAlphabeticalParameterName() {
const parameters = this.#domainObject.configuration.comps.parameters;
const existingNames = new Set(parameters.map((p) => p.name));
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
let suffix = '';

Check warning on line 27 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L24-L27

Added lines #L24 - L27 were not covered by tests
// eslint-disable-next-line no-constant-condition
while (true) {
for (let letter of alphabet) {
const proposedName = letter + suffix;
if (!existingNames.has(proposedName)) {
return proposedName;

Check warning on line 33 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L29-L33

Added lines #L29 - L33 were not covered by tests
}
}
// Increment suffix after exhausting the alphabet
suffix = (parseInt(suffix, 10) || 0) + 1;

Check warning on line 37 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L37

Added line #L37 was not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why wasn't this covered by tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'd need 26 different parameters before slapping numbers on them. e.g., a,b,..z,a1,b2,c2,etc.

}
}

addParameter(telemetryObject) {
const keyString = this.#openmct.objects.makeKeyString(telemetryObject.identifier);
const metaData = this.#openmct.telemetry.getMetadata(telemetryObject);
const timeSystem = this.#openmct.time.getTimeSystem();
const domains = metaData?.valuesForHints(['domain']);
const timeMetaData = domains.find((d) => d.key === timeSystem.key);

Check warning on line 46 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L42-L46

Added lines #L42 - L46 were not covered by tests
// in the valuesMetadata, find the first numeric data type
const rangeItems = metaData.valueMetadatas.filter(
(metaDatum) => metaDatum.hints && metaDatum.hints.range

Check warning on line 49 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L48-L49

Added lines #L48 - L49 were not covered by tests
);
rangeItems.sort((a, b) => a.hints.range - b.hints.range);
let valueToUse = rangeItems[0]?.key;
if (!valueToUse) {

Check warning on line 53 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L51-L53

Added lines #L51 - L53 were not covered by tests
// if no numeric data type, just use the first one
valueToUse = metaData.valueMetadatas[0]?.key;

Check warning on line 55 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L55

Added line #L55 was not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SWGs have numeric data types, so we never fall through here.

}
this.#domainObject.configuration.comps.parameters.push({

Check warning on line 57 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L57

Added line #L57 was not covered by tests
keyString,
name: `${this.#getNextAlphabeticalParameterName()}`,
valueToUse,
testValue: 0,
timeMetaData
});
this.emit('parameterAdded', this.#domainObject);

Check warning on line 64 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L64

Added line #L64 was not covered by tests
}

getParameters() {
const parameters = this.#domainObject.configuration.comps.parameters;
const parametersWithTimeKey = parameters.map((parameter) => {
return {

Check warning on line 70 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L68-L70

Added lines #L68 - L70 were not covered by tests
...parameter,
timeKey: this.#telemetryCollections[parameter.keyString]?.timeKey
};
});
return parametersWithTimeKey;

Check warning on line 75 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L75

Added line #L75 was not covered by tests
}

getTelemetryObjectForParameter(keyString) {
return this.#telemetryObjects[keyString];

Check warning on line 79 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L79

Added line #L79 was not covered by tests
}

getMetaDataValuesForParameter(keyString) {
const telemetryObject = this.getTelemetryObjectForParameter(keyString);
const metaData = this.#openmct.telemetry.getMetadata(telemetryObject);
return metaData.valueMetadatas;

Check warning on line 85 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L83-L85

Added lines #L83 - L85 were not covered by tests
}

deleteParameter(keyString) {
this.#domainObject.configuration.comps.parameters =

Check warning on line 89 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L89

Added line #L89 was not covered by tests
this.#domainObject.configuration.comps.parameters.filter(
(parameter) => parameter.keyString !== keyString

Check warning on line 91 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L91

Added line #L91 was not covered by tests
);
// if there are no parameters referencing this parameter keyString, remove the telemetry object too
const parameterExists = this.#domainObject.configuration.comps.parameters.some(
(parameter) => parameter.keyString === keyString

Check warning on line 95 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L94-L95

Added lines #L94 - L95 were not covered by tests
);
if (!parameterExists) {
this.emit('parameterRemoved', this.#domainObject);

Check warning on line 98 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L97-L98

Added lines #L97 - L98 were not covered by tests
}
}

setDomainObject(passedDomainObject) {
this.#domainObject = passedDomainObject;

Check warning on line 103 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L103

Added line #L103 was not covered by tests
}

isReady() {
return this.#loaded;

Check warning on line 107 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L107

Added line #L107 was not covered by tests
}

async load(telemetryOptions) {
if (!_.isEqual(telemetryOptions, this.#telemetryOptions) && this.#loaded) {
console.debug(

Check warning on line 112 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L111-L112

Added lines #L111 - L112 were not covered by tests
`😩 Reloading comps manager ${this.#domainObject.name} due to telemetry options change`,
`😩 Reloading comps manager ${this.#domainObject.name} due to telemetry options change. New bounds are: ${new Date(telemetryOptions.start).toISOString()} to ${new Date(telemetryOptions.end).toISOString()}`,
telemetryOptions
);
this.#destroy();

Check warning on line 116 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L116

Added line #L116 was not covered by tests
}
this.#telemetryOptions = telemetryOptions;
if (!this.#compositionLoaded) {
await this.#loadComposition();
this.#compositionLoaded = true;

Check warning on line 121 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L118-L121

Added lines #L118 - L121 were not covered by tests
}
if (!this.#loaded) {
await this.#startListeningToUnderlyingTelemetry();
this.#telemetryLoadedPromises = [];
this.#loaded = true;

Check warning on line 126 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L123-L126

Added lines #L123 - L126 were not covered by tests
}
}

async #startListeningToUnderlyingTelemetry() {
Object.keys(this.#telemetryCollections).forEach((keyString) => {
if (!this.#telemetryCollections[keyString].loaded) {
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 warning on line 136 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L131-L136

Added lines #L131 - L136 were not covered by tests
}
});
await Promise.all(this.#telemetryLoadedPromises);
this.#telemetryLoadedPromises = [];

Check warning on line 140 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L139-L140

Added lines #L139 - L140 were not covered by tests
}

#destroy() {
this.stopListeningToUnderlyingTelemetry();
this.#composition = null;
this.#telemetryCollections = {};
this.#compositionLoaded = false;
this.#loaded = false;
this.#telemetryObjects = {};

Check warning on line 149 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L144-L149

Added lines #L144 - L149 were not covered by tests
}

stopListeningToUnderlyingTelemetry() {
this.#loaded = false;
Object.keys(this.#telemetryCollections).forEach((keyString) => {
const specificTelemetryProcessor = this.#telemetryProcessors[keyString];
delete this.#telemetryProcessors[keyString];
this.#telemetryCollections[keyString].off('add', specificTelemetryProcessor);
this.#telemetryCollections[keyString].off('clear', this.clearData);
this.#telemetryCollections[keyString].destroy();

Check warning on line 159 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L153-L159

Added lines #L153 - L159 were not covered by tests
});
}

getTelemetryObjects() {
return this.#telemetryObjects;

Check warning on line 164 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L164

Added line #L164 was not covered by tests
}

async #loadComposition() {
this.#composition = this.#openmct.composition.get(this.#domainObject);
if (this.#composition) {
this.#composition.on('add', this.#addTelemetryObject);
this.#composition.on('remove', this.#removeTelemetryObject);
await this.#composition.load();

Check warning on line 172 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L168-L172

Added lines #L168 - L172 were not covered by tests
}
}

getFullDataFrame(newTelemetry) {
const dataFrame = {};

Check warning on line 177 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L177

Added line #L177 was not covered by tests
// can assume on data item
const newTelemetryKey = Object.keys(newTelemetry)[0];
const newTelemetryData = newTelemetry[newTelemetryKey];
const otherTelemetryKeys = Object.keys(this.#telemetryCollections).filter(
(keyString) => keyString !== newTelemetryKey

Check warning on line 182 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L179-L182

Added lines #L179 - L182 were not covered by tests
);
// initialize the data frame with the new telemetry data
dataFrame[newTelemetryKey] = newTelemetryData;

Check warning on line 185 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L185

Added line #L185 was not covered by tests
// initialize the other telemetry data
otherTelemetryKeys.forEach((keyString) => {
dataFrame[keyString] = [];

Check warning on line 188 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L187-L188

Added lines #L187 - L188 were not covered by tests
});

// march through the new telemetry data and add data to the frame from the other telemetry objects
// using LOCF

newTelemetryData.forEach((newDatum) => {
otherTelemetryKeys.forEach((otherKeyString) => {
const otherCollection = this.#telemetryCollections[otherKeyString];
let insertionPointForNewData = otherCollection._sortedIndex(newDatum);
const otherCollectionData = otherCollection.getAll();
if (insertionPointForNewData && insertionPointForNewData >= otherCollectionData.length) {
insertionPointForNewData = otherCollectionData.length - 1;

Check warning on line 200 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L194-L200

Added lines #L194 - L200 were not covered by tests
}
// get the closest datum to the new datum
const closestDatum = otherCollectionData[insertionPointForNewData];
if (closestDatum) {
dataFrame[otherKeyString].push(closestDatum);

Check warning on line 205 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L203-L205

Added lines #L203 - L205 were not covered by tests
}
});
});
return dataFrame;

Check warning on line 209 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L209

Added line #L209 was not covered by tests
}

#removeTelemetryObject = (telemetryObjectIdentifier) => {
const keyString = this.#openmct.objects.makeKeyString(telemetryObjectIdentifier);
delete this.#telemetryObjects[keyString];
this.#telemetryCollections[keyString]?.destroy();
delete this.#telemetryCollections[keyString];

Check warning on line 216 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L212-L216

Added lines #L212 - L216 were not covered by tests
// remove all parameters that reference this telemetry object
this.deleteParameter(keyString);

Check warning on line 218 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L218

Added line #L218 was not covered by tests
};

requestUnderlyingTelemetry() {
const underlyingTelemetry = {};
Object.keys(this.#telemetryCollections).forEach((collectionKey) => {
const collection = this.#telemetryCollections[collectionKey];
underlyingTelemetry[collectionKey] = collection.getAll();

Check warning on line 225 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L222-L225

Added lines #L222 - L225 were not covered by tests
});
return underlyingTelemetry;

Check warning on line 227 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L227

Added line #L227 was not covered by tests
}

#getTelemetryProcessor(keyString) {
if (this.#telemetryProcessors[keyString]) {
return this.#telemetryProcessors[keyString];

Check warning on line 232 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L231-L232

Added lines #L231 - L232 were not covered by tests
}

const telemetryProcessor = (newTelemetry) => {
this.emit('underlyingTelemetryUpdated', { [keyString]: newTelemetry });

Check warning on line 236 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L235-L236

Added lines #L235 - L236 were not covered by tests
};
this.#telemetryProcessors[keyString] = telemetryProcessor;
return telemetryProcessor;

Check warning on line 239 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L238-L239

Added lines #L238 - L239 were not covered by tests
}

#telemetryProcessor = (newTelemetry, keyString) => {
this.emit('underlyingTelemetryUpdated', { [keyString]: newTelemetry });

Check warning on line 243 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L242-L243

Added lines #L242 - L243 were not covered by tests
};

clearData(telemetryLoadedPromise) {
this.#loaded = false;
this.#telemetryLoadedPromises.push(telemetryLoadedPromise);

Check warning on line 248 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L247-L248

Added lines #L247 - L248 were not covered by tests
}

setOutputFormat(outputFormat) {
this.#domainObject.configuration.comps.outputFormat = outputFormat;
this.emit('outputFormatChanged', outputFormat);

Check warning on line 253 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L252-L253

Added lines #L252 - L253 were not covered by tests
}

getOutputFormat() {
return this.#domainObject.configuration.comps.outputFormat;

Check warning on line 257 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L257

Added line #L257 was not covered by tests
}

getExpression() {
return this.#domainObject.configuration.comps.expression;

Check warning on line 261 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L261

Added line #L261 was not covered by tests
}

#addTelemetryObject = (telemetryObject) => {
const keyString = this.#openmct.objects.makeKeyString(telemetryObject.identifier);
this.#telemetryObjects[keyString] = telemetryObject;
this.#telemetryCollections[keyString] = this.#openmct.telemetry.requestCollection(

Check warning on line 267 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L264-L267

Added lines #L264 - L267 were not covered by tests
telemetryObject,
this.#telemetryOptions
);

// check to see if we have a corresponding parameter
// if not, add one
const parameterExists = this.#domainObject.configuration.comps.parameters.some(
(parameter) => parameter.keyString === keyString

Check warning on line 275 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L274-L275

Added lines #L274 - L275 were not covered by tests
);
if (!parameterExists) {
this.addParameter(telemetryObject);

Check warning on line 278 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L277-L278

Added lines #L277 - L278 were not covered by tests
}
};

static getCompsManager(domainObject, openmct, compsManagerPool) {
const id = openmct.objects.makeKeyString(domainObject.identifier);

Check warning on line 283 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L283

Added line #L283 was not covered by tests

if (!compsManagerPool[id]) {
compsManagerPool[id] = new CompsManager(openmct, domainObject);

Check warning on line 286 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L285-L286

Added lines #L285 - L286 were not covered by tests
}

return compsManagerPool[id];

Check warning on line 289 in src/plugins/comps/CompsManager.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/comps/CompsManager.js#L289

Added line #L289 was not covered by tests
}
}
Loading