Add distance float position handling with backward compatibility #1
@@ -90,7 +90,7 @@ class ChildRegistrationUtils {
|
|||||||
|
|
||||||
case "reactor":
|
case "reactor":
|
||||||
this.logger.debug(`Registering reactor child: ${id}`);
|
this.logger.debug(`Registering reactor child: ${id}`);
|
||||||
this.connectReactor(child);
|
this.connectReactor(child, positionVsParent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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)
|
//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) {
|
if (!reactor) {
|
||||||
this.logger.warn("Invalid reactor provided.");
|
this.logger.warn("Invalid reactor provided.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.mainClass?.upstreamReactor){
|
||||||
this.mainClass.upstreamReactor = reactor; // Add reactor to the main class
|
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) => {
|
reactor.emitter.on("stateChange", (data) => {
|
||||||
this.mainClass.logger.debug(`State change of reactor detected: ${data}`);
|
this.mainClass.logger.debug(`State change of upstream reactor detected.`);
|
||||||
this.mainClass.setInflux = data;
|
this.mainClass.updateState(data);
|
||||||
this.mainClass.updateState(data.timestamp);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user