adding works

This commit is contained in:
Scott Bell 2024-08-02 17:58:14 +02:00
parent ce5e435ae0
commit 69db534042
2 changed files with 9 additions and 7 deletions

View File

@ -47,9 +47,11 @@ export default class CompsManager extends EventEmitter {
return underlyingTelemetry;
}
#telemetryProcessor(telemetryObjects) {
#telemetryProcessor = (telemetryObjects) => {
// new data!
console.debug(`🎉 new data!`, telemetryObjects);
this.emit('underlyingTelemetryUpdated', telemetryObjects);
}
};
#clearData() {
console.debug('Clear Data');

View File

@ -32,16 +32,16 @@ function calculate(telemetryForComps, expression) {
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 utcMap1 = new Map(dataSet1.map((item) => [item.utc, item]));
const utcMap2 = new Map(dataSet2.map((item) => [item.utc, item]));
const sumResults = [];
// Iterate over the first dataset and check for matching utc in the second dataset
for (const [utc, sin1] of utcMap1.entries()) {
for (const [utc, item1] of utcMap1.entries()) {
if (utcMap2.has(utc)) {
const sin2 = utcMap2.get(utc);
const output = evaluate(expression, { a: sin1, b: sin2 });
const item2 = utcMap2.get(utc);
const output = evaluate(expression, { a: item1.sin, b: item2.sin });
sumResults.push({ utc, output });
}
}