mirror of
https://github.com/nasa/openmct.git
synced 2025-05-28 21:24:20 +00:00
[LADTable] Lad bounds listener FIX (#3114)
* 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
7f8764560b
commit
22ca339fb9
@ -28,6 +28,16 @@ define([
|
|||||||
domain: 2
|
domain: 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// Need to enable "LocalTimeSystem" plugin to make use of this
|
||||||
|
// {
|
||||||
|
// key: "local",
|
||||||
|
// name: "Time",
|
||||||
|
// format: "local-format",
|
||||||
|
// source: "utc",
|
||||||
|
// hints: {
|
||||||
|
// domain: 3
|
||||||
|
// }
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
key: "sin",
|
key: "sin",
|
||||||
name: "Sine",
|
name: "Sine",
|
||||||
@ -61,6 +71,15 @@ define([
|
|||||||
domain: 1
|
domain: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "local",
|
||||||
|
name: "Time",
|
||||||
|
format: "utc",
|
||||||
|
source: "utc",
|
||||||
|
hints: {
|
||||||
|
domain: 2
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "state",
|
key: "state",
|
||||||
source: "value",
|
source: "value",
|
||||||
|
@ -64,7 +64,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
formattedTimestamp() {
|
formattedTimestamp() {
|
||||||
return this.timestamp !== undefined ? this.formats[this.timestampKey].format(this.timestamp) : '---';
|
return this.timestamp !== undefined ? this.getFormattedTimestamp(this.timestamp) : '---';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -110,11 +110,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateValues(datum) {
|
updateValues(datum) {
|
||||||
let newTimestamp = this.formats[this.timestampKey].parse(datum),
|
let newTimestamp = this.getParsedTimestamp(datum),
|
||||||
limit;
|
limit;
|
||||||
|
|
||||||
if(this.shouldUpdate(newTimestamp)) {
|
if(this.shouldUpdate(newTimestamp)) {
|
||||||
this.timestamp = this.formats[this.timestampKey].parse(datum);
|
this.timestamp = newTimestamp;
|
||||||
this.value = this.formats[this.valueKey].format(datum);
|
this.value = this.formats[this.valueKey].format(datum);
|
||||||
limit = this.limitEvaluator.evaluate(datum, this.valueMetadata);
|
limit = this.limitEvaluator.evaluate(datum, this.valueMetadata);
|
||||||
if (limit) {
|
if (limit) {
|
||||||
@ -125,9 +125,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
shouldUpdate(newTimestamp) {
|
shouldUpdate(newTimestamp) {
|
||||||
return (this.timestamp === undefined) ||
|
let newTimestampInBounds = this.inBounds(newTimestamp),
|
||||||
(this.inBounds(newTimestamp) &&
|
noExistingTimestamp = this.timestamp === undefined,
|
||||||
newTimestamp > this.timestamp);
|
newTimestampIsLatest = newTimestamp > this.timestamp;
|
||||||
|
|
||||||
|
return newTimestampInBounds &&
|
||||||
|
(noExistingTimestamp || newTimestampIsLatest);
|
||||||
},
|
},
|
||||||
requestHistory() {
|
requestHistory() {
|
||||||
this.openmct
|
this.openmct
|
||||||
@ -146,6 +149,7 @@ export default {
|
|||||||
updateBounds(bounds, isTick) {
|
updateBounds(bounds, isTick) {
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
if(!isTick) {
|
if(!isTick) {
|
||||||
|
this.resetValues();
|
||||||
this.requestHistory();
|
this.requestHistory();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -153,13 +157,34 @@ export default {
|
|||||||
return timestamp >= this.bounds.start && timestamp <= this.bounds.end;
|
return timestamp >= this.bounds.start && timestamp <= this.bounds.end;
|
||||||
},
|
},
|
||||||
updateTimeSystem(timeSystem) {
|
updateTimeSystem(timeSystem) {
|
||||||
this.value = '---';
|
this.resetValues();
|
||||||
this.timestamp = '---';
|
|
||||||
this.valueClass = '';
|
|
||||||
this.timestampKey = timeSystem.key;
|
this.timestampKey = timeSystem.key;
|
||||||
},
|
},
|
||||||
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);
|
||||||
|
},
|
||||||
|
resetValues() {
|
||||||
|
this.value = '---';
|
||||||
|
this.timestamp = undefined;
|
||||||
|
this.valueClass = '';
|
||||||
|
},
|
||||||
|
getParsedTimestamp(timestamp) {
|
||||||
|
if(this.timeSystemFormat()) {
|
||||||
|
return this.formats[this.timestampKey].parse(timestamp);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getFormattedTimestamp(timestamp) {
|
||||||
|
if(this.timeSystemFormat()) {
|
||||||
|
return this.formats[this.timestampKey].format(timestamp);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
timeSystemFormat() {
|
||||||
|
if(this.formats[this.timestampKey]) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
console.warn(`No formatter for ${this.timestampKey} time system for ${this.domainObject.name}.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user