|
@ -7,7 +7,7 @@ class MockDriver { |
|
|
this.events = new EventEmitter(); |
|
|
this.events = new EventEmitter(); |
|
|
this.seconds = 0; |
|
|
this.seconds = 0; |
|
|
this.level = 1; |
|
|
this.level = 1; |
|
|
this.workoutState = { |
|
|
|
|
|
|
|
|
this.workoutStatus = { |
|
|
minutes: 0, |
|
|
minutes: 0, |
|
|
seconds: 0, |
|
|
seconds: 0, |
|
|
speed: 0, |
|
|
speed: 0, |
|
@ -39,26 +39,26 @@ class MockDriver { |
|
|
this.interval = setInterval(() => { |
|
|
this.interval = setInterval(() => { |
|
|
this.seconds++; |
|
|
this.seconds++; |
|
|
|
|
|
|
|
|
this.workoutState.minutes = Math.floor(this.seconds / 60); |
|
|
|
|
|
this.workoutState.seconds = this.seconds % 60; |
|
|
|
|
|
this.workoutState.speed = Math.floor(300 + Math.random() * 200) / 10; |
|
|
|
|
|
this.workoutState.rpm = Math.floor(57 + Math.random() * 5); |
|
|
|
|
|
this.workoutState.distance += (this.seconds % 5 == 0) ? 0.1 : 0; |
|
|
|
|
|
this.workoutState.calories += (this.seconds % 2 == 0) ? 1 : 0; |
|
|
|
|
|
this.workoutState.pulse = null; |
|
|
|
|
|
this.workoutState.watt = Math.floor(100 + Math.random() * 20); |
|
|
|
|
|
this.workoutState.level = this.level; |
|
|
|
|
|
|
|
|
|
|
|
this.events.emit("workoutState", {...this.workoutState}); |
|
|
|
|
|
|
|
|
this.workoutStatus.minutes = Math.floor(this.seconds / 60); |
|
|
|
|
|
this.workoutStatus.seconds = this.seconds % 60; |
|
|
|
|
|
this.workoutStatus.speed = Math.floor(300 + Math.random() * 200) / 10; |
|
|
|
|
|
this.workoutStatus.rpm = Math.floor(57 + Math.random() * 5); |
|
|
|
|
|
this.workoutStatus.distance += (this.seconds % 5 == 0) ? 0.1 : 0; |
|
|
|
|
|
this.workoutStatus.calories += (this.seconds % 2 == 0) ? 1 : 0; |
|
|
|
|
|
this.workoutStatus.pulse = null; |
|
|
|
|
|
this.workoutStatus.watt = Math.floor(100 + Math.random() * 20); |
|
|
|
|
|
this.workoutStatus.level = this.level; |
|
|
|
|
|
|
|
|
|
|
|
this.events.emit("workoutStatus", {...this.workoutStatus}); |
|
|
}, 1000); |
|
|
}, 1000); |
|
|
|
|
|
|
|
|
this.workoutState.level = 1; |
|
|
|
|
|
this.workoutState.speed = 0; |
|
|
|
|
|
this.workoutState.rpm = 0; |
|
|
|
|
|
this.workoutState.watt = 0; |
|
|
|
|
|
|
|
|
this.workoutStatus.level = 1; |
|
|
|
|
|
this.workoutStatus.speed = 0; |
|
|
|
|
|
this.workoutStatus.rpm = 0; |
|
|
|
|
|
this.workoutStatus.watt = 0; |
|
|
|
|
|
|
|
|
if (this.seconds === 0) { |
|
|
if (this.seconds === 0) { |
|
|
this.events.emit("workoutState", {...this.workoutState}); |
|
|
|
|
|
|
|
|
this.events.emit("workoutStatus", {...this.workoutStatus}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return Promise.resolve(); |
|
|
return Promise.resolve(); |
|
@ -83,7 +83,7 @@ class MockDriver { |
|
|
|
|
|
|
|
|
stop() { |
|
|
stop() { |
|
|
this.pause(); |
|
|
this.pause(); |
|
|
this.workoutState = { |
|
|
|
|
|
|
|
|
this.workoutStatus = { |
|
|
minutes: 0, |
|
|
minutes: 0, |
|
|
seconds: 0, |
|
|
seconds: 0, |
|
|
speed: 0, |
|
|
speed: 0, |
|
|