Rewrite reactor to source and register it properly to node object
This commit is contained in:
@@ -14,12 +14,13 @@ class nodeClass {
|
|||||||
this.node = nodeInstance;
|
this.node = nodeInstance;
|
||||||
this.RED = RED;
|
this.RED = RED;
|
||||||
this.name = nameOfNode;
|
this.name = nameOfNode;
|
||||||
|
this.source = null;
|
||||||
|
|
||||||
this._loadConfig(uiConfig)
|
this._loadConfig(uiConfig)
|
||||||
this._registerChild();
|
|
||||||
this._setupClass();
|
this._setupClass();
|
||||||
|
|
||||||
this._attachInputHandler();
|
this._attachInputHandler();
|
||||||
|
this._registerChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,27 +33,28 @@ class nodeClass {
|
|||||||
switch (msg.topic) {
|
switch (msg.topic) {
|
||||||
case "clock":
|
case "clock":
|
||||||
toggleUpdate = true;
|
toggleUpdate = true;
|
||||||
this.reactor.updateState(msg.timestamp);
|
this.source.updateState(msg.timestamp);
|
||||||
send([this.reactor.getEffluent, null, null]);
|
send([this.source.getEffluent, null, null]);
|
||||||
send([msg, null, null])
|
send([msg, null, null])
|
||||||
break;
|
break;
|
||||||
case "Fluent":
|
case "Fluent":
|
||||||
this.reactor.setInfluent = msg;
|
this.source.setInfluent = msg;
|
||||||
break;
|
break;
|
||||||
case "OTR":
|
case "OTR":
|
||||||
this.reactor.setOTR = msg;
|
this.source.setOTR = msg;
|
||||||
break;
|
break;
|
||||||
case "Temperature":
|
case "Temperature":
|
||||||
this.reactor.setTemperature = msg;
|
this.source.setTemperature = msg;
|
||||||
break;
|
break;
|
||||||
case "Dispersion":
|
case "Dispersion":
|
||||||
this.reactor.setDispersion = msg;
|
this.source.setDispersion = msg;
|
||||||
break;
|
break;
|
||||||
case 'registerChild':
|
case 'registerChild':
|
||||||
// Register this node as a child of the parent node
|
// Register this node as a child of the parent node
|
||||||
const childId = msg.payload;
|
const childId = msg.payload;
|
||||||
const childObj = this.RED.nodes.getNode(childId);
|
const childObj = this.RED.nodes.getNode(childId);
|
||||||
this.reactor.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
console.log(childObj.source);
|
||||||
|
this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("Unknown topic: " + msg.topic);
|
console.log("Unknown topic: " + msg.topic);
|
||||||
@@ -76,7 +78,7 @@ class nodeClass {
|
|||||||
unit: null
|
unit: null
|
||||||
},
|
},
|
||||||
functionality: {
|
functionality: {
|
||||||
softwareType: null // should be set in config manager
|
softwareType: "reactor" // should be set in config manager
|
||||||
},
|
},
|
||||||
reactor_type: uiConfig.reactor_type,
|
reactor_type: uiConfig.reactor_type,
|
||||||
volume: parseFloat(uiConfig.volume),
|
volume: parseFloat(uiConfig.volume),
|
||||||
@@ -112,7 +114,7 @@ class nodeClass {
|
|||||||
this.node.send([
|
this.node.send([
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
{ topic: 'registerChild', payload: this.node.id, positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' },
|
{ topic: 'registerChild', payload: this.node.id, positionVsParent: this.config?.functionality?.positionVsParent || 'atEquipment' }
|
||||||
]);
|
]);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
@@ -134,7 +136,8 @@ class nodeClass {
|
|||||||
console.warn("Unknown reactor type: " + uiConfig.reactor_type);
|
console.warn("Unknown reactor type: " + uiConfig.reactor_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.reactor = new_reactor; // protect from reassignment
|
this.source = new_reactor; // protect from reassignment
|
||||||
|
this.node.source = this.source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Reactor {
|
|||||||
* @param {object} config - Configuration object containing reactor parameters.
|
* @param {object} config - Configuration object containing reactor parameters.
|
||||||
*/
|
*/
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
|
this.config = config;
|
||||||
// EVOLV stuff
|
// EVOLV stuff
|
||||||
this.logger = new logger(undefined, undefined, config.general.name);
|
this.logger = new logger(undefined, undefined, config.general.name);
|
||||||
this.emitter = new EventEmitter();
|
this.emitter = new EventEmitter();
|
||||||
@@ -122,7 +123,7 @@ class Reactor {
|
|||||||
n += 1;
|
n += 1;
|
||||||
}
|
}
|
||||||
this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor;
|
this.currentTime += n_iter * this.timeStep * day2ms / this.speedUpFactor;
|
||||||
this.emitter.emit("stateChanges", this.getEffluent);
|
this.emitter.emit("stateChange", this.getEffluent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user