forked from RnD/rotatingMachine
Enhance child registration logging and add validation for measurement child
This commit is contained in:
@@ -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}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user