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'; return domainObject.type === 'conditionSet';
} }
getDomains(domainObject) { getDefaultDomains(domainObject) {
return this.openmct.time.getAllTimeSystems().map(function (ts, i) { return this.openmct.time.getAllTimeSystems().map(function (ts, i) {
return { return {
key: ts.key, key: ts.key,
@ -63,8 +63,8 @@ export default class ConditionSetMetadataProvider {
} }
]; ];
return { const metaDataToReturn = {
values: this.getDomains().concat([ values: [
{ {
key: 'value', key: 'value',
name: 'Value', name: 'Value',
@ -82,7 +82,20 @@ export default class ConditionSetMetadataProvider {
range: 2 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; return specificDatum;
} }
#formatDatumForOutput(datum, metadata) { #formatDatumForOutput(datum, metadata, result) {
const formattedDatum = { const formattedDatum = {
...datum ...datum,
value: datum[metadata],
result
}; };
formattedDatum.value = datum[metadata];
return formattedDatum; return formattedDatum;
} }
@ -89,7 +90,8 @@ export default class HistoricalTelemetryProvider {
dataFrame[outputTelmetryDetail.outputTelemetryKeyString][timestamp]; dataFrame[outputTelmetryDetail.outputTelemetryKeyString][timestamp];
const formattedDatum = this.#formatDatumForOutput( const formattedDatum = this.#formatDatumForOutput(
outputTelmetryDatum, outputTelmetryDatum,
outputTelmetryDetail.outputMetadata outputTelmetryDetail.outputMetadata,
result
); );
return formattedDatum; return formattedDatum;
} else if (outputTelmetryDetail?.staticOutputValue) { } else if (outputTelmetryDetail?.staticOutputValue) {

View File

@ -336,6 +336,7 @@ export default {
if (config?.output !== TELEMETRY_VALUE) { if (config?.output !== TELEMETRY_VALUE) {
config.outputTelemetry = null; config.outputTelemetry = null;
config.outputMetadata = null; config.outputMetadata = null;
config.timeMetadata = null;
} }
}, },
deep: true deep: true
@ -467,10 +468,28 @@ export default {
this.condition.configuration.criteria.splice(index + 1, 0, clonedCriterion); this.condition.configuration.criteria.splice(index + 1, 0, clonedCriterion);
this.persist(); 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() { persist() {
const valueMetadata = this.getOutputMetadata(); const valueMetadata = this.getOutputMetadata();
if (valueMetadata) { if (valueMetadata) {
this.condition.configuration.valueMetadata = valueMetadata; this.condition.configuration.valueMetadata = valueMetadata;
this.persistTimeMetadata();
} }
this.$emit('update-condition', { this.$emit('update-condition', {
condition: this.condition condition: this.condition