From 4b5ec33c1d272c215ddbab7a6702338e68b3489b Mon Sep 17 00:00:00 2001 From: znetsixe <73483679+znetsixe@users.noreply.github.com> Date: Wed, 5 Nov 2025 17:15:47 +0100 Subject: [PATCH] fixed bugs for rotating machine execSequence --- src/nodeClass.js | 3 +++ src/specificClass.js | 33 ++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/nodeClass.js b/src/nodeClass.js index 7fc2acd..2b83066 100644 --- a/src/nodeClass.js +++ b/src/nodeClass.js @@ -145,6 +145,9 @@ class nodeClass { case "decelerating": symbolState = "⏪"; break; + case "maintenance": + symbolState = "🔧"; + break; } const position = m.state.getCurrentPosition(); const roundedPosition = Math.round(position * 100) / 100; diff --git a/src/specificClass.js b/src/specificClass.js index 2409c4b..b2dd199 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -189,26 +189,37 @@ _callMeasurementHandler(measurementType, value, position, context) { // -------- Mode and Input Management -------- // isValidSourceForMode(source, 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) { 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) { + this.logger.debug("hello"); //sanitize input if( typeof action !== 'string'){this.logger.error(`Action must be string`); return;} //convert to lower case to avoid to many mistakes in commands action = action.toLowerCase(); - if (!this.isValidSourceForMode(source, this.currentMode)) { - let warningTxt = `Source '${source}' is not valid for mode '${this.currentMode}'.`; - this.logger.warn(warningTxt); - return {status : false , feedback: warningTxt}; - } + // check for validity of the request + if(!this.isValidActionForMode(action,this.currentMode)){return ;} + if (!this.isValidSourceForMode(source, this.currentMode)) {return ;} + + this.logger.debug("hello2"); 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": return await this.setpoint(parameter); + case "entermaintenance": + + return await this.executeSequence(parameter); + + + case "exitmaintenance": + return await this.executeSequence(parameter); + case "flowmovement": // Calculate the control value for a desired flow const pos = this.calcCtrl(parameter);