persist metadata

This commit is contained in:
Scott Bell 2024-10-11 19:55:12 +02:00
parent f3f8e3a577
commit cf4f3aa618
3 changed files with 42 additions and 8 deletions

View File

@ -29,7 +29,7 @@ export default class ConditionSetMetadataProvider {
return domainObject.type === 'conditionSet';
}
getDomains(domainObject) {
getDefaultDomains(domainObject) {
return this.openmct.time.getAllTimeSystems().map(function (ts, i) {
return {
key: ts.key,
@ -63,8 +63,8 @@ export default class ConditionSetMetadataProvider {
}
];
return {
values: this.getDomains().concat([
const metaDataToReturn = {
values: [
{
key: 'value',
name: 'Value',
@ -82,7 +82,20 @@ export default class ConditionSetMetadataProvider {
range: 2
}
}
])
]
};
// if there are any parameters, grab the first one's timeMetaData
const timeMetaData =
domainObject?.configuration?.conditionCollection[0]?.configuration.timeMetadata;
if (timeMetaData) {
metaDataToReturn.values.push(timeMetaData);
} else {
const defaultDomains = this.getDefaultDomains(domainObject);
metaDataToReturn.values.push(...defaultDomains);
}
return metaDataToReturn;
}
}

View File

@ -57,11 +57,12 @@ export default class HistoricalTelemetryProvider {
return specificDatum;
}
#formatDatumForOutput(datum, metadata) {
#formatDatumForOutput(datum, metadata, result) {
const formattedDatum = {
...datum
...datum,
value: datum[metadata],
result
};
formattedDatum.value = datum[metadata];
return formattedDatum;
}
@ -89,7 +90,8 @@ export default class HistoricalTelemetryProvider {
dataFrame[outputTelmetryDetail.outputTelemetryKeyString][timestamp];
const formattedDatum = this.#formatDatumForOutput(
outputTelmetryDatum,
outputTelmetryDetail.outputMetadata
outputTelmetryDetail.outputMetadata,
result
);
return formattedDatum;
} else if (outputTelmetryDetail?.staticOutputValue) {

View File

@ -336,6 +336,7 @@ export default {
if (config?.output !== TELEMETRY_VALUE) {
config.outputTelemetry = null;
config.outputMetadata = null;
config.timeMetadata = null;
}
},
deep: true
@ -467,10 +468,28 @@ export default {
this.condition.configuration.criteria.splice(index + 1, 0, clonedCriterion);
this.persist();
},
persistTimeMetadata() {
if (!this.condition.configuration.outputTelemetry) {
return;
}
const outputTelemetryObject = this.telemetry.find(
(telemetryItem) =>
this.openmct.objects.makeKeyString(telemetryItem.identifier) ===
this.condition.configuration.outputTelemetry
);
const timeSystem = this.openmct.time.getTimeSystem();
const telemetryMetadata = this.openmct.telemetry.getMetadata(outputTelemetryObject);
const domains = telemetryMetadata?.valuesForHints(['domain']);
const timeMetaData = domains.find((d) => d.key === timeSystem.key);
if (telemetryMetadata) {
this.condition.configuration.timeMetadata = timeMetaData;
}
},
persist() {
const valueMetadata = this.getOutputMetadata();
if (valueMetadata) {
this.condition.configuration.valueMetadata = valueMetadata;
this.persistTimeMetadata();
}
this.$emit('update-condition', {
condition: this.condition