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 -------------------*/
|
/*------------------- Register child events -------------------*/
|
||||||
registerChild(child, softwareType) {
|
registerChild(child, softwareType) {
|
||||||
this.logger.debug('Setting up child event for softwaretype ' + softwareType);
|
|
||||||
|
|
||||||
switch (softwareType) {
|
switch (softwareType) {
|
||||||
case "measurement":
|
case "measurement":
|
||||||
|
this.logger.debug(`Registering measurement child...`);
|
||||||
this._connectMeasurement(child);
|
this._connectMeasurement(child);
|
||||||
break;
|
break;
|
||||||
case "reactor":
|
case "reactor":
|
||||||
|
this.logger.debug(`Registering reactor child...`);
|
||||||
this._connectReactor(child);
|
this._connectReactor(child);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -91,10 +91,14 @@ class Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_connectMeasurement(measurementChild) {
|
_connectMeasurement(measurementChild) {
|
||||||
|
if (!measurementChild) {
|
||||||
|
this.logger.warn("Invalid measurement provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const position = measurementChild.config.functionality.positionVsParent;
|
const position = measurementChild.config.functionality.positionVsParent;
|
||||||
const distance = measurementChild.config.functionality.distanceVsParent || 0;
|
const distance = measurementChild.config.functionality.distanceVsParent || 0;
|
||||||
const measurementType = measurementChild.config.asset.type;
|
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.
|
//rebuild to measurementype.variant no position and then switch based on values not strings or names.
|
||||||
const eventName = `${measurementType}.measured.${position}`;
|
const eventName = `${measurementType}.measured.${position}`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user