diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 191f5f6..f6a3827 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -1,3 +1,17 @@ +// Map a child's raw softwareType (the lowercased node name from +// buildConfig) to the "role" key that parent registerChild() handlers +// dispatch on. Without this, MGC/pumpingStation register-handlers (which +// branch on 'machine' / 'machinegroup' / 'pumpingstation' / 'measurement') +// silently miss every real production child because rotatingMachine +// reports softwareType='rotatingmachine' and machineGroupControl reports +// 'machinegroupcontrol'. Existing tests that pass already-aliased keys +// ('machine', 'machinegroup') stay green because those aren't in the +// alias map and pass through unchanged. +const SOFTWARE_TYPE_ALIASES = { + rotatingmachine: 'machine', + machinegroupcontrol: 'machinegroup', +}; + class ChildRegistrationUtils { constructor(mainClass) { this.mainClass = mainClass; @@ -15,7 +29,8 @@ class ChildRegistrationUtils { return false; } - const softwareType = (child.config.functionality.softwareType || '').toLowerCase(); + const rawSoftwareType = (child.config.functionality.softwareType || '').toLowerCase(); + const softwareType = SOFTWARE_TYPE_ALIASES[rawSoftwareType] || rawSoftwareType; const name = child.config.general.name || child.config.general.id || 'unknown'; const id = child.config.general.id || name;