Fix recirculation flow measurement to use getCurrentValue and handle undefined values

This commit is contained in:
HorriblePerson555
2025-10-20 17:37:29 +02:00
parent 3a820df7f2
commit 018215934e

View File

@@ -76,8 +76,8 @@ class Reactor {
const Cs = isArray(this.state.at(-1)) ? this.state.at(-1) : this.state; const Cs = isArray(this.state.at(-1)) ? this.state.at(-1) : this.state;
const effluent = [{ topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: Cs }, timestamp: this.currentTime }]; const effluent = [{ topic: "Fluent", payload: { inlet: 0, F: math.sum(this.Fs), C: Cs }, timestamp: this.currentTime }];
if (this.returnPump) { if (this.returnPump) {
const recirculationFlow = this.returnPump.measurements.type("flow").variant("measured").position("atEquipement").getValue(); const recirculationFlow = this.returnPump.measurements.type("flow").variant("measured").position("atEquipement").getCurrentValue();
effluent[0].F -= recirculationFlow; effluent[0].F -= recirculationFlow || 0;
effluent.push({ topic: "Fluent", payload: { inlet: 1, F: recirculationFlow, C: Cs }, timestamp: this.currentTime }); effluent.push({ topic: "Fluent", payload: { inlet: 1, F: recirculationFlow, C: Cs }, timestamp: this.currentTime });
} }
return effluent; return effluent;