incyclist-devices 2.3.37 → 2.3.38
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/fe/adapter.js +2 -2
- package/lib/antv2/pwr/adapter.js +1 -1
- package/lib/base/adpater.js +2 -3
- package/lib/ble/cp/adapter.js +1 -1
- package/lib/ble/fm/adapter.js +1 -1
- package/lib/ble/zwift/play/sensor.js +1 -1
- package/lib/modes/antble-smarttrainer.d.ts +4 -0
- package/lib/modes/antble-smarttrainer.js +69 -23
- package/lib/modes/base.d.ts +3 -0
- package/lib/modes/base.js +20 -0
- package/lib/modes/daum-erg.d.ts +1 -0
- package/lib/modes/daum-erg.js +3 -0
- package/lib/modes/power-base.d.ts +1 -0
- package/lib/modes/power-base.js +7 -2
- package/lib/modes/types.d.ts +2 -2
- package/lib/modes/types.js +1 -1
- package/lib/serial/daum/DaumAdapter.js +2 -2
- package/lib/serial/kettler/ergo-racer/adapter.js +2 -2
- package/lib/simulator/Simulator.js +1 -1
- package/package.json +2 -2
package/lib/antv2/fe/adapter.js
CHANGED
|
@@ -53,7 +53,7 @@ class AntFEAdapter extends adapter_1.default {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
let isReset = request.reset && Object.keys(request).length === 1;
|
|
56
|
-
const update = isReset ? this.getCyclingMode().getBikeInitRequest() : this.getCyclingMode().
|
|
56
|
+
const update = isReset ? this.getCyclingMode().getBikeInitRequest() : this.getCyclingMode().buildUpdate(request);
|
|
57
57
|
this.logEvent({ message: 'send bike update requested', device: this.getName(), update, request });
|
|
58
58
|
try {
|
|
59
59
|
const fe = this.sensor;
|
|
@@ -76,7 +76,7 @@ class AntFEAdapter extends adapter_1.default {
|
|
|
76
76
|
yield this.reconnect();
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
this.logEvent({ message: '
|
|
79
|
+
this.logEvent({ message: 'sendUpdate() error', device: this.getName(), error: err.message });
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
}
|
package/lib/antv2/pwr/adapter.js
CHANGED
|
@@ -61,7 +61,7 @@ class AntPwrAdapter extends adapter_1.default {
|
|
|
61
61
|
try {
|
|
62
62
|
if ((this.isPaused() || this.isStopped()) && !request.forced)
|
|
63
63
|
return;
|
|
64
|
-
return yield this.getCyclingMode().
|
|
64
|
+
return yield this.getCyclingMode().buildUpdate(request);
|
|
65
65
|
}
|
|
66
66
|
catch (err) {
|
|
67
67
|
this.logEvent({ message: 'Error', fn: 'sendUpdate', error: err.message });
|
package/lib/base/adpater.js
CHANGED
|
@@ -214,10 +214,9 @@ class IncyclistDevice extends events_1.default {
|
|
|
214
214
|
return;
|
|
215
215
|
if (!request.enforced && (this.isPaused() || this.isStopped()))
|
|
216
216
|
return;
|
|
217
|
-
if (
|
|
218
|
-
return this.getCyclingMode().sendBikeUpdate(request);
|
|
219
|
-
else
|
|
217
|
+
if (this.hasCapability(types_1.IncyclistCapability.Control))
|
|
220
218
|
throw new Error('method not implemented');
|
|
219
|
+
return this.getCyclingMode().buildUpdate(request);
|
|
221
220
|
});
|
|
222
221
|
}
|
|
223
222
|
setUser(user) {
|
package/lib/ble/cp/adapter.js
CHANGED
|
@@ -92,7 +92,7 @@ class PwrAdapter extends adapter_1.default {
|
|
|
92
92
|
try {
|
|
93
93
|
if (this.isPaused() || this.isStopped())
|
|
94
94
|
return;
|
|
95
|
-
return this.getCyclingMode().
|
|
95
|
+
return this.getCyclingMode().buildUpdate(request);
|
|
96
96
|
}
|
|
97
97
|
catch (err) {
|
|
98
98
|
this.logEvent({ message: 'Error', fn: 'BleCP:sendUpdate', error: err.message });
|
package/lib/ble/fm/adapter.js
CHANGED
|
@@ -264,7 +264,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
264
264
|
if (!enforced && (this.stopped && !this.isStarting()))
|
|
265
265
|
return;
|
|
266
266
|
try {
|
|
267
|
-
const update = this.getCyclingMode().
|
|
267
|
+
const update = this.getCyclingMode().buildUpdate(request);
|
|
268
268
|
this.logEvent({ message: 'send bike update requested', profile: this.getProfile(), mode: (_a = this.getCyclingMode()) === null || _a === void 0 ? void 0 : _a.getName(), update, request });
|
|
269
269
|
const device = this.getSensor();
|
|
270
270
|
if (this.hasCapability(types_1.IncyclistCapability.Control)) {
|
|
@@ -387,7 +387,7 @@ class BleZwiftPlaySensor extends sensor_1.TBleSensor {
|
|
|
387
387
|
const { publicKey, privateKey } = this.createKeyPair();
|
|
388
388
|
this.privateKey = (_a = this.privateKey) !== null && _a !== void 0 ? _a : Buffer.from(privateKey);
|
|
389
389
|
this.publicKey = (_b = this.publicKey) !== null && _b !== void 0 ? _b : Buffer.from(publicKey);
|
|
390
|
-
message = Buffer.concat([Buffer.from('RideOn'), Buffer.from([
|
|
390
|
+
message = Buffer.concat([Buffer.from('RideOn'), Buffer.from([0x02, 0x03]), this.publicKey]);
|
|
391
391
|
}
|
|
392
392
|
yield this.write((0, utils_1.fullUUID)('00000003-19ca-4651-86e5-fa29dcdd09d1'), message, { withoutResponse: true });
|
|
393
393
|
this.isHubServicePaired = true;
|
|
@@ -32,6 +32,7 @@ export default class SmartTrainerCyclingMode extends PowerBasedCyclingModeBase i
|
|
|
32
32
|
protected tsStart: number;
|
|
33
33
|
protected simPower: number;
|
|
34
34
|
protected simSlope: number;
|
|
35
|
+
protected prevData: any;
|
|
35
36
|
protected readonly gearRatios: number[];
|
|
36
37
|
constructor(adapter: IAdapter, props?: any);
|
|
37
38
|
getBikeInitRequest(): UpdateRequest;
|
|
@@ -43,12 +44,15 @@ export default class SmartTrainerCyclingMode extends PowerBasedCyclingModeBase i
|
|
|
43
44
|
protected checkSlopeWithSlopeDelta(request: UpdateRequest, newRequest?: UpdateRequest): void;
|
|
44
45
|
protected checkSlopeWithSimulatedShifting(request: UpdateRequest, newRequest?: UpdateRequest): void;
|
|
45
46
|
checkSlope(request: UpdateRequest, newRequest?: UpdateRequest): void;
|
|
47
|
+
checkCadenceChange(request: UpdateRequest, newRequest?: UpdateRequest): void;
|
|
48
|
+
calculateSimulatedPower(request: UpdateRequest): void;
|
|
46
49
|
checkGearChange(request: UpdateRequest, newRequest?: UpdateRequest): void;
|
|
47
50
|
protected verifySimPower(): void;
|
|
48
51
|
protected checkEmptyRequest(newRequest: UpdateRequest): void;
|
|
49
52
|
protected getVirtualShiftMode(): VirtshiftMode;
|
|
50
53
|
updateData(bikeData: IncyclistBikeData, log?: boolean): IncyclistBikeData;
|
|
51
54
|
getData(): Partial<IncyclistBikeData>;
|
|
55
|
+
protected updateRequired(request?: UpdateRequest): boolean;
|
|
52
56
|
sendBikeUpdate(incoming: UpdateRequest): UpdateRequest;
|
|
53
57
|
protected getGearString(): string;
|
|
54
58
|
}
|
|
@@ -151,11 +151,13 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
151
151
|
const prevPower = this.data.power;
|
|
152
152
|
if (this.data.speed < 10 && this.data.isPedalling && (this.data.slope < 1 || this.data.speed === 0)) {
|
|
153
153
|
this.simPower = Math.max(newPower, prevPower);
|
|
154
|
-
|
|
154
|
+
console.log('# set simulated power', { power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevPower, newPower });
|
|
155
|
+
this.logger.logEvent({ message: 'set simulated power', power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevPower, newPower });
|
|
155
156
|
}
|
|
156
157
|
else if (this.data.slope === prev && newPower < prevPower) {
|
|
157
158
|
this.simPower = prevPower;
|
|
158
|
-
|
|
159
|
+
console.log('# set simulated power:', { power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevPower, newPower });
|
|
160
|
+
this.logger.logEvent({ message: 'set simulated power', power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevPower, newPower });
|
|
159
161
|
}
|
|
160
162
|
else {
|
|
161
163
|
const powerDiff = newPower - prevPower;
|
|
@@ -166,10 +168,15 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
166
168
|
const eKinAfter1sec = eKinPrev - powerDiff * 1;
|
|
167
169
|
const vAfter1sec = Math.sqrt(2 * eKinAfter1sec / m) * 3600 / 1000;
|
|
168
170
|
this.simPower = calculations_1.default.calculatePower(m, vAfter1sec / 3.6, (_e = this.simSlope) !== null && _e !== void 0 ? _e : 0);
|
|
169
|
-
|
|
171
|
+
console.log('# set simulated power (Ekin):', { power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, eKinPrev, eKinTarget, delta, prevPower, newPower });
|
|
172
|
+
this.logger.logEvent({ message: 'set simulated power (Ekin)', power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, eKinPrev, eKinTarget, delta, prevPower, newPower });
|
|
170
173
|
}
|
|
171
174
|
this.verifySimPower();
|
|
172
175
|
}
|
|
176
|
+
else {
|
|
177
|
+
console.log('# set simulated power (same slope):', { simPower: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, cadence: this.data.pedalRpm, power: this.data.power });
|
|
178
|
+
this.logger.logEvent({ message: 'set simulated power (same slope)', simPower: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, cadence: this.data.pedalRpm, power: this.data.power });
|
|
179
|
+
}
|
|
173
180
|
newRequest.targetPower = this.simPower;
|
|
174
181
|
}
|
|
175
182
|
checkSlope(request, newRequest = {}) {
|
|
@@ -190,8 +197,53 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
190
197
|
break;
|
|
191
198
|
}
|
|
192
199
|
}
|
|
193
|
-
|
|
200
|
+
checkCadenceChange(request, newRequest = {}) {
|
|
201
|
+
const virtshiftMode = this.getVirtualShiftMode();
|
|
202
|
+
if (virtshiftMode !== 'Simulated') {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (request.targetPower !== undefined || request.targetPowerDelta !== undefined || request.gearDelta !== undefined || request.gearRatio !== undefined) {
|
|
206
|
+
console.log('# cadence change ignored due to other power/gear request', request);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (this.data.pedalRpm !== this.prevData.pedalRpm) {
|
|
210
|
+
console.log('# cadence changed ', { cadence: this.data.pedalRpm, prevCadence: this.prevData.pedalRpm });
|
|
211
|
+
this.calculateSimulatedPower(request);
|
|
212
|
+
delete request.slope;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
calculateSimulatedPower(request) {
|
|
194
216
|
var _a, _b, _c, _d;
|
|
217
|
+
const m = (_b = (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.getWeight()) !== null && _b !== void 0 ? _b : 85;
|
|
218
|
+
const vCurrent = this.data.speed * 1000 / 3600;
|
|
219
|
+
const eKinCurrent = m * vCurrent * vCurrent / 2;
|
|
220
|
+
if (this.data.pedalRpm > 0) {
|
|
221
|
+
const virtualSpeed = (0, calculations_1.calculateVirtualSpeed)(this.data.pedalRpm, this.gearRatios[this.gear - 1]);
|
|
222
|
+
const newPower = calculations_1.default.calculatePower(m, virtualSpeed, (_c = this.simSlope) !== null && _c !== void 0 ? _c : 0);
|
|
223
|
+
const prevPower = this.data.power;
|
|
224
|
+
if (this.data.speed < 10 && this.data.isPedalling && (this.data.slope < 1 || this.data.speed === 0)) {
|
|
225
|
+
this.simPower = Math.max(newPower, prevPower);
|
|
226
|
+
console.log('# set simulated power (starting)', { power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevPower, newPower });
|
|
227
|
+
this.logger.logEvent({ message: 'set simulated power (starting)', power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevPower, newPower });
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
const powerDiff = newPower - prevPower;
|
|
231
|
+
const vTarget = virtualSpeed * 1000 / 3600;
|
|
232
|
+
const eKinTarget = m * vTarget * vTarget / 2;
|
|
233
|
+
const eKinPrev = eKinCurrent;
|
|
234
|
+
const delta = eKinTarget - eKinPrev;
|
|
235
|
+
const eKinAfter1sec = eKinPrev - powerDiff * 1;
|
|
236
|
+
const vAfter1sec = Math.sqrt(2 * eKinAfter1sec / m) * 3600 / 1000;
|
|
237
|
+
this.simPower = calculations_1.default.calculatePower(m, vAfter1sec / 3.6, (_d = this.simSlope) !== null && _d !== void 0 ? _d : 0);
|
|
238
|
+
console.log('# set simulated power (Ekin):', { power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, eKinPrev, eKinTarget, delta, prevPower, newPower });
|
|
239
|
+
this.logger.logEvent({ message: 'set simulated power (Ekin)', power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, eKinPrev, eKinTarget, delta, prevPower, newPower });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
delete this.simPower;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
checkGearChange(request, newRequest = {}) {
|
|
195
247
|
const virtshiftMode = this.getVirtualShiftMode();
|
|
196
248
|
switch (virtshiftMode) {
|
|
197
249
|
case 'SlopeDelta':
|
|
@@ -217,17 +269,10 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
217
269
|
this.gear = this.gearRatios.length;
|
|
218
270
|
}
|
|
219
271
|
delete request.gearDelta;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const m = (_b = (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.getWeight()) !== null && _b !== void 0 ? _b : 85;
|
|
223
|
-
this.simPower = calculations_1.default.calculatePower(m, virtualSpeed, (_d = (_c = this.simSlope) !== null && _c !== void 0 ? _c : this.data.slope) !== null && _d !== void 0 ? _d : 0);
|
|
224
|
-
this.verifySimPower();
|
|
225
|
-
this.logger.logEvent({ message: 'set simulater power', power: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope });
|
|
272
|
+
this.calculateSimulatedPower(request);
|
|
273
|
+
if (this.simPower !== undefined) {
|
|
226
274
|
this.adapter.sendUpdate({ targetPower: this.simPower }).then(() => { });
|
|
227
275
|
}
|
|
228
|
-
else {
|
|
229
|
-
delete this.simPower;
|
|
230
|
-
}
|
|
231
276
|
}
|
|
232
277
|
break;
|
|
233
278
|
case 'Adapter':
|
|
@@ -316,8 +361,8 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
316
361
|
return 'Disabled';
|
|
317
362
|
}
|
|
318
363
|
updateData(bikeData, log) {
|
|
319
|
-
var _a
|
|
320
|
-
const prev = Object.assign({}, this.data);
|
|
364
|
+
var _a;
|
|
365
|
+
const prev = this.prevData = Object.assign({}, this.data);
|
|
321
366
|
const data = super.updateData(bikeData, log);
|
|
322
367
|
const mode = this.getVirtualShiftMode();
|
|
323
368
|
let virtualSpeed;
|
|
@@ -332,14 +377,6 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
332
377
|
this.gear = (_a = this.getSetting('startGear')) !== null && _a !== void 0 ? _a : 0;
|
|
333
378
|
data.gearStr = this.getGearString();
|
|
334
379
|
}
|
|
335
|
-
else if (this.gear !== undefined) {
|
|
336
|
-
if (prev.power !== data.power || prev.pedalRpm !== data.pedalRpm) {
|
|
337
|
-
virtualSpeed = (0, calculations_1.calculateVirtualSpeed)(data.pedalRpm, this.gearRatios[this.gear - 1]);
|
|
338
|
-
const m = (_c = (_b = this.adapter) === null || _b === void 0 ? void 0 : _b.getWeight()) !== null && _c !== void 0 ? _c : 85;
|
|
339
|
-
this.simPower = calculations_1.default.calculatePower(m, virtualSpeed, (_e = (_d = this.simSlope) !== null && _d !== void 0 ? _d : data.slope) !== null && _e !== void 0 ? _e : 0);
|
|
340
|
-
this.verifySimPower();
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
380
|
return data;
|
|
344
381
|
}
|
|
345
382
|
getData() {
|
|
@@ -347,6 +384,14 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
347
384
|
const data = super.getData();
|
|
348
385
|
return Object.assign(Object.assign({}, data), { gearStr });
|
|
349
386
|
}
|
|
387
|
+
updateRequired(request) {
|
|
388
|
+
console.log('# SmartTrainerCyclingMode updateRequired check');
|
|
389
|
+
const virtshiftMode = this.getVirtualShiftMode();
|
|
390
|
+
if (virtshiftMode === 'Adapter' || virtshiftMode === 'Simulated') {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
return super.updateRequired(request);
|
|
394
|
+
}
|
|
350
395
|
sendBikeUpdate(incoming) {
|
|
351
396
|
this.logger.logEvent({ message: "processing update request", request: incoming, prev: this.prevRequest, data: this.getData() });
|
|
352
397
|
let newRequest = {};
|
|
@@ -356,6 +401,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
356
401
|
if (req) {
|
|
357
402
|
return req;
|
|
358
403
|
}
|
|
404
|
+
this.checkCadenceChange(request, newRequest);
|
|
359
405
|
this.checkGearChange(request, newRequest);
|
|
360
406
|
this.checkSlope(request, newRequest);
|
|
361
407
|
this.checkEmptyRequest(newRequest);
|
package/lib/modes/base.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare abstract class CyclingModeBase extends CyclingMode implements ICy
|
|
|
7
7
|
localConfig: CyclingModeConfig;
|
|
8
8
|
protected static config: CyclingModeConfig;
|
|
9
9
|
protected static isERG: boolean;
|
|
10
|
+
protected prevUpdate: UpdateRequest;
|
|
10
11
|
static supportsERGMode(): boolean;
|
|
11
12
|
constructor(adapter: IAdapter, props?: any);
|
|
12
13
|
setAdapter(adapter: IAdapter): void;
|
|
@@ -23,6 +24,8 @@ export declare abstract class CyclingModeBase extends CyclingMode implements ICy
|
|
|
23
24
|
getSettings(): Settings;
|
|
24
25
|
setModeProperty(name: string, value: any): void;
|
|
25
26
|
getModeProperty(name: string): any;
|
|
27
|
+
protected updateRequired(request?: UpdateRequest): boolean;
|
|
28
|
+
buildUpdate(request?: UpdateRequest): UpdateRequest;
|
|
26
29
|
abstract getBikeInitRequest(): UpdateRequest;
|
|
27
30
|
abstract sendBikeUpdate(request: UpdateRequest): UpdateRequest;
|
|
28
31
|
abstract updateData(data: IncyclistBikeData): IncyclistBikeData;
|
package/lib/modes/base.js
CHANGED
|
@@ -71,6 +71,26 @@ class CyclingModeBase extends types_1.CyclingMode {
|
|
|
71
71
|
return prop.default;
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
74
|
+
updateRequired(request = {}) {
|
|
75
|
+
const prevRequest = Object.assign({}, this.prevUpdate);
|
|
76
|
+
this.prevUpdate = Object.assign({}, request);
|
|
77
|
+
if (prevRequest && !request.targetPowerDelta && !request.reset) {
|
|
78
|
+
if ((request.slope !== undefined && prevRequest.slope === request.slope) &&
|
|
79
|
+
(request.targetPower !== undefined && prevRequest.targetPower === request.targetPower)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
buildUpdate(request) {
|
|
86
|
+
if (!request) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
if (!this.updateRequired(request)) {
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
92
|
+
return this.sendBikeUpdate(request);
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
exports.CyclingModeBase = CyclingModeBase;
|
|
76
96
|
CyclingModeBase.config = { name: '', description: '', properties: [] };
|
package/lib/modes/daum-erg.d.ts
CHANGED
|
@@ -47,4 +47,5 @@ export default class ERGCyclingMode extends PowerBasedCyclingModeBase implements
|
|
|
47
47
|
private checkIsStarting;
|
|
48
48
|
calculateTargetPower(request: any, updateMode?: boolean): any;
|
|
49
49
|
protected checkForTempPowerAdjustments(request: UpdateRequest): void;
|
|
50
|
+
protected applyCadenceFixes(): boolean;
|
|
50
51
|
}
|
package/lib/modes/daum-erg.js
CHANGED
|
@@ -34,6 +34,7 @@ export default class PowerBasedCyclingModeBase extends CyclingModeBase {
|
|
|
34
34
|
bikeType: any;
|
|
35
35
|
slope: any;
|
|
36
36
|
};
|
|
37
|
+
protected applyCadenceFixes(): boolean;
|
|
37
38
|
copyBikeData(data: IncyclistBikeData, bikeData: IncyclistBikeData): IncyclistBikeData;
|
|
38
39
|
calculatePowerAndDistance(speed: number, slope: number, m: number, t: number, props?: {}): {
|
|
39
40
|
power: number;
|
package/lib/modes/power-base.js
CHANGED
|
@@ -177,6 +177,9 @@ class PowerBasedCyclingModeBase extends base_1.CyclingModeBase {
|
|
|
177
177
|
this.copyBikeData(data, bikeData);
|
|
178
178
|
return { data, prevData, prevRequest, bikeType, slope };
|
|
179
179
|
}
|
|
180
|
+
applyCadenceFixes() {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
180
183
|
copyBikeData(data, bikeData) {
|
|
181
184
|
var _a;
|
|
182
185
|
const prevCadence = data.pedalRpm;
|
|
@@ -197,8 +200,10 @@ class PowerBasedCyclingModeBase extends base_1.CyclingModeBase {
|
|
|
197
200
|
data.slope = 0;
|
|
198
201
|
if (bikeData.isPedalling === undefined)
|
|
199
202
|
(data.isPedalling = data.pedalRpm > 0 || data.power > 0);
|
|
200
|
-
if (
|
|
201
|
-
|
|
203
|
+
if (this.applyCadenceFixes()) {
|
|
204
|
+
if (bikeData.pedalRpm === 0 && bikeData.power > 0 && prevCadence !== undefined) {
|
|
205
|
+
data.pedalRpm = prevCadence;
|
|
206
|
+
}
|
|
202
207
|
}
|
|
203
208
|
if (((_a = this.prevRequest) === null || _a === void 0 ? void 0 : _a.slope) !== undefined) {
|
|
204
209
|
data.slope = this.prevRequest.slope;
|
package/lib/modes/types.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export default interface ICyclingMode {
|
|
|
41
41
|
getProperties(): CyclingModeProperty[];
|
|
42
42
|
getProperty(name: string): CyclingModeProperty;
|
|
43
43
|
getBikeInitRequest(): UpdateRequest;
|
|
44
|
-
|
|
44
|
+
buildUpdate(request: UpdateRequest): UpdateRequest;
|
|
45
45
|
updateData(data: IncyclistBikeData): IncyclistBikeData;
|
|
46
46
|
setSettings(settings: any): any;
|
|
47
47
|
setSetting(name: string, value: any): void;
|
|
@@ -66,7 +66,7 @@ export declare class CyclingMode implements ICyclingMode {
|
|
|
66
66
|
getProperties(): CyclingModeProperty[];
|
|
67
67
|
getProperty(_name: string): CyclingModeProperty;
|
|
68
68
|
getBikeInitRequest(): UpdateRequest;
|
|
69
|
-
|
|
69
|
+
buildUpdate(_request: UpdateRequest): UpdateRequest;
|
|
70
70
|
updateData(_data: IncyclistBikeData): IncyclistBikeData;
|
|
71
71
|
setSettings(_settings: any): void;
|
|
72
72
|
setSetting(_name: string, _value: any): void;
|
package/lib/modes/types.js
CHANGED
|
@@ -508,7 +508,7 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
508
508
|
return;
|
|
509
509
|
if (!this.deviceData.isPedalling || this.deviceData.pedalRpm === 0)
|
|
510
510
|
return;
|
|
511
|
-
let bikeRequest = this.getCyclingMode().
|
|
511
|
+
let bikeRequest = this.getCyclingMode().buildUpdate({ refresh: true }) || {};
|
|
512
512
|
const prev = this.requests[this.requests.length - 1] || {};
|
|
513
513
|
if (bikeRequest.targetPower !== undefined && bikeRequest.targetPower !== prev.targetPower) {
|
|
514
514
|
this.logEvent({ message: 'add request', request: bikeRequest });
|
|
@@ -521,7 +521,7 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
521
521
|
}
|
|
522
522
|
return new Promise((resolve) => {
|
|
523
523
|
const fn = () => __awaiter(this, void 0, void 0, function* () {
|
|
524
|
-
let bikeRequest = this.getCyclingMode().
|
|
524
|
+
let bikeRequest = this.getCyclingMode().buildUpdate(request);
|
|
525
525
|
this.logEvent({ message: 'add request', request: bikeRequest });
|
|
526
526
|
this.requests.push(bikeRequest);
|
|
527
527
|
resolve(bikeRequest);
|
|
@@ -489,7 +489,7 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
489
489
|
var _a;
|
|
490
490
|
if (((_a = this.kettlerData) === null || _a === void 0 ? void 0 : _a.cadence) === 0)
|
|
491
491
|
return;
|
|
492
|
-
let bikeRequest = this.getCyclingMode().
|
|
492
|
+
let bikeRequest = this.getCyclingMode().buildUpdate({ refresh: true }) || {};
|
|
493
493
|
const prev = this.requests[this.requests.length - 1] || {};
|
|
494
494
|
if (bikeRequest.targetPower !== undefined && bikeRequest.targetPower !== prev.targetPower) {
|
|
495
495
|
this.logEvent({ message: 'add request', request: bikeRequest });
|
|
@@ -501,7 +501,7 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
501
501
|
this.data.slope = request.slope;
|
|
502
502
|
}
|
|
503
503
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
504
|
-
let bikeRequest = this.getCyclingMode().
|
|
504
|
+
let bikeRequest = this.getCyclingMode().buildUpdate(request);
|
|
505
505
|
this.logEvent({ message: 'add request', request: bikeRequest });
|
|
506
506
|
this.requests.push(bikeRequest);
|
|
507
507
|
resolve(bikeRequest);
|
|
@@ -188,7 +188,7 @@ class Simulator extends adpater_1.default {
|
|
|
188
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
189
|
if (this.paused)
|
|
190
190
|
return;
|
|
191
|
-
return
|
|
191
|
+
return this.getCyclingMode().buildUpdate(request);
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-devices",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.38",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@protobuf-ts/runtime": "^2.11.1",
|
|
6
6
|
"@serialport/bindings-interface": "^1.2.2",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"lint": "eslint . --ext .ts",
|
|
36
36
|
"build": "tsc",
|
|
37
|
-
"test": "npx jest --coverage",
|
|
37
|
+
"test:unit": "npx jest --coverage",
|
|
38
38
|
"test:ci": "npx jest --coverage --forceExit",
|
|
39
39
|
"dev": "tsc --watch",
|
|
40
40
|
"postversion": "git push && git push --tags",
|