refactor: adopt POSITIONS constants and fix ESLint warnings

Replace hardcoded position strings with POSITIONS.* constants.
Prefix unused variables with _ to resolve no-unused-vars warnings.
Fix no-prototype-builtins where applicable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rene De Ren
2026-03-11 15:35:28 +01:00
parent 8ae21ce787
commit 417fad4ec3

View File

@@ -1,4 +1,4 @@
const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions'); const { childRegistrationUtils, logger, MeasurementContainer, POSITIONS } = require('generalFunctions');
const EventEmitter = require('events'); const EventEmitter = require('events');
class Settler { class Settler {
@@ -26,7 +26,7 @@ class Settler {
let F_sr = 0; let F_sr = 0;
if (this.returnPump) { if (this.returnPump) {
F_sr = Math.min(this.returnPump.measurements.type("flow").variant("measured").position("atEquipment").getCurrentValue(), F_s); F_sr = Math.min(this.returnPump.measurements.type("flow").variant("measured").position(POSITIONS.AT_EQUIPMENT).getCurrentValue(), F_s);
} }
const F_so = F_s - F_sr; const F_so = F_s - F_sr;
@@ -105,13 +105,13 @@ class Settler {
} }
_connectReactor(reactorChild) { _connectReactor(reactorChild) {
if (reactorChild.config.functionality.positionVsParent != "upstream") { if (reactorChild.config.functionality.positionVsParent != POSITIONS.UPSTREAM) {
this.logger.warn("Reactor children of settlers should be upstream."); this.logger.warn("Reactor children of settlers should be upstream.");
} }
this.upstreamReactor = reactorChild; this.upstreamReactor = reactorChild;
reactorChild.emitter.on("stateChange", (eventData) => { reactorChild.emitter.on("stateChange", (_eventData) => {
this.logger.debug(`State change of upstream reactor detected.`); this.logger.debug(`State change of upstream reactor detected.`);
const effluent = this.upstreamReactor.getEffluent[0]; const effluent = this.upstreamReactor.getEffluent[0];
this.F_in = effluent.payload.F; this.F_in = effluent.payload.F;
@@ -120,7 +120,7 @@ class Settler {
} }
_connectMachine(machineChild) { _connectMachine(machineChild) {
if (machineChild.config.functionality.positionVsParent == "downstream") { if (machineChild.config.functionality.positionVsParent == POSITIONS.DOWNSTREAM) {
machineChild.upstreamSource = this; machineChild.upstreamSource = this;
this.returnPump = machineChild; this.returnPump = machineChild;
return; return;
@@ -128,7 +128,7 @@ class Settler {
this.logger.warn(`Failed to register machine child.`); this.logger.warn(`Failed to register machine child.`);
} }
_updateMeasurement(measurementType, value, position, context) { _updateMeasurement(measurementType, value, _position, _context) {
switch(measurementType) { switch(measurementType) {
case "quantity (tss)": case "quantity (tss)":
this.C_TS = value; this.C_TS = value;