Add distance float position handling with backward compatibility #1

Merged
p.vanderwilt merged 22 commits from :main into main 2025-09-26 11:41:53 +00:00
Showing only changes of commit 6dcd3c3d26 - Show all commits

View File

@@ -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);
});
}