Skip to content

Commit

Permalink
clean up the new hasNumericTelemetry method in the telemetry api
Browse files Browse the repository at this point in the history
  • Loading branch information
jvigliotta committed Dec 30, 2024
1 parent bac8c80 commit 3cba87d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/api/telemetry/TelemetryAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,23 @@ export default class TelemetryAPI {
return value;
}

/**
* Determines whether a domain object has numeric telemetry data.
* A domain object has numeric telemetry if it:
* 1. Has a telemetry property
* 2. Has telemetry metadata with domain values (like timestamps)
* 3. Has range values (measurements) where at least one is numeric
*
* @method hasNumericTelemetry
* @param {import('openmct').DomainObject} domainObject The domain object to check
* @returns {boolean} True if the object has numeric telemetry, false otherwise
*/
hasNumericTelemetry(domainObject) {
if (!Object.prototype.hasOwnProperty.call(domainObject, 'telemetry')) {
return false;
}

let metadata = this.openmct.telemetry.getMetadata(domainObject);

return metadata.values().length > 0 && this.#hasDomainAndNumericRange(metadata);
}

#hasDomainAndNumericRange(metadata) {
const metadata = this.openmct.telemetry.getMetadata(domainObject);
const rangeValues = metadata.valuesForHints(['range']);
const domains = metadata.valuesForHints(['domain']);

Expand Down

0 comments on commit 3cba87d

Please sign in to comment.