mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
LAD views should respond to conductor bounds changes (#2946)
Added bounds listener, moved history request to function, checking for race conditions Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
parent
bab53ad9bd
commit
357b25a76b
@ -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
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
* Administration. All rights reserved.
|
* Administration. All rights reserved.
|
||||||
*
|
*
|
||||||
@ -24,10 +24,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<tr @contextmenu.prevent="showContextMenu">
|
<tr @contextmenu.prevent="showContextMenu">
|
||||||
<td>{{ name }}</td>
|
<td>{{ name }}</td>
|
||||||
<td>{{ timestamp }}</td>
|
<td>{{ formattedTimestamp }}</td>
|
||||||
<td :class="valueClass">
|
<td :class="valueClass">{{ value }}</td>
|
||||||
{{ value }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -52,16 +50,22 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: this.domainObject.name,
|
name: this.domainObject.name,
|
||||||
timestamp: '---',
|
timestamp: undefined,
|
||||||
value: '---',
|
value: '---',
|
||||||
valueClass: '',
|
valueClass: '',
|
||||||
currentObjectPath
|
currentObjectPath
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
formattedTimestamp() {
|
||||||
|
return this.timestamp !== undefined ? this.formats[this.timestampKey].format(this.timestamp) : '---';
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
|
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
|
||||||
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
|
this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
|
||||||
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||||
|
this.bounds = this.openmct.time.bounds();
|
||||||
|
|
||||||
this.limitEvaluator = this.openmct
|
this.limitEvaluator = this.openmct
|
||||||
.telemetry
|
.telemetry
|
||||||
@ -76,6 +80,7 @@ export default {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.openmct.time.on('timeSystem', this.updateTimeSystem);
|
this.openmct.time.on('timeSystem', this.updateTimeSystem);
|
||||||
|
this.openmct.time.on('bounds', this.updateBounds);
|
||||||
|
|
||||||
this.timestampKey = this.openmct.time.timeSystem().key;
|
this.timestampKey = this.openmct.time.timeSystem().key;
|
||||||
|
|
||||||
@ -89,43 +94,63 @@ export default {
|
|||||||
.telemetry
|
.telemetry
|
||||||
.subscribe(this.domainObject, this.updateValues);
|
.subscribe(this.domainObject, this.updateValues);
|
||||||
|
|
||||||
this.openmct
|
this.requestHistory();
|
||||||
.telemetry
|
|
||||||
.request(this.domainObject, {strategy: 'latest'})
|
|
||||||
.then((array) => this.updateValues(array[array.length - 1]));
|
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.stopWatchingMutation();
|
this.stopWatchingMutation();
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
this.openmct.off('timeSystem', this.updateTimeSystem);
|
this.openmct.time.off('timeSystem', this.updateTimeSystem);
|
||||||
|
this.openmct.time.off('bounds', this.updateBounds);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateValues(datum) {
|
updateValues(datum) {
|
||||||
this.timestamp = this.formats[this.timestampKey].format(datum);
|
let newTimestamp = this.formats[this.timestampKey].parse(datum),
|
||||||
|
limit;
|
||||||
|
|
||||||
|
if(this.shouldUpdate(newTimestamp)) {
|
||||||
|
this.timestamp = this.formats[this.timestampKey].parse(datum);
|
||||||
this.value = this.formats[this.valueKey].format(datum);
|
this.value = this.formats[this.valueKey].format(datum);
|
||||||
|
limit = this.limitEvaluator.evaluate(datum, this.valueMetadata);
|
||||||
var limit = this.limitEvaluator.evaluate(datum, this.valueMetadata);
|
|
||||||
|
|
||||||
if (limit) {
|
if (limit) {
|
||||||
this.valueClass = limit.cssClass;
|
this.valueClass = limit.cssClass;
|
||||||
} else {
|
} else {
|
||||||
this.valueClass = '';
|
this.valueClass = '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
shouldUpdate(newTimestamp) {
|
||||||
|
return (this.timestamp === undefined) ||
|
||||||
|
(this.inBounds(newTimestamp) &&
|
||||||
|
newTimestamp > this.timestamp);
|
||||||
|
},
|
||||||
|
requestHistory() {
|
||||||
|
this.openmct
|
||||||
|
.telemetry
|
||||||
|
.request(this.domainObject, {
|
||||||
|
start: this.bounds.start,
|
||||||
|
end: this.bounds.end,
|
||||||
|
size: 1,
|
||||||
|
strategy: 'latest'
|
||||||
|
})
|
||||||
|
.then((array) => this.updateValues(array[array.length - 1]));
|
||||||
},
|
},
|
||||||
updateName(name) {
|
updateName(name) {
|
||||||
this.name = 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) {
|
updateTimeSystem(timeSystem) {
|
||||||
this.value = '---';
|
this.value = '---';
|
||||||
this.timestamp = '---';
|
this.timestamp = '---';
|
||||||
this.valueClass = '';
|
this.valueClass = '';
|
||||||
this.timestampKey = timeSystem.key;
|
this.timestampKey = timeSystem.key;
|
||||||
|
|
||||||
this.openmct
|
|
||||||
.telemetry
|
|
||||||
.request(this.domainObject, {strategy: 'latest'})
|
|
||||||
.then((array) => this.updateValues(array[array.length - 1]));
|
|
||||||
|
|
||||||
},
|
},
|
||||||
showContextMenu(event) {
|
showContextMenu(event) {
|
||||||
this.openmct.contextMenu._showContextMenuForObjectPath(this.currentObjectPath, event.x, event.y, CONTEXT_MENU_ACTIONS);
|
this.openmct.contextMenu._showContextMenuForObjectPath(this.currentObjectPath, event.x, event.y, CONTEXT_MENU_ACTIONS);
|
||||||
|
Loading…
Reference in New Issue
Block a user