diff --git a/src/specificClass.js b/src/specificClass.js index a0f3853..3ad3fa5 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -75,13 +75,13 @@ class Machine { /*------------------- Register child events -------------------*/ registerChild(child, softwareType) { - this.logger.debug('Setting up child event for softwaretype ' + softwareType); - switch (softwareType) { case "measurement": + this.logger.debug(`Registering measurement child...`); this._connectMeasurement(child); break; case "reactor": + this.logger.debug(`Registering reactor child...`); this._connectReactor(child); break; @@ -91,10 +91,14 @@ class Machine { } _connectMeasurement(measurementChild) { + if (!measurementChild) { + this.logger.warn("Invalid measurement provided."); + return; + } + const position = measurementChild.config.functionality.positionVsParent; const distance = measurementChild.config.functionality.distanceVsParent || 0; const measurementType = measurementChild.config.asset.type; - const key = `${measurementType}_${position}`; //rebuild to measurementype.variant no position and then switch based on values not strings or names. const eventName = `${measurementType}.measured.${position}`;