mirror of
https://github.com/nasa/openmct.git
synced 2025-01-28 23:24:26 +00:00
improvement in loading
This commit is contained in:
parent
1a9401039e
commit
8e5ac68360
@ -31,7 +31,7 @@ onconnect = function (e) {
|
|||||||
|
|
||||||
function getFullDataFrame(telemetryForComps, parameters) {
|
function getFullDataFrame(telemetryForComps, parameters) {
|
||||||
const dataFrame = {};
|
const dataFrame = {};
|
||||||
Object.keys(telemetryForComps).forEach((key) => {
|
Object.keys(telemetryForComps)?.forEach((key) => {
|
||||||
const parameter = parameters.find((p) => p.keyString === key);
|
const parameter = parameters.find((p) => p.keyString === key);
|
||||||
const dataSet = telemetryForComps[key];
|
const dataSet = telemetryForComps[key];
|
||||||
const telemetryMap = new Map(dataSet.map((item) => [item[parameter.timeKey], item]));
|
const telemetryMap = new Map(dataSet.map((item) => [item[parameter.timeKey], item]));
|
||||||
@ -61,7 +61,7 @@ function calculate(dataFrame, parameters, expression) {
|
|||||||
const otherParameters = parameters.slice(1);
|
const otherParameters = parameters.slice(1);
|
||||||
// iterate over the reference telemetry data
|
// iterate over the reference telemetry data
|
||||||
const referenceTelemetry = dataFrame[referenceParameter.keyString];
|
const referenceTelemetry = dataFrame[referenceParameter.keyString];
|
||||||
referenceTelemetry.forEach((referenceTelemetryItem) => {
|
referenceTelemetry?.forEach((referenceTelemetryItem) => {
|
||||||
const scope = {
|
const scope = {
|
||||||
[referenceParameter.name]: referenceTelemetryItem[referenceParameter.valueToUse]
|
[referenceParameter.name]: referenceTelemetryItem[referenceParameter.valueToUse]
|
||||||
};
|
};
|
||||||
|
@ -63,7 +63,9 @@ export default class CompsTelemetryProvider {
|
|||||||
);
|
);
|
||||||
specificCompsManager.load(options).then(() => {
|
specificCompsManager.load(options).then(() => {
|
||||||
const callbackID = this.#getCallbackID();
|
const callbackID = this.#getCallbackID();
|
||||||
const telemetryForComps = specificCompsManager.requestUnderlyingTelemetry();
|
const telemetryForComps = JSON.parse(
|
||||||
|
JSON.stringify(specificCompsManager.requestUnderlyingTelemetry())
|
||||||
|
);
|
||||||
const expression = specificCompsManager.getExpression();
|
const expression = specificCompsManager.getExpression();
|
||||||
const parameters = JSON.parse(JSON.stringify(specificCompsManager.getParameters()));
|
const parameters = JSON.parse(JSON.stringify(specificCompsManager.getParameters()));
|
||||||
if (!expression || !parameters) {
|
if (!expression || !parameters) {
|
||||||
@ -78,6 +80,11 @@ export default class CompsTelemetryProvider {
|
|||||||
parameters,
|
parameters,
|
||||||
callbackID
|
callbackID
|
||||||
};
|
};
|
||||||
|
console.debug(
|
||||||
|
`📝 Requesting calculation for ${domainObject.name} with callback ID ${callbackID}:`,
|
||||||
|
options,
|
||||||
|
payload
|
||||||
|
);
|
||||||
this.#sharedWorker.port.postMessage(payload);
|
this.#sharedWorker.port.postMessage(payload);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -117,12 +124,22 @@ export default class CompsTelemetryProvider {
|
|||||||
callbackID
|
callbackID
|
||||||
);
|
);
|
||||||
specificCompsManager.on('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
specificCompsManager.on('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
||||||
specificCompsManager.load();
|
const telemetryOptions = {
|
||||||
|
strategy: 'latest',
|
||||||
|
size: 1
|
||||||
|
};
|
||||||
|
specificCompsManager.load(telemetryOptions);
|
||||||
|
console.debug(
|
||||||
|
`📝 Starting subscription for ${domainObject.name} with callback ID ${callbackID}`
|
||||||
|
);
|
||||||
return () => {
|
return () => {
|
||||||
specificCompsManager.off('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
|
||||||
delete this.#subscriptionCallbacks[callbackID];
|
delete this.#subscriptionCallbacks[callbackID];
|
||||||
// if this is the last subscription, tell the comp manager to stop listening
|
console.debug(
|
||||||
|
`🛑 Stopping subscription for ${domainObject.name} with callback ID ${callbackID}. We now have ${Object.keys(this.#subscriptionCallbacks).length} subscribers`,
|
||||||
|
this.#subscriptionCallbacks
|
||||||
|
);
|
||||||
specificCompsManager.stopListeningToUnderlyingTelemetry();
|
specificCompsManager.stopListeningToUnderlyingTelemetry();
|
||||||
|
specificCompsManager.off('underlyingTelemetryUpdated', boundComputeOnNewTelemetry);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +174,7 @@ export default class CompsTelemetryProvider {
|
|||||||
console.error('📝 Error calculating request:', event.data);
|
console.error('📝 Error calculating request:', event.data);
|
||||||
this.#requestPromises[callbackID].resolve([]);
|
this.#requestPromises[callbackID].resolve([]);
|
||||||
} else {
|
} else {
|
||||||
|
console.debug(`🧮 Calculation request result for ${callbackID}:`, result);
|
||||||
this.#requestPromises[callbackID].resolve(result);
|
this.#requestPromises[callbackID].resolve(result);
|
||||||
}
|
}
|
||||||
delete this.#requestPromises[callbackID];
|
delete this.#requestPromises[callbackID];
|
||||||
|
@ -185,11 +185,10 @@ onBeforeMount(async () => {
|
|||||||
compsManager.on('parameterAdded', reloadParameters);
|
compsManager.on('parameterAdded', reloadParameters);
|
||||||
compsManager.on('parameterRemoved', reloadParameters);
|
compsManager.on('parameterRemoved', reloadParameters);
|
||||||
compsManager.on('outputFormatChanged', updateOutputFormat);
|
compsManager.on('outputFormatChanged', updateOutputFormat);
|
||||||
await compsManager.load();
|
await outputTelemetryCollection.load(telemetryOptions); // will implicitly load compsManager
|
||||||
parameters.value = compsManager.getParameters();
|
parameters.value = compsManager.getParameters();
|
||||||
expression.value = compsManager.getExpression();
|
expression.value = compsManager.getExpression();
|
||||||
outputFormat.value = compsManager.getOutputFormat();
|
outputFormat.value = compsManager.getOutputFormat();
|
||||||
outputTelemetryCollection.load();
|
|
||||||
applyTestData();
|
applyTestData();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user