add stuff

This commit is contained in:
2019-11-06 22:11:07 +01:00
parent a57a558dc5
commit a8e7b5b1fa
4 changed files with 152 additions and 23 deletions
+11 -1
View File
@@ -12,6 +12,7 @@ class IConsoleDriver {
this.maxLevel = 24;
this.lastLevel = 18;
this.workoutStatus = {};
this.started = false;
}
async connect() {
@@ -36,8 +37,17 @@ class IConsoleDriver {
})
}
get state() {
return this.client.state;
}
async start() {
await this.client.start({level: this.lastLevel});
if (!this.started) {
await this.client.start({level: this.lastLevel});
this.started = true;
} else {
await this.client.resume();
}
}
async pause() {
+12
View File
@@ -18,6 +18,7 @@ class MockDriver {
watt: 0,
level: 1,
};
this.state = "disconnected";
this.interval = null;
}
@@ -27,6 +28,8 @@ class MockDriver {
this.events.emit("maxLevel", 32);
})
this.state = "connected";
return Promise.resolve();
}
@@ -34,6 +37,7 @@ class MockDriver {
if (this.started) {
return;
}
this.state = "started";
this.started = true;
this.interval = setInterval(() => {
@@ -77,10 +81,15 @@ class MockDriver {
pause() {
clearInterval(this.interval);
this.started = false;
this.state = "connected";
return Promise.resolve();
}
resume() {
return this.start();
}
stop() {
this.pause();
this.workoutStatus = {
@@ -95,6 +104,9 @@ class MockDriver {
level: 1,
};
this.seconds = 0;
this.started = false;
this.state = "disconnected";
return Promise.resolve();
}