Compare commits

...

3 Commits

Author SHA1 Message Date
Rene De Ren
417fad4ec3 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>
2026-03-11 15:35:28 +01:00
Rene De Ren
8ae21ce787 Migrate _loadConfig to use ConfigManager.buildConfig()
Replaces manual base config construction with shared buildConfig() method.
Node now only specifies domain-specific config sections.

Part of #1: Extract base config schema

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:59:35 +01:00
Rene De Ren
5deb22b8da Fix ESLint errors and bugs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 13:39:57 +01:00
2 changed files with 12 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
const { Settler } = require('./specificClass.js');
const { configManager } = require('generalFunctions');
class nodeClass {
@@ -32,12 +33,13 @@ class nodeClass {
this.node.on('input', (msg, send, done) => {
switch (msg.topic) {
case 'registerChild':
case 'registerChild': {
// Register this node as a parent of the child node
const childId = msg.payload;
const childObj = this.RED.nodes.getNode(childId);
this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
break;
}
default:
console.log("Unknown topic: " + msg.topic);
}
@@ -53,21 +55,8 @@ class nodeClass {
* @param {object} uiConfig Config set in UI in node-red
*/
_loadConfig(uiConfig) {
this.config = {
general: {
name: uiConfig.name || this.name,
id: this.node.id,
unit: null,
logging: {
enabled: uiConfig.enableLog,
logLevel: uiConfig.logLevel
}
},
functionality: {
positionVsParent: uiConfig.positionVsParent || 'atEquipment', // Default to 'atEquipment' if not specified
softwareType: "settler" // should be set in config manager
}
}
const cfgMgr = new configManager();
this.config = cfgMgr.buildConfig('settler', uiConfig, this.node.id);
}
/**

View File

@@ -1,4 +1,4 @@
const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions');
const { childRegistrationUtils, logger, MeasurementContainer, POSITIONS } = require('generalFunctions');
const EventEmitter = require('events');
class Settler {
@@ -26,7 +26,7 @@ class Settler {
let F_sr = 0;
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;
@@ -105,13 +105,13 @@ class Settler {
}
_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.upstreamReactor = reactorChild;
reactorChild.emitter.on("stateChange", (eventData) => {
reactorChild.emitter.on("stateChange", (_eventData) => {
this.logger.debug(`State change of upstream reactor detected.`);
const effluent = this.upstreamReactor.getEffluent[0];
this.F_in = effluent.payload.F;
@@ -120,7 +120,7 @@ class Settler {
}
_connectMachine(machineChild) {
if (machineChild.config.functionality.positionVsParent == "downstream") {
if (machineChild.config.functionality.positionVsParent == POSITIONS.DOWNSTREAM) {
machineChild.upstreamSource = this;
this.returnPump = machineChild;
return;
@@ -128,7 +128,7 @@ class Settler {
this.logger.warn(`Failed to register machine child.`);
}
_updateMeasurement(measurementType, value, position, context) {
_updateMeasurement(measurementType, value, _position, _context) {
switch(measurementType) {
case "quantity (tss)":
this.C_TS = value;