update
This commit is contained in:
@@ -167,39 +167,42 @@ class nodeClass {
|
|||||||
this.node.on(
|
this.node.on(
|
||||||
"input",
|
"input",
|
||||||
async (msg, send, done) => {
|
async (msg, send, done) => {
|
||||||
const vg = this.source;
|
const vg = this.source;
|
||||||
const RED = this.RED;
|
const RED = this.RED;
|
||||||
|
try {
|
||||||
switch (msg.topic) {
|
switch (msg.topic) {
|
||||||
case "registerChild":
|
case "registerChild": {
|
||||||
//console.log(`Registering child in mgc: ${msg.payload}`);
|
|
||||||
const childId = msg.payload;
|
const childId = msg.payload;
|
||||||
const childObj = RED.nodes.getNode(childId);
|
const childObj = RED.nodes.getNode(childId);
|
||||||
vg.childRegistrationUtils.registerChild(
|
if (!childObj || !childObj.source) {
|
||||||
childObj.source,
|
vg.logger.warn(`registerChild skipped: missing child/source for id=${childId}`);
|
||||||
msg.positionVsParent
|
break;
|
||||||
);
|
}
|
||||||
|
vg.childRegistrationUtils.registerChild(childObj.source, msg.positionVsParent);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'setMode':
|
case 'setMode':
|
||||||
vg.setMode(msg.payload);
|
vg.setMode(msg.payload);
|
||||||
break;
|
break;
|
||||||
case 'execSequence':
|
case 'execSequence': {
|
||||||
const { source: seqSource, action: seqAction, parameter } = msg.payload;
|
const { source: seqSource, action: seqAction, parameter } = msg.payload;
|
||||||
vg.handleInput(seqSource, seqAction, parameter);
|
vg.handleInput(seqSource, seqAction, parameter);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'totalFlowChange': // een van valves is van stand veranderd waardoor total flow is veranderd
|
case 'totalFlowChange': {
|
||||||
const { source: tfcSource, action: tfcAction, q} = msg.payload;
|
const { source: tfcSource, action: tfcAction, q} = msg.payload;
|
||||||
vg.handleInput(tfcSource, tfcAction, Number(q));
|
vg.handleInput(tfcSource, tfcAction, Number(q));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Handle unknown topics if needed
|
|
||||||
vg.logger.warn(`Unknown topic: ${msg.topic}`);
|
vg.logger.warn(`Unknown topic: ${msg.topic}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
done();
|
} catch (error) {
|
||||||
|
vg.logger.error(`Input handler failure: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
if (typeof done === 'function') done();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +213,7 @@ class nodeClass {
|
|||||||
this.node.on("close", (done) => {
|
this.node.on("close", (done) => {
|
||||||
clearInterval(this._tickInterval);
|
clearInterval(this._tickInterval);
|
||||||
clearInterval(this._statusInterval);
|
clearInterval(this._statusInterval);
|
||||||
done();
|
if (typeof done === 'function') done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user