From 294cf49521f1725ab0a7f63cbf35dfd5e9732c47 Mon Sep 17 00:00:00 2001 From: Rene De Ren Date: Wed, 11 Mar 2026 14:59:41 +0100 Subject: [PATCH] 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 --- src/nodeClass.js | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/nodeClass.js b/src/nodeClass.js index d49657a..928e18a 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -39,32 +39,16 @@ class nodeClass { /** * 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. */ _loadConfig(uiConfig,node) { const cfgMgr = new configManager(); this.defaultConfig = cfgMgr.getConfig(this.name); - // Merge UI config over defaults - this.config = { - 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 - }, + // Build config: base sections + measurement-specific domain config + this.config = cfgMgr.buildConfig(this.name, uiConfig, node.id, { scaling: { enabled: uiConfig.scaling, inputMin: uiConfig.i_min, @@ -79,14 +63,8 @@ class nodeClass { }, simulation: { 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 this._output = new outputUtils();