From 43d7e45aee7c877f9bcbdeffe9694eab8946ce6b Mon Sep 17 00:00:00 2001 From: Jaap van Ekris <82339657+JaapvanEkris@users.noreply.github.com> Date: Fri, 28 Apr 2023 20:22:14 +0200 Subject: [PATCH] Fix a state machine bug Fixed a bug where allowMovement() would be called at the start of the first drive, which would force it back to a paused state, causing all kind of weird metrics. --- app/engine/Rower.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/engine/Rower.js b/app/engine/Rower.js index 8dcf2a7..47708c5 100644 --- a/app/engine/Rower.js +++ b/app/engine/Rower.js @@ -299,8 +299,11 @@ function createRower (rowerSettings) { } function allowMovement () { - log.debug(`*** ALLOW MOVEMENT command by RowingEngine recieved at time: ${flywheel.spinningTime().toFixed(4)} sec`) - _strokeState = 'WaitingForDrive' + if (_strokeState === 'Stopped') { + // We have to check whether there actually was a stop/pause, in order to prevent weird behaviour from the state machine + log.debug(`*** ALLOW MOVEMENT command by RowingEngine recieved at time: ${flywheel.spinningTime().toFixed(4)} sec`) + _strokeState = 'WaitingForDrive' + } } function pauseMoving () {