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>
This commit is contained in:
@@ -42,32 +42,13 @@ class nodeClass {
|
|||||||
* @param {object} uiConfig - Raw config from Node-RED UI.
|
* @param {object} uiConfig - Raw config from Node-RED UI.
|
||||||
*/
|
*/
|
||||||
_loadConfig(uiConfig,node) {
|
_loadConfig(uiConfig,node) {
|
||||||
|
// Resolve flow unit with validation before building config
|
||||||
const flowUnit = this._resolveUnitOrFallback(uiConfig.unit, 'volumeFlowRate', 'm3/h', 'flow');
|
const flowUnit = this._resolveUnitOrFallback(uiConfig.unit, 'volumeFlowRate', 'm3/h', 'flow');
|
||||||
|
const resolvedUiConfig = { ...uiConfig, unit: flowUnit };
|
||||||
|
|
||||||
// Merge UI config over defaults
|
// Build config: base sections handle general, asset, functionality
|
||||||
this.config = {
|
const cfgMgr = new configManager();
|
||||||
general: {
|
this.config = cfgMgr.buildConfig(this.name, resolvedUiConfig, node.id);
|
||||||
name: uiConfig.name,
|
|
||||||
id: node.id, // node.id is for the child registration process
|
|
||||||
unit: flowUnit,
|
|
||||||
logging: {
|
|
||||||
enabled: uiConfig.enableLog,
|
|
||||||
logLevel: uiConfig.logLevel
|
|
||||||
}
|
|
||||||
},
|
|
||||||
asset: {
|
|
||||||
uuid: uiConfig.uuid || uiConfig.assetUuid || null,
|
|
||||||
tagCode: uiConfig.tagCode || uiConfig.assetTagCode || null,
|
|
||||||
supplier: uiConfig.supplier,
|
|
||||||
category: uiConfig.category, //add later to define as the software type
|
|
||||||
type: uiConfig.assetType,
|
|
||||||
model: uiConfig.model,
|
|
||||||
unit: flowUnit
|
|
||||||
},
|
|
||||||
functionality: {
|
|
||||||
positionVsParent: uiConfig.positionVsParent || 'atEquipment', // Default to 'atEquipment' if not specified
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Utility for formatting outputs
|
// Utility for formatting outputs
|
||||||
this._output = new outputUtils();
|
this._output = new outputUtils();
|
||||||
|
|||||||
Reference in New Issue
Block a user