mirror of
https://github.com/nasa/openmct.git
synced 2025-06-07 18:01:40 +00:00
more scaffolding
This commit is contained in:
parent
431600342f
commit
6c74e84e11
@ -48,6 +48,7 @@ const config = {
|
|||||||
generatorWorker: './example/generator/generatorWorker.js',
|
generatorWorker: './example/generator/generatorWorker.js',
|
||||||
couchDBChangesFeed: './src/plugins/persistence/couch/CouchChangesFeed.js',
|
couchDBChangesFeed: './src/plugins/persistence/couch/CouchChangesFeed.js',
|
||||||
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
||||||
|
compsMathWorker: './src/plugins/comps/CompsMathWorker.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'
|
||||||
@ -91,7 +92,7 @@ const config = {
|
|||||||
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`,
|
__OPENMCT_BUILD_BRANCH__: `'${gitBranch}'`,
|
||||||
__VUE_OPTIONS_API__: true, // enable/disable Options API support, default: true
|
__VUE_OPTIONS_API__: true, // enable/disable Options API support, default: true
|
||||||
__VUE_PROD_DEVTOOLS__: false, // enable/disable devtools support in production, default: false
|
__VUE_PROD_DEVTOOLS__: false, // enable/disable devtools support in production, default: false
|
||||||
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false', // enable/disable hydration mismatch details in production, default: false
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false, // enable/disable hydration mismatch details in production, default: false
|
||||||
}),
|
}),
|
||||||
new VueLoaderPlugin(),
|
new VueLoaderPlugin(),
|
||||||
new CopyWebpackPlugin({
|
new CopyWebpackPlugin({
|
||||||
|
26
src/plugins/comps/CompsMathWorker.js
Normal file
26
src/plugins/comps/CompsMathWorker.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { evaluate } from 'mathjs';
|
||||||
|
|
||||||
|
onconnect = function (e) {
|
||||||
|
const port = e.ports[0];
|
||||||
|
console.debug('🧮 Comps Math Worker connected');
|
||||||
|
|
||||||
|
port.onmessage = function (event) {
|
||||||
|
console.debug('🧮 Comps Math Worker message:', event);
|
||||||
|
const { type, id, data, expression } = event.data;
|
||||||
|
if (type === 'calculate') {
|
||||||
|
try {
|
||||||
|
const result = data.map((point) => {
|
||||||
|
// Using Math.js to evaluate the expression against the data
|
||||||
|
return { ...point, value: evaluate(expression, point) };
|
||||||
|
});
|
||||||
|
port.postMessage({ type: 'response', id, result });
|
||||||
|
} catch (error) {
|
||||||
|
port.postMessage({ type: 'error', id, error: error.message });
|
||||||
|
}
|
||||||
|
} else if (type === 'init') {
|
||||||
|
port.postMessage({ type: 'ready' });
|
||||||
|
} else {
|
||||||
|
port.postMessage({ type: 'error', id, error: 'Invalid message type' });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
@ -23,6 +23,7 @@
|
|||||||
export default class ConditionSetTelemetryProvider {
|
export default class ConditionSetTelemetryProvider {
|
||||||
constructor(openmct) {
|
constructor(openmct) {
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
|
this.#startSharedWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
isTelemetryObject(domainObject) {
|
isTelemetryObject(domainObject) {
|
||||||
@ -37,6 +38,7 @@ export default class ConditionSetTelemetryProvider {
|
|||||||
return domainObject.type === 'comps';
|
return domainObject.type === 'comps';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line require-await
|
||||||
async request(domainObject, options) {
|
async request(domainObject, options) {
|
||||||
// TODO: do some math in a worker
|
// TODO: do some math in a worker
|
||||||
return { value: 0 };
|
return { value: 0 };
|
||||||
@ -46,4 +48,36 @@ export default class ConditionSetTelemetryProvider {
|
|||||||
// TODO: add to listener list and return a function to remove it
|
// TODO: add to listener list and return a function to remove it
|
||||||
return () => {};
|
return () => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#startSharedWorker() {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
const sharedWorkerURL = `${this.openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}compsMathWorker.js`;
|
||||||
|
|
||||||
|
const sharedWorker = new SharedWorker(sharedWorkerURL, `Comps Math Worker`);
|
||||||
|
sharedWorker.port.onmessage = this.onSharedWorkerMessage.bind(this);
|
||||||
|
sharedWorker.port.onmessageerror = this.onSharedWorkerMessageError.bind(this);
|
||||||
|
sharedWorker.port.start();
|
||||||
|
|
||||||
|
// send an initial message to the worker
|
||||||
|
sharedWorker.port.postMessage({ type: 'init' });
|
||||||
|
|
||||||
|
// for testing, try a message adding two numbers
|
||||||
|
sharedWorker.port.postMessage({
|
||||||
|
type: 'calculate',
|
||||||
|
data: [{ a: 1, b: 2 }],
|
||||||
|
expression: 'a + b'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.openmct.on('destroy', () => {
|
||||||
|
sharedWorker.port.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSharedWorkerMessage(event) {
|
||||||
|
console.log('📝 Shared worker message:', event.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
onSharedWorkerMessageError(event) {
|
||||||
|
console.error('❌ Shared worker message error:', event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ export default function CompsPlugin() {
|
|||||||
creatable: true,
|
creatable: true,
|
||||||
cssClass: 'icon-telemetry',
|
cssClass: 'icon-telemetry',
|
||||||
initialize: function (domainObject) {
|
initialize: function (domainObject) {
|
||||||
domainObject.configuration = {
|
domainObject.configuration = {};
|
||||||
};
|
|
||||||
domainObject.composition = [];
|
domainObject.composition = [];
|
||||||
domainObject.telemetry = {};
|
domainObject.telemetry = {};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user