mirror of
https://github.com/nasa/openmct.git
synced 2025-03-01 12:22:42 +00:00
WIP add support for LAD request
This commit is contained in:
parent
5b00246cc0
commit
3e6509ce6f
@ -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) => {
|
||||
|
@ -251,6 +251,10 @@ export default class ConditionManager extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
requestLatest() {
|
||||
|
||||
}
|
||||
|
||||
persist() {
|
||||
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.domainObject.configuration.conditionCollection);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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); });
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user