Compare commits

..

2 Commits

Author SHA1 Message Date
Rene De Ren
1b7285f29e 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
294cf49521 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:41 +01:00
2 changed files with 7 additions and 29 deletions

View File

@@ -39,32 +39,16 @@ class nodeClass {
/** /**
* Load and merge default config with user-defined settings. * Load and merge default config with user-defined settings.
* Uses ConfigManager.buildConfig() for base sections (general, asset, functionality),
* then adds measurement-specific domain config.
* @param {object} uiConfig - Raw config from Node-RED UI. * @param {object} uiConfig - Raw config from Node-RED UI.
*/ */
_loadConfig(uiConfig,node) { _loadConfig(uiConfig,node) {
const cfgMgr = new configManager(); const cfgMgr = new configManager();
this.defaultConfig = cfgMgr.getConfig(this.name); this.defaultConfig = cfgMgr.getConfig(this.name);
// Merge UI config over defaults // Build config: base sections + measurement-specific domain config
this.config = { this.config = cfgMgr.buildConfig(this.name, uiConfig, node.id, {
general: {
name: this.name,
id: node.id, // node.id is for the child registration process
unit: uiConfig.unit, // add converter options later to convert to default units (need like a model that defines this which units we are going to use and then conver to those standards)
logging: {
enabled: uiConfig.enableLog,
logLevel: uiConfig.logLevel
}
},
asset: {
uuid: uiConfig.assetUuid, //need to add this later to the asset model
tagCode: uiConfig.assetTagCode, //need to add this later to the asset model
supplier: uiConfig.supplier,
category: uiConfig.category, //add later to define as the software type
type: uiConfig.assetType,
model: uiConfig.model,
unit: uiConfig.unit
},
scaling: { scaling: {
enabled: uiConfig.scaling, enabled: uiConfig.scaling,
inputMin: uiConfig.i_min, inputMin: uiConfig.i_min,
@@ -79,14 +63,8 @@ class nodeClass {
}, },
simulation: { simulation: {
enabled: uiConfig.simulator enabled: uiConfig.simulator
},
functionality: {
positionVsParent: uiConfig.positionVsParent,// Default to 'atEquipment' if not specified
distance: uiConfig.hasDistance ? uiConfig.distance : undefined
} }
}; });
console.log(`position vs child for ${this.name} is ${this.config.functionality.positionVsParent} the distance is ${this.config.functionality.distance}`);
// Utility for formatting outputs // Utility for formatting outputs
this._output = new outputUtils(); this._output = new outputUtils();

View File

@@ -381,7 +381,7 @@ class Measurement {
const lowPass = this.lowPassFilter(arr); // Apply low-pass filter const lowPass = this.lowPassFilter(arr); // Apply low-pass filter
const highPass = this.highPassFilter(arr); // Apply high-pass filter const highPass = this.highPassFilter(arr); // Apply high-pass filter
return arr.map((val, idx) => lowPass + highPass - val).pop(); // Combine the filters return arr.map((val, _idx) => lowPass + highPass - val).pop(); // Combine the filters
} }
weightedMovingAverage(arr) { weightedMovingAverage(arr) {
@@ -558,7 +558,7 @@ const configuration = {
enabled: true, enabled: true,
}, },
functionality: { functionality: {
positionVsParent: "upstream" positionVsParent: POSITIONS.UPSTREAM
} }
}; };