mirror of
https://github.com/nasa/openmct.git
synced 2025-03-01 12:22:42 +00:00
request LAD for conditions provides telemetry
This commit is contained in:
parent
cf9336dae9
commit
4a5e106709
@ -204,9 +204,8 @@ export default class ConditionClass extends EventEmitter {
|
||||
}
|
||||
|
||||
requestLADConditionResult() {
|
||||
const criteriaResults = this.criteria.map(criterion =>
|
||||
criterion.requestLAD()
|
||||
);
|
||||
const criteriaResults = this.criteria
|
||||
.map(criterion => criterion.requestLAD());
|
||||
|
||||
return Promise.all(criteriaResults)
|
||||
.then(results => {
|
||||
@ -214,8 +213,12 @@ export default class ConditionClass extends EventEmitter {
|
||||
this.updateCriteriaResults(result);
|
||||
this.latestTimestamp = this.getLatestTimestamp(this.latestTimestamp, result)
|
||||
});
|
||||
console.log(Object.assign({}, this.latestTimestamp, { result: this.result }));
|
||||
return Object.assign({}, this.latestTimestamp, { result: this.result });
|
||||
this.evaluate();
|
||||
|
||||
return {
|
||||
id: this.id,
|
||||
data: Object.assign({}, this.latestTimestamp, { result: this.result })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,9 @@ export default class ConditionManager extends EventEmitter {
|
||||
this.timeAPI = this.openmct.time;
|
||||
this.latestTimestamp = {};
|
||||
this.instantiate = this.openmct.$injector.get('instantiate');
|
||||
this.loaded = undefined;
|
||||
this.conditionCollection = [];
|
||||
this.composition = this.openmct.composition.get(domainObject);
|
||||
this.loaded = this.composition.load();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
@ -45,7 +46,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
this.conditionResults = {};
|
||||
|
||||
this.openmct.objects.get(this.domainObject.identifier)
|
||||
.then((obj) => {
|
||||
.then((obj) => {
|
||||
this.observeForChanges(obj);
|
||||
if (this.domainObject.configuration.conditionCollection.length) {
|
||||
this.domainObject.configuration.conditionCollection.forEach((conditionConfigurationId, index) => {
|
||||
@ -225,7 +226,6 @@ export default class ConditionManager extends EventEmitter {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return currentConditionIdentifier;
|
||||
}
|
||||
|
||||
@ -247,7 +247,6 @@ export default class ConditionManager extends EventEmitter {
|
||||
this.updateConditionResults(resultObj);
|
||||
|
||||
const currentConditionIdentifier = this.getCurrentConditionId();
|
||||
|
||||
this.openmct.objects.get(currentConditionIdentifier).then((obj) => {
|
||||
this.emit('conditionSetResultUpdated',
|
||||
Object.assign(
|
||||
@ -277,41 +276,36 @@ export default class ConditionManager extends EventEmitter {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
const conditionResults = [];
|
||||
return this.load().then(() => {
|
||||
if (this.conditionCollection && this.conditionCollection.length === 1) {
|
||||
return Promise([]);
|
||||
}
|
||||
|
||||
this.domainObject.configuration.conditionCollection.forEach((conditionId, index) => {
|
||||
this.openmct.objects.get(conditionId)
|
||||
.then(conditionConfiguration => {
|
||||
let condition = new Condition(conditionConfiguration, this.openmct);
|
||||
if (index !== undefined) {
|
||||
this.conditionCollection.splice(index + 1, 0, condition);
|
||||
} else {
|
||||
this.conditionCollection.unshift(condition);
|
||||
}
|
||||
let ladConditionResults = [];
|
||||
|
||||
conditionResults.push(
|
||||
condition.requestLADConditionResult()
|
||||
);
|
||||
// do not request LAD for default collection, which is always last
|
||||
for (let i = 0; i < this.conditionCollection.length - 1; i++) {
|
||||
ladConditionResults.push(this.conditionCollection[i].requestLADConditionResult());
|
||||
}
|
||||
return Promise.all(ladConditionResults)
|
||||
.then((results) => {
|
||||
results.forEach(resultObj => { this.updateConditionResults(resultObj); });
|
||||
const currentConditionIdentifier = this.getCurrentConditionId();
|
||||
return this.openmct.objects.get(currentConditionIdentifier)
|
||||
.then(obj => {
|
||||
// uncomment to see output of lad request (before subscriptions kick in)
|
||||
// console.log(obj.configuration.output);
|
||||
return Object.assign(
|
||||
{
|
||||
output: obj.configuration.output,
|
||||
id: this.domainObject.identifier,
|
||||
conditionId: currentConditionIdentifier
|
||||
},
|
||||
this.latestTimestamp
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(conditionResults)
|
||||
.then((results) => {
|
||||
results.forEach(resultObj => { this.updateConditionResults(resultObj); });
|
||||
const currentConditionIdentifier = this.getCurrentConditionId();
|
||||
|
||||
this.openmct.objects.get(currentConditionIdentifier).then((obj) => {
|
||||
return Object.assign(
|
||||
{
|
||||
output: obj.configuration.output,
|
||||
id: this.domainObject.identifier,
|
||||
conditionId: currentConditionIdentifier
|
||||
},
|
||||
this.latestTimestamp
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
persist() {
|
||||
|
@ -20,16 +20,17 @@ export default class ConditionSetTelemetryProvider {
|
||||
request(domainObject, options) {
|
||||
const conditionManager = new ConditionManager(domainObject, this.openmct);
|
||||
|
||||
return conditionManager.requestLADConditionSetOutput();
|
||||
return conditionManager.requestLADConditionSetOutput()
|
||||
.then(latestOutput => { return latestOutput ? [latestOutput] : []; });
|
||||
}
|
||||
|
||||
subscribe(domainObject, callback) {
|
||||
// const conditionManager = new ConditionManager(domainObject, this.openmct);
|
||||
// conditionManager.on('conditionSetResultUpdated', callback);
|
||||
const conditionManager = new ConditionManager(domainObject, this.openmct);
|
||||
conditionManager.on('conditionSetResultUpdated', callback);
|
||||
|
||||
// return function unsubscribe() {
|
||||
// conditionManager.off('conditionSetResultUpdated');
|
||||
// conditionManager.destroy();
|
||||
// }
|
||||
return function unsubscribe() {
|
||||
conditionManager.off('conditionSetResultUpdated');
|
||||
conditionManager.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ export default {
|
||||
this.openmct.telemetry
|
||||
.request(this.domainObject)
|
||||
.then(output => {
|
||||
this.updateCurrentOutput(output);
|
||||
this.updateCurrentOutput(output[0]);
|
||||
});
|
||||
this.stopProvidingTelemetry = this.openmct.telemetry
|
||||
.subscribe(this.domainObject, output => { this.updateCurrentOutput(output); });
|
||||
|
@ -66,7 +66,6 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
datum[timeSystem.key] = data[timeSystem.key]
|
||||
});
|
||||
}
|
||||
|
||||
return datum;
|
||||
}
|
||||
|
||||
@ -129,7 +128,10 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
options
|
||||
).then(results => {
|
||||
const latestDatum = results.length ? results[results.length - 1] : {};
|
||||
return this.formatData(latestDatum);
|
||||
return {
|
||||
id: this.id,
|
||||
data: this.formatData(latestDatum)
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user