fixed pressure updates from machines. Everything seems to be working again.

This commit is contained in:
znetsixe
2025-09-23 15:50:40 +02:00
parent ac9d1b4fdd
commit a55c6bdbea
2 changed files with 50 additions and 19 deletions

View File

@@ -63,17 +63,21 @@ class MachineGroup {
if(softwareType == "machine"){
// Check if the machine is already registered
this.machines[child.config.general.id] === undefined ? this.machines[child.config.general.id] = child : this.logger.warn(`Machine ${child.config.general.id} is already registered.`);
this.handleChildChange();
/*
// Listen for changes in the child machine
child.emitter.on('stateChange', () => this.handleChildChange());
child.emitter.on('pressureChange', () => this.handlePressureChange());
child.emitter.on('ncogChange', () => this.handleChildChange());
*/
//listen for machine pressure changes
this.logger.debug(`Listening for pressure changes from machine ${child.config.general.id}`);
child.measurements.emitter.on("pressure.measured.differential", (eventData) => {
this.logger.debug(`Pressure update from ${child.config.general.id}: ${eventData.value} ${eventData.unit}`);
this.handleChildChange();
});
}
}
calcAbsoluteTotals() {
const absoluteTotals = { flow: { min: Infinity, max: 0 }, power: { min: Infinity, max: 0 } };
@@ -112,7 +116,10 @@ class MachineGroup {
const dynamicTotals = { flow: { min: Infinity, max: 0 }, power: { min: Infinity, max: 0 }, NCog : 0 };
this.logger.debug(`\n --------- Calculating dynamic totals for ${Object.keys(this.machines).length} machines. @ current pressure settings : ----------`);
Object.values(this.machines).forEach(machine => {
this.logger.debug(`Processing machine with id: ${machine.config.general.id}`);
this.logger.debug(`Current pressure settings: ${JSON.stringify(machine.predictFlow.currentF)}`);
//fetch min flow ever seen over all machines
const minFlow = machine.predictFlow.currentFxyYMin;
const maxFlow = machine.predictFlow.currentFxyYMax;