mirror of
https://github.com/nasa/openmct.git
synced 2024-12-22 06:27:48 +00:00
Update emitted values
This commit is contained in:
parent
101baa58e0
commit
7896f36748
@ -116,6 +116,22 @@ async function createDomainObjectWithDefaults(page, { type, name, parent = 'mine
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the properties of an OpenMCT domain object by its identifier.
|
||||
*
|
||||
* @param {import('@playwright/test').Page} page - The Playwright page object.
|
||||
* @param {string | identifier - The identifier or UUID of the domain object.
|
||||
* @returns {Promise<Object>} An object containing the properties of the domain object.
|
||||
*/
|
||||
async function getDomainObject(page, identifier) {
|
||||
const domainObject = await page.evaluate(async (objIdentifier) => {
|
||||
const object = await window.openmct.objects.get(objIdentifier);
|
||||
return object;
|
||||
}, identifier);
|
||||
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a notification with the given options.
|
||||
* @param {import('@playwright/test').Page} page
|
||||
@ -636,6 +652,7 @@ export {
|
||||
createPlanFromJSON,
|
||||
expandEntireTree,
|
||||
getCanvasPixels,
|
||||
getDomainObject,
|
||||
navigateToObjectWithFixedTimeBounds,
|
||||
navigateToObjectWithRealTime,
|
||||
setEndOffset,
|
||||
|
@ -29,7 +29,8 @@ import { fileURLToPath } from 'url';
|
||||
|
||||
import {
|
||||
createDomainObjectWithDefaults,
|
||||
createExampleTelemetryObject
|
||||
createExampleTelemetryObject,
|
||||
getDomainObject
|
||||
} from '../../../../appActions.js';
|
||||
import { expect, test } from '../../../../pluginFixtures.js';
|
||||
|
||||
@ -468,6 +469,34 @@ test.describe('Basic Condition Set Use', () => {
|
||||
description: 'https://github.com/nasa/openmct/issues/7484'
|
||||
});
|
||||
});
|
||||
|
||||
test('should toggle shouldFetchHistorical property in inspector', async ({ page }) => {
|
||||
await page.goto(conditionSet.url);
|
||||
await page.getByLabel('Edit Object').click();
|
||||
await page.getByRole('tab', { name: 'Config' }).click();
|
||||
let toggleSwitch = page.getByLabel('condition-historical-toggle');
|
||||
const initialState = await toggleSwitch.isChecked();
|
||||
expect(initialState).toBe(false);
|
||||
|
||||
await toggleSwitch.click();
|
||||
let toggledState = await toggleSwitch.isChecked();
|
||||
expect(toggledState).toBe(true);
|
||||
await page.click('button[title="Save"]');
|
||||
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||
let conditionSetObject = await getDomainObject(page, conditionSet.uuid);
|
||||
expect(conditionSetObject.configuration.shouldFetchHistorical).toBe(true);
|
||||
|
||||
await page.getByLabel('Edit Object').click();
|
||||
await page.getByRole('tab', { name: 'Config' }).click();
|
||||
toggleSwitch = page.getByLabel('condition-historical-toggle');
|
||||
await toggleSwitch.click();
|
||||
toggledState = await toggleSwitch.isChecked();
|
||||
expect(toggledState).toBe(false);
|
||||
await page.click('button[title="Save"]');
|
||||
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||
conditionSetObject = await getDomainObject(page, conditionSet.uuid);
|
||||
expect(conditionSetObject.configuration.shouldFetchHistorical).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Condition Set Composition', () => {
|
||||
|
@ -474,14 +474,15 @@ export default class ConditionManager extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
emitConditionSetResult(currentCondition, timestamp, outputValue) {
|
||||
emitConditionSetResult(currentCondition, timestamp, outputValue, result) {
|
||||
this.emit(
|
||||
'conditionSetResultUpdated',
|
||||
Object.assign(
|
||||
{
|
||||
output: outputValue,
|
||||
id: this.conditionSetDomainObject.identifier,
|
||||
conditionId: currentCondition.id
|
||||
conditionId: currentCondition.id,
|
||||
output: outputValue,
|
||||
result
|
||||
},
|
||||
timestamp
|
||||
)
|
||||
@ -509,6 +510,10 @@ export default class ConditionManager extends EventEmitter {
|
||||
|
||||
async processCondition(timestamp, telemetryObject, telemetryData) {
|
||||
const currentCondition = this.getCurrentCondition();
|
||||
const conditionDetails = this.conditions.filter(
|
||||
(condition) => condition.id === currentCondition.id
|
||||
)?.[0];
|
||||
const conditionResult = currentCondition?.isDefault ? false : conditionDetails?.result;
|
||||
let telemetryValue = currentCondition.configuration.output;
|
||||
if (currentCondition?.configuration?.outputTelemetry) {
|
||||
const selectedOutputIdentifier = currentCondition?.configuration?.outputTelemetry;
|
||||
@ -539,7 +544,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
this.emitConditionSetResult(currentCondition, timestamp, telemetryValue);
|
||||
this.emitConditionSetResult(currentCondition, timestamp, telemetryValue, conditionResult);
|
||||
}
|
||||
|
||||
getTestData(metadatum) {
|
||||
|
@ -50,12 +50,23 @@ export default class ConditionSetMetadataProvider {
|
||||
};
|
||||
});
|
||||
|
||||
const resultEnum = [
|
||||
{
|
||||
string: 'true',
|
||||
value: true
|
||||
},
|
||||
{
|
||||
string: 'false',
|
||||
value: false
|
||||
}
|
||||
];
|
||||
|
||||
return {
|
||||
values: this.getDomains().concat([
|
||||
{
|
||||
key: 'state',
|
||||
key: 'output',
|
||||
source: 'output',
|
||||
name: 'State',
|
||||
name: 'Value',
|
||||
format: 'enum',
|
||||
enumerations: enumerations,
|
||||
hints: {
|
||||
@ -63,9 +74,11 @@ export default class ConditionSetMetadataProvider {
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'output',
|
||||
name: 'Value',
|
||||
format: 'string',
|
||||
key: 'result',
|
||||
source: 'result',
|
||||
name: 'Result',
|
||||
format: 'enum',
|
||||
enumerations: resultEnum,
|
||||
hints: {
|
||||
range: 2
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ export default class HistoricalTelemetryProvider {
|
||||
const conditionConfiguration = conditionCollectionMap.get(condition.id)?.configuration;
|
||||
const { outputTelemetry, outputMetadata } = conditionConfiguration;
|
||||
let output = {};
|
||||
output.result = true;
|
||||
if (outputTelemetry) {
|
||||
const outputTelemetryID = this.openmct.objects.makeKeyString(outputTelemetry);
|
||||
const outputTelemetryData = telemetryData.get(outputTelemetryID);
|
||||
@ -203,9 +204,11 @@ export default class HistoricalTelemetryProvider {
|
||||
const { outputTelemetry, outputMetadata, output } = conditionConfiguration;
|
||||
if (isDefault) {
|
||||
const conditionOutput = {
|
||||
condition,
|
||||
telemetry: null,
|
||||
value: output,
|
||||
condition
|
||||
result: false,
|
||||
isDefault: true
|
||||
};
|
||||
outputTelemetryDateMap.set(timestamp, conditionOutput);
|
||||
}
|
||||
@ -274,12 +277,14 @@ export default class HistoricalTelemetryProvider {
|
||||
const outputTelemetryList = [];
|
||||
const domainObject = this.conditionSetDomainObject;
|
||||
outputTelemetryMap.forEach((outputMetadata, timestamp) => {
|
||||
const { condition, telemetry, value } = outputMetadata;
|
||||
const { condition, telemetry, value, result, isDefault } = outputMetadata;
|
||||
outputTelemetryList.push({
|
||||
conditionId: condition.id,
|
||||
id: domainObject.identifier,
|
||||
output: value,
|
||||
utc: timestamp
|
||||
utc: timestamp,
|
||||
result,
|
||||
isDefault
|
||||
});
|
||||
});
|
||||
return outputTelemetryList;
|
||||
|
Loading…
Reference in New Issue
Block a user