incyclist-devices 1.4.102 → 1.5.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/LICENSE +0 -0
- package/lib/DeviceSupport.d.ts +36 -34
- package/lib/DeviceSupport.js +82 -78
- package/lib/ant/AntAdapter.d.ts +50 -50
- package/lib/ant/AntAdapter.js +109 -109
- package/lib/ant/AntScanner.d.ts +60 -60
- package/lib/ant/AntScanner.js +651 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +83 -83
- package/lib/ant/antfe/AntFEAdapter.js +652 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +9 -9
- package/lib/ant/antfe/ant-fe-adv-st-mode.js +51 -51
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +6 -6
- package/lib/ant/antfe/ant-fe-erg-mode.js +14 -14
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +5 -5
- package/lib/ant/antfe/ant-fe-st-mode.js +13 -13
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +16 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +130 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +49 -49
- package/lib/ant/antpwr/pwr-adapter.js +251 -251
- package/lib/ant/utils.d.ts +1 -1
- package/lib/ant/utils.js +23 -23
- package/lib/antv2/adapter-factory.d.ts +11 -0
- package/lib/antv2/adapter-factory.js +40 -0
- package/lib/antv2/ant-binding.d.ts +13 -0
- package/lib/antv2/ant-binding.js +27 -0
- package/lib/antv2/ant-device.d.ts +51 -0
- package/lib/antv2/ant-device.js +115 -0
- package/lib/antv2/ant-interface.d.ts +37 -0
- package/lib/antv2/ant-interface.js +239 -0
- package/lib/antv2/fe.d.ts +28 -0
- package/lib/antv2/fe.js +237 -0
- package/lib/antv2/hr.d.ts +18 -0
- package/lib/antv2/hr.js +93 -0
- package/lib/antv2/incyclist-protocol.d.ts +37 -0
- package/lib/antv2/incyclist-protocol.js +126 -0
- package/lib/antv2/pwr.d.ts +28 -0
- package/lib/antv2/pwr.js +163 -0
- package/lib/antv2/sensor-factory.d.ts +5 -0
- package/lib/antv2/sensor-factory.js +20 -0
- package/lib/ble/ble-device.d.ts +63 -63
- package/lib/ble/ble-device.js +444 -444
- package/lib/ble/ble-erg-mode.d.ts +18 -18
- package/lib/ble/ble-erg-mode.js +132 -132
- package/lib/ble/ble-interface.d.ts +100 -100
- package/lib/ble/ble-interface.js +721 -719
- package/lib/ble/ble-peripheral.d.ts +36 -36
- package/lib/ble/ble-peripheral.js +200 -200
- package/lib/ble/ble-st-mode.d.ts +15 -15
- package/lib/ble/ble-st-mode.js +95 -95
- package/lib/ble/ble.d.ts +129 -129
- package/lib/ble/ble.js +86 -86
- package/lib/ble/consts.d.ts +14 -14
- package/lib/ble/consts.js +17 -17
- package/lib/ble/fm.d.ts +125 -125
- package/lib/ble/fm.js +745 -745
- package/lib/ble/hrm.d.ts +48 -48
- package/lib/ble/hrm.js +134 -134
- package/lib/ble/incyclist-protocol.d.ts +31 -31
- package/lib/ble/incyclist-protocol.js +147 -147
- package/lib/ble/pwr.d.ts +89 -89
- package/lib/ble/pwr.js +321 -321
- package/lib/ble/tacx.d.ts +90 -90
- package/lib/ble/tacx.js +731 -731
- package/lib/ble/wahoo-kickr.d.ts +98 -98
- package/lib/ble/wahoo-kickr.js +496 -496
- package/lib/calculations.d.ts +13 -13
- package/lib/calculations.js +150 -150
- package/lib/{CyclingMode.d.ts → cycling-mode.d.ts} +76 -76
- package/lib/{CyclingMode.js → cycling-mode.js} +79 -79
- package/lib/daum/DaumAdapter.d.ts +66 -66
- package/lib/daum/DaumAdapter.js +396 -396
- package/lib/daum/DaumPowerMeterCyclingMode.d.ts +8 -8
- package/lib/daum/DaumPowerMeterCyclingMode.js +21 -21
- package/lib/daum/ERGCyclingMode.d.ts +26 -26
- package/lib/daum/ERGCyclingMode.js +201 -201
- package/lib/daum/SmartTrainerCyclingMode.d.ts +41 -41
- package/lib/daum/SmartTrainerCyclingMode.js +344 -344
- package/lib/daum/classic/DaumClassicAdapter.d.ts +18 -18
- package/lib/daum/classic/DaumClassicAdapter.js +146 -146
- package/lib/daum/classic/DaumClassicCyclingMode.d.ts +13 -13
- package/lib/daum/classic/DaumClassicCyclingMode.js +97 -97
- package/lib/daum/classic/DaumClassicProtocol.d.ts +27 -27
- package/lib/daum/classic/DaumClassicProtocol.js +185 -185
- package/lib/daum/classic/bike.d.ts +64 -64
- package/lib/daum/classic/bike.js +456 -456
- package/lib/daum/classic/utils.d.ts +13 -13
- package/lib/daum/classic/utils.js +143 -143
- package/lib/daum/constants.d.ts +19 -19
- package/lib/daum/constants.js +22 -22
- package/lib/daum/premium/DaumClassicCyclingMode.d.ts +14 -14
- package/lib/daum/premium/DaumClassicCyclingMode.js +86 -86
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +12 -12
- package/lib/daum/premium/DaumPremiumAdapter.js +131 -131
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +32 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +207 -207
- package/lib/daum/premium/bike.d.ts +123 -123
- package/lib/daum/premium/bike.js +894 -894
- package/lib/daum/premium/tcpserial.d.ts +33 -33
- package/lib/daum/premium/tcpserial.js +123 -123
- package/lib/daum/premium/utils.d.ts +62 -62
- package/lib/daum/premium/utils.js +376 -376
- package/lib/{Device.d.ts → device.d.ts} +92 -92
- package/lib/{Device.js → device.js} +71 -71
- package/lib/kettler/comms.d.ts +59 -59
- package/lib/kettler/comms.js +242 -242
- package/lib/kettler/ergo-racer/ERGCyclingMode.d.ts +25 -25
- package/lib/kettler/ergo-racer/ERGCyclingMode.js +144 -144
- package/lib/kettler/ergo-racer/adapter.d.ts +101 -101
- package/lib/kettler/ergo-racer/adapter.js +639 -639
- package/lib/kettler/ergo-racer/protocol.d.ts +41 -41
- package/lib/kettler/ergo-racer/protocol.js +203 -203
- package/lib/modes/power-base.d.ts +20 -20
- package/lib/modes/power-base.js +70 -70
- package/lib/modes/power-meter.d.ts +20 -20
- package/lib/modes/power-meter.js +78 -78
- package/lib/modes/simulator.d.ts +29 -29
- package/lib/modes/simulator.js +140 -140
- package/lib/{DeviceProtocol.d.ts → protocol.d.ts} +74 -74
- package/lib/{DeviceProtocol.js → protocol.js} +41 -41
- package/lib/{DeviceRegistry.d.ts → registry.d.ts} +8 -8
- package/lib/{DeviceRegistry.js → registry.js} +33 -33
- package/lib/simulator/Simulator.d.ts +69 -69
- package/lib/simulator/Simulator.js +288 -288
- package/lib/types/command.d.ts +8 -8
- package/lib/types/command.js +2 -2
- package/lib/types/route.d.ts +24 -24
- package/lib/types/route.js +9 -9
- package/lib/types/user.d.ts +11 -11
- package/lib/types/user.js +9 -9
- package/lib/utils.d.ts +14 -14
- package/lib/utils.js +114 -114
- package/package.json +47 -46
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import FtmsCyclingMode from "../../ble/ble-st-mode";
|
|
2
|
-
import { UpdateRequest } from "../../
|
|
3
|
-
import { DeviceAdapter } from "../../
|
|
4
|
-
export default class AntAdvSimCyclingMode extends FtmsCyclingMode {
|
|
5
|
-
constructor(adapter: DeviceAdapter, props?: any);
|
|
6
|
-
getName(): string;
|
|
7
|
-
getDescription(): string;
|
|
8
|
-
sendBikeUpdate(request: UpdateRequest): UpdateRequest;
|
|
9
|
-
}
|
|
1
|
+
import FtmsCyclingMode from "../../ble/ble-st-mode";
|
|
2
|
+
import { UpdateRequest } from "../../cycling-mode";
|
|
3
|
+
import { DeviceAdapter } from "../../device";
|
|
4
|
+
export default class AntAdvSimCyclingMode extends FtmsCyclingMode {
|
|
5
|
+
constructor(adapter: DeviceAdapter, props?: any);
|
|
6
|
+
getName(): string;
|
|
7
|
+
getDescription(): string;
|
|
8
|
+
sendBikeUpdate(request: UpdateRequest): UpdateRequest;
|
|
9
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ble_st_mode_1 = __importDefault(require("../../ble/ble-st-mode"));
|
|
7
|
-
const MAX_DEVIATION = 10;
|
|
8
|
-
class AntAdvSimCyclingMode extends ble_st_mode_1.default {
|
|
9
|
-
constructor(adapter, props) {
|
|
10
|
-
super(adapter, props);
|
|
11
|
-
this.initLogger('AntAdvSimMode');
|
|
12
|
-
}
|
|
13
|
-
getName() {
|
|
14
|
-
return 'Advanced Smart Trainer';
|
|
15
|
-
}
|
|
16
|
-
getDescription() {
|
|
17
|
-
return 'Sends Slope to device. Respects Limits (from workout or settings). Calculates speed based on power and slope. ';
|
|
18
|
-
}
|
|
19
|
-
sendBikeUpdate(request) {
|
|
20
|
-
const getData = () => {
|
|
21
|
-
if (!this.data)
|
|
22
|
-
return {};
|
|
23
|
-
const { gear, pedalRpm, slope, power, speed } = this.data;
|
|
24
|
-
return { gear, pedalRpm, slope, power, speed };
|
|
25
|
-
};
|
|
26
|
-
this.logger.logEvent({ message: "processing update request", request, prev: this.prevRequest, data: getData() });
|
|
27
|
-
let newRequest = {};
|
|
28
|
-
if (request.slope === undefined && request.targetPower === undefined && request.refresh && this.prevRequest) {
|
|
29
|
-
return this.prevRequest;
|
|
30
|
-
}
|
|
31
|
-
if (request.slope !== undefined) {
|
|
32
|
-
newRequest.slope = parseFloat(request.slope.toFixed(1));
|
|
33
|
-
this.data.slope = newRequest.slope;
|
|
34
|
-
}
|
|
35
|
-
if (this.data && this.data.power) {
|
|
36
|
-
const { minPower, maxPower } = request;
|
|
37
|
-
let { targetPower } = request;
|
|
38
|
-
if (minPower !== undefined && maxPower !== undefined && minPower === maxPower)
|
|
39
|
-
targetPower = maxPower;
|
|
40
|
-
if (targetPower !== undefined && Math.abs(this.data.power - targetPower) > MAX_DEVIATION)
|
|
41
|
-
newRequest.targetPower = targetPower;
|
|
42
|
-
else if (minPower !== undefined && this.data.power < minPower)
|
|
43
|
-
newRequest.targetPower = minPower;
|
|
44
|
-
else if (request.maxPower !== undefined && this.data.power > request.maxPower)
|
|
45
|
-
newRequest.targetPower = maxPower;
|
|
46
|
-
}
|
|
47
|
-
this.prevRequest = JSON.parse(JSON.stringify(newRequest));
|
|
48
|
-
return newRequest;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.default = AntAdvSimCyclingMode;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ble_st_mode_1 = __importDefault(require("../../ble/ble-st-mode"));
|
|
7
|
+
const MAX_DEVIATION = 10;
|
|
8
|
+
class AntAdvSimCyclingMode extends ble_st_mode_1.default {
|
|
9
|
+
constructor(adapter, props) {
|
|
10
|
+
super(adapter, props);
|
|
11
|
+
this.initLogger('AntAdvSimMode');
|
|
12
|
+
}
|
|
13
|
+
getName() {
|
|
14
|
+
return 'Advanced Smart Trainer';
|
|
15
|
+
}
|
|
16
|
+
getDescription() {
|
|
17
|
+
return 'Sends Slope to device. Respects Limits (from workout or settings). Calculates speed based on power and slope. ';
|
|
18
|
+
}
|
|
19
|
+
sendBikeUpdate(request) {
|
|
20
|
+
const getData = () => {
|
|
21
|
+
if (!this.data)
|
|
22
|
+
return {};
|
|
23
|
+
const { gear, pedalRpm, slope, power, speed } = this.data;
|
|
24
|
+
return { gear, pedalRpm, slope, power, speed };
|
|
25
|
+
};
|
|
26
|
+
this.logger.logEvent({ message: "processing update request", request, prev: this.prevRequest, data: getData() });
|
|
27
|
+
let newRequest = {};
|
|
28
|
+
if (request.slope === undefined && request.targetPower === undefined && request.refresh && this.prevRequest) {
|
|
29
|
+
return this.prevRequest;
|
|
30
|
+
}
|
|
31
|
+
if (request.slope !== undefined) {
|
|
32
|
+
newRequest.slope = parseFloat(request.slope.toFixed(1));
|
|
33
|
+
this.data.slope = newRequest.slope;
|
|
34
|
+
}
|
|
35
|
+
if (this.data && this.data.power) {
|
|
36
|
+
const { minPower, maxPower } = request;
|
|
37
|
+
let { targetPower } = request;
|
|
38
|
+
if (minPower !== undefined && maxPower !== undefined && minPower === maxPower)
|
|
39
|
+
targetPower = maxPower;
|
|
40
|
+
if (targetPower !== undefined && Math.abs(this.data.power - targetPower) > MAX_DEVIATION)
|
|
41
|
+
newRequest.targetPower = targetPower;
|
|
42
|
+
else if (minPower !== undefined && this.data.power < minPower)
|
|
43
|
+
newRequest.targetPower = minPower;
|
|
44
|
+
else if (request.maxPower !== undefined && this.data.power > request.maxPower)
|
|
45
|
+
newRequest.targetPower = maxPower;
|
|
46
|
+
}
|
|
47
|
+
this.prevRequest = JSON.parse(JSON.stringify(newRequest));
|
|
48
|
+
return newRequest;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.default = AntAdvSimCyclingMode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BleERGCyclingMode from "../../ble/ble-erg-mode";
|
|
2
|
-
import { DeviceAdapter } from "../../
|
|
3
|
-
export default class AntFeERGCyclingMode extends BleERGCyclingMode {
|
|
4
|
-
static isERG: boolean;
|
|
5
|
-
constructor(adapter: DeviceAdapter, props?: any);
|
|
6
|
-
}
|
|
1
|
+
import BleERGCyclingMode from "../../ble/ble-erg-mode";
|
|
2
|
+
import { DeviceAdapter } from "../../device";
|
|
3
|
+
export default class AntFeERGCyclingMode extends BleERGCyclingMode {
|
|
4
|
+
static isERG: boolean;
|
|
5
|
+
constructor(adapter: DeviceAdapter, props?: any);
|
|
6
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ble_erg_mode_1 = __importDefault(require("../../ble/ble-erg-mode"));
|
|
7
|
-
class AntFeERGCyclingMode extends ble_erg_mode_1.default {
|
|
8
|
-
constructor(adapter, props) {
|
|
9
|
-
super(adapter, props);
|
|
10
|
-
this.initLogger('AntERGMode');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.default = AntFeERGCyclingMode;
|
|
14
|
-
AntFeERGCyclingMode.isERG = true;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ble_erg_mode_1 = __importDefault(require("../../ble/ble-erg-mode"));
|
|
7
|
+
class AntFeERGCyclingMode extends ble_erg_mode_1.default {
|
|
8
|
+
constructor(adapter, props) {
|
|
9
|
+
super(adapter, props);
|
|
10
|
+
this.initLogger('AntERGMode');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = AntFeERGCyclingMode;
|
|
14
|
+
AntFeERGCyclingMode.isERG = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import FtmsCyclingMode from "../../ble/ble-st-mode";
|
|
2
|
-
import { DeviceAdapter } from "../../
|
|
3
|
-
export default class AntStCyclingMode extends FtmsCyclingMode {
|
|
4
|
-
constructor(adapter: DeviceAdapter, props?: any);
|
|
5
|
-
}
|
|
1
|
+
import FtmsCyclingMode from "../../ble/ble-st-mode";
|
|
2
|
+
import { DeviceAdapter } from "../../device";
|
|
3
|
+
export default class AntStCyclingMode extends FtmsCyclingMode {
|
|
4
|
+
constructor(adapter: DeviceAdapter, props?: any);
|
|
5
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ble_st_mode_1 = __importDefault(require("../../ble/ble-st-mode"));
|
|
7
|
-
class AntStCyclingMode extends ble_st_mode_1.default {
|
|
8
|
-
constructor(adapter, props) {
|
|
9
|
-
super(adapter, props);
|
|
10
|
-
this.initLogger('AntSimMode');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.default = AntStCyclingMode;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ble_st_mode_1 = __importDefault(require("../../ble/ble-st-mode"));
|
|
7
|
+
class AntStCyclingMode extends ble_st_mode_1.default {
|
|
8
|
+
constructor(adapter, props) {
|
|
9
|
+
super(adapter, props);
|
|
10
|
+
this.initLogger('AntSimMode');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.default = AntStCyclingMode;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import AntAdapter from '../AntAdapter';
|
|
2
|
-
export default class AntHrmAdapter extends AntAdapter {
|
|
3
|
-
started: boolean;
|
|
4
|
-
starting: boolean;
|
|
5
|
-
constructor(DeviceID: any, port: any, stick: any, protocol: any);
|
|
6
|
-
isBike(): boolean;
|
|
7
|
-
isHrm(): boolean;
|
|
8
|
-
isPower(): boolean;
|
|
9
|
-
getProfile(): string;
|
|
10
|
-
getName(): string;
|
|
11
|
-
getDisplayName(): string;
|
|
12
|
-
onDeviceData(deviceData: any): void;
|
|
13
|
-
updateData(data: any, deviceData: any): any;
|
|
14
|
-
start(props?: any): Promise<any>;
|
|
15
|
-
stop(): Promise<boolean>;
|
|
16
|
-
}
|
|
1
|
+
import AntAdapter from '../AntAdapter';
|
|
2
|
+
export default class AntHrmAdapter extends AntAdapter {
|
|
3
|
+
started: boolean;
|
|
4
|
+
starting: boolean;
|
|
5
|
+
constructor(DeviceID: any, port: any, stick: any, protocol: any);
|
|
6
|
+
isBike(): boolean;
|
|
7
|
+
isHrm(): boolean;
|
|
8
|
+
isPower(): boolean;
|
|
9
|
+
getProfile(): string;
|
|
10
|
+
getName(): string;
|
|
11
|
+
getDisplayName(): string;
|
|
12
|
+
onDeviceData(deviceData: any): void;
|
|
13
|
+
updateData(data: any, deviceData: any): any;
|
|
14
|
+
start(props?: any): Promise<any>;
|
|
15
|
+
stop(): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
|
-
const AntAdapter_1 = __importDefault(require("../AntAdapter"));
|
|
17
|
-
const utils_1 = require("../utils");
|
|
18
|
-
const DEFAULT_START_TIMEOUT = 5000;
|
|
19
|
-
class AntHrmAdapter extends AntAdapter_1.default {
|
|
20
|
-
constructor(DeviceID, port, stick, protocol) {
|
|
21
|
-
super(protocol);
|
|
22
|
-
this.logger = new gd_eventlog_1.EventLogger('Ant+Hrm');
|
|
23
|
-
this.deviceID = DeviceID;
|
|
24
|
-
this.port = port;
|
|
25
|
-
this.stick = stick;
|
|
26
|
-
this.paused = false;
|
|
27
|
-
this.deviceData = {
|
|
28
|
-
DeviceID
|
|
29
|
-
};
|
|
30
|
-
this.data = {};
|
|
31
|
-
this.started = false;
|
|
32
|
-
this.starting = false;
|
|
33
|
-
}
|
|
34
|
-
isBike() { return false; }
|
|
35
|
-
isHrm() { return true; }
|
|
36
|
-
isPower() { return false; }
|
|
37
|
-
getProfile() {
|
|
38
|
-
return 'Heartrate Monitor';
|
|
39
|
-
}
|
|
40
|
-
getName() {
|
|
41
|
-
return `Ant+Hrm ${this.deviceID}`;
|
|
42
|
-
}
|
|
43
|
-
getDisplayName() {
|
|
44
|
-
const { DeviceID, manID, ComputedHeartRate } = this.deviceData;
|
|
45
|
-
const hrmStr = ComputedHeartRate ? ` (${ComputedHeartRate})` : '';
|
|
46
|
-
return `${(0, utils_1.getBrand)(manID)} Hrm ${DeviceID}${hrmStr}`;
|
|
47
|
-
}
|
|
48
|
-
onDeviceData(deviceData) {
|
|
49
|
-
if (!this.started)
|
|
50
|
-
return;
|
|
51
|
-
this.deviceData = deviceData;
|
|
52
|
-
try {
|
|
53
|
-
if (this.onDataFn && !this.ignoreHrm && !this.paused) {
|
|
54
|
-
if (this.lastUpdate === undefined || (Date.now() - this.lastUpdate) > this.updateFrequency) {
|
|
55
|
-
this.logger.logEvent({ message: 'onDeviceData', data: deviceData });
|
|
56
|
-
const data = this.updateData(this.data, deviceData);
|
|
57
|
-
this.onDataFn(data);
|
|
58
|
-
this.lastUpdate = Date.now();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
updateData(data, deviceData) {
|
|
66
|
-
data.heartrate = deviceData.ComputedHeartRate;
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
start(props) {
|
|
70
|
-
const _super = Object.create(null, {
|
|
71
|
-
start: { get: () => super.start }
|
|
72
|
-
});
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
yield _super.start.call(this, props);
|
|
75
|
-
this.logger.logEvent({ message: 'start()' });
|
|
76
|
-
const args = props || {};
|
|
77
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
if (this.ignoreHrm)
|
|
79
|
-
resolve(false);
|
|
80
|
-
if (this.starting) {
|
|
81
|
-
this.logger.logEvent({ message: 'start() not done: bike starting' });
|
|
82
|
-
return resolve(false);
|
|
83
|
-
}
|
|
84
|
-
if (this.started) {
|
|
85
|
-
this.logger.logEvent({ message: 'start() done: bike was already started' });
|
|
86
|
-
return resolve(true);
|
|
87
|
-
}
|
|
88
|
-
this.starting = true;
|
|
89
|
-
const Ant = this.getProtocol().getAnt();
|
|
90
|
-
const protocol = this.getProtocol();
|
|
91
|
-
let start = Date.now();
|
|
92
|
-
let timeout = start + (args.timeout || DEFAULT_START_TIMEOUT);
|
|
93
|
-
const iv = setInterval(() => {
|
|
94
|
-
if (Date.now() > timeout) {
|
|
95
|
-
clearInterval(iv);
|
|
96
|
-
this.starting = false;
|
|
97
|
-
reject(new Error('timeout'));
|
|
98
|
-
}
|
|
99
|
-
if (this.isStopped()) {
|
|
100
|
-
clearInterval(iv);
|
|
101
|
-
this.starting = false;
|
|
102
|
-
reject(new Error('stopped'));
|
|
103
|
-
}
|
|
104
|
-
}, 100);
|
|
105
|
-
protocol.attachSensors(this, Ant.HeartRateSensor, 'hbData')
|
|
106
|
-
.then(() => {
|
|
107
|
-
this.starting = false;
|
|
108
|
-
this.started = true;
|
|
109
|
-
clearInterval(iv);
|
|
110
|
-
resolve(true);
|
|
111
|
-
})
|
|
112
|
-
.catch(err => reject(err));
|
|
113
|
-
}));
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
stop() {
|
|
117
|
-
const _super = Object.create(null, {
|
|
118
|
-
stop: { get: () => super.stop }
|
|
119
|
-
});
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
yield _super.stop.call(this);
|
|
122
|
-
this.logger.logEvent({ message: 'stop()' });
|
|
123
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
this.starting = false;
|
|
125
|
-
return resolve(true);
|
|
126
|
-
}));
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.default = AntHrmAdapter;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
|
+
const AntAdapter_1 = __importDefault(require("../AntAdapter"));
|
|
17
|
+
const utils_1 = require("../utils");
|
|
18
|
+
const DEFAULT_START_TIMEOUT = 5000;
|
|
19
|
+
class AntHrmAdapter extends AntAdapter_1.default {
|
|
20
|
+
constructor(DeviceID, port, stick, protocol) {
|
|
21
|
+
super(protocol);
|
|
22
|
+
this.logger = new gd_eventlog_1.EventLogger('Ant+Hrm');
|
|
23
|
+
this.deviceID = DeviceID;
|
|
24
|
+
this.port = port;
|
|
25
|
+
this.stick = stick;
|
|
26
|
+
this.paused = false;
|
|
27
|
+
this.deviceData = {
|
|
28
|
+
DeviceID
|
|
29
|
+
};
|
|
30
|
+
this.data = {};
|
|
31
|
+
this.started = false;
|
|
32
|
+
this.starting = false;
|
|
33
|
+
}
|
|
34
|
+
isBike() { return false; }
|
|
35
|
+
isHrm() { return true; }
|
|
36
|
+
isPower() { return false; }
|
|
37
|
+
getProfile() {
|
|
38
|
+
return 'Heartrate Monitor';
|
|
39
|
+
}
|
|
40
|
+
getName() {
|
|
41
|
+
return `Ant+Hrm ${this.deviceID}`;
|
|
42
|
+
}
|
|
43
|
+
getDisplayName() {
|
|
44
|
+
const { DeviceID, manID, ComputedHeartRate } = this.deviceData;
|
|
45
|
+
const hrmStr = ComputedHeartRate ? ` (${ComputedHeartRate})` : '';
|
|
46
|
+
return `${(0, utils_1.getBrand)(manID)} Hrm ${DeviceID}${hrmStr}`;
|
|
47
|
+
}
|
|
48
|
+
onDeviceData(deviceData) {
|
|
49
|
+
if (!this.started)
|
|
50
|
+
return;
|
|
51
|
+
this.deviceData = deviceData;
|
|
52
|
+
try {
|
|
53
|
+
if (this.onDataFn && !this.ignoreHrm && !this.paused) {
|
|
54
|
+
if (this.lastUpdate === undefined || (Date.now() - this.lastUpdate) > this.updateFrequency) {
|
|
55
|
+
this.logger.logEvent({ message: 'onDeviceData', data: deviceData });
|
|
56
|
+
const data = this.updateData(this.data, deviceData);
|
|
57
|
+
this.onDataFn(data);
|
|
58
|
+
this.lastUpdate = Date.now();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
updateData(data, deviceData) {
|
|
66
|
+
data.heartrate = deviceData.ComputedHeartRate;
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
start(props) {
|
|
70
|
+
const _super = Object.create(null, {
|
|
71
|
+
start: { get: () => super.start }
|
|
72
|
+
});
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
yield _super.start.call(this, props);
|
|
75
|
+
this.logger.logEvent({ message: 'start()' });
|
|
76
|
+
const args = props || {};
|
|
77
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
if (this.ignoreHrm)
|
|
79
|
+
resolve(false);
|
|
80
|
+
if (this.starting) {
|
|
81
|
+
this.logger.logEvent({ message: 'start() not done: bike starting' });
|
|
82
|
+
return resolve(false);
|
|
83
|
+
}
|
|
84
|
+
if (this.started) {
|
|
85
|
+
this.logger.logEvent({ message: 'start() done: bike was already started' });
|
|
86
|
+
return resolve(true);
|
|
87
|
+
}
|
|
88
|
+
this.starting = true;
|
|
89
|
+
const Ant = this.getProtocol().getAnt();
|
|
90
|
+
const protocol = this.getProtocol();
|
|
91
|
+
let start = Date.now();
|
|
92
|
+
let timeout = start + (args.timeout || DEFAULT_START_TIMEOUT);
|
|
93
|
+
const iv = setInterval(() => {
|
|
94
|
+
if (Date.now() > timeout) {
|
|
95
|
+
clearInterval(iv);
|
|
96
|
+
this.starting = false;
|
|
97
|
+
reject(new Error('timeout'));
|
|
98
|
+
}
|
|
99
|
+
if (this.isStopped()) {
|
|
100
|
+
clearInterval(iv);
|
|
101
|
+
this.starting = false;
|
|
102
|
+
reject(new Error('stopped'));
|
|
103
|
+
}
|
|
104
|
+
}, 100);
|
|
105
|
+
protocol.attachSensors(this, Ant.HeartRateSensor, 'hbData')
|
|
106
|
+
.then(() => {
|
|
107
|
+
this.starting = false;
|
|
108
|
+
this.started = true;
|
|
109
|
+
clearInterval(iv);
|
|
110
|
+
resolve(true);
|
|
111
|
+
})
|
|
112
|
+
.catch(err => reject(err));
|
|
113
|
+
}));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
stop() {
|
|
117
|
+
const _super = Object.create(null, {
|
|
118
|
+
stop: { get: () => super.stop }
|
|
119
|
+
});
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
yield _super.stop.call(this);
|
|
122
|
+
this.logger.logEvent({ message: 'stop()' });
|
|
123
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
this.starting = false;
|
|
125
|
+
return resolve(true);
|
|
126
|
+
}));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.default = AntHrmAdapter;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import AntAdapter from '../AntAdapter';
|
|
2
|
-
import { IncyclistBikeData } from '../../
|
|
3
|
-
import CyclingMode from '../../
|
|
4
|
-
import { DeviceData } from '../../
|
|
5
|
-
export declare type AntPwrData = {
|
|
6
|
-
DeviceID: number;
|
|
7
|
-
PedalPower?: number;
|
|
8
|
-
RightPedalPower?: number;
|
|
9
|
-
LeftPedalPower?: number;
|
|
10
|
-
Cadence?: number;
|
|
11
|
-
AccumulatedPower?: number;
|
|
12
|
-
Power?: number;
|
|
13
|
-
offset?: number;
|
|
14
|
-
EventCount?: number;
|
|
15
|
-
TimeStamp?: number;
|
|
16
|
-
Slope?: number;
|
|
17
|
-
TorqueTicksStamp?: number;
|
|
18
|
-
CalculatedCadence?: number;
|
|
19
|
-
CalculatedTorque?: number;
|
|
20
|
-
CalculatedPower?: number;
|
|
21
|
-
};
|
|
22
|
-
export default class AntFEAdapter extends AntAdapter {
|
|
23
|
-
started: boolean;
|
|
24
|
-
starting: boolean;
|
|
25
|
-
connected: boolean;
|
|
26
|
-
distanceInternal?: number;
|
|
27
|
-
workerId?: any;
|
|
28
|
-
currentCmd?: any;
|
|
29
|
-
mode: CyclingMode;
|
|
30
|
-
constructor(DeviceID: any, port: any, stick: any, protocol: any);
|
|
31
|
-
isBike(): boolean;
|
|
32
|
-
isHrm(): boolean;
|
|
33
|
-
isPower(): boolean;
|
|
34
|
-
getProfile(): string;
|
|
35
|
-
getName(): string;
|
|
36
|
-
getDisplayName(): string;
|
|
37
|
-
getCyclingMode(): CyclingMode;
|
|
38
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
39
|
-
getSupportedCyclingModes(): any[];
|
|
40
|
-
onAttached(): void;
|
|
41
|
-
getLogData(data: any, excludeList: any): any;
|
|
42
|
-
onDeviceData(deviceData: AntPwrData): void;
|
|
43
|
-
onDeviceEvent(data: any): void;
|
|
44
|
-
sendUpdate(request: any): void;
|
|
45
|
-
mapData(deviceData: AntPwrData): IncyclistBikeData;
|
|
46
|
-
transformData(bikeData: IncyclistBikeData): DeviceData;
|
|
47
|
-
start(props?: any): Promise<any>;
|
|
48
|
-
stop(): Promise<boolean>;
|
|
49
|
-
}
|
|
1
|
+
import AntAdapter from '../AntAdapter';
|
|
2
|
+
import { IncyclistBikeData } from '../../cycling-mode';
|
|
3
|
+
import CyclingMode from '../../cycling-mode';
|
|
4
|
+
import { DeviceData } from '../../device';
|
|
5
|
+
export declare type AntPwrData = {
|
|
6
|
+
DeviceID: number;
|
|
7
|
+
PedalPower?: number;
|
|
8
|
+
RightPedalPower?: number;
|
|
9
|
+
LeftPedalPower?: number;
|
|
10
|
+
Cadence?: number;
|
|
11
|
+
AccumulatedPower?: number;
|
|
12
|
+
Power?: number;
|
|
13
|
+
offset?: number;
|
|
14
|
+
EventCount?: number;
|
|
15
|
+
TimeStamp?: number;
|
|
16
|
+
Slope?: number;
|
|
17
|
+
TorqueTicksStamp?: number;
|
|
18
|
+
CalculatedCadence?: number;
|
|
19
|
+
CalculatedTorque?: number;
|
|
20
|
+
CalculatedPower?: number;
|
|
21
|
+
};
|
|
22
|
+
export default class AntFEAdapter extends AntAdapter {
|
|
23
|
+
started: boolean;
|
|
24
|
+
starting: boolean;
|
|
25
|
+
connected: boolean;
|
|
26
|
+
distanceInternal?: number;
|
|
27
|
+
workerId?: any;
|
|
28
|
+
currentCmd?: any;
|
|
29
|
+
mode: CyclingMode;
|
|
30
|
+
constructor(DeviceID: any, port: any, stick: any, protocol: any);
|
|
31
|
+
isBike(): boolean;
|
|
32
|
+
isHrm(): boolean;
|
|
33
|
+
isPower(): boolean;
|
|
34
|
+
getProfile(): string;
|
|
35
|
+
getName(): string;
|
|
36
|
+
getDisplayName(): string;
|
|
37
|
+
getCyclingMode(): CyclingMode;
|
|
38
|
+
getDefaultCyclingMode(): CyclingMode;
|
|
39
|
+
getSupportedCyclingModes(): any[];
|
|
40
|
+
onAttached(): void;
|
|
41
|
+
getLogData(data: any, excludeList: any): any;
|
|
42
|
+
onDeviceData(deviceData: AntPwrData): void;
|
|
43
|
+
onDeviceEvent(data: any): void;
|
|
44
|
+
sendUpdate(request: any): void;
|
|
45
|
+
mapData(deviceData: AntPwrData): IncyclistBikeData;
|
|
46
|
+
transformData(bikeData: IncyclistBikeData): DeviceData;
|
|
47
|
+
start(props?: any): Promise<any>;
|
|
48
|
+
stop(): Promise<boolean>;
|
|
49
|
+
}
|