fix timing issue (#5896)

This commit is contained in:
Scott Bell 2022-10-21 20:19:41 +02:00 committed by GitHub
parent e4a36532e7
commit bd1e869f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 45 deletions

View File

@ -382,7 +382,7 @@ export default {
makeLimitLines(series) { makeLimitLines(series) {
this.clearLimitLines(series); this.clearLimitLines(series);
if (!series.get('limitLines')) { if (!series || !series.get('limitLines')) {
return; return;
} }

View File

@ -151,16 +151,6 @@ export default class PlotSeries extends Model {
this.limitEvaluator = this.openmct.telemetry.limitEvaluator(options.domainObject); this.limitEvaluator = this.openmct.telemetry.limitEvaluator(options.domainObject);
this.limitDefinition = this.openmct.telemetry.limitDefinition(options.domainObject); this.limitDefinition = this.openmct.telemetry.limitDefinition(options.domainObject);
this.limits = []; this.limits = [];
this.limitDefinition.limits().then(response => {
this.limits = [];
if (response) {
this.limits = response;
}
this.emit('limits', this);
});
this.openmct.time.on('bounds', this.updateLimits); this.openmct.time.on('bounds', this.updateLimits);
this.removeMutationListener = this.openmct.objects.observe( this.removeMutationListener = this.openmct.objects.observe(
this.domainObject, this.domainObject,
@ -176,15 +166,6 @@ export default class PlotSeries extends Model {
this.emit('limitBounds', bounds); this.emit('limitBounds', bounds);
} }
locateOldObject(oldStyleParent) {
return oldStyleParent.useCapability('composition')
.then(function (children) {
this.oldObject = children
.filter(function (child) {
return child.getId() === this.keyString;
}, this)[0];
}.bind(this));
}
/** /**
* Fetch historical data and establish a realtime subscription. Returns * Fetch historical data and establish a realtime subscription. Returns
* a promise that is resolved when all connections have been successfully * a promise that is resolved when all connections have been successfully
@ -192,7 +173,7 @@ export default class PlotSeries extends Model {
* *
* @returns {Promise} * @returns {Promise}
*/ */
fetch(options) { async fetch(options) {
let strategy; let strategy;
if (this.model.interpolate !== 'none') { if (this.model.interpolate !== 'none') {
@ -217,23 +198,19 @@ export default class PlotSeries extends Model {
); );
} }
/* eslint-disable you-dont-need-lodash-underscore/concat */ try {
return this.openmct const points = await this.openmct.telemetry.request(this.domainObject, options);
.telemetry const data = this.getSeriesData();
.request(this.domainObject, options) // eslint-disable-next-line you-dont-need-lodash-underscore/concat
.then((points) => { const newPoints = _(data)
const data = this.getSeriesData(); .concat(points)
const newPoints = _(data) .sortBy(this.getXVal)
.concat(points) .uniq(true, point => [this.getXVal(point), this.getYVal(point)].join())
.sortBy(this.getXVal) .value();
.uniq(true, point => [this.getXVal(point), this.getYVal(point)].join()) this.reset(newPoints);
.value(); } catch (error) {
this.reset(newPoints); console.warn('Error fetching data', error);
}) }
.catch((error) => {
console.warn('Error fetching data', error);
});
/* eslint-enable you-dont-need-lodash-underscore/concat */
} }
updateName(name) { updateName(name) {
@ -334,16 +311,19 @@ export default class PlotSeries extends Model {
* Override this to implement plot series loading functionality. Must return * Override this to implement plot series loading functionality. Must return
* a promise that is resolved when loading is completed. * a promise that is resolved when loading is completed.
* *
* @private
* @returns {Promise} * @returns {Promise}
*/ */
load(options) { async load(options) {
return this.fetch(options) await this.fetch(options);
.then(function (res) { this.emit('load');
this.emit('load'); const limitsResponse = await this.limitDefinition.limits();
this.limits = [];
if (limitsResponse) {
this.limits = limitsResponse;
}
return res; this.emit('limits', this);
}.bind(this)); this.emit('change:limitLines', this);
} }
/** /**