diff --git a/src/nodeClass.js b/src/nodeClass.js index 47ec062..b00364f 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -114,12 +114,12 @@ class nodeClass { const vol = pickVariant('volume', ['measured', 'predicted'], 'atEquipment', 'm3'); const volPercent = pickVariant('volumePercent', ['measured','predicted'], 'atEquipment'); // already unitless const level = pickVariant('level', ['measured', 'predicted'], 'atEquipment', 'm'); - const netFlow = pickVariant('netFlowRate', ['measured', 'predicted'], 'atEquipment', 'm3/s'); + const netFlow = pickVariant('netFlowRate', ['measured', 'predicted'], 'atEquipment', 'm3/h'); const maxVolBeforeOverflow = ps.basin?.maxVolOverflow ?? ps.basin?.maxVol ?? 0; const currentVolume = vol.value ?? 0; const currentvolPercent = volPercent.value ?? 0; - const netFlowM3h = (netFlow.value ?? 0) * 3600; + const netFlowM3h = netFlow.value ?? 0; const direction = ps.state?.direction ?? 'unknown'; const secondsRemaining = ps.state?.seconds ?? null; @@ -128,9 +128,9 @@ class nodeClass { const badgePieces = []; badgePieces.push(`${currentvolPercent.toFixed(1)}% `); badgePieces.push( - `V=${currentVolume.toFixed(2)} / ${maxVolBeforeOverflow.toFixed(2)} m³ (${'n/a'})` + `V=${currentVolume.toFixed(2)} / ${maxVolBeforeOverflow.toFixed(2)} m³` ); - badgePieces.push(`net=${netFlowM3h.toFixed(1)} m³/h (${'n/a'})`); + badgePieces.push(`net: ${netFlowM3h.toFixed(0)} m³/h`); if (timeRemainingMinutes != null) { badgePieces.push(`t≈${timeRemainingMinutes} min)`); } diff --git a/src/specificClass.js b/src/specificClass.js index d9ee587..c306f96 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -12,12 +12,12 @@ class PumpingStation { this.measurements = new MeasurementContainer({ autoConvert: true }); this.measurements.setPreferredUnit('flow', 'm3/s'); + this.measurements.setPreferredUnit('netFlowRate', 'm3/s'); this.measurements.setPreferredUnit('level', 'm'); this.measurements.setPreferredUnit('volume', 'm3'); this.childRegistrationUtils = new childRegistrationUtils(this); this.machines = {}; this.stations = {}; - //variants in determining what gets priority @@ -64,7 +64,7 @@ class PumpingStation { const netFlow = this._selectBestNetFlow(snapshot); //write netflow in measurment container - //this.measurements() + const remaining = this._computeRemainingTime(snapshot, netFlow); this.state = { @@ -301,12 +301,16 @@ class PumpingStation { _selectBestNetFlow(snapshot) { for (const variant of this.flowVariants) { const flow = snapshot.flows[variant]; + if (!flow.inflow.exists && !flow.outflow.exists) continue; const inflow = flow.inflow.current?.value ?? 0; const outflow = flow.outflow.current?.value ?? 0; const net = inflow - outflow; // positive => filling + this.measurements.type('netFlowRate').variant(variant).position('atequipment').value(net).unit('m3/s'); + this.logger.debug(`inflow : ${inflow} - outflow : ${outflow}`); + return { value: net,source: variant,direction: this._deriveDirection(net) }; }