Merge pull request 'Implement Reactor parent-child' (#1) from implement-reactor-child into main

Reviewed-on: p.vanderwilt/generalFunctions#1
This commit is contained in:
2025-07-21 12:29:42 +00:00

View File

@@ -88,8 +88,12 @@ class ChildRegistrationUtils {
this.connectActuator(child,positionVsParent); this.connectActuator(child,positionVsParent);
break; break;
case "reactor":
this.logger.debug(`Registering reactor child: ${id}`);
this.connectReactor(child);
break;
default: default:
this.logger.error(`Child registration unrecognized desc: ${desc}`);
this.logger.error(`Unrecognized softwareType: ${softwareType}`); this.logger.error(`Unrecognized softwareType: ${softwareType}`);
} }
} }
@@ -223,6 +227,22 @@ class ChildRegistrationUtils {
} }
//wanneer hij deze ontvangt is deltaP van een van de valves veranderd (kan ook zijn niet child zijn, maar dat maakt niet uit) //wanneer hij deze ontvangt is deltaP van een van de valves veranderd (kan ook zijn niet child zijn, maar dat maakt niet uit)
connectReactor(reactor) {
if (!reactor) {
this.logger.warn("Invalid reactor provided.");
return;
}
this.mainClass.upstreamReactor = reactor; // Add reactor to the main class
this.logger.info(`Reactor registered successfully.`);
reactor.emitter.on("stateChange", (data) => {
this.mainClass.logger.debug(`State change of reactor detected: ${data}`);
this.mainClass.setInflux = data;
this.mainClass.updateState(data.timestamp);
});
}
} }
module.exports = ChildRegistrationUtils; module.exports = ChildRegistrationUtils;