Fix ESLint errors and bugs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -190,7 +190,7 @@ class nodeClass {
|
|||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
node.error("Error in updateNodeStatus: " + error.message);
|
this.node.error("Error in updateNodeStatus: " + error.message);
|
||||||
return { fill: "red", shape: "ring", text: "Status Error" };
|
return { fill: "red", shape: "ring", text: "Status Error" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,32 +246,36 @@ class nodeClass {
|
|||||||
/* Update to complete event based node by putting the tick function after an input event */
|
/* Update to complete event based node by putting the tick function after an input event */
|
||||||
const m = this.source;
|
const m = this.source;
|
||||||
switch(msg.topic) {
|
switch(msg.topic) {
|
||||||
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);
|
||||||
m.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);
|
m.childRegistrationUtils.registerChild(childObj.source ,msg.positionVsParent);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'setMode':
|
case 'setMode':
|
||||||
m.setMode(msg.payload);
|
m.setMode(msg.payload);
|
||||||
break;
|
break;
|
||||||
case 'execSequence':
|
case 'execSequence': {
|
||||||
const { source, action, parameter } = msg.payload;
|
const { source, action, parameter } = msg.payload;
|
||||||
m.handleInput(source, action, parameter);
|
m.handleInput(source, action, parameter);
|
||||||
break;
|
break;
|
||||||
case 'execMovement':
|
}
|
||||||
|
case 'execMovement': {
|
||||||
const { source: mvSource, action: mvAction, setpoint } = msg.payload;
|
const { source: mvSource, action: mvAction, setpoint } = msg.payload;
|
||||||
m.handleInput(mvSource, mvAction, Number(setpoint));
|
m.handleInput(mvSource, mvAction, Number(setpoint));
|
||||||
break;
|
break;
|
||||||
case 'flowMovement':
|
}
|
||||||
|
case 'flowMovement': {
|
||||||
const { source: fmSource, action: fmAction, setpoint: fmSetpoint } = msg.payload;
|
const { source: fmSource, action: fmAction, setpoint: fmSetpoint } = msg.payload;
|
||||||
m.handleInput(fmSource, fmAction, Number(fmSetpoint));
|
m.handleInput(fmSource, fmAction, Number(fmSetpoint));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'emergencystop':
|
}
|
||||||
|
case 'emergencystop': {
|
||||||
const { source: esSource, action: esAction } = msg.payload;
|
const { source: esSource, action: esAction } = msg.payload;
|
||||||
m.handleInput(esSource, esAction);
|
m.handleInput(esSource, esAction);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'showWorkingCurves':
|
case 'showWorkingCurves':
|
||||||
m.showWorkingCurves();
|
m.showWorkingCurves();
|
||||||
send({ topic : "Showing curve" , payload: m.showWorkingCurves() });
|
send({ topic : "Showing curve" , payload: m.showWorkingCurves() });
|
||||||
|
|||||||
@@ -101,9 +101,11 @@ class Machine {
|
|||||||
//assume standard atm pressure is at sea level
|
//assume standard atm pressure is at sea level
|
||||||
this.measurements.type('atmPressure').variant('measured').position('atEquipment').value(101325).unit('Pa');
|
this.measurements.type('atmPressure').variant('measured').position('atEquipment').value(101325).unit('Pa');
|
||||||
//populate min and max
|
//populate min and max
|
||||||
const flowunit = this.config.general.unit;
|
if (this.predictFlow) {
|
||||||
this.measurements.type('flow').variant('predicted').position('max').value(this.predictFlow.currentFxyYMax, Date.now() , flowunit)
|
const flowunit = this.config.general.unit;
|
||||||
this.measurements.type('flow').variant('predicted').position('min').value(this.predictFlow.currentFxyYMin).unit(this.config.general.unit);
|
this.measurements.type('flow').variant('predicted').position('max').value(this.predictFlow.currentFxyYMax, Date.now() , flowunit);
|
||||||
|
this.measurements.type('flow').variant('predicted').position('min').value(this.predictFlow.currentFxyYMin).unit(this.config.general.unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateState(){
|
_updateState(){
|
||||||
@@ -143,48 +145,6 @@ class Machine {
|
|||||||
//rebuild to measurementype.variant no position and then switch based on values not strings or names.
|
//rebuild to measurementype.variant no position and then switch based on values not strings or names.
|
||||||
const eventName = `${measurementType}.measured.${position}`;
|
const eventName = `${measurementType}.measured.${position}`;
|
||||||
|
|
||||||
this.logger.debug(`Setting up listener for ${eventName} from child ${child.config.general.name}`);
|
|
||||||
// Register event listener for measurement updates
|
|
||||||
child.measurements.emitter.on(eventName, (eventData) => {
|
|
||||||
this.logger.debug(`🔄 ${position} ${measurementType} from ${eventData.childName}: ${eventData.value} ${eventData.unit}`);
|
|
||||||
|
|
||||||
|
|
||||||
this.logger.debug(` Emitting... ${eventName} with data:`);
|
|
||||||
// Store directly in parent's measurement container
|
|
||||||
this.measurements
|
|
||||||
.type(measurementType)
|
|
||||||
.variant("measured")
|
|
||||||
.position(position)
|
|
||||||
.value(eventData.value, eventData.timestamp, eventData.unit);
|
|
||||||
|
|
||||||
// Call the appropriate handler
|
|
||||||
this._callMeasurementHandler(measurementType, eventData.value, position, eventData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Centralized handler dispatcher
|
|
||||||
_callMeasurementHandler(measurementType, value, position, context) {
|
|
||||||
switch (measurementType) {
|
|
||||||
case 'pressure':
|
|
||||||
this.updateMeasuredPressure(value, position, context);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'flow':
|
|
||||||
this.updateMeasuredFlow(value, position, context);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'temperature':
|
|
||||||
this.updateMeasuredTemperature(value, position, context);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
this.logger.warn(`No handler for measurement type: ${measurementType}`);
|
|
||||||
// Generic handler - just update position
|
|
||||||
this.updatePosition();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.logger.debug(`Setting up listener for ${eventName} from child ${measurementChild.config.general.name}`);
|
this.logger.debug(`Setting up listener for ${eventName} from child ${measurementChild.config.general.name}`);
|
||||||
// Register event listener for measurement updates
|
// Register event listener for measurement updates
|
||||||
measurementChild.measurements.emitter.on(eventName, (eventData) => {
|
measurementChild.measurements.emitter.on(eventName, (eventData) => {
|
||||||
@@ -198,23 +158,33 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
.value(eventData.value, eventData.timestamp, eventData.unit);
|
.value(eventData.value, eventData.timestamp, eventData.unit);
|
||||||
|
|
||||||
// Call the appropriate handler
|
// Call the appropriate handler
|
||||||
switch (measurementType) {
|
this._callMeasurementHandler(measurementType, eventData.value, position, eventData);
|
||||||
case 'pressure':
|
|
||||||
this.updateMeasuredPressure(eventData.value, position, eventData);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'flow':
|
|
||||||
this.updateMeasuredFlow(eventData.value, position, eventData);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
this.logger.warn(`No handler for measurement type: ${measurementType}`);
|
|
||||||
// Generic handler - just update position
|
|
||||||
this.updatePosition();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Centralized handler dispatcher
|
||||||
|
_callMeasurementHandler(measurementType, value, position, context) {
|
||||||
|
switch (measurementType) {
|
||||||
|
case 'pressure':
|
||||||
|
this.updateMeasuredPressure(value, position, context);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'flow':
|
||||||
|
this.updateMeasuredFlow(value, position, context);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'temperature':
|
||||||
|
this.updateMeasuredTemperature(value, position, context);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
this.logger.warn(`No handler for measurement type: ${measurementType}`);
|
||||||
|
// Generic handler - just update position
|
||||||
|
this.updatePosition();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_connectReactor(reactorChild) {
|
_connectReactor(reactorChild) {
|
||||||
this.downstreamSink = reactorChild; // downstream from the pumps perpective
|
this.downstreamSink = reactorChild; // downstream from the pumps perpective
|
||||||
}
|
}
|
||||||
@@ -304,11 +274,12 @@ _callMeasurementHandler(measurementType, value, position, context) {
|
|||||||
case "exitmaintenance":
|
case "exitmaintenance":
|
||||||
return await this.executeSequence(parameter);
|
return await this.executeSequence(parameter);
|
||||||
|
|
||||||
case "flowmovement":
|
case "flowmovement": {
|
||||||
// Calculate the control value for a desired flow
|
// Calculate the control value for a desired flow
|
||||||
const pos = this.calcCtrl(parameter);
|
const pos = this.calcCtrl(parameter);
|
||||||
// Move to the desired setpoint
|
// Move to the desired setpoint
|
||||||
return await this.setpoint(pos);
|
return await this.setpoint(pos);
|
||||||
|
}
|
||||||
|
|
||||||
case "emergencystop":
|
case "emergencystop":
|
||||||
this.logger.warn(`Emergency stop activated by '${source}'.`);
|
this.logger.warn(`Emergency stop activated by '${source}'.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user