Compare commits

...

3 Commits

2 changed files with 122 additions and 55 deletions

View File

@@ -1,6 +1,6 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
@@ -62,6 +62,7 @@ export default {
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
this.bounds = this.openmct.time.bounds();
this.limitEvaluator = this.openmct
.telemetry
@@ -76,6 +77,7 @@ export default {
);
this.openmct.time.on('timeSystem', this.updateTimeSystem);
this.openmct.time.on('bounds', this.updateBounds);
this.timestampKey = this.openmct.time.timeSystem().key;
@@ -89,43 +91,80 @@ export default {
.telemetry
.subscribe(this.domainObject, this.updateValues);
this.openmct
.telemetry
.request(this.domainObject, {strategy: 'latest'})
.then((array) => this.updateValues(array[array.length - 1]));
this.requestHistory();
},
destroyed() {
this.stopWatchingMutation();
this.unsubscribe();
this.openmct.off('timeSystem', this.updateTimeSystem);
this.openmct.time.off('timeSystem', this.updateTimeSystem);
this.openmct.time.off('bounds', this.updateBounds);
},
methods: {
updateValues(datum) {
this.timestamp = this.formats[this.timestampKey].format(datum);
this.value = this.formats[this.valueKey].format(datum);
let newTimestamp = this.formats[this.timestampKey].parse(datum),
update = false, limit;
var limit = this.limitEvaluator.evaluate(datum, this.valueMetadata);
if(this.inBounds(newTimestamp)) {
// if timestamp is set, need tocheck, else update
if(this.timestamp !== '---') {
let existingTimestamp = this.formats[this.timestampKey].parse(this.timestamp);
// if existing is in bounds, need to check, if not update
if(this.inBounds(existingTimestamp)) {
// race condition check
if(newTimestamp >= existingTimestamp) {
update = true;
}
} else {
update = true;
}
} else {
update = true;
}
if(update) {
this.timestamp = this.formats[this.timestampKey].format(datum);
this.value = this.formats[this.valueKey].format(datum);
limit = this.limitEvaluator.evaluate(datum, this.valueMetadata);
if (limit) {
this.valueClass = limit.cssClass;
} else {
this.valueClass = '';
}
}
if (limit) {
this.valueClass = limit.cssClass;
} else {
this.valueClass = '';
}
},
requestHistory() {
this.openmct
.telemetry
.request(this.domainObject, {
start: this.bounds.start,
end: this.bounds.end,
strategy: 'latest'
})
.then((array) => this.updateValues(array[array.length - 1]));
},
updateName(name) {
this.name = name;
},
updateBounds(bounds, isTick) {
this.bounds = bounds;
if(!isTick) {
this.requestHistory();
}
},
inBounds(timestamp) {
return timestamp >= this.bounds.start && timestamp <= this.bounds.end;
},
updateTimeSystem(timeSystem) {
this.value = '---';
this.timestamp = '---';
this.valueClass = '';
this.timestampKey = timeSystem.key;
this.openmct
.telemetry
.request(this.domainObject, {strategy: 'latest'})
.then((array) => this.updateValues(array[array.length - 1]));
},
showContextMenu(event) {
this.openmct.contextMenu._showContextMenuForObjectPath(this.currentObjectPath, event.x, event.y, CONTEXT_MENU_ACTIONS);

View File

@@ -66,7 +66,7 @@ export default {
data() {
return {
autoScroll: true,
date: '',
bounds: {},
filters : {
brightness: 100,
contrast: 100
@@ -78,19 +78,37 @@ export default {
imageHistory: [],
imageUrl: '',
isPaused: false,
metadata: {},
requestCount: 0,
timeFormat: ''
}
},
mounted() {
// set
this.keystring = this.openmct.objects.makeKeyString(this.domainObject.identifier);
this.subscribe(this.domainObject);
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
this.imageFormat = this.openmct.telemetry.getValueFormatter(this.metadata.valuesForHints(['image'])[0]);
// initialize
this.bounds = this.openmct.time.bounds();
this.timeKey = this.openmct.time.timeSystem().key;
this.timeFormat = this.getTimeFormat();
// listen
this.openmct.time.on('bounds', this.boundsChange);
this.openmct.time.on('timeSystem', this.timeSystemChange);
// kickoff
this.subscribe();
this.requestHistory(false);
},
updated() {
this.scrollToRight();
},
beforeDestroy() {
this.stopListening();
if (this.unsubscribe) {
this.unsubscribe();
delete this.unsubscribe;
}
this.openmct.time.off('bounds', this.boundsChange);
this.openmct.time.off('timeSystem', this.timeSystemChange);
},
methods: {
datumMatchesMostRecent(datum) {
@@ -115,6 +133,15 @@ export default {
this.timeFormat.format(datum) :
this.time;
},
getTimeFormat() {
let tf = false;
try {
tf = this.openmct.telemetry.getValueFormatter(this.metadata.value(this.timeKey));
} catch(e) {
alert('Issue receiving time format.');
}
return tf;
},
handleScroll() {
const thumbsWrapper = this.$refs.thumbsWrapper
if (!thumbsWrapper) {
@@ -147,21 +174,6 @@ export default {
return this.isPaused;
},
requestHistory(bounds) {
this.requestCount++;
this.imageHistory = [];
const requestId = this.requestCount;
this.openmct.telemetry
.request(this.domainObject, bounds)
.then((values = []) => {
if (this.requestCount > requestId) {
return Promise.resolve('Stale request');
}
values.forEach(this.updateHistory);
this.updateValues(values[values.length - 1]);
});
},
scrollToRight() {
if (this.isPaused || !this.$refs.thumbsWrapper || !this.autoScroll) {
return;
@@ -188,28 +200,44 @@ export default {
image.selected = true;
}
},
stopListening() {
if (this.unsubscribe) {
this.unsubscribe();
delete this.unsubscribe;
boundsChange(bounds, isTick) {
this.bounds = bounds;
this.requestHistory(isTick);
},
requestHistory(isTick) {
if(!isTick) {
this.requestCount++;
const requestId = this.requestCount;
this.imageHistory = [];
this.openmct.telemetry
.request(this.domainObject, this.bounds)
.then((values = []) => {
if (this.requestCount > requestId) {
return Promise.resolve('Stale request');
}
if(this.timeFormat) {
values.forEach(this.updateHistory);
this.updateValues(values[values.length - 1]);
}
});
}
},
subscribe(domainObject) {
this.date = ''
this.imageUrl = '';
this.openmct.objects.get(this.keystring)
.then((object) => {
const metadata = this.openmct.telemetry.getMetadata(this.domainObject);
this.timeKey = this.openmct.time.timeSystem().key;
this.timeFormat = this.openmct.telemetry.getValueFormatter(metadata.value(this.timeKey));
this.imageFormat = this.openmct.telemetry.getValueFormatter(metadata.valuesForHints(['image'])[0]);
this.unsubscribe = this.openmct.telemetry
.subscribe(this.domainObject, (datum) => {
timeSystemChange(system) {
// reset timesystem dependent variables
this.timeKey = system.key;
this.timeFormat = this.getTimeFormat();
},
subscribe() {
this.unsubscribe = this.openmct.telemetry
.subscribe(this.domainObject, (datum) => {
if(this.timeFormat) {
let parsedTimestamp = this.timeFormat.parse(datum[this.timeKey]);
if(parsedTimestamp >= this.bounds.start && parsedTimestamp <= this.bounds.end) {
this.updateHistory(datum);
this.updateValues(datum);
});
this.requestHistory(this.openmct.time.bounds());
}
}
});
},
unselectAllImages() {