Wait for bounds change to reset telemetry collection data (#6857)

* Reset and re-request telemetry only after receiving bounds following a mode change

* Don't check for tick - just in case the mode is set without bounds

* Use the imagery view timeContext to get related telemetry.

---------

Co-authored-by: Khalid Adil <khalidadil29@gmail.com>
This commit is contained in:
Shefali Joshi 2023-07-31 11:15:08 -07:00 committed by GitHub
parent 50559ac502
commit f705bf9a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 29 deletions

View File

@ -204,7 +204,8 @@ export default class TelemetryAPI {
*/ */
standardizeRequestOptions(options = {}) { standardizeRequestOptions(options = {}) {
if (!Object.hasOwn(options, 'start')) { if (!Object.hasOwn(options, 'start')) {
if (options.timeContext?.getBounds()) { const bounds = options.timeContext?.getBounds();
if (bounds?.start) {
options.start = options.timeContext.getBounds().start; options.start = options.timeContext.getBounds().start;
} else { } else {
options.start = this.openmct.time.getBounds().start; options.start = this.openmct.time.getBounds().start;
@ -212,7 +213,8 @@ export default class TelemetryAPI {
} }
if (!Object.hasOwn(options, 'end')) { if (!Object.hasOwn(options, 'end')) {
if (options.timeContext?.getBounds()) { const bounds = options.timeContext?.getBounds();
if (bounds?.end) {
options.end = options.timeContext.getBounds().end; options.end = options.timeContext.getBounds().end;
} else { } else {
options.end = this.openmct.time.getBounds().end; options.end = this.openmct.time.getBounds().end;

View File

@ -71,6 +71,7 @@ export default class TelemetryCollection extends EventEmitter {
this.requestAbort = undefined; this.requestAbort = undefined;
this.isStrategyLatest = this.options.strategy === 'latest'; this.isStrategyLatest = this.options.strategy === 'latest';
this.dataOutsideTimeBounds = false; this.dataOutsideTimeBounds = false;
this.modeChanged = false;
} }
/** /**
@ -306,6 +307,12 @@ export default class TelemetryCollection extends EventEmitter {
* @private * @private
*/ */
_bounds(bounds, isTick) { _bounds(bounds, isTick) {
if (this.modeChanged) {
this.modeChanged = false;
this._reset();
return;
}
let startChanged = this.lastBounds.start !== bounds.start; let startChanged = this.lastBounds.start !== bounds.start;
let endChanged = this.lastBounds.end !== bounds.end; let endChanged = this.lastBounds.end !== bounds.end;
@ -439,7 +446,8 @@ export default class TelemetryCollection extends EventEmitter {
} }
_timeModeChanged() { _timeModeChanged() {
this._reset(); //We're need this so that when the bounds change comes in after this mode change, we can reset and request historic telemetry
this.modeChanged = true;
} }
/** /**

View File

@ -209,6 +209,7 @@ import ImageControls from './ImageControls.vue';
import ImageThumbnail from './ImageThumbnail.vue'; import ImageThumbnail from './ImageThumbnail.vue';
import imageryData from '../../imagery/mixins/imageryData'; import imageryData from '../../imagery/mixins/imageryData';
import AnnotationsCanvas from './AnnotationsCanvas.vue'; import AnnotationsCanvas from './AnnotationsCanvas.vue';
import { TIME_CONTEXT_EVENTS } from '../../../api/time/constants';
const REFRESH_CSS_MS = 500; const REFRESH_CSS_MS = 500;
const DURATION_TRACK_MS = 1000; const DURATION_TRACK_MS = 1000;
@ -754,32 +755,28 @@ export default {
this.stopFollowingTimeContext(); this.stopFollowingTimeContext();
this.timeContext = this.openmct.time.getContextForView(this.objectPath); this.timeContext = this.openmct.time.getContextForView(this.objectPath);
//listen //listen
this.timeContext.on('timeSystem', this.timeContextChanged); this.timeContext.on('timeSystem', this.setModeAndTrackDuration);
this.timeContext.on('clock', this.timeContextChanged); this.timeContext.on(TIME_CONTEXT_EVENTS.clockChanged, this.setModeAndTrackDuration);
this.timeContextChanged(); this.timeContext.on(TIME_CONTEXT_EVENTS.modeChanged, this.setModeAndTrackDuration);
this.setModeAndTrackDuration();
}, },
stopFollowingTimeContext() { stopFollowingTimeContext() {
if (this.timeContext) { if (this.timeContext) {
this.timeContext.off('timeSystem', this.timeContextChanged); this.timeContext.off('timeSystem', this.setModeAndTrackDuration);
this.timeContext.off('clock', this.timeContextChanged); this.timeContext.off(TIME_CONTEXT_EVENTS.clockChanged, this.setModeAndTrackDuration);
this.timeContext.off(TIME_CONTEXT_EVENTS.modeChanged, this.setModeAndTrackDuration);
} }
}, },
timeContextChanged() { setModeAndTrackDuration() {
this.setIsFixed(); this.setIsFixed();
this.setCanTrackDuration(); this.setCanTrackDuration();
this.trackDuration(); this.trackDuration();
}, },
setIsFixed() { setIsFixed() {
this.isFixed = this.timeContext ? this.timeContext.isFixed() : this.openmct.time.isFixed(); this.isFixed = this.timeContext.isRealTime() === false;
}, },
setCanTrackDuration() { setCanTrackDuration() {
let isRealTime; let isRealTime = this.timeContext.isRealTime();
if (this.timeContext) {
isRealTime = this.timeContext.isRealTime();
} else {
isRealTime = this.openmct.time.isRealTime();
}
this.canTrackDuration = isRealTime && this.timeSystem.isUTCBased; this.canTrackDuration = isRealTime && this.timeSystem.isUTCBased;
}, },
updateSelection(selection) { updateSelection(selection) {
@ -809,13 +806,18 @@ export default {
} }
}, },
async initializeRelatedTelemetry() { async initializeRelatedTelemetry() {
this.relatedTelemetry = new RelatedTelemetry(this.openmct, this.domainObject, [ this.relatedTelemetry = new RelatedTelemetry(
...this.spacecraftPositionKeys, this.openmct,
...this.spacecraftOrientationKeys, this.domainObject,
...this.cameraKeys, [
...this.sunKeys, ...this.spacecraftPositionKeys,
...this.transformationsKeys ...this.spacecraftOrientationKeys,
]); ...this.cameraKeys,
...this.sunKeys,
...this.transformationsKeys
],
this.timeContext
);
if (this.relatedTelemetry.hasRelatedTelemetry) { if (this.relatedTelemetry.hasRelatedTelemetry) {
await this.relatedTelemetry.load(); await this.relatedTelemetry.load();

View File

@ -30,9 +30,10 @@ function copyRelatedMetadata(metadata) {
import IndependentTimeContext from '@/api/time/IndependentTimeContext'; import IndependentTimeContext from '@/api/time/IndependentTimeContext';
export default class RelatedTelemetry { export default class RelatedTelemetry {
constructor(openmct, domainObject, telemetryKeys) { constructor(openmct, domainObject, telemetryKeys, timeContext) {
this._openmct = openmct; this._openmct = openmct;
this._domainObject = domainObject; this._domainObject = domainObject;
this.timeContext = timeContext;
let metadata = this._openmct.telemetry.getMetadata(this._domainObject); let metadata = this._openmct.telemetry.getMetadata(this._domainObject);
let imageHints = metadata.valuesForHints(['image'])[0]; let imageHints = metadata.valuesForHints(['image'])[0];
@ -43,7 +44,7 @@ export default class RelatedTelemetry {
this.keys = telemetryKeys; this.keys = telemetryKeys;
this._timeFormatter = undefined; this._timeFormatter = undefined;
this._timeSystemChange(this._openmct.time.timeSystem()); this._timeSystemChange(this.timeContext.timeSystem());
// grab related telemetry metadata // grab related telemetry metadata
for (let key of this.keys) { for (let key of this.keys) {
@ -57,7 +58,7 @@ export default class RelatedTelemetry {
this._timeSystemChange = this._timeSystemChange.bind(this); this._timeSystemChange = this._timeSystemChange.bind(this);
this.destroy = this.destroy.bind(this); this.destroy = this.destroy.bind(this);
this._openmct.time.on('timeSystem', this._timeSystemChange); this.timeContext.on('timeSystem', this._timeSystemChange);
} }
} }
@ -109,7 +110,7 @@ export default class RelatedTelemetry {
// and set bounds. // and set bounds.
ephemeralContext.resetContext(); ephemeralContext.resetContext();
const newBounds = { const newBounds = {
start: this._openmct.time.bounds().start, start: this.timeContext.bounds().start,
end: this._parseTime(datum) end: this._parseTime(datum)
}; };
ephemeralContext.bounds(newBounds); ephemeralContext.bounds(newBounds);
@ -183,7 +184,7 @@ export default class RelatedTelemetry {
} }
destroy() { destroy() {
this._openmct.time.off('timeSystem', this._timeSystemChange); this.timeContext.off('timeSystem', this._timeSystemChange);
for (let key of this.keys) { for (let key of this.keys) {
if (this[key] && this[key].unsubscribe) { if (this[key] && this[key].unsubscribe) {
this[key].unsubscribe(); this[key].unsubscribe();