update
This commit is contained in:
@@ -248,36 +248,51 @@ class nodeClass {
|
||||
*/
|
||||
_attachInputHandler() {
|
||||
this.node.on('input', (msg, send, done) => {
|
||||
const v = this.source;
|
||||
switch(msg.topic) {
|
||||
case 'registerChild':
|
||||
const childId = msg.payload;
|
||||
const childObj = this.RED.nodes.getNode(childId);
|
||||
v.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);
|
||||
break;
|
||||
case 'setMode':
|
||||
v.setMode(msg.payload);
|
||||
break;
|
||||
case 'execSequence':
|
||||
const { source: seqSource, action: seqAction, parameter } = msg.payload;
|
||||
v.handleInput(seqSource, seqAction, parameter);
|
||||
break;
|
||||
case 'execMovement':
|
||||
const { source: mvSource, action: mvAction, setpoint } = msg.payload;
|
||||
v.handleInput(mvSource, mvAction, Number(setpoint));
|
||||
break;
|
||||
case 'emergencystop':
|
||||
const { source: esSource, action: esAction } = msg.payload;
|
||||
v.handleInput(esSource, esAction);
|
||||
break;
|
||||
case 'showcurve':
|
||||
v.showCurve();
|
||||
send({ topic : "Showing curve" , payload: v.showCurve() });
|
||||
break;
|
||||
case 'updateFlow': //Als nieuwe flow van header node dan moet deltaP weer opnieuw worden berekend en doorgegeven aan header node
|
||||
v.updateFlow(msg.payload.variant, msg.payload.value, msg.payload.position);
|
||||
const v = this.source;
|
||||
try {
|
||||
switch(msg.topic) {
|
||||
case 'registerChild': {
|
||||
const childId = msg.payload;
|
||||
const childObj = this.RED.nodes.getNode(childId);
|
||||
if (!childObj || !childObj.source) {
|
||||
v.logger.warn(`registerChild skipped: missing child/source for id=${childId}`);
|
||||
break;
|
||||
}
|
||||
v.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
||||
break;
|
||||
}
|
||||
case 'setMode':
|
||||
v.setMode(msg.payload);
|
||||
break;
|
||||
case 'execSequence': {
|
||||
const { source: seqSource, action: seqAction, parameter } = msg.payload;
|
||||
v.handleInput(seqSource, seqAction, parameter);
|
||||
break;
|
||||
}
|
||||
case 'execMovement': {
|
||||
const { source: mvSource, action: mvAction, setpoint } = msg.payload;
|
||||
v.handleInput(mvSource, mvAction, Number(setpoint));
|
||||
break;
|
||||
}
|
||||
case 'emergencystop': {
|
||||
const { source: esSource, action: esAction } = msg.payload;
|
||||
v.handleInput(esSource, esAction);
|
||||
break;
|
||||
}
|
||||
case 'showcurve':
|
||||
send({ topic: 'Showing curve', payload: v.showCurve() });
|
||||
break;
|
||||
case 'updateFlow':
|
||||
v.updateFlow(msg.payload.variant, msg.payload.value, msg.payload.position);
|
||||
break;
|
||||
default:
|
||||
v.logger.warn(`Unknown topic: ${msg.topic}`);
|
||||
}
|
||||
} catch (error) {
|
||||
v.logger.error(`Input handler failure: ${error.message}`);
|
||||
}
|
||||
done();
|
||||
|
||||
if (typeof done === 'function') done();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -288,7 +303,7 @@ class nodeClass {
|
||||
this.node.on('close', (done) => {
|
||||
clearInterval(this._tickInterval);
|
||||
clearInterval(this._statusInterval);
|
||||
done();
|
||||
if (typeof done === 'function') done();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,9 @@ class Valve {
|
||||
}
|
||||
|
||||
setMode(newMode) {
|
||||
const availableModes = defaultConfig.mode.current.rules.values.map(v => v.value);
|
||||
const availableModes = Array.isArray(this.defaultConfig?.mode?.current?.rules?.values)
|
||||
? this.defaultConfig.mode.current.rules.values.map(v => v.value)
|
||||
: Object.keys(this.config?.mode?.allowedSources || {});
|
||||
if (!availableModes.includes(newMode)) {
|
||||
this.logger.warn(`Invalid mode '${newMode}'. Allowed modes are: ${availableModes.join(', ')}`);
|
||||
return;
|
||||
@@ -190,7 +192,7 @@ class Valve {
|
||||
await this.state.moveTo(setpoint);
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error setting setpoint: ${error}`);
|
||||
this.logger.error(`Error setting setpoint: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +206,6 @@ class Valve {
|
||||
switch (variant) {
|
||||
case ("measured"):
|
||||
// put value in measurements container
|
||||
console.log( 'wtf ... ' + value);
|
||||
this.measurements.type("pressure").variant("measured").position(position).value(value);
|
||||
// get latest downstream pressure measurement
|
||||
const measuredDownStreamP = this.measurements.type("pressure").variant("measured").position("downstream").getCurrentValue(); //update downstream pressure measurement
|
||||
|
||||
Reference in New Issue
Block a user