mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 21:53:08 +00:00
Cleanup and add missing files
This commit is contained in:
parent
23cf829fdc
commit
21e94fd7ff
@ -50,7 +50,8 @@ const config = {
|
|||||||
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
||||||
espressoTheme: './src/plugins/themes/espresso-theme.scss',
|
espressoTheme: './src/plugins/themes/espresso-theme.scss',
|
||||||
snowTheme: './src/plugins/themes/snow-theme.scss',
|
snowTheme: './src/plugins/themes/snow-theme.scss',
|
||||||
darkmatterTheme: './src/plugins/themes/darkmatter-theme.scss'
|
darkmatterTheme: './src/plugins/themes/darkmatter-theme.scss',
|
||||||
|
historicalTelemetryWorker: './src/plugins/condition/historicalTelemetryWorker.js',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
globalObject: 'this',
|
globalObject: 'this',
|
||||||
|
@ -66,6 +66,10 @@ module.exports = async (config) => {
|
|||||||
{
|
{
|
||||||
pattern: 'dist/generatorWorker.js*',
|
pattern: 'dist/generatorWorker.js*',
|
||||||
included: false
|
included: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: 'dist/historicalTelemetryWorker.js*',
|
||||||
|
included: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
port: 9876,
|
port: 9876,
|
||||||
|
53
src/plugins/condition/ConditionInspectorViewProvider.js
Normal file
53
src/plugins/condition/ConditionInspectorViewProvider.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// src/plugins/condition/ConditionInspectorView.js
|
||||||
|
|
||||||
|
import mount from 'utils/mount';
|
||||||
|
|
||||||
|
import ConditionConfigView from './components/ConditionInspectorConfigView.vue';
|
||||||
|
|
||||||
|
export default function ConditionInspectorView(openmct) {
|
||||||
|
return {
|
||||||
|
key: 'condition-config',
|
||||||
|
name: 'Config',
|
||||||
|
canView: function (selection) {
|
||||||
|
return selection.length > 0 && selection[0][0].context.item.type === 'conditionSet';
|
||||||
|
},
|
||||||
|
view: function (selection) {
|
||||||
|
let _destroy = null;
|
||||||
|
const domainObject = selection[0][0].context.item;
|
||||||
|
|
||||||
|
return {
|
||||||
|
show: function (element) {
|
||||||
|
const { destroy } = mount(
|
||||||
|
{
|
||||||
|
el: element,
|
||||||
|
components: {
|
||||||
|
ConditionConfigView: ConditionConfigView
|
||||||
|
},
|
||||||
|
provide: {
|
||||||
|
openmct,
|
||||||
|
domainObject
|
||||||
|
},
|
||||||
|
template: '<condition-config-view></condition-config-view>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
app: openmct.app,
|
||||||
|
element
|
||||||
|
}
|
||||||
|
);
|
||||||
|
_destroy = destroy;
|
||||||
|
},
|
||||||
|
showTab: function (isEditing) {
|
||||||
|
return isEditing;
|
||||||
|
},
|
||||||
|
priority: function () {
|
||||||
|
return 1;
|
||||||
|
},
|
||||||
|
destroy: function () {
|
||||||
|
if (_destroy) {
|
||||||
|
_destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -324,10 +324,12 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getHistoricalData() {
|
getHistoricalData() {
|
||||||
|
if (!this.conditionSetDomainObject.configuration.shouldFetchHistorical) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const historicalTelemetry = new HistoricalTelemetryProvider(
|
const historicalTelemetry = new HistoricalTelemetryProvider(
|
||||||
this.openmct,
|
this.openmct,
|
||||||
this.telemetryObjects,
|
this.telemetryObjects,
|
||||||
this.compositionLoad,
|
|
||||||
this.conditions,
|
this.conditions,
|
||||||
this.conditionSetDomainObject
|
this.conditionSetDomainObject
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
<template>
|
||||||
|
<div class="c-inspect-properties">
|
||||||
|
<h2>Configuration</h2>
|
||||||
|
<section>
|
||||||
|
<div class="c-form-row">
|
||||||
|
<label for="historical-toggle">Enable Historical: </label>
|
||||||
|
<ToggleSwitch
|
||||||
|
id="historical-toggle"
|
||||||
|
class="c-toggle-switch"
|
||||||
|
:checked="historicalEnabled"
|
||||||
|
name="condition-historical-toggle"
|
||||||
|
@change="onToggleChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ToggleSwitch from '../../../ui/components/ToggleSwitch.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
ToggleSwitch
|
||||||
|
},
|
||||||
|
inject: ['openmct', 'domainObject'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
historicalEnabled: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.historicalEnabled = this.domainObject.configuration.shouldFetchHistorical;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onToggleChange() {
|
||||||
|
this.historicalEnabled = !this.historicalEnabled;
|
||||||
|
this.openmct.objects.mutate(
|
||||||
|
this.domainObject,
|
||||||
|
'configuration.shouldFetchHistorical',
|
||||||
|
this.historicalEnabled
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.c-inspect-properties {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.c-form-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,8 +1,7 @@
|
|||||||
export default class HistoricalTelemetryProvider {
|
export default class HistoricalTelemetryProvider {
|
||||||
constructor(openmct, telemetryObjects, compositionLoad, conditions, conditionSetDomainObject) {
|
constructor(openmct, telemetryObjects, conditions, conditionSetDomainObject) {
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
this.telemetryObjects = telemetryObjects;
|
this.telemetryObjects = telemetryObjects;
|
||||||
this.compositionLoad = compositionLoad;
|
|
||||||
this.bounds = { start: null, end: null };
|
this.bounds = { start: null, end: null };
|
||||||
this.telemetryList = [];
|
this.telemetryList = [];
|
||||||
this.conditions = conditions;
|
this.conditions = conditions;
|
||||||
@ -130,6 +129,50 @@ export default class HistoricalTelemetryProvider {
|
|||||||
return historicalTelemetryDateMap;
|
return historicalTelemetryDateMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sortTelemetriesInWorker(historicalTelemetriesPool) {
|
||||||
|
const sortedTelemetries = await this.startWorker('sortTelemetries', {
|
||||||
|
historicalTelemetriesPool
|
||||||
|
});
|
||||||
|
return sortedTelemetries;
|
||||||
|
}
|
||||||
|
|
||||||
|
async startWorker(type, data) {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
const workerUrl = `${this.openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}historicalTelemetryWorker.js`;
|
||||||
|
const worker = new Worker(workerUrl);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await this.getDataFromWorker(worker, type, data);
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error in condition manager getHistoricalData:', error);
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
worker.terminate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getDataFromWorker(worker, type, data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
worker.onmessage = (e) => {
|
||||||
|
if (e.data.type === 'result') {
|
||||||
|
resolve(e.data.data);
|
||||||
|
} else if (e.data.type === 'error') {
|
||||||
|
reject(new Error(e.data.error));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
worker.onerror = (error) => {
|
||||||
|
reject(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
worker.postMessage({
|
||||||
|
type,
|
||||||
|
data
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
evaluateConditionsByDate(historicalTelemetryDateMap, conditionCollectionMap) {
|
evaluateConditionsByDate(historicalTelemetryDateMap, conditionCollectionMap) {
|
||||||
const outputTelemetryDateMap = new Map();
|
const outputTelemetryDateMap = new Map();
|
||||||
historicalTelemetryDateMap.forEach((historicalTelemetryMap, timestamp) => {
|
historicalTelemetryDateMap.forEach((historicalTelemetryMap, timestamp) => {
|
||||||
@ -177,7 +220,6 @@ export default class HistoricalTelemetryProvider {
|
|||||||
condition,
|
condition,
|
||||||
conditionCollectionMap
|
conditionCollectionMap
|
||||||
);
|
);
|
||||||
console.log(conditionOutput.value);
|
|
||||||
outputTelemetryDateMap.set(timestamp, conditionOutput);
|
outputTelemetryDateMap.set(timestamp, conditionOutput);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -186,8 +228,6 @@ export default class HistoricalTelemetryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getHistoricalInputsByDate() {
|
async getHistoricalInputsByDate() {
|
||||||
console.log('getHistoricalInputsByDate');
|
|
||||||
console.log(this.conditions);
|
|
||||||
const conditionCollection = this.conditionSetDomainObject.configuration.conditionCollection;
|
const conditionCollection = this.conditionSetDomainObject.configuration.conditionCollection;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -197,7 +237,8 @@ export default class HistoricalTelemetryProvider {
|
|||||||
conditionCollectionMap
|
conditionCollectionMap
|
||||||
} = await this.getAllTelemetries(conditionCollection);
|
} = await this.getAllTelemetries(conditionCollection);
|
||||||
|
|
||||||
const historicalTelemetryDateMap = this.sortTelemetriesByDate(historicalTelemetriesPool);
|
const historicalTelemetryDateMap =
|
||||||
|
await this.sortTelemetriesInWorker(historicalTelemetriesPool);
|
||||||
const outputTelemetryDateMap = this.evaluateConditionsByDate(
|
const outputTelemetryDateMap = this.evaluateConditionsByDate(
|
||||||
historicalTelemetryDateMap,
|
historicalTelemetryDateMap,
|
||||||
conditionCollectionMap
|
conditionCollectionMap
|
||||||
@ -222,15 +263,10 @@ export default class HistoricalTelemetryProvider {
|
|||||||
|
|
||||||
async getHistoricalData() {
|
async getHistoricalData() {
|
||||||
console.log('getHistoricalData');
|
console.log('getHistoricalData');
|
||||||
await this.compositionLoad;
|
|
||||||
this.setTimeBounds(this.openmct.time.getBounds());
|
this.setTimeBounds(this.openmct.time.getBounds());
|
||||||
const outputTelemetryMap = await this.getHistoricalInputsByDate();
|
const outputTelemetryMap = await this.getHistoricalInputsByDate();
|
||||||
const formattedOutputTelemetry = this.formatOutputData(outputTelemetryMap);
|
const formattedOutputTelemetry = this.formatOutputData(outputTelemetryMap);
|
||||||
// const firstObjectKey = this.historicalTelemetryPoolMap.keys().next().value;
|
|
||||||
// const firstObjectValue = this.historicalTelemetryPoolMap.values().next().value;
|
|
||||||
// const formattedHistoricalData = this.formatHistoricalData(firstObjectKey, firstObjectValue);
|
|
||||||
console.log(formattedOutputTelemetry);
|
console.log(formattedOutputTelemetry);
|
||||||
// console.log(formattedHistoricalData);
|
|
||||||
return formattedOutputTelemetry;
|
return formattedOutputTelemetry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,27 +284,4 @@ export default class HistoricalTelemetryProvider {
|
|||||||
});
|
});
|
||||||
return outputTelemetryList;
|
return outputTelemetryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleTelemetryList(outputTelemetryMap) {
|
|
||||||
const outputTelemetryList = [];
|
|
||||||
outputTelemetryMap.forEach((outputMetadata, timestamp) => {
|
|
||||||
const { value } = outputMetadata;
|
|
||||||
outputTelemetryList.push(value);
|
|
||||||
});
|
|
||||||
return outputTelemetryList;
|
|
||||||
}
|
|
||||||
|
|
||||||
formatHistoricalData(historicalDataKey, telemetryDetails) {
|
|
||||||
const formattedData = [];
|
|
||||||
const { domainObject, historicalTelemetry } = telemetryDetails;
|
|
||||||
historicalTelemetry.forEach((value) => {
|
|
||||||
formattedData.push({
|
|
||||||
id: domainObject.identifier,
|
|
||||||
output: value.sin,
|
|
||||||
conditionId: historicalDataKey,
|
|
||||||
utc: value.utc
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return formattedData;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
33
src/plugins/condition/historicalTelemetryWorker.js
Normal file
33
src/plugins/condition/historicalTelemetryWorker.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { makeKeyString } from '../../api/objects/object-utils.js';
|
||||||
|
|
||||||
|
function sortTelemetriesByDate(historicalTelemetriesPool) {
|
||||||
|
const historicalTelemetryDateMap = new Map();
|
||||||
|
historicalTelemetriesPool.forEach((historicalTelemetryList) => {
|
||||||
|
const { historicalTelemetry, domainObject } = historicalTelemetryList;
|
||||||
|
const { identifier } = domainObject;
|
||||||
|
const telemetryIdentifier = makeKeyString(identifier);
|
||||||
|
historicalTelemetry.forEach((historicalTelemetryItem) => {
|
||||||
|
if (!historicalTelemetryDateMap.get(historicalTelemetryItem.utc)) {
|
||||||
|
const telemetryMap = new Map();
|
||||||
|
telemetryMap.set(telemetryIdentifier, historicalTelemetryItem);
|
||||||
|
historicalTelemetryDateMap.set(historicalTelemetryItem.utc, telemetryMap);
|
||||||
|
} else {
|
||||||
|
const telemetryMap = historicalTelemetryDateMap.get(historicalTelemetryItem.utc);
|
||||||
|
telemetryMap.set(telemetryIdentifier, historicalTelemetryItem);
|
||||||
|
historicalTelemetryDateMap.set(historicalTelemetryItem.utc, telemetryMap);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return historicalTelemetryDateMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.onmessage = function (e) {
|
||||||
|
const { type, data } = e.data;
|
||||||
|
|
||||||
|
if (type === 'sortTelemetries') {
|
||||||
|
const sortedTelemetries = sortTelemetriesByDate(data.historicalTelemetriesPool);
|
||||||
|
self.postMessage({ type: 'result', data: sortedTelemetries });
|
||||||
|
} else {
|
||||||
|
self.postMessage({ type: 'error', error: 'Unknown message type' });
|
||||||
|
}
|
||||||
|
};
|
@ -21,6 +21,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
|
import ConditionInspectorViewProvider from './ConditionInspectorViewProvider.js';
|
||||||
import ConditionSetCompositionPolicy from './ConditionSetCompositionPolicy.js';
|
import ConditionSetCompositionPolicy from './ConditionSetCompositionPolicy.js';
|
||||||
import ConditionSetMetadataProvider from './ConditionSetMetadataProvider.js';
|
import ConditionSetMetadataProvider from './ConditionSetMetadataProvider.js';
|
||||||
import ConditionSetTelemetryProvider from './ConditionSetTelemetryProvider.js';
|
import ConditionSetTelemetryProvider from './ConditionSetTelemetryProvider.js';
|
||||||
@ -37,6 +38,7 @@ export default function ConditionPlugin() {
|
|||||||
cssClass: 'icon-conditional',
|
cssClass: 'icon-conditional',
|
||||||
initialize: function (domainObject) {
|
initialize: function (domainObject) {
|
||||||
domainObject.configuration = {
|
domainObject.configuration = {
|
||||||
|
shouldFetchHistorical: false,
|
||||||
conditionTestData: [],
|
conditionTestData: [],
|
||||||
conditionCollection: [
|
conditionCollection: [
|
||||||
{
|
{
|
||||||
@ -61,5 +63,6 @@ export default function ConditionPlugin() {
|
|||||||
openmct.telemetry.addProvider(new ConditionSetMetadataProvider(openmct));
|
openmct.telemetry.addProvider(new ConditionSetMetadataProvider(openmct));
|
||||||
openmct.telemetry.addProvider(new ConditionSetTelemetryProvider(openmct));
|
openmct.telemetry.addProvider(new ConditionSetTelemetryProvider(openmct));
|
||||||
openmct.objectViews.addProvider(new ConditionSetViewProvider(openmct));
|
openmct.objectViews.addProvider(new ConditionSetViewProvider(openmct));
|
||||||
|
openmct.inspectorViews.addProvider(new ConditionInspectorViewProvider(openmct));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user