55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
module.exports = function(RED) {
|
|
function reactor(config) {
|
|
RED.nodes.createNode(this, config);
|
|
var node = this;
|
|
|
|
let name = config.name;
|
|
|
|
const Reactor = require('./dependencies/reactor_class');
|
|
|
|
const reactor = new Reactor(
|
|
parseFloat(config.volume),
|
|
parseInt(config.n_inlets),
|
|
[
|
|
parseFloat(config.S_O_init),
|
|
parseFloat(config.S_I_init),
|
|
parseFloat(config.S_S_init),
|
|
parseFloat(config.S_NH_init),
|
|
parseFloat(config.S_N2_init),
|
|
parseFloat(config.S_NO_init),
|
|
parseFloat(config.S_HCO_init),
|
|
parseFloat(config.X_I_init),
|
|
parseFloat(config.X_S_init),
|
|
parseFloat(config.X_H_init),
|
|
parseFloat(config.X_STO_init),
|
|
parseFloat(config.X_A_init),
|
|
parseFloat(config.X_TS_init)
|
|
]
|
|
);
|
|
|
|
node.on('input', function(msg, send, done) {
|
|
switch (msg.topic) {
|
|
case "clock":
|
|
reactor.updateState(msg.timestamp);
|
|
break;
|
|
case "Fluent":
|
|
reactor.setInfluent = msg;
|
|
reactor.updateState(msg.timestamp);
|
|
break;
|
|
case "OTR":
|
|
reactor.setOTR = msg;
|
|
break;
|
|
default:
|
|
console.log("Unknown topic: " + msg.topic);
|
|
}
|
|
|
|
send(reactor.getEffluent);
|
|
|
|
if (done) {
|
|
done();
|
|
}
|
|
});
|
|
}
|
|
RED.nodes.registerType("advanced-reactor", reactor);
|
|
};
|