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

Wait for bounds change to reset telemetry collection data #6857

Merged
merged 5 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions src/api/telemetry/TelemetryAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,17 @@ export default class TelemetryAPI {
*/
standardizeRequestOptions(options = {}) {
if (!Object.hasOwn(options, 'start')) {
if (options.timeContext?.getBounds()) {
const bounds = options.timeContext?.getBounds();
if (bounds?.start) {
options.start = options.timeContext.getBounds().start;
} else {
options.start = this.openmct.time.getBounds().start;
}
}

if (!Object.hasOwn(options, 'end')) {
if (options.timeContext?.getBounds()) {
const bounds = options.timeContext?.getBounds();
if (bounds?.end) {
options.end = options.timeContext.getBounds().end;
} else {
options.end = this.openmct.time.getBounds().end;
Expand Down
10 changes: 9 additions & 1 deletion src/api/telemetry/TelemetryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class TelemetryCollection extends EventEmitter {
this.requestAbort = undefined;
this.isStrategyLatest = this.options.strategy === 'latest';
this.dataOutsideTimeBounds = false;
this.modeChanged = false;
}

/**
Expand Down Expand Up @@ -306,6 +307,12 @@ export default class TelemetryCollection extends EventEmitter {
* @private
*/
_bounds(bounds, isTick) {
if (this.modeChanged) {
this.modeChanged = false;
this._reset();
return;
}

let startChanged = this.lastBounds.start !== bounds.start;
let endChanged = this.lastBounds.end !== bounds.end;

Expand Down Expand Up @@ -439,7 +446,8 @@ export default class TelemetryCollection extends EventEmitter {
}

_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;
}

/**
Expand Down
44 changes: 23 additions & 21 deletions src/plugins/imagery/components/ImageryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ import ImageControls from './ImageControls.vue';
import ImageThumbnail from './ImageThumbnail.vue';
import imageryData from '../../imagery/mixins/imageryData';
import AnnotationsCanvas from './AnnotationsCanvas.vue';
import { TIME_CONTEXT_EVENTS } from '../../../api/time/constants';

const REFRESH_CSS_MS = 500;
const DURATION_TRACK_MS = 1000;
Expand Down Expand Up @@ -754,32 +755,28 @@ export default {
this.stopFollowingTimeContext();
this.timeContext = this.openmct.time.getContextForView(this.objectPath);
//listen
this.timeContext.on('timeSystem', this.timeContextChanged);
this.timeContext.on('clock', this.timeContextChanged);
this.timeContextChanged();
this.timeContext.on('timeSystem', this.setModeAndTrackDuration);
this.timeContext.on(TIME_CONTEXT_EVENTS.clockChanged, this.setModeAndTrackDuration);
this.timeContext.on(TIME_CONTEXT_EVENTS.modeChanged, this.setModeAndTrackDuration);
this.setModeAndTrackDuration();
},
stopFollowingTimeContext() {
if (this.timeContext) {
this.timeContext.off('timeSystem', this.timeContextChanged);
this.timeContext.off('clock', this.timeContextChanged);
this.timeContext.off('timeSystem', this.setModeAndTrackDuration);
this.timeContext.off(TIME_CONTEXT_EVENTS.clockChanged, this.setModeAndTrackDuration);
this.timeContext.off(TIME_CONTEXT_EVENTS.modeChanged, this.setModeAndTrackDuration);
}
},
timeContextChanged() {
setModeAndTrackDuration() {
this.setIsFixed();
this.setCanTrackDuration();
this.trackDuration();
},
setIsFixed() {
this.isFixed = this.timeContext ? this.timeContext.isFixed() : this.openmct.time.isFixed();
this.isFixed = this.timeContext.isRealTime() === false;
},
setCanTrackDuration() {
let isRealTime;
if (this.timeContext) {
isRealTime = this.timeContext.isRealTime();
} else {
isRealTime = this.openmct.time.isRealTime();
}

let isRealTime = this.timeContext.isRealTime();
this.canTrackDuration = isRealTime && this.timeSystem.isUTCBased;
},
updateSelection(selection) {
Expand Down Expand Up @@ -809,13 +806,18 @@ export default {
}
},
async initializeRelatedTelemetry() {
this.relatedTelemetry = new RelatedTelemetry(this.openmct, this.domainObject, [
...this.spacecraftPositionKeys,
...this.spacecraftOrientationKeys,
...this.cameraKeys,
...this.sunKeys,
...this.transformationsKeys
]);
this.relatedTelemetry = new RelatedTelemetry(
this.openmct,
this.domainObject,
[
...this.spacecraftPositionKeys,
...this.spacecraftOrientationKeys,
...this.cameraKeys,
...this.sunKeys,
...this.transformationsKeys
],
this.timeContext
);

if (this.relatedTelemetry.hasRelatedTelemetry) {
await this.relatedTelemetry.load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ function copyRelatedMetadata(metadata) {

import IndependentTimeContext from '@/api/time/IndependentTimeContext';
export default class RelatedTelemetry {
constructor(openmct, domainObject, telemetryKeys) {
constructor(openmct, domainObject, telemetryKeys, timeContext) {
this._openmct = openmct;
this._domainObject = domainObject;
this.timeContext = timeContext;

let metadata = this._openmct.telemetry.getMetadata(this._domainObject);
let imageHints = metadata.valuesForHints(['image'])[0];
Expand All @@ -43,7 +44,7 @@ export default class RelatedTelemetry {
this.keys = telemetryKeys;

this._timeFormatter = undefined;
this._timeSystemChange(this._openmct.time.timeSystem());
this._timeSystemChange(this.timeContext.timeSystem());

// grab related telemetry metadata
for (let key of this.keys) {
Expand All @@ -57,7 +58,7 @@ export default class RelatedTelemetry {
this._timeSystemChange = this._timeSystemChange.bind(this);
this.destroy = this.destroy.bind(this);

this._openmct.time.on('timeSystem', this._timeSystemChange);
this.timeContext.on('timeSystem', this._timeSystemChange);
}
}

Expand Down Expand Up @@ -109,7 +110,7 @@ export default class RelatedTelemetry {
// and set bounds.
ephemeralContext.resetContext();
const newBounds = {
start: this._openmct.time.bounds().start,
start: this.timeContext.bounds().start,
end: this._parseTime(datum)
};
ephemeralContext.bounds(newBounds);
Expand Down Expand Up @@ -183,7 +184,7 @@ export default class RelatedTelemetry {
}

destroy() {
this._openmct.time.off('timeSystem', this._timeSystemChange);
this.timeContext.off('timeSystem', this._timeSystemChange);
for (let key of this.keys) {
if (this[key] && this[key].unsubscribe) {
this[key].unsubscribe();
Expand Down