mirror of
https://github.com/nasa/openmct.git
synced 2025-02-25 19:11:35 +00:00
implement output format
This commit is contained in:
parent
28ec13a532
commit
386c3b4131
@ -110,6 +110,10 @@ export default class CompsManager extends EventEmitter {
|
||||
this.#domainObject = passedDomainObject;
|
||||
}
|
||||
|
||||
isLoaded() {
|
||||
return this.#loaded;
|
||||
}
|
||||
|
||||
async load() {
|
||||
if (!this.#loaded) {
|
||||
await this.#loadComposition();
|
||||
@ -236,6 +240,10 @@ export default class CompsManager extends EventEmitter {
|
||||
console.debug('Clear Data');
|
||||
}
|
||||
|
||||
getOutputFormat() {
|
||||
return this.#domainObject.configuration.comps.outputFormat;
|
||||
}
|
||||
|
||||
getExpression() {
|
||||
return this.#domainObject.configuration.comps.expression;
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ export default class CompsMetadataProvider {
|
||||
const metaDataToReturn = {
|
||||
values: this.getDomains().concat([
|
||||
{
|
||||
key: 'output',
|
||||
source: 'output',
|
||||
key: 'comps-output',
|
||||
source: 'comps-output',
|
||||
name: 'Output',
|
||||
formatString: '%0.2f',
|
||||
formatString: specificCompsManager.getOutputFormat(),
|
||||
hints: {
|
||||
range: 1
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ export default class CompsTelemetryProvider {
|
||||
}
|
||||
|
||||
#computeOnNewTelemetry(specificCompsManager, newTelemetry, callbackID) {
|
||||
if (!specificCompsManager.isValid()) {
|
||||
if (!specificCompsManager.isValid() || !specificCompsManager.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
const expression = specificCompsManager.getExpression();
|
||||
|
@ -49,14 +49,7 @@
|
||||
<span class="c-toggle-switch__label">Apply Test Values</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
:class="{ 'is-active-dragging': isDragging }"
|
||||
class="c-cs__content"
|
||||
@drop="drop($event)"
|
||||
@dragover.prevent
|
||||
@dragstart="dragStart($event)"
|
||||
@dragleave="dragLeave($event)"
|
||||
>
|
||||
<div class="c-cs__content">
|
||||
<div class="hint" :class="{ 's-status-icon-warning-lo': !parameters?.length && isEditing }">
|
||||
<div v-for="parameter in parameters" :key="parameter.name" class="telemery-reference">
|
||||
Reference
|
||||
@ -143,7 +136,7 @@ const testDataApplied = ref(false);
|
||||
const parameters = ref(null);
|
||||
const expression = ref(null);
|
||||
const expressionOutput = ref(null);
|
||||
const isDragging = ref(false);
|
||||
const outputFormat = ref(null);
|
||||
|
||||
let outputTelemetryCollection;
|
||||
|
||||
@ -159,6 +152,7 @@ onBeforeMount(async () => {
|
||||
await compsManager.load();
|
||||
parameters.value = compsManager.getParameters();
|
||||
expression.value = compsManager.getExpression();
|
||||
outputFormat.value = compsManager.getOutputFormat();
|
||||
compsManager.on('parametersUpdated', reloadParameters);
|
||||
outputTelemetryCollection.load();
|
||||
applyTestData();
|
||||
@ -170,19 +164,6 @@ onBeforeUnmount(() => {
|
||||
outputTelemetryCollection.destroy();
|
||||
});
|
||||
|
||||
function drop(event) {
|
||||
isDragging.value = false;
|
||||
console.debug('🚀 CompsView: drop', event);
|
||||
}
|
||||
|
||||
function dragStart(event) {
|
||||
isDragging.value = true;
|
||||
}
|
||||
|
||||
function dragLeave(event) {
|
||||
isDragging.value = false;
|
||||
}
|
||||
|
||||
function reloadParameters() {
|
||||
parameters.value = compsManager.getParameters();
|
||||
domainObject.configuration.comps.parameters = parameters.value;
|
||||
@ -210,6 +191,12 @@ function updateExpression() {
|
||||
applyTestData();
|
||||
}
|
||||
|
||||
function getValueFormatter() {
|
||||
const metaData = openmct.telemetry.getMetadata(domainObject);
|
||||
const outputMetaDatum = metaData.values().find((metaDatum) => metaDatum.key === 'comps-output');
|
||||
return openmct.telemetry.getValueFormatter(outputMetaDatum);
|
||||
}
|
||||
|
||||
function applyTestData() {
|
||||
const scope = parameters.value.reduce((acc, parameter) => {
|
||||
acc[parameter.name] = parameter.testValue;
|
||||
@ -217,7 +204,8 @@ function applyTestData() {
|
||||
}, {});
|
||||
try {
|
||||
const testOutput = evaluate(expression.value, scope);
|
||||
currentTestOutput.value = testOutput;
|
||||
const formattedData = getValueFormatter().format(testOutput);
|
||||
currentTestOutput.value = formattedData;
|
||||
expressionOutput.value = null;
|
||||
compsManager.setValid(true);
|
||||
} catch (error) {
|
||||
@ -233,7 +221,9 @@ function telemetryProcessor(data) {
|
||||
return;
|
||||
}
|
||||
// new data will come in as array, so just take the last element
|
||||
currentCompOutput.value = data[data.length - 1]?.output;
|
||||
const currentOutput = data[data.length - 1]?.output;
|
||||
const formattedOutput = getValueFormatter().format(currentOutput);
|
||||
currentCompOutput.value = formattedOutput;
|
||||
}
|
||||
|
||||
function clearData() {
|
||||
|
@ -19,6 +19,7 @@
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
import CompsInspectorViewProvider from './CompsInspectorViewProvider.js';
|
||||
import CompsMetadataProvider from './CompsMetadataProvider.js';
|
||||
import CompsTelemetryProvider from './CompsTelemetryProvider.js';
|
||||
import CompsViewProvider from './CompsViewProvider.js';
|
||||
@ -55,5 +56,6 @@ export default function CompsPlugin() {
|
||||
openmct.telemetry.addProvider(new CompsMetadataProvider(openmct, compsManagerPool));
|
||||
openmct.telemetry.addProvider(new CompsTelemetryProvider(openmct, compsManagerPool));
|
||||
openmct.objectViews.addProvider(new CompsViewProvider(openmct, compsManagerPool));
|
||||
openmct.inspectorViews.addProvider(new CompsInspectorViewProvider(openmct, compsManagerPool));
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user