mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 03:06:54 +00:00
[Conditionals] evaluation fixes (#2981)
* change single output to state and value * do not send telemetryObjects to telemetry api request cal * normalize data on requests Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
This commit is contained in:
parent
cb5d47f66f
commit
96eb6d6b74
@ -204,7 +204,7 @@ export default class ConditionClass extends EventEmitter {
|
|||||||
let latestTimestamp;
|
let latestTimestamp;
|
||||||
let criteriaResults = {};
|
let criteriaResults = {};
|
||||||
const criteriaRequests = this.criteria
|
const criteriaRequests = this.criteria
|
||||||
.map(criterion => criterion.requestLAD({telemetryObjects: this.conditionManager.telemetryObjects}));
|
.map(criterion => criterion.requestLAD(this.conditionManager.telemetryObjects));
|
||||||
|
|
||||||
return Promise.all(criteriaRequests)
|
return Promise.all(criteriaRequests)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
|
@ -55,7 +55,7 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
this.telemetryObjects[id] = Object.assign({}, endpoint, {telemetryMetaData: this.openmct.telemetry.getMetadata(endpoint).valueMetadatas});
|
this.telemetryObjects[id] = Object.assign({}, endpoint, {telemetryMetaData: this.openmct.telemetry.getMetadata(endpoint).valueMetadatas});
|
||||||
this.subscriptions[id] = this.openmct.telemetry.subscribe(
|
this.subscriptions[id] = this.openmct.telemetry.subscribe(
|
||||||
endpoint,
|
endpoint,
|
||||||
this.telemetryReceived.bind(this, id)
|
this.telemetryReceived.bind(this, endpoint)
|
||||||
);
|
);
|
||||||
this.updateConditionTelemetry();
|
this.updateConditionTelemetry();
|
||||||
}
|
}
|
||||||
@ -272,7 +272,9 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isTelemetryUsed(id) {
|
isTelemetryUsed(endpoint) {
|
||||||
|
const id = this.openmct.objects.makeKeyString(endpoint.identifier);
|
||||||
|
|
||||||
for(const condition of this.conditionClassCollection) {
|
for(const condition of this.conditionClassCollection) {
|
||||||
if (condition.isTelemetryUsed(id)) {
|
if (condition.isTelemetryUsed(id)) {
|
||||||
return true;
|
return true;
|
||||||
@ -282,12 +284,12 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
telemetryReceived(id, datum) {
|
telemetryReceived(endpoint, datum) {
|
||||||
if (!this.isTelemetryUsed(id)) {
|
if (!this.isTelemetryUsed(endpoint)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedDatum = this.createNormalizedDatum(datum, id);
|
const normalizedDatum = this.createNormalizedDatum(datum, endpoint);
|
||||||
const timeSystemKey = this.openmct.time.timeSystem().key;
|
const timeSystemKey = this.openmct.time.timeSystem().key;
|
||||||
let timestamp = {};
|
let timestamp = {};
|
||||||
timestamp[timeSystemKey] = normalizedDatum[timeSystemKey];
|
timestamp[timeSystemKey] = normalizedDatum[timeSystemKey];
|
||||||
@ -321,8 +323,11 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
createNormalizedDatum(telemetryDatum, id) {
|
createNormalizedDatum(telemetryDatum, endpoint) {
|
||||||
const normalizedDatum = Object.values(this.telemetryObjects[id].telemetryMetaData).reduce((datum, metadatum) => {
|
const id = this.openmct.objects.makeKeyString(endpoint.identifier);
|
||||||
|
const metadata = this.openmct.telemetry.getMetadata(endpoint).valueMetadatas;
|
||||||
|
|
||||||
|
const normalizedDatum = Object.values(metadata).reduce((datum, metadatum) => {
|
||||||
const testValue = this.getTestData(metadatum);
|
const testValue = this.getTestData(metadatum);
|
||||||
const formatter = this.openmct.telemetry.getValueFormatter(metadatum);
|
const formatter = this.openmct.telemetry.getValueFormatter(metadatum);
|
||||||
datum[metadatum.key] = testValue !== undefined ? formatter.parse(testValue) : formatter.parse(telemetryDatum[metadatum.source]);
|
datum[metadatum.key] = testValue !== undefined ? formatter.parse(testValue) : formatter.parse(telemetryDatum[metadatum.source]);
|
||||||
|
@ -54,13 +54,22 @@ export default class ConditionSetMetadataProvider {
|
|||||||
return {
|
return {
|
||||||
values: this.getDomains().concat([
|
values: this.getDomains().concat([
|
||||||
{
|
{
|
||||||
name: 'Output',
|
key: "state",
|
||||||
key: 'output',
|
source: "output",
|
||||||
format: 'enum',
|
name: "State",
|
||||||
|
format: "enum",
|
||||||
enumerations: enumerations,
|
enumerations: enumerations,
|
||||||
hints: {
|
hints: {
|
||||||
range: 1
|
range: 1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "output",
|
||||||
|
name: "Value",
|
||||||
|
format: "string",
|
||||||
|
hints: {
|
||||||
|
range: 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
};
|
};
|
||||||
|
@ -108,23 +108,20 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry);
|
this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLAD(options) {
|
requestLAD(telemetryObjects) {
|
||||||
options = Object.assign({},
|
const options = {
|
||||||
options,
|
|
||||||
{
|
|
||||||
strategy: 'latest',
|
strategy: 'latest',
|
||||||
size: 1
|
size: 1
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
|
||||||
if (!this.isValid()) {
|
if (!this.isValid()) {
|
||||||
return this.formatData({}, options.telemetryObjects);
|
return this.formatData({}, telemetryObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
let keys = Object.keys(Object.assign({}, options.telemetryObjects));
|
let keys = Object.keys(Object.assign({}, telemetryObjects));
|
||||||
const telemetryRequests = keys
|
const telemetryRequests = keys
|
||||||
.map(key => this.openmct.telemetry.request(
|
.map(key => this.openmct.telemetry.request(
|
||||||
options.telemetryObjects[key],
|
telemetryObjects[key],
|
||||||
options
|
options
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -138,12 +135,13 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
|||||||
telemetryRequestsResults.forEach((results, index) => {
|
telemetryRequestsResults.forEach((results, index) => {
|
||||||
const latestDatum = results.length ? results[results.length - 1] : {};
|
const latestDatum = results.length ? results[results.length - 1] : {};
|
||||||
const datumId = keys[index];
|
const datumId = keys[index];
|
||||||
|
const normalizedDatum = this.createNormalizedDatum(latestDatum, telemetryObjects[datumId]);
|
||||||
|
|
||||||
telemetryDataCache[datumId] = this.computeResult(latestDatum);
|
telemetryDataCache[datumId] = this.computeResult(normalizedDatum);
|
||||||
|
|
||||||
latestTimestamp = getLatestTimestamp(
|
latestTimestamp = getLatestTimestamp(
|
||||||
latestTimestamp,
|
latestTimestamp,
|
||||||
latestDatum,
|
normalizedDatum,
|
||||||
timeSystems,
|
timeSystems,
|
||||||
timeSystem
|
timeSystem
|
||||||
);
|
);
|
||||||
|
@ -61,6 +61,21 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
this.telemetryObject = telemetryObjects[this.telemetryObjectIdAsString];
|
this.telemetryObject = telemetryObjects[this.telemetryObjectIdAsString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNormalizedDatum(telemetryDatum, endpoint) {
|
||||||
|
const id = this.openmct.objects.makeKeyString(endpoint.identifier);
|
||||||
|
const metadata = this.openmct.telemetry.getMetadata(endpoint).valueMetadatas;
|
||||||
|
|
||||||
|
const normalizedDatum = Object.values(metadata).reduce((datum, metadatum) => {
|
||||||
|
const formatter = this.openmct.telemetry.getValueFormatter(metadatum);
|
||||||
|
datum[metadatum.key] = formatter.parse(telemetryDatum[metadatum.source]);
|
||||||
|
return datum;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
normalizedDatum.id = id;
|
||||||
|
|
||||||
|
return normalizedDatum;
|
||||||
|
}
|
||||||
|
|
||||||
formatData(data) {
|
formatData(data) {
|
||||||
const datum = {
|
const datum = {
|
||||||
result: this.computeResult(data)
|
result: this.computeResult(data)
|
||||||
@ -79,14 +94,11 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
this.result = this.computeResult(validatedData);
|
this.result = this.computeResult(validatedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLAD(options) {
|
requestLAD() {
|
||||||
options = Object.assign({},
|
const options = {
|
||||||
options,
|
|
||||||
{
|
|
||||||
strategy: 'latest',
|
strategy: 'latest',
|
||||||
size: 1
|
size: 1
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
|
||||||
if (!this.isValid()) {
|
if (!this.isValid()) {
|
||||||
return {
|
return {
|
||||||
@ -100,9 +112,11 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
options
|
options
|
||||||
).then(results => {
|
).then(results => {
|
||||||
const latestDatum = results.length ? results[results.length - 1] : {};
|
const latestDatum = results.length ? results[results.length - 1] : {};
|
||||||
|
const normalizedDatum = this.createNormalizedDatum(latestDatum, this.telemetryObject);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
data: this.formatData(latestDatum)
|
data: this.formatData(normalizedDatum)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user