Compare commits
3 Commits
7f2d326612
...
417fad4ec3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
417fad4ec3 | ||
|
|
8ae21ce787 | ||
|
|
5deb22b8da |
@@ -1,4 +1,5 @@
|
||||
const { Settler } = require('./specificClass.js');
|
||||
const { configManager } = require('generalFunctions');
|
||||
|
||||
|
||||
class nodeClass {
|
||||
@@ -32,12 +33,13 @@ class nodeClass {
|
||||
this.node.on('input', (msg, send, done) => {
|
||||
|
||||
switch (msg.topic) {
|
||||
case 'registerChild':
|
||||
case 'registerChild': {
|
||||
// Register this node as a parent of the child node
|
||||
const childId = msg.payload;
|
||||
const childObj = this.RED.nodes.getNode(childId);
|
||||
const childObj = this.RED.nodes.getNode(childId);
|
||||
this.source.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log("Unknown topic: " + msg.topic);
|
||||
}
|
||||
@@ -53,21 +55,8 @@ class nodeClass {
|
||||
* @param {object} uiConfig Config set in UI in node-red
|
||||
*/
|
||||
_loadConfig(uiConfig) {
|
||||
this.config = {
|
||||
general: {
|
||||
name: uiConfig.name || this.name,
|
||||
id: this.node.id,
|
||||
unit: null,
|
||||
logging: {
|
||||
enabled: uiConfig.enableLog,
|
||||
logLevel: uiConfig.logLevel
|
||||
}
|
||||
},
|
||||
functionality: {
|
||||
positionVsParent: uiConfig.positionVsParent || 'atEquipment', // Default to 'atEquipment' if not specified
|
||||
softwareType: "settler" // should be set in config manager
|
||||
}
|
||||
}
|
||||
const cfgMgr = new configManager();
|
||||
this.config = cfgMgr.buildConfig('settler', uiConfig, this.node.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions');
|
||||
const { childRegistrationUtils, logger, MeasurementContainer, POSITIONS } = require('generalFunctions');
|
||||
const EventEmitter = require('events');
|
||||
|
||||
class Settler {
|
||||
@@ -26,7 +26,7 @@ class Settler {
|
||||
|
||||
let F_sr = 0;
|
||||
if (this.returnPump) {
|
||||
F_sr = Math.min(this.returnPump.measurements.type("flow").variant("measured").position("atEquipment").getCurrentValue(), F_s);
|
||||
F_sr = Math.min(this.returnPump.measurements.type("flow").variant("measured").position(POSITIONS.AT_EQUIPMENT).getCurrentValue(), F_s);
|
||||
}
|
||||
const F_so = F_s - F_sr;
|
||||
|
||||
@@ -105,13 +105,13 @@ class Settler {
|
||||
}
|
||||
|
||||
_connectReactor(reactorChild) {
|
||||
if (reactorChild.config.functionality.positionVsParent != "upstream") {
|
||||
if (reactorChild.config.functionality.positionVsParent != POSITIONS.UPSTREAM) {
|
||||
this.logger.warn("Reactor children of settlers should be upstream.");
|
||||
}
|
||||
|
||||
this.upstreamReactor = reactorChild;
|
||||
|
||||
reactorChild.emitter.on("stateChange", (eventData) => {
|
||||
reactorChild.emitter.on("stateChange", (_eventData) => {
|
||||
this.logger.debug(`State change of upstream reactor detected.`);
|
||||
const effluent = this.upstreamReactor.getEffluent[0];
|
||||
this.F_in = effluent.payload.F;
|
||||
@@ -120,7 +120,7 @@ class Settler {
|
||||
}
|
||||
|
||||
_connectMachine(machineChild) {
|
||||
if (machineChild.config.functionality.positionVsParent == "downstream") {
|
||||
if (machineChild.config.functionality.positionVsParent == POSITIONS.DOWNSTREAM) {
|
||||
machineChild.upstreamSource = this;
|
||||
this.returnPump = machineChild;
|
||||
return;
|
||||
@@ -128,7 +128,7 @@ class Settler {
|
||||
this.logger.warn(`Failed to register machine child.`);
|
||||
}
|
||||
|
||||
_updateMeasurement(measurementType, value, position, context) {
|
||||
_updateMeasurement(measurementType, value, _position, _context) {
|
||||
switch(measurementType) {
|
||||
case "quantity (tss)":
|
||||
this.C_TS = value;
|
||||
|
||||
Reference in New Issue
Block a user