WIP add support for LAD request

This commit is contained in:
David Tsay 2020-03-05 12:14:27 -08:00
parent 5b00246cc0
commit 3e6509ce6f
5 changed files with 66 additions and 5 deletions

View File

@ -189,6 +189,10 @@ export default class ConditionClass extends EventEmitter {
}
}
handleLADCriterionResult(eventData) {
}
handleCriterionResult(eventData) {
const id = eventData.id;
@ -199,6 +203,13 @@ export default class ConditionClass extends EventEmitter {
this.handleConditionUpdated(eventData.data);
}
requestLatest() {
const promises =
Promise.all(promises)
.then()
}
subscribe() {
// TODO it looks like on any single criterion update subscriptions fire for all criteria
this.criteria.forEach((criterion) => {

View File

@ -251,6 +251,10 @@ export default class ConditionManager extends EventEmitter {
});
}
requestLatest() {
}
persist() {
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.domainObject.configuration.conditionCollection);
}

View File

@ -9,14 +9,23 @@ export default class ConditionSetTelemetryProvider {
return domainObject.type === 'conditionSet';
}
supportsRequest(domainObject, options) {
return false;
supportsRequest(domainObject) {
return domainObject.type === 'conditionSet';
}
supportsSubscribe(domainObject) {
return domainObject.type === 'conditionSet';
}
request(domainObject, options) {
let conditionManager = new ConditionManager(domainObject, this.openmct);
return conditionManager.requestLatest()
.then(latestDatum => {
return latestDatum ? [latestDatum] : [];
});
// return Promise.resolve([]);
}
subscribe(domainObject, callback) {
let conditionManager = new ConditionManager(domainObject, this.openmct);
conditionManager.on('conditionSetResultUpdated', callback);

View File

@ -74,6 +74,11 @@ export default {
this.currentConditionOutput = currentConditionResult.output;
},
provideTelemetry() {
this.openmct.telemetry
.request(this.domainObject)
.then(output => {
this.updateCurrentOutput(output);
});
this.stopProvidingTelemetry = this.openmct.telemetry
.subscribe(this.domainObject, output => { this.updateCurrentOutput(output); });
}

View File

@ -55,10 +55,11 @@ export default class TelemetryCriterion extends EventEmitter {
this.emitEvent('criterionUpdated', this);
}
handleSubscription(data) {
formatData(data) {
const datum = {
result: this.computeResult(data)
};
}
if (data) {
// TODO check back to see if we should format times here
this.timeAPI.getAllTimeSystems().forEach(timeSystem => {
@ -66,7 +67,15 @@ export default class TelemetryCriterion extends EventEmitter {
});
}
this.emitEvent('criterionResultUpdated', datum);
return datum;
}
handleRequest(data) {
this.emitEvent('criterionLADResultUpdated', this.formatData(data));
}
handleSubscription(data) {
this.emitEvent('criterionResultUpdated', this.formatData(data));
}
findOperation(operation) {
@ -105,6 +114,29 @@ export default class TelemetryCriterion extends EventEmitter {
return this.telemetryObject && this.metadata && this.operation;
}
requestLatest(options) {
if (this.isValid()) {
options = Object.assign({},
options,
{
strategy: 'latest',
size: 1
}
);
this.telemetryAPI.request(
this.telemetryObject,
options
).then(results => {
if(results && results.length) {
results[results.length - 1]
}
})
} else {
// default
}
}
/**
* Subscribes to the telemetry object and returns an unsubscribe function
* If the telemetry is not valid, returns nothing