incyclist-devices 2.0.38 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/antv2/adapter-factory.d.ts +4 -2
- package/lib/antv2/adapter.d.ts +3 -20
- package/lib/antv2/adapter.js +2 -92
- package/lib/antv2/fe/adapter.d.ts +9 -5
- package/lib/antv2/fe/adapter.js +25 -14
- package/lib/antv2/hr/adapter.d.ts +2 -1
- package/lib/antv2/pwr/adapter.d.ts +9 -5
- package/lib/antv2/pwr/adapter.js +19 -8
- package/lib/antv2/types.d.ts +2 -1
- package/lib/base/adpater.d.ts +31 -13
- package/lib/base/adpater.js +84 -28
- package/lib/ble/adapter-factory.d.ts +10 -9
- package/lib/ble/base/adapter.d.ts +9 -20
- package/lib/ble/base/adapter.js +13 -69
- package/lib/ble/ble-interface.d.ts +5 -4
- package/lib/ble/cp/adapter.d.ts +5 -8
- package/lib/ble/cp/adapter.js +26 -10
- package/lib/ble/elite/adapter.d.ts +6 -5
- package/lib/ble/elite/adapter.js +26 -2
- package/lib/ble/fm/adapter.d.ts +10 -9
- package/lib/ble/fm/adapter.js +38 -11
- package/lib/ble/hr/adapter.d.ts +5 -3
- package/lib/ble/peripheral-cache.d.ts +3 -2
- package/lib/ble/tacx/adapter.d.ts +2 -2
- package/lib/ble/wahoo/adapter.d.ts +2 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +4 -2
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ant-fe-adv-st-mode.d.ts +12 -0
- package/lib/modes/ant-fe-adv-st-mode.js +83 -0
- package/lib/modes/antble-erg.d.ts +31 -0
- package/lib/modes/antble-erg.js +28 -0
- package/lib/modes/antble-smarttrainer.d.ts +23 -0
- package/lib/modes/antble-smarttrainer.js +65 -0
- package/lib/modes/base.d.ts +29 -0
- package/lib/modes/{cycling-mode.js → base.js} +23 -26
- package/lib/modes/daum-classic-standard.d.ts +16 -0
- package/lib/modes/daum-classic-standard.js +54 -0
- package/lib/modes/daum-erg.d.ts +49 -0
- package/lib/{serial/daum/ERGCyclingMode.js → modes/daum-erg.js} +45 -73
- package/lib/modes/daum-power.d.ts +5 -0
- package/lib/{serial/daum/DaumPowerMeterCyclingMode.js → modes/daum-power.js} +1 -10
- package/lib/modes/daum-premium-standard.d.ts +23 -0
- package/lib/{serial/daum/premium/modes/daum-classic.js → modes/daum-premium-standard.js} +26 -38
- package/lib/modes/daum-smarttrainer.d.ts +82 -0
- package/lib/{serial/daum/SmartTrainerCyclingMode.js → modes/daum-smarttrainer.js} +23 -26
- package/lib/modes/kettler-erg.d.ts +44 -0
- package/lib/{serial/kettler/ergo-racer/modes/erg.js → modes/kettler-erg.js} +12 -23
- package/lib/modes/power-base.d.ts +28 -3
- package/lib/modes/power-base.js +182 -5
- package/lib/modes/power-meter.d.ts +10 -16
- package/lib/modes/power-meter.js +15 -54
- package/lib/modes/simulator.d.ts +37 -10
- package/lib/modes/simulator.js +14 -46
- package/lib/modes/{cycling-mode.d.ts → types.d.ts} +22 -19
- package/lib/modes/types.js +56 -0
- package/lib/serial/adapter-factory.d.ts +7 -5
- package/lib/serial/adapter.d.ts +2 -2
- package/lib/serial/adapter.js +5 -2
- package/lib/serial/daum/DaumAdapter.d.ts +27 -24
- package/lib/serial/daum/DaumAdapter.js +200 -128
- package/lib/serial/daum/classic/adapter.d.ts +20 -21
- package/lib/serial/daum/classic/adapter.js +83 -157
- package/lib/serial/daum/classic/comms.d.ts +19 -13
- package/lib/serial/daum/classic/comms.js +39 -12
- package/lib/serial/daum/classic/mock.d.ts +4 -0
- package/lib/serial/daum/classic/mock.js +14 -4
- package/lib/serial/daum/premium/adapter.d.ts +16 -11
- package/lib/serial/daum/premium/adapter.js +98 -95
- package/lib/serial/daum/premium/comms.d.ts +4 -1
- package/lib/serial/daum/premium/comms.js +25 -17
- package/lib/serial/daum/premium/mock.d.ts +4 -0
- package/lib/serial/daum/premium/mock.js +15 -5
- package/lib/serial/daum/types.d.ts +11 -0
- package/lib/serial/daum/types.js +5 -0
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +10 -8
- package/lib/serial/kettler/ergo-racer/adapter.js +17 -7
- package/lib/serial/serial-interface.js +1 -2
- package/lib/simulator/Simulator.d.ts +14 -17
- package/lib/simulator/Simulator.js +18 -47
- package/lib/types/adapter.d.ts +29 -8
- package/lib/types/adapter.js +68 -0
- package/lib/utils/utils.d.ts +1 -1
- package/package.json +3 -3
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/antv2/modes/ant-fe-adv-st-mode.js +0 -51
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +0 -6
- package/lib/antv2/modes/ant-fe-erg-mode.js +0 -14
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +0 -5
- package/lib/antv2/modes/ant-fe-st-mode.js +0 -13
- package/lib/modes/ble-erg-mode.d.ts +0 -18
- package/lib/modes/ble-erg-mode.js +0 -148
- package/lib/modes/ble-st-mode.d.ts +0 -15
- package/lib/modes/ble-st-mode.js +0 -96
- package/lib/serial/daum/DaumPowerMeterCyclingMode.d.ts +0 -8
- package/lib/serial/daum/ERGCyclingMode.d.ts +0 -26
- package/lib/serial/daum/SmartTrainerCyclingMode.d.ts +0 -42
- package/lib/serial/daum/classic/modes/daum-classic.d.ts +0 -13
- package/lib/serial/daum/classic/modes/daum-classic.js +0 -97
- package/lib/serial/daum/premium/modes/daum-classic.d.ts +0 -14
- package/lib/serial/kettler/ergo-racer/modes/erg.d.ts +0 -25
- /package/lib/serial/daum/{constants.d.ts → consts.d.ts} +0 -0
- /package/lib/serial/daum/{constants.js → consts.js} +0 -0
|
@@ -12,25 +12,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
15
|
+
exports.DaumControl = void 0;
|
|
16
|
+
const daum_erg_1 = __importDefault(require("../../modes/daum-erg"));
|
|
17
|
+
const daum_smarttrainer_1 = __importDefault(require("../../modes/daum-smarttrainer"));
|
|
18
|
+
const daum_power_1 = __importDefault(require("../../modes/daum-power"));
|
|
19
19
|
const utils_1 = require("../../utils/utils");
|
|
20
20
|
const adapter_1 = require("../adapter");
|
|
21
21
|
const capabilities_1 = require("../../types/capabilities");
|
|
22
|
-
|
|
22
|
+
const adpater_1 = require("../../base/adpater");
|
|
23
|
+
class DaumControl extends adpater_1.ControllableDevice {
|
|
24
|
+
getSupportedCyclingModes() {
|
|
25
|
+
return [daum_erg_1.default, daum_smarttrainer_1.default, daum_power_1.default];
|
|
26
|
+
}
|
|
27
|
+
getDefaultCyclingMode() {
|
|
28
|
+
return new daum_erg_1.default(this.adapter);
|
|
29
|
+
}
|
|
30
|
+
sendInitCommands() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
23
35
|
}
|
|
24
|
-
exports.
|
|
25
|
-
class DaumAdapter extends
|
|
36
|
+
exports.DaumControl = DaumControl;
|
|
37
|
+
class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
26
38
|
constructor(settings, props) {
|
|
27
39
|
super(settings, props);
|
|
28
40
|
this.requests = [];
|
|
29
41
|
this.adapterTime = 0;
|
|
30
42
|
this.requestBusy = false;
|
|
31
43
|
this.updateBusy = false;
|
|
32
|
-
this.
|
|
33
|
-
this.paused = false;
|
|
44
|
+
this.iv = undefined;
|
|
34
45
|
this.cyclingData = {
|
|
35
46
|
isPedalling: false,
|
|
36
47
|
time: 0,
|
|
@@ -45,31 +56,21 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
45
56
|
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Speed, capabilities_1.IncyclistCapability.Cadence, capabilities_1.IncyclistCapability.Gear, capabilities_1.IncyclistCapability.HeartRate,
|
|
46
57
|
capabilities_1.IncyclistCapability.Control
|
|
47
58
|
];
|
|
59
|
+
this.setControl(new DaumControl(this, props));
|
|
48
60
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.cyclingMode = new CyclingModeClass(this, settings);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
selectedMode = this.getDefaultCyclingMode();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
selectedMode = mode;
|
|
64
|
-
}
|
|
65
|
-
this.cyclingMode = selectedMode;
|
|
66
|
-
this.cyclingMode.setSettings(settings);
|
|
61
|
+
getPort() {
|
|
62
|
+
var _a;
|
|
63
|
+
return (_a = this.bike) === null || _a === void 0 ? void 0 : _a.getPort();
|
|
64
|
+
}
|
|
65
|
+
getSerialInterface() {
|
|
66
|
+
var _a;
|
|
67
|
+
return (_a = this.bike) === null || _a === void 0 ? void 0 : _a.serial;
|
|
67
68
|
}
|
|
68
69
|
sendInitCommands() {
|
|
69
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
71
|
if (this.started && !this.stopped) {
|
|
71
72
|
try {
|
|
72
|
-
if (this.getCyclingMode() instanceof
|
|
73
|
+
if (this.getCyclingMode() instanceof daum_erg_1.default) {
|
|
73
74
|
const power = this.deviceData.power;
|
|
74
75
|
const request = power ? { targetPower: power } : this.getCyclingMode().getBikeInitRequest();
|
|
75
76
|
yield this.sendUpdate(request);
|
|
@@ -80,22 +81,9 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
80
81
|
return false;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
84
|
+
return false;
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
|
-
getSupportedCyclingModes() {
|
|
89
|
-
return [ERGCyclingMode_1.default, SmartTrainerCyclingMode_1.default, DaumPowerMeterCyclingMode_1.default];
|
|
90
|
-
}
|
|
91
|
-
getCyclingMode() {
|
|
92
|
-
if (!this.cyclingMode)
|
|
93
|
-
this.setCyclingMode(this.getDefaultCyclingMode());
|
|
94
|
-
return this.cyclingMode;
|
|
95
|
-
}
|
|
96
|
-
getDefaultCyclingMode() {
|
|
97
|
-
return new ERGCyclingMode_1.default(this);
|
|
98
|
-
}
|
|
99
87
|
getCurrentBikeData() {
|
|
100
88
|
throw new Error('Method not implemented.');
|
|
101
89
|
}
|
|
@@ -133,7 +121,6 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
133
121
|
heartrate: 0
|
|
134
122
|
};
|
|
135
123
|
this.deviceData = {};
|
|
136
|
-
this.currentRequest = {};
|
|
137
124
|
this.requests = [];
|
|
138
125
|
const name = this.getCyclingMode().getName();
|
|
139
126
|
const settings = this.getCyclingMode().getSettings();
|
|
@@ -159,38 +146,131 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
159
146
|
return resumed;
|
|
160
147
|
});
|
|
161
148
|
}
|
|
149
|
+
waitForPrevCheckFinished() {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
if (this.checkPromise) {
|
|
152
|
+
this.logEvent({ message: "waiting for previous check device", port: this.getPort() });
|
|
153
|
+
try {
|
|
154
|
+
yield this.checkPromise;
|
|
155
|
+
}
|
|
156
|
+
catch (_a) { }
|
|
157
|
+
this.logEvent({ message: "previous check device completed", port: this.getPort() });
|
|
158
|
+
this.checkPromise = undefined;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
check() {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
yield this.waitForPrevCheckFinished();
|
|
165
|
+
yield this.waitForPrevStartFinished();
|
|
166
|
+
if (this.isStopped())
|
|
167
|
+
return false;
|
|
168
|
+
this.checkPromise = this.performCheck();
|
|
169
|
+
try {
|
|
170
|
+
const res = yield this.checkPromise;
|
|
171
|
+
this.checkPromise = undefined;
|
|
172
|
+
return res;
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
this.checkPromise = undefined;
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
performCheck() {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
throw new Error('Method not implemented.');
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
waitForPrevStartFinished() {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
if (this.startPromise) {
|
|
188
|
+
this.logEvent({ message: "waiting for previous device launch", port: this.getPort() });
|
|
189
|
+
try {
|
|
190
|
+
yield this.startPromise;
|
|
191
|
+
}
|
|
192
|
+
catch (_a) { }
|
|
193
|
+
this.logEvent({ message: "previous device launch attempt completed", port: this.getPort() });
|
|
194
|
+
this.startPromise = undefined;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
162
198
|
start(props) {
|
|
163
|
-
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
yield this.waitForPrevCheckFinished();
|
|
201
|
+
yield this.waitForPrevStartFinished();
|
|
202
|
+
const isRelaunch = this.started;
|
|
203
|
+
const message = isRelaunch ? 'relaunch of device' : 'initial start of device';
|
|
204
|
+
this.logEvent({ message });
|
|
205
|
+
try {
|
|
206
|
+
if (isRelaunch && this.isPaused())
|
|
207
|
+
this.resume();
|
|
208
|
+
this.startPromise = this.performStart(props, isRelaunch).then((started) => __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
if (!started) {
|
|
210
|
+
this.logEvent({ message: 'start result: not started' });
|
|
211
|
+
this.started = false;
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
if (!isRelaunch) {
|
|
215
|
+
try {
|
|
216
|
+
const deviceInfo = yield this.getDeviceInfo();
|
|
217
|
+
this.logEvent({ message: 'device info', deviceInfo });
|
|
218
|
+
}
|
|
219
|
+
catch (_a) { }
|
|
220
|
+
}
|
|
221
|
+
this.logEvent({ message: 'start result: success' });
|
|
222
|
+
this.started = true;
|
|
223
|
+
return true;
|
|
224
|
+
}));
|
|
225
|
+
const started = yield this.startPromise;
|
|
226
|
+
this.startPromise = undefined;
|
|
227
|
+
return started;
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
this.logEvent({ message: 'start result: error', error: err.message });
|
|
231
|
+
this.startPromise = undefined;
|
|
232
|
+
this.started = false;
|
|
233
|
+
throw new Error(`could not start device, reason:${err.message}`);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
164
236
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return;
|
|
168
|
-
if (this.iv.sync)
|
|
169
|
-
clearInterval(this.iv.sync);
|
|
170
|
-
if (this.iv.update)
|
|
171
|
-
clearInterval(this.iv.update);
|
|
172
|
-
this.iv = undefined;
|
|
237
|
+
performStart(props, isRelaunch = false) {
|
|
238
|
+
throw new Error('Method not implemented.');
|
|
173
239
|
}
|
|
174
240
|
startUpdatePull() {
|
|
175
|
-
this.logEvent({ message: 'start update pull', iv: this.iv, ignoreBike: this.ignoreBike, ignoreHrm: this.ignoreHrm, ignorePower: this.ignorePower });
|
|
176
241
|
if (this.iv)
|
|
177
242
|
return;
|
|
178
|
-
|
|
179
|
-
return;
|
|
243
|
+
this.logEvent({ message: 'start update pull', port: this.getPort() });
|
|
180
244
|
const ivSync = setInterval(() => {
|
|
181
|
-
|
|
245
|
+
try {
|
|
246
|
+
this.bikeSync();
|
|
247
|
+
}
|
|
248
|
+
catch (_a) { }
|
|
182
249
|
}, this.pullFrequency);
|
|
183
250
|
const ivUpdate = setInterval(() => {
|
|
184
|
-
|
|
185
|
-
|
|
251
|
+
try {
|
|
252
|
+
this.emitData(this.deviceData);
|
|
253
|
+
this.refreshRequests();
|
|
254
|
+
}
|
|
255
|
+
catch (_a) { }
|
|
186
256
|
}, this.pullFrequency);
|
|
187
257
|
this.iv = {
|
|
188
258
|
sync: ivSync,
|
|
189
259
|
update: ivUpdate
|
|
190
260
|
};
|
|
191
261
|
}
|
|
262
|
+
stopUpdatePull() {
|
|
263
|
+
if (!this.iv)
|
|
264
|
+
return;
|
|
265
|
+
this.logEvent({ message: 'stop update pull', port: this.getPort() });
|
|
266
|
+
clearInterval(this.iv.sync);
|
|
267
|
+
clearInterval(this.iv.update);
|
|
268
|
+
this.iv = undefined;
|
|
269
|
+
}
|
|
192
270
|
connect() {
|
|
193
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
if (!this.bike)
|
|
273
|
+
return false;
|
|
194
274
|
if (this.bike.isConnected())
|
|
195
275
|
return true;
|
|
196
276
|
try {
|
|
@@ -205,19 +285,21 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
205
285
|
}
|
|
206
286
|
close() {
|
|
207
287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
if (!this.bike)
|
|
289
|
+
return true;
|
|
208
290
|
if (!this.bike.isConnected())
|
|
209
291
|
return true;
|
|
210
292
|
return yield this.bike.close();
|
|
211
293
|
});
|
|
212
294
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
295
|
+
verifyConnection() {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
297
|
+
if (!this.bike.isConnected()) {
|
|
298
|
+
const connected = yield this.bike.connect();
|
|
299
|
+
if (!connected)
|
|
300
|
+
throw new Error('not connected');
|
|
301
|
+
}
|
|
302
|
+
});
|
|
221
303
|
}
|
|
222
304
|
reconnect() {
|
|
223
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -231,33 +313,34 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
231
313
|
}
|
|
232
314
|
});
|
|
233
315
|
}
|
|
316
|
+
logEvent(event) {
|
|
317
|
+
if (!this.logger || this.paused)
|
|
318
|
+
return;
|
|
319
|
+
this.logger.logEvent(event);
|
|
320
|
+
const w = global.window;
|
|
321
|
+
if (w === null || w === void 0 ? void 0 : w.DEVICE_DEBUG) {
|
|
322
|
+
console.log(`~~~ ${this.logger.getName()}`, event);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
234
325
|
stop() {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
this.
|
|
240
|
-
|
|
241
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
if (this.stopped)
|
|
328
|
+
return true;
|
|
329
|
+
this.logEvent({ message: 'stop request' });
|
|
330
|
+
if (this.paused)
|
|
331
|
+
this.resume();
|
|
242
332
|
try {
|
|
243
|
-
|
|
244
|
-
if (this.iv.sync)
|
|
245
|
-
clearInterval(this.iv.sync);
|
|
246
|
-
if (this.iv.update)
|
|
247
|
-
clearInterval(this.iv.update);
|
|
248
|
-
this.iv = undefined;
|
|
249
|
-
}
|
|
250
|
-
if (this.bike.stopWorker && typeof this.bike.stopWorker === 'function')
|
|
251
|
-
this.bike.stopWorker();
|
|
333
|
+
this.stopUpdatePull();
|
|
252
334
|
yield this.bike.close();
|
|
253
335
|
this.logEvent({ message: 'stop request completed' });
|
|
254
|
-
|
|
336
|
+
this.stopped = true;
|
|
255
337
|
}
|
|
256
338
|
catch (err) {
|
|
257
|
-
this.logEvent({ message: 'stop
|
|
258
|
-
|
|
339
|
+
this.logEvent({ message: 'stop request failed', reason: err.message });
|
|
340
|
+
throw (err);
|
|
259
341
|
}
|
|
260
|
-
|
|
342
|
+
return this.stopped;
|
|
343
|
+
});
|
|
261
344
|
}
|
|
262
345
|
canSendUpdate() {
|
|
263
346
|
if (this.paused || this.stopped)
|
|
@@ -274,39 +357,44 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
274
357
|
}
|
|
275
358
|
update() {
|
|
276
359
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
if (this.
|
|
360
|
+
if (!this.canSendUpdate() || this.updateBusy)
|
|
278
361
|
return;
|
|
279
362
|
this.updateBusy = true;
|
|
280
|
-
|
|
281
|
-
|
|
363
|
+
try {
|
|
364
|
+
const bikeData = yield this.getCurrentBikeData();
|
|
282
365
|
const incyclistData = this.updateData(bikeData);
|
|
283
366
|
const data = this.transformData(incyclistData);
|
|
284
367
|
this.updateBusy = false;
|
|
285
368
|
this.emitData(data);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
369
|
+
}
|
|
370
|
+
catch (err) {
|
|
371
|
+
try {
|
|
372
|
+
this.logEvent({ message: 'bike update error', error: err.message, stack: err.stack });
|
|
373
|
+
const incyclistData = this.updateData(this.cyclingData);
|
|
374
|
+
this.transformData(incyclistData);
|
|
375
|
+
}
|
|
376
|
+
catch (_a) { }
|
|
291
377
|
this.updateBusy = false;
|
|
292
|
-
}
|
|
378
|
+
}
|
|
293
379
|
});
|
|
294
380
|
}
|
|
295
381
|
sendRequests() {
|
|
296
382
|
return __awaiter(this, void 0, void 0, function* () {
|
|
297
383
|
if (this.stopped || this.paused)
|
|
298
384
|
return;
|
|
385
|
+
if (this.requestBusy)
|
|
386
|
+
return;
|
|
299
387
|
if (this.requests.length > 0) {
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
388
|
+
const cnt = this.requests.length;
|
|
389
|
+
if (cnt > 1) {
|
|
390
|
+
this.requests.forEach((request, idx) => {
|
|
391
|
+
if (idx !== cnt - 1) {
|
|
392
|
+
this.logEvent({ message: 'ignoring bike update request', request });
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
this.requests = [this.requests[cnt - 1]];
|
|
396
|
+
}
|
|
397
|
+
let request = this.requests[0];
|
|
310
398
|
try {
|
|
311
399
|
yield this.sendRequest(request);
|
|
312
400
|
this.requests.shift();
|
|
@@ -319,16 +407,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
319
407
|
}
|
|
320
408
|
bikeSync() {
|
|
321
409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
322
|
-
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
if (this.updateBusy || this.requestBusy) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
this.logEvent({ message: 'bikeSync', ignoreBike: this.ignoreBike });
|
|
329
|
-
if (!this.ignoreBike) {
|
|
330
|
-
yield this.sendRequests();
|
|
331
|
-
}
|
|
410
|
+
yield this.sendRequests();
|
|
332
411
|
yield this.update();
|
|
333
412
|
});
|
|
334
413
|
}
|
|
@@ -367,15 +446,6 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
367
446
|
deviceTime: cyclingData.time,
|
|
368
447
|
deviceDistanceCounter: cyclingData.distanceInternal
|
|
369
448
|
};
|
|
370
|
-
if (this.ignoreHrm)
|
|
371
|
-
delete data.heartrate;
|
|
372
|
-
if (this.ignorePower) {
|
|
373
|
-
delete data.power;
|
|
374
|
-
delete data.cadence;
|
|
375
|
-
}
|
|
376
|
-
if (this.ignoreBike) {
|
|
377
|
-
data = { heartrate: data.heartrate };
|
|
378
|
-
}
|
|
379
449
|
this.deviceData = data;
|
|
380
450
|
return data;
|
|
381
451
|
}
|
|
@@ -391,10 +461,10 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
391
461
|
return {};
|
|
392
462
|
}
|
|
393
463
|
if (request.slope !== undefined) {
|
|
394
|
-
yield bike.
|
|
464
|
+
yield bike.setTargetSlope(request.slope);
|
|
395
465
|
}
|
|
396
466
|
if (request.targetPower !== undefined) {
|
|
397
|
-
yield bike.
|
|
467
|
+
yield bike.setTargetPower(request.targetPower);
|
|
398
468
|
}
|
|
399
469
|
this.requestBusy = false;
|
|
400
470
|
return request;
|
|
@@ -429,8 +499,10 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
429
499
|
resolve(bikeRequest);
|
|
430
500
|
}));
|
|
431
501
|
}
|
|
432
|
-
|
|
433
|
-
|
|
502
|
+
getDeviceInfo() {
|
|
503
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
504
|
+
throw new Error('Method not implemented.');
|
|
505
|
+
});
|
|
434
506
|
}
|
|
435
507
|
}
|
|
436
508
|
exports.default = DaumAdapter;
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import DaumAdapter from '../DaumAdapter';
|
|
1
|
+
import ICyclingMode, { CyclingMode, IncyclistBikeData } from '../../../modes/types';
|
|
2
|
+
import DaumAdapter, { DaumControl } from '../DaumAdapter';
|
|
3
3
|
import { DeviceProperties } from '../../../types/device';
|
|
4
4
|
import { SerialDeviceSettings } from '../../adapter';
|
|
5
|
-
import
|
|
5
|
+
import { SerialCommProps } from '../../comm';
|
|
6
|
+
import Daum8008 from './comms';
|
|
6
7
|
export interface DaumClassicDeviceProperties extends DeviceProperties {
|
|
7
8
|
gear?: number;
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
+
export type DaumClassicStartInfo = {
|
|
11
|
+
bikeNo?: number;
|
|
12
|
+
serialNo?: string;
|
|
13
|
+
cockpit?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare class DaumClassicControl extends DaumControl<DaumClassicDeviceProperties> {
|
|
16
|
+
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
17
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
18
|
+
}
|
|
19
|
+
export default class DaumClassicAdapter extends DaumAdapter<DaumClassicControl, SerialDeviceSettings, DaumClassicDeviceProperties, Daum8008> {
|
|
10
20
|
static NAME: string;
|
|
11
|
-
name: string;
|
|
12
|
-
id: string;
|
|
13
|
-
started: boolean;
|
|
14
|
-
startPromise: Promise<unknown>;
|
|
15
|
-
checkPromise: Promise<boolean>;
|
|
21
|
+
protected name: string;
|
|
22
|
+
protected id: string;
|
|
16
23
|
constructor(settings: SerialDeviceSettings, props?: DaumClassicDeviceProperties);
|
|
17
|
-
|
|
18
|
-
getID(): string;
|
|
24
|
+
getBikeProps(props: SerialDeviceSettings): SerialCommProps;
|
|
19
25
|
getName(): string;
|
|
20
|
-
setName(name:
|
|
21
|
-
getPort(): any;
|
|
26
|
+
setName(name: string): void;
|
|
22
27
|
getProtocolName(): string;
|
|
23
|
-
getSupportedCyclingModes(): Array<any>;
|
|
24
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
25
|
-
getSerialInterface(): SerialInterface;
|
|
26
|
-
check(): Promise<boolean>;
|
|
27
28
|
performCheck(): Promise<boolean>;
|
|
28
|
-
|
|
29
|
-
start(props?: DaumClassicDeviceProperties): Promise<boolean>;
|
|
30
|
-
launch(props: DaumClassicDeviceProperties, isRelaunch?: boolean): Promise<boolean>;
|
|
31
|
-
performStart(props?: DaumClassicDeviceProperties, isRelaunch?: boolean): Promise<unknown>;
|
|
29
|
+
performStart(props?: DaumClassicDeviceProperties, isRelaunch?: boolean): Promise<boolean>;
|
|
32
30
|
getCurrentBikeData(): Promise<IncyclistBikeData>;
|
|
31
|
+
getDeviceInfo(): Promise<any>;
|
|
33
32
|
}
|