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 aacbc1e99d
commit a18c36b2e5
5 changed files with 7 additions and 10 deletions

View File

@@ -3,7 +3,6 @@ module.exports = function(RED) {
RED.nodes.createNode(this, config); RED.nodes.createNode(this, config);
var node = this; var node = this;
let name = config.name;
let F2 = parseFloat(config.F2); let F2 = parseFloat(config.F2);
const inlet_F2 = parseInt(config.inlet); const inlet_F2 = parseInt(config.inlet);

View File

@@ -3,7 +3,6 @@ module.exports = function(RED) {
RED.nodes.createNode(this, config); RED.nodes.createNode(this, config);
var node = this; var node = this;
let name = config.name;
let TS_set = parseFloat(config.TS_set); let TS_set = parseFloat(config.TS_set);
const inlet_sludge = parseInt(config.inlet); const inlet_sludge = parseInt(config.inlet);

View File

@@ -171,7 +171,7 @@ class ASM3 {
compute_rates(state, T = 20) { compute_rates(state, T = 20) {
// state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS // state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS
const rates = Array(12); const rates = Array(12);
const [S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS] = state; const [S_O, , S_S, S_NH, , S_NO, S_HCO, , X_S, X_H, X_STO, X_A] = state;
const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params; const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params;
const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params; const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params;

View File

@@ -171,7 +171,7 @@ class ASM3 {
compute_rates(state, T = 20) { compute_rates(state, T = 20) {
// state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS // state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS
const rates = Array(12); const rates = Array(12);
const [S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS] = state; const [S_O, , S_S, S_NH, , S_NO, S_HCO, , X_S, X_H, X_STO, X_A] = state;
const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params; const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params;
const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params; const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params;

View File

@@ -1,7 +1,7 @@
const ASM3 = require('./reaction_modules/asm3_class.js'); const ASM3 = require('./reaction_modules/asm3_class.js');
const { create, all, isArray } = require('mathjs'); const { create, all, isArray } = require('mathjs');
const { assertNoNaN } = require('./utils.js'); const { assertNoNaN } = require('./utils.js');
const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions'); const { childRegistrationUtils, logger, MeasurementContainer, POSITIONS } = require('generalFunctions');
const EventEmitter = require('events'); const EventEmitter = require('events');
const mathConfig = { const mathConfig = {
@@ -126,7 +126,6 @@ class Reactor {
position = measurement.config.functionality.positionVsParent; position = measurement.config.functionality.positionVsParent;
} }
const measurementType = measurement.config.asset.type; const measurementType = measurement.config.asset.type;
const key = `${measurementType}_${position}`;
const eventName = `${measurementType}.measured.${position}`; const eventName = `${measurementType}.measured.${position}`;
// Register event listener for measurement updates // Register event listener for measurement updates
@@ -160,11 +159,11 @@ class Reactor {
} }
_updateMeasurement(measurementType, value, position, context) { _updateMeasurement(measurementType, value, position, _context) {
this.logger.debug(`---------------------- updating ${measurementType} ------------------ `); this.logger.debug(`---------------------- updating ${measurementType} ------------------ `);
switch (measurementType) { switch (measurementType) {
case "temperature": case "temperature":
if (position == "atEquipment") { if (position == POSITIONS.AT_EQUIPMENT) {
this.temperature = value; this.temperature = value;
} }
break; break;
@@ -320,7 +319,7 @@ class Reactor_PFR extends Reactor {
return stateNew; return stateNew;
} }
_updateMeasurement(measurementType, value, position, context) { _updateMeasurement(measurementType, value, position, _context) {
switch(measurementType) { switch(measurementType) {
case "quantity (oxygen)": { case "quantity (oxygen)": {
let grid_pos = Math.round(position / this.config.length * this.n_x); let grid_pos = Math.round(position / this.config.length * this.n_x);
@@ -328,7 +327,7 @@ class Reactor_PFR extends Reactor {
break; break;
} }
default: default:
super._updateMeasurement(measurementType, value, position, context); super._updateMeasurement(measurementType, value, position, _context);
} }
} }