From 221d10d3e6654e2d9a95c50d6cf3ff1c582fa392 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 2 Mar 2021 16:55:27 -0800 Subject: [PATCH] [Imagery Freshness] Update Telemetry for Imagery Freshness (#3723) * added new spacecraftPosition keys and changed old spacecraft keys to spacecraftOriention keys, updated how freshness is determined * due to tests, added some checks for missing related telemetry before acting on it * lint fixes * pr comments, change simple if to Boolean --- .../imagery/components/ImageryViewLayout.vue | 39 +++++++++++++------ .../RelatedTelemetry/RelatedTelemetry.js | 14 ++++--- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/plugins/imagery/components/ImageryViewLayout.vue b/src/plugins/imagery/components/ImageryViewLayout.vue index abe329d9c2..53d3abcbce 100644 --- a/src/plugins/imagery/components/ImageryViewLayout.vue +++ b/src/plugins/imagery/components/ImageryViewLayout.vue @@ -271,11 +271,27 @@ export default { if (this.relatedTelemetry.hasRelatedTelemetry) { isFresh = true; - for (let key of this.spacecraftKeys) { + for (let key of this.spacecraftPositionKeys) { if (this.relatedTelemetry[key] && latest[key] && focused[key]) { - if (!this.relatedTelemetry[key].comparisonFunction(latest[key], focused[key])) { - isFresh = false; - } + isFresh = Boolean(this.relatedTelemetry[key].comparisonFunction(latest[key], focused[key])); + } else { + isFresh = false; + } + } + } + + return isFresh; + }, + isSpacecraftOrientationFresh() { + let isFresh = undefined; + let latest = this.latestRelatedTelemetry; + let focused = this.focusedImageRelatedTelemetry; + + if (this.relatedTelemetry.hasRelatedTelemetry) { + isFresh = true; + for (let key of this.spacecraftOrientationKeys) { + if (this.relatedTelemetry[key] && latest[key] && focused[key]) { + isFresh = Boolean(this.relatedTelemetry[key].comparisonFunction(latest[key], focused[key])); } else { isFresh = false; } @@ -293,12 +309,10 @@ export default { isFresh = true; // camera freshness relies on spacecraft position freshness - if (this.isSpacecraftPositionFresh) { + if (this.isSpacecraftPositionFresh && this.isSpacecraftOrientationFresh) { for (let key of this.cameraKeys) { if (this.relatedTelemetry[key] && latest[key] && focused[key]) { - if (!this.relatedTelemetry[key].comparisonFunction(latest[key], focused[key])) { - isFresh = false; - } + isFresh = Boolean(this.relatedTelemetry[key].comparisonFunction(latest[key], focused[key])); } else { isFresh = false; } @@ -333,7 +347,8 @@ export default { this.imageFormatter = this.openmct.telemetry.getValueFormatter(this.imageHints); // related telemetry keys - this.spacecraftKeys = ['heading', 'roll', 'pitch']; + this.spacecraftPositionKeys = ['positionX', 'positionY', 'positionZ']; + this.spacecraftOrientationKeys = ['heading', 'roll', 'pitch']; this.cameraKeys = ['cameraPan', 'cameraTilt']; this.sunKeys = ['sunOrientation']; @@ -380,7 +395,7 @@ export default { // unsubscribe from related telemetry if (this.relatedTelemetry.hasRelatedTelemetry) { for (let key of this.relatedTelemetry.keys) { - if (this.relatedTelemetry[key].unsubscribe) { + if (this.relatedTelemetry[key] && this.relatedTelemetry[key].unsubscribe) { this.relatedTelemetry[key].unsubscribe(); } } @@ -391,7 +406,7 @@ export default { this.relatedTelemetry = new RelatedTelemetry( this.openmct, this.domainObject, - [...this.spacecraftKeys, ...this.cameraKeys, ...this.sunKeys] + [...this.spacecraftPositionKeys, ...this.spacecraftOrientationKeys, ...this.cameraKeys, ...this.sunKeys] ); if (this.relatedTelemetry.hasRelatedTelemetry) { @@ -466,7 +481,7 @@ export default { } }, trackLatestRelatedTelemetry() { - [...this.spacecraftKeys, ...this.cameraKeys, ...this.sunKeys].forEach(key => { + [...this.spacecraftPositionKeys, ...this.spacecraftOrientationKeys, ...this.cameraKeys, ...this.sunKeys].forEach(key => { if (this.relatedTelemetry[key] && this.relatedTelemetry[key].subscribe) { this.relatedTelemetry[key].subscribe((datum) => { let valueKey = this.relatedTelemetry[key].realtime.valueKey; diff --git a/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js b/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js index 267931f4e7..272552126c 100644 --- a/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js +++ b/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js @@ -68,12 +68,14 @@ export default class RelatedTelemetry { await Promise.all( this.keys.map(async (key) => { - if (this[key].historical) { - await this._initializeHistorical(key); - } + if (this[key]) { + if (this[key].historical) { + await this._initializeHistorical(key); + } - if (this[key].realtime && this[key].realtime.telemetryObjectId) { - await this._intializeRealtime(key); + if (this[key].realtime && this[key].realtime.telemetryObjectId) { + await this._intializeRealtime(key); + } } }) ); @@ -153,7 +155,7 @@ export default class RelatedTelemetry { destroy() { this._openmct.time.off('timeSystem', this._timeSystemChange); for (let key of this.keys) { - if (this[key].unsubscribe) { + if (this[key] && this[key].unsubscribe) { this[key].unsubscribe(); } }