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