mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 17:57:04 +00:00
telemetry is null for some reason
This commit is contained in:
parent
ff814544c6
commit
74c3a95ca3
@ -14,10 +14,7 @@ onconnect = function (e) {
|
|||||||
type === 'calculateRequest'
|
type === 'calculateRequest'
|
||||||
? 'calculationRequestResult'
|
? 'calculationRequestResult'
|
||||||
: 'calculationSubscriptionResult';
|
: 'calculationSubscriptionResult';
|
||||||
const result = telemetryForComps.map((point) => {
|
const result = calculate(telemetryForComps, expression);
|
||||||
// Using Math.js to evaluate the expression against the data
|
|
||||||
return { ...point, value: evaluate(expression, point) };
|
|
||||||
});
|
|
||||||
port.postMessage({ type: replyType, callbackID, result });
|
port.postMessage({ type: replyType, callbackID, result });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
port.postMessage({ type: 'error', callbackID, error: error.message });
|
port.postMessage({ type: 'error', callbackID, error: error.message });
|
||||||
@ -29,3 +26,24 @@ onconnect = function (e) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function calculate(telemetryForComps, expression) {
|
||||||
|
const dataSet1 = Object.values(telemetryForComps)[0];
|
||||||
|
const dataSet2 = Object.values(telemetryForComps)[1];
|
||||||
|
|
||||||
|
// Organize data by utc for quick access
|
||||||
|
const utcMap1 = new Map(dataSet1.map((item) => [item.utc, item.sin]));
|
||||||
|
const utcMap2 = new Map(dataSet2.map((item) => [item.utc, item.sin]));
|
||||||
|
|
||||||
|
const sumResults = [];
|
||||||
|
|
||||||
|
// Iterate over the first dataset and check for matching utc in the second dataset
|
||||||
|
for (const [utc, sin1] of utcMap1.entries()) {
|
||||||
|
if (utcMap2.has(utc)) {
|
||||||
|
const sin2 = utcMap2.get(utc);
|
||||||
|
const sumSin = evaluate(expression, { a: sin1, b: sin2 });
|
||||||
|
sumResults.push({ utc, sumSin });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sumResults;
|
||||||
|
}
|
||||||
|
@ -59,12 +59,12 @@ export default class CompsTelemetryProvider {
|
|||||||
this.#compsManagerPool
|
this.#compsManagerPool
|
||||||
);
|
);
|
||||||
await specificCompsManager.load();
|
await specificCompsManager.load();
|
||||||
const telemetryForComps = specificCompsManager.requestUnderlyingTelemetry();
|
|
||||||
console.debug('🏟️ Telemetry for comps:', telemetryForComps);
|
|
||||||
const expression = specificCompsManager.getExpression();
|
|
||||||
// need to create callbackID with a promise for future execution
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const callbackID = this.#getCallbackID();
|
const callbackID = this.#getCallbackID();
|
||||||
|
const telemetryForComps = specificCompsManager.requestUnderlyingTelemetry();
|
||||||
|
const expression = specificCompsManager.getExpression();
|
||||||
|
// need to create callbackID with a promise for future execution
|
||||||
|
console.debug('🏟️ Telemetry for comps:', telemetryForComps);
|
||||||
this.#requestPromises[callbackID] = { resolve, reject };
|
this.#requestPromises[callbackID] = { resolve, reject };
|
||||||
this.#sharedWorker.port.postMessage({
|
this.#sharedWorker.port.postMessage({
|
||||||
type: 'calculateRequest',
|
type: 'calculateRequest',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user