incyclist-devices 2.0.38 → 2.1.1
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/adapters.d.ts +1 -1
- package/lib/antv2/adapter-factory.d.ts +4 -13
- package/lib/antv2/adapter.d.ts +16 -33
- package/lib/antv2/adapter.js +68 -112
- package/lib/antv2/ant-interface.d.ts +3 -11
- package/lib/antv2/ant-interface.js +1 -1
- package/lib/antv2/base/adapter.d.ts +62 -0
- package/lib/antv2/base/adapter.js +360 -0
- package/lib/antv2/base/ant-interface.d.ts +35 -0
- package/lib/antv2/base/ant-interface.js +285 -0
- package/lib/antv2/base/binding.d.ts +13 -0
- package/lib/antv2/base/binding.js +27 -0
- package/lib/antv2/cad/adapter.d.ts +10 -0
- package/lib/antv2/cad/adapter.js +25 -0
- package/lib/antv2/cad/index.d.ts +2 -0
- package/lib/antv2/cad/index.js +7 -0
- package/lib/antv2/consts.d.ts +2 -0
- package/lib/antv2/consts.js +5 -0
- package/lib/antv2/factories/adapter-factory.d.ts +14 -0
- package/lib/antv2/factories/adapter-factory.js +65 -0
- package/lib/antv2/factories/sensor-factory.d.ts +5 -0
- package/lib/antv2/factories/sensor-factory.js +22 -0
- package/lib/antv2/fe/adapter.d.ts +25 -26
- package/lib/antv2/fe/adapter.js +212 -218
- package/lib/antv2/hr/adapter.d.ts +6 -14
- package/lib/antv2/hr/adapter.js +7 -55
- package/lib/antv2/hr copy/adapter.d.ts +11 -0
- package/lib/antv2/hr copy/adapter.js +30 -0
- package/lib/antv2/hr copy/index.d.ts +2 -0
- package/lib/antv2/hr copy/index.js +7 -0
- package/lib/antv2/index.d.ts +5 -4
- package/lib/antv2/index.js +4 -2
- package/lib/antv2/pwr/adapter.d.ts +9 -29
- package/lib/antv2/pwr/adapter.js +20 -130
- package/lib/antv2/types.d.ts +23 -3
- package/lib/base/adpater.d.ts +42 -45
- package/lib/base/adpater.js +144 -110
- package/lib/base/consts.d.ts +4 -0
- package/lib/base/consts.js +9 -0
- package/lib/ble/adapter-factory.d.ts +4 -4
- package/lib/ble/base/adapter.d.ts +6 -24
- package/lib/ble/base/adapter.js +4 -94
- package/lib/ble/ble-interface.d.ts +2 -3
- package/lib/ble/cp/adapter.d.ts +6 -11
- package/lib/ble/cp/adapter.js +9 -12
- package/lib/ble/elite/adapter.d.ts +8 -8
- package/lib/ble/elite/adapter.js +6 -2
- package/lib/ble/fm/adapter.d.ts +11 -11
- package/lib/ble/fm/adapter.js +26 -20
- package/lib/ble/hr/adapter.d.ts +3 -4
- package/lib/ble/hr/adapter.js +2 -2
- package/lib/ble/tacx/adapter.d.ts +2 -3
- package/lib/ble/tacx/adapter.js +8 -8
- package/lib/ble/types.d.ts +1 -2
- package/lib/ble/wahoo/adapter.d.ts +2 -2
- package/lib/ble/wahoo/adapter.js +6 -6
- package/lib/ble/wahoo/comms.js +16 -16
- package/lib/factories/adapters.d.ts +7 -0
- package/lib/factories/adapters.js +49 -0
- package/lib/factories/index.d.ts +3 -0
- package/lib/factories/index.js +10 -0
- package/lib/factories/interfaces.d.ts +7 -0
- package/lib/factories/interfaces.js +27 -0
- package/lib/index.d.ts +8 -9
- package/lib/index.js +5 -8
- 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 +17 -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 +24 -0
- package/lib/{serial/daum/premium/modes/daum-classic.js → modes/daum-premium-standard.js} +26 -38
- package/lib/modes/daum-smarttrainer.d.ts +83 -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 +184 -7
- package/lib/modes/power-meter.d.ts +11 -16
- package/lib/modes/power-meter.js +15 -54
- package/lib/modes/simulator.d.ts +38 -10
- package/lib/modes/simulator.js +14 -46
- package/lib/modes/{cycling-mode.d.ts → types.d.ts} +22 -30
- package/lib/modes/types.js +56 -0
- package/lib/serial/SinglePathScanner.d.ts +17 -0
- package/lib/serial/SinglePathScanner.js +87 -0
- package/lib/serial/adapter-factory.d.ts +8 -6
- package/lib/serial/adapter.d.ts +6 -11
- package/lib/serial/adapter.js +5 -2
- package/lib/serial/base/adapter.d.ts +17 -0
- package/lib/serial/base/adapter.js +67 -0
- package/lib/serial/base/comms.d.ts +62 -0
- package/lib/serial/base/comms.js +280 -0
- package/lib/serial/base/serial-interface.d.ts +36 -0
- package/lib/serial/base/serial-interface.js +288 -0
- package/lib/serial/base/serial-scanner.d.ts +16 -0
- package/lib/serial/base/serial-scanner.js +87 -0
- package/lib/serial/base/serialport.d.ts +17 -0
- package/lib/serial/base/serialport.js +87 -0
- package/lib/serial/comms.d.ts +2 -2
- package/lib/serial/daum/DaumAdapter.d.ts +26 -35
- package/lib/serial/daum/DaumAdapter.js +214 -161
- package/lib/serial/daum/classic/PROTOCOL_NAME.d.ts +2 -0
- package/lib/serial/daum/classic/PROTOCOL_NAME.js +5 -0
- package/lib/serial/daum/classic/adapter.d.ts +13 -26
- package/lib/serial/daum/classic/adapter.js +72 -176
- package/lib/serial/daum/classic/comms.d.ts +21 -17
- package/lib/serial/daum/classic/comms.js +41 -14
- package/lib/serial/daum/classic/consts.d.ts +2 -0
- package/lib/serial/daum/classic/consts.js +5 -0
- package/lib/serial/daum/classic/mock.d.ts +4 -0
- package/lib/serial/daum/classic/mock.js +18 -7
- package/lib/serial/daum/classic/types.d.ts +8 -10
- package/lib/serial/daum/classic/utils.d.ts +1 -2
- package/lib/serial/daum/consts.d.ts +0 -0
- package/lib/serial/daum/consts.js +0 -0
- package/lib/serial/daum/premium/adapter.d.ts +17 -15
- package/lib/serial/daum/premium/adapter.js +86 -109
- package/lib/serial/daum/premium/comms.d.ts +7 -7
- package/lib/serial/daum/premium/comms.js +25 -16
- package/lib/serial/daum/premium/mock.d.ts +5 -1
- package/lib/serial/daum/premium/mock.js +17 -7
- package/lib/serial/daum/premium/types.d.ts +32 -17
- package/lib/serial/daum/premium/types.js +8 -8
- package/lib/serial/daum/premium/utils.d.ts +2 -3
- package/lib/serial/daum/premium/utils.js +3 -3
- package/lib/serial/daum/types.d.ts +14 -0
- package/lib/serial/daum/types.js +13 -0
- package/lib/serial/factories/adapter-factory.d.ts +14 -0
- package/lib/serial/factories/adapter-factory.js +30 -0
- package/lib/serial/index.d.ts +8 -5
- package/lib/serial/index.js +15 -15
- package/lib/serial/kettler/comms.d.ts +1 -1
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +11 -16
- package/lib/serial/kettler/ergo-racer/adapter.js +10 -12
- package/lib/serial/kettler/types.d.ts +8 -0
- package/lib/serial/kettler/types.js +2 -0
- package/lib/serial/serial-interface.d.ts +2 -32
- package/lib/serial/serial-interface.js +4 -78
- package/lib/serial/serial-scanner.d.ts +16 -0
- package/lib/serial/serial-scanner.js +87 -0
- package/lib/serial/serialport.d.ts +1 -13
- package/lib/serial/types.d.ts +45 -0
- package/lib/serial/types.js +9 -0
- package/lib/simulator/Simulator.d.ts +13 -19
- package/lib/simulator/Simulator.js +10 -51
- package/lib/types/Command.d.ts +8 -0
- package/lib/types/Command.js +2 -0
- package/lib/types/adapter.d.ts +34 -24
- package/lib/types/command.d.ts +0 -8
- package/lib/types/command.js +0 -2
- package/lib/types/data.d.ts +12 -1
- package/lib/types/device.d.ts +8 -23
- package/lib/types/device.js +9 -8
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +22 -0
- package/lib/types/route.d.ts +0 -19
- package/lib/types/route.js +0 -2
- package/lib/types/types.d.ts +8 -0
- package/lib/types/types.js +2 -0
- package/lib/utils/utils.d.ts +2 -1
- package/lib/utils/utils.js +22 -4
- 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/constants.d.ts +0 -19
- package/lib/serial/daum/constants.js +0 -22
- package/lib/serial/daum/premium/modes/daum-classic.d.ts +0 -14
- package/lib/serial/kettler/ergo-racer/modes/erg.d.ts +0 -25
|
@@ -12,26 +12,21 @@ 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
|
-
|
|
16
|
-
const ERGCyclingMode_1 = __importDefault(require("./ERGCyclingMode"));
|
|
17
|
-
const SmartTrainerCyclingMode_1 = __importDefault(require("./SmartTrainerCyclingMode"));
|
|
18
|
-
const DaumPowerMeterCyclingMode_1 = __importDefault(require("./DaumPowerMeterCyclingMode"));
|
|
15
|
+
const daum_erg_1 = __importDefault(require("../../modes/daum-erg"));
|
|
19
16
|
const utils_1 = require("../../utils/utils");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class DaumAdapter extends AbstractDaumAdapter {
|
|
17
|
+
const types_1 = require("../../types");
|
|
18
|
+
const adapter_1 = require("../base/adapter");
|
|
19
|
+
const daum_smarttrainer_1 = __importDefault(require("../../modes/daum-smarttrainer"));
|
|
20
|
+
const daum_power_1 = __importDefault(require("../../modes/daum-power"));
|
|
21
|
+
class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
26
22
|
constructor(settings, props) {
|
|
27
23
|
super(settings, props);
|
|
28
24
|
this.requests = [];
|
|
29
25
|
this.adapterTime = 0;
|
|
30
26
|
this.requestBusy = false;
|
|
31
27
|
this.updateBusy = false;
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.cyclingData = {
|
|
28
|
+
this.iv = undefined;
|
|
29
|
+
this.deviceData = {
|
|
35
30
|
isPedalling: false,
|
|
36
31
|
time: 0,
|
|
37
32
|
power: 0,
|
|
@@ -40,37 +35,25 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
40
35
|
distanceInternal: 0,
|
|
41
36
|
heartrate: 0
|
|
42
37
|
};
|
|
43
|
-
this.deviceData = {};
|
|
44
38
|
this.capabilities = [
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
types_1.IncyclistCapability.Power, types_1.IncyclistCapability.Speed, types_1.IncyclistCapability.Cadence, types_1.IncyclistCapability.Gear, types_1.IncyclistCapability.HeartRate,
|
|
40
|
+
types_1.IncyclistCapability.Control
|
|
47
41
|
];
|
|
48
42
|
}
|
|
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);
|
|
43
|
+
getPort() {
|
|
44
|
+
var _a;
|
|
45
|
+
return (_a = this.comms) === null || _a === void 0 ? void 0 : _a.getPort();
|
|
46
|
+
}
|
|
47
|
+
getSerialInterface() {
|
|
48
|
+
var _a;
|
|
49
|
+
return (_a = this.comms) === null || _a === void 0 ? void 0 : _a.serial;
|
|
67
50
|
}
|
|
68
51
|
sendInitCommands() {
|
|
69
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
53
|
if (this.started && !this.stopped) {
|
|
71
54
|
try {
|
|
72
|
-
if (this.getCyclingMode() instanceof
|
|
73
|
-
const power = this.
|
|
55
|
+
if (this.getCyclingMode() instanceof daum_erg_1.default) {
|
|
56
|
+
const power = this.data.power;
|
|
74
57
|
const request = power ? { targetPower: power } : this.getCyclingMode().getBikeInitRequest();
|
|
75
58
|
yield this.sendUpdate(request);
|
|
76
59
|
return true;
|
|
@@ -80,27 +63,14 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
80
63
|
return false;
|
|
81
64
|
}
|
|
82
65
|
}
|
|
83
|
-
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
66
|
+
return false;
|
|
86
67
|
});
|
|
87
68
|
}
|
|
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
69
|
getCurrentBikeData() {
|
|
100
70
|
throw new Error('Method not implemented.');
|
|
101
71
|
}
|
|
102
|
-
|
|
103
|
-
return this.
|
|
72
|
+
getComms() {
|
|
73
|
+
return this.comms;
|
|
104
74
|
}
|
|
105
75
|
isEqual(settings) {
|
|
106
76
|
const as = this.settings;
|
|
@@ -123,7 +93,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
123
93
|
this.distanceInternal = undefined;
|
|
124
94
|
this.paused = false;
|
|
125
95
|
this.stopped = false;
|
|
126
|
-
this.
|
|
96
|
+
this.deviceData = {
|
|
127
97
|
isPedalling: false,
|
|
128
98
|
time: 0,
|
|
129
99
|
power: 0,
|
|
@@ -132,8 +102,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
132
102
|
distanceInternal: 0,
|
|
133
103
|
heartrate: 0
|
|
134
104
|
};
|
|
135
|
-
this.
|
|
136
|
-
this.currentRequest = {};
|
|
105
|
+
this.data = {};
|
|
137
106
|
this.requests = [];
|
|
138
107
|
const name = this.getCyclingMode().getName();
|
|
139
108
|
const settings = this.getCyclingMode().getSettings();
|
|
@@ -145,7 +114,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
145
114
|
});
|
|
146
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
116
|
const paused = yield _super.pause.call(this);
|
|
148
|
-
this.
|
|
117
|
+
this.comms.pauseLogging();
|
|
149
118
|
return paused;
|
|
150
119
|
});
|
|
151
120
|
}
|
|
@@ -155,75 +124,170 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
155
124
|
});
|
|
156
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
126
|
const resumed = yield _super.resume.call(this);
|
|
158
|
-
this.
|
|
127
|
+
this.comms.resumeLogging();
|
|
159
128
|
return resumed;
|
|
160
129
|
});
|
|
161
130
|
}
|
|
131
|
+
waitForPrevCheckFinished() {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
if (this.checkPromise) {
|
|
134
|
+
this.logEvent({ message: "waiting for previous check device", port: this.getPort() });
|
|
135
|
+
try {
|
|
136
|
+
yield this.checkPromise;
|
|
137
|
+
}
|
|
138
|
+
catch (_a) { }
|
|
139
|
+
this.logEvent({ message: "previous check device completed", port: this.getPort() });
|
|
140
|
+
this.checkPromise = undefined;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
check() {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
yield this.waitForPrevCheckFinished();
|
|
147
|
+
yield this.waitForPrevStartFinished();
|
|
148
|
+
if (this.isStopped())
|
|
149
|
+
return false;
|
|
150
|
+
this.checkPromise = this.performCheck();
|
|
151
|
+
try {
|
|
152
|
+
const res = yield this.checkPromise;
|
|
153
|
+
this.checkPromise = undefined;
|
|
154
|
+
return res;
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
this.checkPromise = undefined;
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
performCheck() {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
throw new Error('Method not implemented.');
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
waitForPrevStartFinished() {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
if (this.startPromise) {
|
|
170
|
+
this.logEvent({ message: "waiting for previous device launch", port: this.getPort() });
|
|
171
|
+
try {
|
|
172
|
+
yield this.startPromise;
|
|
173
|
+
}
|
|
174
|
+
catch (_a) { }
|
|
175
|
+
this.logEvent({ message: "previous device launch attempt completed", port: this.getPort() });
|
|
176
|
+
this.startPromise = undefined;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
162
180
|
start(props) {
|
|
163
|
-
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
yield this.waitForPrevCheckFinished();
|
|
183
|
+
yield this.waitForPrevStartFinished();
|
|
184
|
+
const isRelaunch = this.started;
|
|
185
|
+
const message = isRelaunch ? 'relaunch of device' : 'initial start of device';
|
|
186
|
+
this.logEvent({ message });
|
|
187
|
+
try {
|
|
188
|
+
if (isRelaunch && this.isPaused())
|
|
189
|
+
this.resume();
|
|
190
|
+
this.startPromise = this.performStart(props, isRelaunch).then((started) => __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
if (!started) {
|
|
192
|
+
this.logEvent({ message: 'start result: not started' });
|
|
193
|
+
this.started = false;
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (!isRelaunch) {
|
|
197
|
+
try {
|
|
198
|
+
const deviceInfo = yield this.getDeviceInfo();
|
|
199
|
+
this.logEvent({ message: 'device info', deviceInfo });
|
|
200
|
+
}
|
|
201
|
+
catch (_a) { }
|
|
202
|
+
}
|
|
203
|
+
this.logEvent({ message: 'start result: success' });
|
|
204
|
+
this.started = true;
|
|
205
|
+
return true;
|
|
206
|
+
}));
|
|
207
|
+
const started = yield this.startPromise;
|
|
208
|
+
this.startPromise = undefined;
|
|
209
|
+
return started;
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
this.logEvent({ message: 'start result: error', error: err.message });
|
|
213
|
+
this.startPromise = undefined;
|
|
214
|
+
this.started = false;
|
|
215
|
+
throw new Error(`could not start device, reason:${err.message}`);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
164
218
|
}
|
|
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;
|
|
219
|
+
performStart(props, isRelaunch = false) {
|
|
220
|
+
throw new Error('Method not implemented.');
|
|
173
221
|
}
|
|
174
222
|
startUpdatePull() {
|
|
175
|
-
this.logEvent({ message: 'start update pull', iv: this.iv, ignoreBike: this.ignoreBike, ignoreHrm: this.ignoreHrm, ignorePower: this.ignorePower });
|
|
176
223
|
if (this.iv)
|
|
177
224
|
return;
|
|
178
|
-
|
|
179
|
-
return;
|
|
225
|
+
this.logEvent({ message: 'start update pull', port: this.getPort() });
|
|
180
226
|
const ivSync = setInterval(() => {
|
|
181
|
-
|
|
227
|
+
try {
|
|
228
|
+
this.bikeSync();
|
|
229
|
+
}
|
|
230
|
+
catch (_a) { }
|
|
182
231
|
}, this.pullFrequency);
|
|
183
232
|
const ivUpdate = setInterval(() => {
|
|
184
|
-
|
|
185
|
-
|
|
233
|
+
try {
|
|
234
|
+
this.emitData(this.data);
|
|
235
|
+
this.refreshRequests();
|
|
236
|
+
}
|
|
237
|
+
catch (_a) { }
|
|
186
238
|
}, this.pullFrequency);
|
|
187
239
|
this.iv = {
|
|
188
240
|
sync: ivSync,
|
|
189
241
|
update: ivUpdate
|
|
190
242
|
};
|
|
191
243
|
}
|
|
244
|
+
stopUpdatePull() {
|
|
245
|
+
if (!this.iv)
|
|
246
|
+
return;
|
|
247
|
+
this.logEvent({ message: 'stop update pull', port: this.getPort() });
|
|
248
|
+
clearInterval(this.iv.sync);
|
|
249
|
+
clearInterval(this.iv.update);
|
|
250
|
+
this.iv = undefined;
|
|
251
|
+
}
|
|
192
252
|
connect() {
|
|
193
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
-
if (this.
|
|
254
|
+
if (!this.comms)
|
|
255
|
+
return false;
|
|
256
|
+
if (this.comms.isConnected())
|
|
195
257
|
return true;
|
|
196
258
|
try {
|
|
197
|
-
const connected = yield this.
|
|
259
|
+
const connected = yield this.comms.connect();
|
|
198
260
|
return connected;
|
|
199
261
|
}
|
|
200
262
|
catch (err) {
|
|
201
|
-
yield this.
|
|
263
|
+
yield this.comms.close();
|
|
202
264
|
return false;
|
|
203
265
|
}
|
|
204
266
|
});
|
|
205
267
|
}
|
|
206
268
|
close() {
|
|
207
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
-
if (!this.
|
|
270
|
+
if (!this.comms)
|
|
271
|
+
return true;
|
|
272
|
+
if (!this.comms.isConnected())
|
|
209
273
|
return true;
|
|
210
|
-
return yield this.
|
|
274
|
+
return yield this.comms.close();
|
|
211
275
|
});
|
|
212
276
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
277
|
+
verifyConnection() {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
if (!this.comms.isConnected()) {
|
|
280
|
+
const connected = yield this.comms.connect();
|
|
281
|
+
if (!connected)
|
|
282
|
+
throw new Error('not connected');
|
|
283
|
+
}
|
|
284
|
+
});
|
|
221
285
|
}
|
|
222
286
|
reconnect() {
|
|
223
287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
288
|
try {
|
|
225
|
-
yield this.
|
|
226
|
-
const connected = yield this.
|
|
289
|
+
yield this.comms.close();
|
|
290
|
+
const connected = yield this.comms.connect();
|
|
227
291
|
return connected;
|
|
228
292
|
}
|
|
229
293
|
catch (err) {
|
|
@@ -231,38 +295,34 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
231
295
|
}
|
|
232
296
|
});
|
|
233
297
|
}
|
|
298
|
+
logEvent(event) {
|
|
299
|
+
if (!this.logger || this.paused)
|
|
300
|
+
return;
|
|
301
|
+
this.logger.logEvent(event);
|
|
302
|
+
const w = global.window;
|
|
303
|
+
if (w === null || w === void 0 ? void 0 : w.DEVICE_DEBUG) {
|
|
304
|
+
console.log(`~~~ ${this.logger.getName()}`, event);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
234
307
|
stop() {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
this.
|
|
240
|
-
|
|
241
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
if (this.stopped)
|
|
310
|
+
return true;
|
|
311
|
+
this.logEvent({ message: 'stop request' });
|
|
312
|
+
if (this.paused)
|
|
313
|
+
this.resume();
|
|
242
314
|
try {
|
|
243
|
-
|
|
244
|
-
|
|
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();
|
|
252
|
-
yield this.bike.close();
|
|
315
|
+
this.stopUpdatePull();
|
|
316
|
+
yield this.comms.close();
|
|
253
317
|
this.logEvent({ message: 'stop request completed' });
|
|
254
|
-
|
|
318
|
+
this.stopped = true;
|
|
255
319
|
}
|
|
256
320
|
catch (err) {
|
|
257
|
-
this.logEvent({ message: 'stop
|
|
258
|
-
|
|
321
|
+
this.logEvent({ message: 'stop request failed', reason: err.message });
|
|
322
|
+
throw (err);
|
|
259
323
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
canSendUpdate() {
|
|
263
|
-
if (this.paused || this.stopped)
|
|
264
|
-
return false;
|
|
265
|
-
return super.canSendUpdate();
|
|
324
|
+
return this.stopped;
|
|
325
|
+
});
|
|
266
326
|
}
|
|
267
327
|
sendUpdate(request) {
|
|
268
328
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -274,39 +334,44 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
274
334
|
}
|
|
275
335
|
update() {
|
|
276
336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
-
if (this.
|
|
337
|
+
if (!this.canEmitData() || this.updateBusy)
|
|
278
338
|
return;
|
|
279
339
|
this.updateBusy = true;
|
|
280
|
-
|
|
281
|
-
|
|
340
|
+
try {
|
|
341
|
+
const bikeData = yield this.getCurrentBikeData();
|
|
282
342
|
const incyclistData = this.updateData(bikeData);
|
|
283
343
|
const data = this.transformData(incyclistData);
|
|
284
344
|
this.updateBusy = false;
|
|
285
345
|
this.emitData(data);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
346
|
+
}
|
|
347
|
+
catch (err) {
|
|
348
|
+
try {
|
|
349
|
+
this.logEvent({ message: 'bike update error', error: err.message, stack: err.stack });
|
|
350
|
+
const incyclistData = this.updateData(this.deviceData);
|
|
351
|
+
this.transformData(incyclistData);
|
|
352
|
+
}
|
|
353
|
+
catch (_a) { }
|
|
291
354
|
this.updateBusy = false;
|
|
292
|
-
}
|
|
355
|
+
}
|
|
293
356
|
});
|
|
294
357
|
}
|
|
295
358
|
sendRequests() {
|
|
296
359
|
return __awaiter(this, void 0, void 0, function* () {
|
|
297
360
|
if (this.stopped || this.paused)
|
|
298
361
|
return;
|
|
362
|
+
if (this.requestBusy)
|
|
363
|
+
return;
|
|
299
364
|
if (this.requests.length > 0) {
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
365
|
+
const cnt = this.requests.length;
|
|
366
|
+
if (cnt > 1) {
|
|
367
|
+
this.requests.forEach((request, idx) => {
|
|
368
|
+
if (idx !== cnt - 1) {
|
|
369
|
+
this.logEvent({ message: 'ignoring bike update request', request });
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
this.requests = [this.requests[cnt - 1]];
|
|
373
|
+
}
|
|
374
|
+
let request = this.requests[0];
|
|
310
375
|
try {
|
|
311
376
|
yield this.sendRequest(request);
|
|
312
377
|
this.requests.shift();
|
|
@@ -319,16 +384,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
319
384
|
}
|
|
320
385
|
bikeSync() {
|
|
321
386
|
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
|
-
}
|
|
387
|
+
yield this.sendRequests();
|
|
332
388
|
yield this.update();
|
|
333
389
|
});
|
|
334
390
|
}
|
|
@@ -346,8 +402,8 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
346
402
|
data.time = bikeData.time;
|
|
347
403
|
if (bikeData.slope)
|
|
348
404
|
data.slope = bikeData.slope;
|
|
349
|
-
this.
|
|
350
|
-
return this.
|
|
405
|
+
this.deviceData = this.getCyclingMode().updateData(data);
|
|
406
|
+
return this.deviceData;
|
|
351
407
|
}
|
|
352
408
|
transformData(cyclingData) {
|
|
353
409
|
let distance = 0;
|
|
@@ -367,16 +423,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
367
423
|
deviceTime: cyclingData.time,
|
|
368
424
|
deviceDistanceCounter: cyclingData.distanceInternal
|
|
369
425
|
};
|
|
370
|
-
|
|
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
|
-
this.deviceData = data;
|
|
426
|
+
this.data = data;
|
|
380
427
|
return data;
|
|
381
428
|
}
|
|
382
429
|
sendRequest(request) {
|
|
@@ -384,17 +431,17 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
384
431
|
this.requestBusy = true;
|
|
385
432
|
try {
|
|
386
433
|
this.logEvent({ message: 'sendRequest', request });
|
|
387
|
-
const bike = this.
|
|
434
|
+
const bike = this.getComms();
|
|
388
435
|
const isReset = (!request || request.reset || Object.keys(request).length === 0);
|
|
389
436
|
if (isReset) {
|
|
390
437
|
this.requestBusy = false;
|
|
391
438
|
return {};
|
|
392
439
|
}
|
|
393
440
|
if (request.slope !== undefined) {
|
|
394
|
-
yield bike.
|
|
441
|
+
yield bike.setTargetSlope(request.slope);
|
|
395
442
|
}
|
|
396
443
|
if (request.targetPower !== undefined) {
|
|
397
|
-
yield bike.
|
|
444
|
+
yield bike.setTargetPower(request.targetPower);
|
|
398
445
|
}
|
|
399
446
|
this.requestBusy = false;
|
|
400
447
|
return request;
|
|
@@ -409,7 +456,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
409
456
|
refreshRequests() {
|
|
410
457
|
if (this.isPaused() || this.isStopped())
|
|
411
458
|
return;
|
|
412
|
-
if (!this.
|
|
459
|
+
if (!this.deviceData.isPedalling || this.deviceData.pedalRpm === 0)
|
|
413
460
|
return;
|
|
414
461
|
let bikeRequest = this.getCyclingMode().sendBikeUpdate({ refresh: true }) || {};
|
|
415
462
|
const prev = this.requests[this.requests.length - 1] || {};
|
|
@@ -420,7 +467,7 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
420
467
|
}
|
|
421
468
|
processClientRequest(request) {
|
|
422
469
|
if (request.slope !== undefined) {
|
|
423
|
-
this.
|
|
470
|
+
this.deviceData.slope = request.slope;
|
|
424
471
|
}
|
|
425
472
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
426
473
|
let bikeRequest = this.getCyclingMode().sendBikeUpdate(request);
|
|
@@ -429,8 +476,14 @@ class DaumAdapter extends AbstractDaumAdapter {
|
|
|
429
476
|
resolve(bikeRequest);
|
|
430
477
|
}));
|
|
431
478
|
}
|
|
432
|
-
|
|
433
|
-
|
|
479
|
+
getDeviceInfo() {
|
|
480
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
481
|
+
throw new Error('Method not implemented.');
|
|
482
|
+
});
|
|
434
483
|
}
|
|
435
484
|
}
|
|
485
|
+
DaumAdapter.controllers = {
|
|
486
|
+
modes: [daum_erg_1.default, daum_smarttrainer_1.default, daum_power_1.default],
|
|
487
|
+
default: daum_erg_1.default
|
|
488
|
+
};
|
|
436
489
|
exports.default = DaumAdapter;
|
|
@@ -1,33 +1,20 @@
|
|
|
1
|
-
import CyclingMode, { IncyclistBikeData } from '../../../modes/cycling-mode';
|
|
2
1
|
import DaumAdapter from '../DaumAdapter';
|
|
3
|
-
import {
|
|
4
|
-
import { SerialDeviceSettings } from
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export default class DaumClassicAdapter extends DaumAdapter<SerialDeviceSettings, DaumClassicDeviceProperties> {
|
|
2
|
+
import { DaumClassicProperties } from './types';
|
|
3
|
+
import { SerialDeviceSettings, SerialCommProps } from "../../types";
|
|
4
|
+
import { IncyclistBikeData, ControllerConfig } from "../../../types";
|
|
5
|
+
import Daum8008 from './comms';
|
|
6
|
+
export default class DaumClassicAdapter extends DaumAdapter<SerialDeviceSettings, DaumClassicProperties, Daum8008> {
|
|
10
7
|
static NAME: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor(settings: SerialDeviceSettings, props?: DaumClassicDeviceProperties);
|
|
17
|
-
setID(id: any): void;
|
|
18
|
-
getID(): string;
|
|
8
|
+
protected static controllers: ControllerConfig;
|
|
9
|
+
protected name: string;
|
|
10
|
+
protected id: string;
|
|
11
|
+
constructor(settings: SerialDeviceSettings, props?: DaumClassicProperties);
|
|
12
|
+
getBikeProps(props: SerialDeviceSettings): SerialCommProps;
|
|
19
13
|
getName(): string;
|
|
20
|
-
setName(name:
|
|
21
|
-
getPort(): any;
|
|
14
|
+
setName(name: string): void;
|
|
22
15
|
getProtocolName(): string;
|
|
23
|
-
getSupportedCyclingModes(): Array<any>;
|
|
24
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
25
|
-
getSerialInterface(): SerialInterface;
|
|
26
|
-
check(): Promise<boolean>;
|
|
27
16
|
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>;
|
|
17
|
+
performStart(props?: DaumClassicProperties, isRelaunch?: boolean): Promise<boolean>;
|
|
32
18
|
getCurrentBikeData(): Promise<IncyclistBikeData>;
|
|
19
|
+
getDeviceInfo(): Promise<any>;
|
|
33
20
|
}
|