fixed bugs for rotating machine execSequence

This commit is contained in:
znetsixe
2025-11-05 17:15:47 +01:00
parent 51f966cfb9
commit 4b5ec33c1d
2 changed files with 29 additions and 7 deletions

View File

@@ -145,6 +145,9 @@ class nodeClass {
case "decelerating": case "decelerating":
symbolState = "⏪"; symbolState = "⏪";
break; break;
case "maintenance":
symbolState = "🔧";
break;
} }
const position = m.state.getCurrentPosition(); const position = m.state.getCurrentPosition();
const roundedPosition = Math.round(position * 100) / 100; const roundedPosition = Math.round(position * 100) / 100;

View File

@@ -189,26 +189,37 @@ _callMeasurementHandler(measurementType, value, position, context) {
// -------- Mode and Input Management -------- // // -------- Mode and Input Management -------- //
isValidSourceForMode(source, mode) { isValidSourceForMode(source, mode) {
const allowedSourcesSet = this.config.mode.allowedSources[mode] || []; const allowedSourcesSet = this.config.mode.allowedSources[mode] || [];
return allowedSourcesSet.has(source); const allowed = allowedSourcesSet.has(source);
allowed?
this.logger.debug(`source is allowed proceeding with ${source} for mode ${mode}`) :
this.logger.warn(`${source} is not allowed in mode ${mode}`);
return allowed;
} }
isValidActionForMode(action, mode) { isValidActionForMode(action, mode) {
const allowedActionsSet = this.config.mode.allowedActions[mode] || []; const allowedActionsSet = this.config.mode.allowedActions[mode] || [];
return allowedActionsSet.has(action); const allowed = allowedActionsSet.has(action);
allowed ?
this.logger.debug(`Action is allowed proceeding with ${action} for mode ${mode}`) :
this.logger.warn(`${action} is not allowed in mode ${mode}`);
return allowed;
} }
async handleInput(source, action, parameter) { async handleInput(source, action, parameter) {
this.logger.debug("hello");
//sanitize input //sanitize input
if( typeof action !== 'string'){this.logger.error(`Action must be string`); return;} if( typeof action !== 'string'){this.logger.error(`Action must be string`); return;}
//convert to lower case to avoid to many mistakes in commands //convert to lower case to avoid to many mistakes in commands
action = action.toLowerCase(); action = action.toLowerCase();
if (!this.isValidSourceForMode(source, this.currentMode)) { // check for validity of the request
let warningTxt = `Source '${source}' is not valid for mode '${this.currentMode}'.`; if(!this.isValidActionForMode(action,this.currentMode)){return ;}
this.logger.warn(warningTxt); if (!this.isValidSourceForMode(source, this.currentMode)) {return ;}
return {status : false , feedback: warningTxt};
} this.logger.debug("hello2");
this.logger.info(`Handling input from source '${source}' with action '${action}' in mode '${this.currentMode}'.`); this.logger.info(`Handling input from source '${source}' with action '${action}' in mode '${this.currentMode}'.`);
@@ -221,6 +232,14 @@ _callMeasurementHandler(measurementType, value, position, context) {
case "execmovement": case "execmovement":
return await this.setpoint(parameter); return await this.setpoint(parameter);
case "entermaintenance":
return await this.executeSequence(parameter);
case "exitmaintenance":
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);