Merge pull request 'implement-reactor-child' (#2) from implement-reactor-child into main
Reviewed-on: p.vanderwilt/generalFunctions#2
This commit is contained in:
@@ -85,12 +85,12 @@ class ChildRegistrationUtils {
|
||||
|
||||
case "actuator":
|
||||
this.logger.debug(`Registering linear actuator child: ${id}`);
|
||||
this.connectActuator(child,positionVsParent);
|
||||
this.connectActuator(child, positionVsParent);
|
||||
break;
|
||||
|
||||
case "reactor":
|
||||
this.logger.debug(`Registering reactor child: ${id}`);
|
||||
this.connectReactor(child);
|
||||
this.connectReactor(child, positionVsParent);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -228,18 +228,30 @@ 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)
|
||||
|
||||
connectReactor(reactor) {
|
||||
connectReactor(reactor, positionVsParent) {
|
||||
if (!reactor) {
|
||||
this.logger.warn("Invalid reactor provided.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.mainClass?.upstreamReactor){
|
||||
this.mainClass.upstreamReactor = reactor; // Add reactor to the main class
|
||||
this.logger.info(`Reactor registered successfully.`);
|
||||
this.logger.info(`Upstream reactor registered successfully.`);
|
||||
} else if (this.mainClass?.reactors) {
|
||||
if (positionVsParent == "downstream") {
|
||||
this.mainClass.reactors[0] = reactor;
|
||||
}
|
||||
if (positionVsParent == "upstream") {
|
||||
this.mainClass.reactors[1] = reactor;
|
||||
}
|
||||
this.logger.info(`Reactor registered successfully: ${this.mainClass.reactors}`);
|
||||
} else {
|
||||
this.logger.error(`Reactor not registered!`)
|
||||
}
|
||||
|
||||
reactor.emitter.on("stateChange", (data) => {
|
||||
this.mainClass.logger.debug(`State change of reactor detected: ${data}`);
|
||||
this.mainClass.setInflux = data;
|
||||
this.mainClass.updateState(data.timestamp);
|
||||
this.mainClass.logger.debug(`State change of upstream reactor detected.`);
|
||||
this.mainClass.updateState(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user