ensure output format propagates

This commit is contained in:
Scott Bell 2024-09-06 11:27:20 +02:00
parent 1b186d7596
commit b251fde1fc
6 changed files with 28 additions and 7 deletions

View File

@ -684,6 +684,15 @@ export default class TelemetryAPI {
return this.metadataCache.get(domainObject); return this.metadataCache.get(domainObject);
} }
/**
* Remove a domain object from the telemetry metadata cache.
* @param {import('openmct').DomainObject} domainObject
*/
removeMetadataFromCache(domainObject) {
this.metadataCache.delete(domainObject);
}
/** /**
* Get a value formatter for a given valueMetadata. * Get a value formatter for a given valueMetadata.
* *

View File

@ -115,7 +115,6 @@ export default class TelemetryCollection extends EventEmitter {
} }
this.removeAllListeners(); this.removeAllListeners();
console.debug('🔥 Telemetry Collection destroyed', this.domainObject?.identifier?.key);
this.loaded = false; this.loaded = false;
} }
@ -187,10 +186,6 @@ export default class TelemetryCollection extends EventEmitter {
const options = { ...this.options }; const options = { ...this.options };
//We always want to receive all available values in telemetry tables. //We always want to receive all available values in telemetry tables.
options.strategy = this.openmct.telemetry.SUBSCRIBE_STRATEGY.BATCH; options.strategy = this.openmct.telemetry.SUBSCRIBE_STRATEGY.BATCH;
console.debug(
'🔊 Telemetry Collection Subscribing to telemetry data...',
this.domainObject?.identifier?.key
);
this.unsubscribe = this.openmct.telemetry.subscribe( this.unsubscribe = this.openmct.telemetry.subscribe(
this.domainObject, this.domainObject,
(datum) => this._processNewTelemetry(datum), (datum) => this._processNewTelemetry(datum),

View File

@ -45,6 +45,7 @@ export default class ConditionSetViewProvider {
let _destroy = null; let _destroy = null;
const domainObject = selection[0][0].context.item; const domainObject = selection[0][0].context.item;
const openmct = this.openmct; const openmct = this.openmct;
const compsManagerPool = this.compsManagerPool;
return { return {
show: function (element) { show: function (element) {
@ -57,7 +58,7 @@ export default class ConditionSetViewProvider {
provide: { provide: {
openmct, openmct,
domainObject, domainObject,
compsManagerPool: this.compsManagerPool compsManagerPool
}, },
template: '<comps-inspector-view></comps-inspector-view>' template: '<comps-inspector-view></comps-inspector-view>'
}, },

View File

@ -236,6 +236,11 @@ export default class CompsManager extends EventEmitter {
this.#telemetryLoadedPromises.push(telemetryLoadedPromise); this.#telemetryLoadedPromises.push(telemetryLoadedPromise);
} }
setOutputFormat(outputFormat) {
this.#domainObject.configuration.comps.outputFormat = outputFormat;
this.emit('outputFormatChanged', outputFormat);
}
getOutputFormat() { getOutputFormat() {
return this.#domainObject.configuration.comps.outputFormat; return this.#domainObject.configuration.comps.outputFormat;
} }

View File

@ -45,6 +45,8 @@
<script setup> <script setup>
import { inject, onBeforeMount, onBeforeUnmount, ref } from 'vue'; import { inject, onBeforeMount, onBeforeUnmount, ref } from 'vue';
import CompsManager from '../CompsManager';
const isEditing = ref(false); const isEditing = ref(false);
const inputFormatValue = ref(''); const inputFormatValue = ref('');
@ -68,6 +70,7 @@ function toggleEdit(passedIsEditing) {
function changeInputFormat() { function changeInputFormat() {
openmct.objects.mutate(domainObject, `configuration.comps.outputFormat`, inputFormatValue.value); openmct.objects.mutate(domainObject, `configuration.comps.outputFormat`, inputFormatValue.value);
compsManagerPool.setDomainObject(domainObject); const compsManager = CompsManager.getCompsManager(domainObject, openmct, compsManagerPool);
compsManager.setOutputFormat(inputFormatValue.value);
} }
</script> </script>

View File

@ -179,6 +179,7 @@ onBeforeMount(async () => {
outputTelemetryCollection.on('clear', clearData); outputTelemetryCollection.on('clear', clearData);
compsManager.on('parameterAdded', reloadParameters); compsManager.on('parameterAdded', reloadParameters);
compsManager.on('parameterRemoved', reloadParameters); compsManager.on('parameterRemoved', reloadParameters);
compsManager.on('outputFormatChanged', updateOutputFormat);
await compsManager.load(); await compsManager.load();
parameters.value = compsManager.getParameters(); parameters.value = compsManager.getParameters();
expression.value = compsManager.getExpression(); expression.value = compsManager.getExpression();
@ -192,6 +193,7 @@ onBeforeUnmount(() => {
outputTelemetryCollection.off('clear', clearData); outputTelemetryCollection.off('clear', clearData);
compsManager.off('parameterAdded', reloadParameters); compsManager.off('parameterAdded', reloadParameters);
compsManager.off('parameterRemoved', reloadParameters); compsManager.off('parameterRemoved', reloadParameters);
compsManager.off('outputFormatChanged', updateOutputFormat);
outputTelemetryCollection.destroy(); outputTelemetryCollection.destroy();
}); });
@ -204,6 +206,12 @@ watch(
} }
); );
function updateOutputFormat() {
outputFormat.value = compsManager.getOutputFormat();
// delete the metadata cache so that the new output format is used
openmct.telemetry.removeMetadataFromCache(domainObject);
}
function reloadParameters(passedDomainObject) { function reloadParameters(passedDomainObject) {
// Because this is triggered by a composition change, we have // Because this is triggered by a composition change, we have
// to defer mutation of our domain object, otherwise we might // to defer mutation of our domain object, otherwise we might