incyclist-devices 2.0.37 → 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 +7 -93
- 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 +15 -72
- 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
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,54 +35,58 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
36
|
};
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.DaumPremiumControl = void 0;
|
|
15
39
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
40
|
const device_1 = require("../../../types/device");
|
|
17
41
|
const __1 = require("../..");
|
|
18
42
|
const serial_interface_1 = require("../../serial-interface");
|
|
19
43
|
const utils_1 = require("../../../utils/utils");
|
|
20
|
-
const DaumAdapter_1 =
|
|
44
|
+
const DaumAdapter_1 = __importStar(require("../DaumAdapter"));
|
|
21
45
|
const comms_1 = __importDefault(require("./comms"));
|
|
22
|
-
const
|
|
46
|
+
const daum_premium_standard_1 = __importDefault(require("../../../modes/daum-premium-standard"));
|
|
23
47
|
const PROTOCOL_NAME = "Daum Premium";
|
|
24
48
|
const DAUM_PREMIUM_DEFAULT_PORT = 51955;
|
|
25
49
|
const START_RETRY_TIMEOUT = 1500;
|
|
26
50
|
const DEFAULT_GEAR = 10;
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else {
|
|
34
|
-
serial = props.interface;
|
|
35
|
-
}
|
|
36
|
-
if (!serial || !serial.binding)
|
|
37
|
-
throw new Error(`unknonwn interface: ${ifaceName}`);
|
|
38
|
-
if (serial.getName() === serial_interface_1.SerialInterfaceType.TCPIP) {
|
|
39
|
-
const path = `${host}:${port}`;
|
|
40
|
-
return { serial, path };
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
const path = `${port}`;
|
|
44
|
-
return { serial, path };
|
|
51
|
+
const START_RETRIES = 5;
|
|
52
|
+
class DaumPremiumControl extends DaumAdapter_1.DaumControl {
|
|
53
|
+
getSupportedCyclingModes() {
|
|
54
|
+
const supported = super.getSupportedCyclingModes();
|
|
55
|
+
supported.push(daum_premium_standard_1.default);
|
|
56
|
+
return supported;
|
|
45
57
|
}
|
|
46
|
-
}
|
|
58
|
+
}
|
|
59
|
+
exports.DaumPremiumControl = DaumPremiumControl;
|
|
47
60
|
class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
48
61
|
constructor(settings, props) {
|
|
49
|
-
const logger = new gd_eventlog_1.EventLogger('DaumPremium');
|
|
50
|
-
const commProps = Object.assign(Object.assign({}, getBikeProps(settings)), { logger });
|
|
51
|
-
const bike = new comms_1.default(commProps);
|
|
52
62
|
super(settings, props);
|
|
53
|
-
this.
|
|
54
|
-
|
|
63
|
+
this.setControl(new DaumPremiumControl(this, props));
|
|
64
|
+
const logger = new gd_eventlog_1.EventLogger('DaumPremium');
|
|
65
|
+
const commProps = Object.assign(Object.assign({}, this.getBikeProps(settings)), { logger });
|
|
66
|
+
this.bike = new comms_1.default(commProps);
|
|
55
67
|
this.logger = logger;
|
|
56
|
-
this.ignoreHrm = false;
|
|
57
|
-
this.ignorePower = false;
|
|
58
|
-
this.ignoreBike = false;
|
|
59
|
-
this.iv = undefined;
|
|
60
|
-
this.distanceInternal = undefined;
|
|
61
68
|
this.initData();
|
|
62
69
|
}
|
|
70
|
+
getBikeProps(props) {
|
|
71
|
+
const { host, port = DAUM_PREMIUM_DEFAULT_PORT, interface: ifaceName } = props;
|
|
72
|
+
let serial;
|
|
73
|
+
if (ifaceName && typeof ifaceName === 'string') {
|
|
74
|
+
serial = __1.SerialInterface.getInstance({ ifaceName });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
serial = props.interface;
|
|
78
|
+
}
|
|
79
|
+
if (!serial || !serial.binding)
|
|
80
|
+
throw new Error(`unknonwn interface: ${ifaceName}`);
|
|
81
|
+
if (serial.getName() === serial_interface_1.SerialInterfaceType.TCPIP) {
|
|
82
|
+
const path = `${host}:${port}`;
|
|
83
|
+
return { serial, path };
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const path = `${port}`;
|
|
87
|
+
return { serial, path };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
63
90
|
getName() {
|
|
64
91
|
return 'Daum8i';
|
|
65
92
|
}
|
|
@@ -71,9 +98,6 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
71
98
|
}
|
|
72
99
|
return super.getUniqueName();
|
|
73
100
|
}
|
|
74
|
-
getPort() {
|
|
75
|
-
return this.bike.getPort();
|
|
76
|
-
}
|
|
77
101
|
getInterface() {
|
|
78
102
|
var _a;
|
|
79
103
|
return (_a = this.bike) === null || _a === void 0 ? void 0 : _a.getInterface();
|
|
@@ -81,10 +105,6 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
81
105
|
getProtocolName() {
|
|
82
106
|
return PROTOCOL_NAME;
|
|
83
107
|
}
|
|
84
|
-
getSerialInterface() {
|
|
85
|
-
var _a;
|
|
86
|
-
return (_a = this.bike) === null || _a === void 0 ? void 0 : _a.serial;
|
|
87
|
-
}
|
|
88
108
|
isEqual(settings) {
|
|
89
109
|
if (this.getInterface() === device_1.INTERFACE.TCPIP) {
|
|
90
110
|
const as = this.settings;
|
|
@@ -100,72 +120,48 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
100
120
|
return super.isEqual(settings);
|
|
101
121
|
}
|
|
102
122
|
}
|
|
103
|
-
|
|
104
|
-
const supported = super.getSupportedCyclingModes();
|
|
105
|
-
supported.push(daum_classic_1.default);
|
|
106
|
-
return supported;
|
|
107
|
-
}
|
|
108
|
-
check() {
|
|
123
|
+
performCheck() {
|
|
109
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
125
|
var info = {};
|
|
111
126
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
112
127
|
this.logEvent({ message: "checking device", port: this.getPort() });
|
|
113
128
|
try {
|
|
114
|
-
yield this.
|
|
129
|
+
yield this.stop();
|
|
115
130
|
const connected = yield this.connect();
|
|
116
131
|
if (!connected)
|
|
117
132
|
resolve(false);
|
|
133
|
+
this.stopped = false;
|
|
134
|
+
this.started = false;
|
|
135
|
+
this.paused = false;
|
|
118
136
|
info.deviceType = yield this.bike.getDeviceType();
|
|
119
137
|
info.version = yield this.bike.getProtocolVersion();
|
|
120
138
|
this.logEvent({ message: "checking device success", port: this.getPort(), info });
|
|
139
|
+
this.pause();
|
|
121
140
|
resolve(true);
|
|
122
141
|
}
|
|
123
142
|
catch (err) {
|
|
124
|
-
this.logEvent({ message: "checking device failed", port: this.getPort(), reason: err.message
|
|
143
|
+
this.logEvent({ message: "checking device failed", port: this.getPort(), reason: err.message });
|
|
125
144
|
resolve(false);
|
|
126
145
|
}
|
|
127
146
|
}));
|
|
128
147
|
});
|
|
129
148
|
}
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
this.logEvent({ message: 'relaunch of device' });
|
|
133
|
-
try {
|
|
134
|
-
yield this.launch(props, true);
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
catch (err) {
|
|
138
|
-
this.logEvent({ message: 'start result: error', error: err.message });
|
|
139
|
-
throw err;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
149
|
+
getStartRetries() {
|
|
150
|
+
return START_RETRIES;
|
|
142
151
|
}
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
this.logEvent({ message: 'initial start of device' });
|
|
146
|
-
try {
|
|
147
|
-
yield this.launch(props, false);
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
catch (err) {
|
|
151
|
-
this.logEvent({ message: 'start result: error', error: err.message });
|
|
152
|
-
throw err;
|
|
153
|
-
}
|
|
154
|
-
});
|
|
152
|
+
getStartRetryTimeout() {
|
|
153
|
+
return START_RETRY_TIMEOUT;
|
|
155
154
|
}
|
|
156
|
-
|
|
155
|
+
performStart(props = {}, _isRelaunch = false) {
|
|
157
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
const isPaused = this.isPaused() !== false;
|
|
159
157
|
this.setBikeProps(props);
|
|
160
|
-
const user = this.user;
|
|
161
|
-
const { route, onStatusUpdate, gear } = props;
|
|
162
|
-
var info = {};
|
|
163
158
|
this.initData();
|
|
164
159
|
yield this.stop();
|
|
165
|
-
|
|
160
|
+
var info = {};
|
|
161
|
+
yield (0, utils_1.runWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
166
162
|
try {
|
|
167
|
-
|
|
168
|
-
if (!connected)
|
|
163
|
+
info.connected = yield this.connect();
|
|
164
|
+
if (!info.connected)
|
|
169
165
|
throw new Error('not connected');
|
|
170
166
|
if (!info.deviceType) {
|
|
171
167
|
info.deviceType = yield this.bike.getDeviceType();
|
|
@@ -173,7 +169,9 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
173
169
|
if (!info.version) {
|
|
174
170
|
info.version = yield this.bike.getProtocolVersion();
|
|
175
171
|
}
|
|
176
|
-
|
|
172
|
+
const user = this.getUser();
|
|
173
|
+
const { route, onStatusUpdate, gear } = props;
|
|
174
|
+
if (this.requiresProgramUpload()) {
|
|
177
175
|
const bikeType = this.getCyclingMode().getSetting('bikeType');
|
|
178
176
|
if (!info.upload) {
|
|
179
177
|
info.upload = yield this.bike.programUpload(bikeType, route, onStatusUpdate);
|
|
@@ -197,33 +195,38 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
197
195
|
return;
|
|
198
196
|
}
|
|
199
197
|
catch (err) {
|
|
200
|
-
if (!info.deviceType) {
|
|
198
|
+
if (info.connected && !info.deviceType) {
|
|
201
199
|
yield (0, utils_1.sleep)(500);
|
|
202
200
|
yield this.reconnect();
|
|
203
201
|
}
|
|
204
|
-
throw (
|
|
202
|
+
throw (err);
|
|
205
203
|
}
|
|
206
|
-
}),
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
this.startUpdatePull();
|
|
213
|
-
return true;
|
|
214
|
-
});
|
|
204
|
+
}), this.getStartRetries(), this.getStartRetryTimeout());
|
|
205
|
+
this.stopped = false;
|
|
206
|
+
this.paused = false;
|
|
207
|
+
this.started = true;
|
|
208
|
+
this.startUpdatePull();
|
|
209
|
+
return true;
|
|
215
210
|
});
|
|
216
211
|
}
|
|
212
|
+
requiresProgramUpload() {
|
|
213
|
+
if (!this.getCyclingMode())
|
|
214
|
+
return false;
|
|
215
|
+
return this.getCyclingMode().getModeProperty('eppSupport');
|
|
216
|
+
}
|
|
217
217
|
getCurrentBikeData() {
|
|
218
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
-
|
|
220
|
-
const connected = yield this.bike.connect();
|
|
221
|
-
if (!connected)
|
|
222
|
-
throw new Error('not connected');
|
|
223
|
-
}
|
|
219
|
+
yield this.verifyConnection();
|
|
224
220
|
return this.getBike().getTrainingData();
|
|
225
221
|
});
|
|
226
222
|
}
|
|
223
|
+
getDeviceInfo() {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
const deviceType = yield this.bike.getDeviceType();
|
|
226
|
+
const version = yield this.bike.getProtocolVersion();
|
|
227
|
+
return { deviceType, version };
|
|
228
|
+
});
|
|
229
|
+
}
|
|
227
230
|
}
|
|
228
231
|
DaumPremiumAdapter.NAME = PROTOCOL_NAME;
|
|
229
232
|
exports.default = DaumPremiumAdapter;
|
|
@@ -6,7 +6,8 @@ import { OnDeviceStartCallback } from "./types";
|
|
|
6
6
|
import SerialPortComms from "../../comms";
|
|
7
7
|
import { DaumPremiumCommsState, DaumPremiumRequest, ResponseObject } from "./types";
|
|
8
8
|
import { IncyclistBikeData } from "../../..";
|
|
9
|
-
|
|
9
|
+
import DaumSerialComms from "../types";
|
|
10
|
+
export default class Daum8i extends SerialPortComms<DaumPremiumCommsState, DaumPremiumRequest, ResponseObject> implements DaumSerialComms {
|
|
10
11
|
validatePath(path: string): string;
|
|
11
12
|
getDefaultLoggerName(): string;
|
|
12
13
|
getAckTimeoutValue(): number;
|
|
@@ -23,6 +24,8 @@ export default class Daum8i extends SerialPortComms<DaumPremiumCommsState, DaumP
|
|
|
23
24
|
write(buffer: Buffer, ackExpected?: boolean): Promise<void>;
|
|
24
25
|
sendACK(logPayload: any): Promise<void>;
|
|
25
26
|
sendNAK(logPayload: any): Promise<void>;
|
|
27
|
+
setTargetPower(power: number): Promise<void>;
|
|
28
|
+
setTargetSlope(_slope: number): Promise<void>;
|
|
26
29
|
getProtocolVersion(): Promise<string>;
|
|
27
30
|
getDashboardVersion(): Promise<string>;
|
|
28
31
|
getDeviceType(): Promise<string>;
|
|
@@ -12,12 +12,12 @@ 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
|
-
const
|
|
15
|
+
const consts_1 = require("../consts");
|
|
16
16
|
const utils_1 = require("./utils");
|
|
17
17
|
const types_1 = require("./types");
|
|
18
18
|
const utils_2 = require("../../../utils/utils");
|
|
19
19
|
const comms_1 = __importDefault(require("../../comms"));
|
|
20
|
-
const
|
|
20
|
+
const consts_2 = require("./consts");
|
|
21
21
|
class Daum8i extends comms_1.default {
|
|
22
22
|
validatePath(path) {
|
|
23
23
|
return (0, utils_1.validatePath)(path);
|
|
@@ -26,10 +26,10 @@ class Daum8i extends comms_1.default {
|
|
|
26
26
|
return 'DaumPremium';
|
|
27
27
|
}
|
|
28
28
|
getAckTimeoutValue() {
|
|
29
|
-
return
|
|
29
|
+
return consts_2.DEFAULT_ACK_TIMEOUT;
|
|
30
30
|
}
|
|
31
31
|
getTimeoutValue() {
|
|
32
|
-
return
|
|
32
|
+
return consts_2.DEFAULT_TIMEOUT;
|
|
33
33
|
}
|
|
34
34
|
onConnected() {
|
|
35
35
|
this.sp.on('data', this.onData.bind(this));
|
|
@@ -280,6 +280,14 @@ class Daum8i extends comms_1.default {
|
|
|
280
280
|
yield this.write(Buffer.from([0x15]), false);
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
|
+
setTargetPower(power) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
yield this.setPower(power);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
setTargetSlope(_slope) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
283
291
|
getProtocolVersion() {
|
|
284
292
|
return __awaiter(this, void 0, void 0, function* () {
|
|
285
293
|
const data = yield this.sendStrCommand('getProtocolVersion', 'V00');
|
|
@@ -312,11 +320,11 @@ class Daum8i extends comms_1.default {
|
|
|
312
320
|
const str = yield this.sendStrCommand('getActualBikeType', 'M72');
|
|
313
321
|
let deviceType;
|
|
314
322
|
if (str === '0')
|
|
315
|
-
deviceType =
|
|
323
|
+
deviceType = consts_1.ACTUAL_BIKE_TYPE.ALLROUND;
|
|
316
324
|
else if (str === '1')
|
|
317
|
-
deviceType =
|
|
325
|
+
deviceType = consts_1.ACTUAL_BIKE_TYPE.RACE;
|
|
318
326
|
else if (str === '2')
|
|
319
|
-
deviceType =
|
|
327
|
+
deviceType = consts_1.ACTUAL_BIKE_TYPE.MOUNTAIN;
|
|
320
328
|
else {
|
|
321
329
|
throw (new Error(`unknown actual device type ${typeof str === 'string' ? (0, utils_1.ascii)(str.charAt(0)) : str}`));
|
|
322
330
|
}
|
|
@@ -328,16 +336,16 @@ class Daum8i extends comms_1.default {
|
|
|
328
336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
329
337
|
let bikeType;
|
|
330
338
|
switch (actualBikeType) {
|
|
331
|
-
case
|
|
339
|
+
case consts_1.ACTUAL_BIKE_TYPE.ALLROUND:
|
|
332
340
|
bikeType = '0';
|
|
333
341
|
break;
|
|
334
|
-
case
|
|
342
|
+
case consts_1.ACTUAL_BIKE_TYPE.RACE:
|
|
335
343
|
bikeType = '1';
|
|
336
344
|
break;
|
|
337
|
-
case
|
|
345
|
+
case consts_1.ACTUAL_BIKE_TYPE.TRIATHLON:
|
|
338
346
|
bikeType = '1';
|
|
339
347
|
break;
|
|
340
|
-
case
|
|
348
|
+
case consts_1.ACTUAL_BIKE_TYPE.MOUNTAIN:
|
|
341
349
|
bikeType = '2';
|
|
342
350
|
break;
|
|
343
351
|
default:
|
|
@@ -346,11 +354,11 @@ class Daum8i extends comms_1.default {
|
|
|
346
354
|
const str = yield this.sendStrCommand('setActualBikeType', `M72${bikeType}`);
|
|
347
355
|
let deviceType;
|
|
348
356
|
if (str === '0')
|
|
349
|
-
deviceType =
|
|
357
|
+
deviceType = consts_1.ACTUAL_BIKE_TYPE.ALLROUND;
|
|
350
358
|
else if (str === '1')
|
|
351
|
-
deviceType =
|
|
359
|
+
deviceType = consts_1.ACTUAL_BIKE_TYPE.RACE;
|
|
352
360
|
else if (str === '2')
|
|
353
|
-
deviceType =
|
|
361
|
+
deviceType = consts_1.ACTUAL_BIKE_TYPE.MOUNTAIN;
|
|
354
362
|
else
|
|
355
363
|
throw (new Error('unknown actual device type'));
|
|
356
364
|
this.actualBikeType = deviceType;
|
|
@@ -454,7 +462,7 @@ class Daum8i extends comms_1.default {
|
|
|
454
462
|
const epp = route ? (0, utils_1.routeToEpp)(route) : undefined;
|
|
455
463
|
const eppLength = epp ? epp.length : 0;
|
|
456
464
|
const bikeTypeVal = (0, utils_1.getBikeType)(bikeType);
|
|
457
|
-
const wBits = route.lapMode ?
|
|
465
|
+
const wBits = route.lapMode ? consts_2.DS_BITS_ENDLESS_RACE : consts_2.DS_BITS_OFF;
|
|
458
466
|
payload.writeInt32LE(0, 0);
|
|
459
467
|
payload.writeInt8(bikeTypeVal, 4);
|
|
460
468
|
payload.writeInt8(0, 5);
|
|
@@ -484,7 +492,7 @@ class Daum8i extends comms_1.default {
|
|
|
484
492
|
const remaining = epp.length - offset;
|
|
485
493
|
if (remaining <= 0)
|
|
486
494
|
return Promise.resolve(true);
|
|
487
|
-
const size = remaining >
|
|
495
|
+
const size = remaining > consts_2.MAX_DATA_BLOCK_SIZE ? consts_2.MAX_DATA_BLOCK_SIZE : remaining;
|
|
488
496
|
const payload = Buffer.alloc(size + 8);
|
|
489
497
|
payload.writeInt32LE(size, 0);
|
|
490
498
|
payload.writeInt32LE(offset, 4);
|
|
@@ -545,7 +553,7 @@ class Daum8i extends comms_1.default {
|
|
|
545
553
|
done = true;
|
|
546
554
|
while (success && !done) {
|
|
547
555
|
success = yield this.programUploadSendBlock(epp, offset);
|
|
548
|
-
offset +=
|
|
556
|
+
offset += consts_2.MAX_DATA_BLOCK_SIZE;
|
|
549
557
|
done = offset >= epp.length;
|
|
550
558
|
if (onStatusUpdate)
|
|
551
559
|
onStatusUpdate(done ? epp.length : offset, epp.length);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
|
|
3
4
|
import { BindingInterface } from '@serialport/bindings-interface';
|
|
4
5
|
import { User } from '../../../types/user';
|
|
@@ -60,6 +61,7 @@ export declare class Daum8MockSimulator {
|
|
|
60
61
|
person: User;
|
|
61
62
|
program: Program;
|
|
62
63
|
data: trainingData;
|
|
64
|
+
openHandles: Array<NodeJS.Timeout>;
|
|
63
65
|
_isSimulateACKTimeout: boolean;
|
|
64
66
|
_isSimulateCheckSumError: boolean;
|
|
65
67
|
_isSimulateReservedError: boolean;
|
|
@@ -71,6 +73,8 @@ export declare class Daum8MockSimulator {
|
|
|
71
73
|
simulateReservedError(): void;
|
|
72
74
|
onNAK(): void;
|
|
73
75
|
onACK(): void;
|
|
76
|
+
addHandle(handle: NodeJS.Timeout): void;
|
|
77
|
+
cleanup(): void;
|
|
74
78
|
}
|
|
75
79
|
export declare function parseProgramListNewData(buffer: Buffer): Program;
|
|
76
80
|
export declare class Daum8iMockBinding extends MockPortBinding {
|
|
@@ -101,6 +101,7 @@ class Daum8MockSimulator {
|
|
|
101
101
|
this.loadControl = 1;
|
|
102
102
|
this.person = { weight: 75, length: 180, age: 30, sex: user_1.Gender.MALE };
|
|
103
103
|
this.data = DEFAULT_TRAINING_DATA;
|
|
104
|
+
this.openHandles = [];
|
|
104
105
|
this._isSimulateACKTimeout = false;
|
|
105
106
|
this._isSimulateCheckSumError = false;
|
|
106
107
|
this._isSimulateReservedError = false;
|
|
@@ -121,6 +122,12 @@ class Daum8MockSimulator {
|
|
|
121
122
|
}
|
|
122
123
|
onNAK() { }
|
|
123
124
|
onACK() { }
|
|
125
|
+
addHandle(handle) {
|
|
126
|
+
this.openHandles.push(handle);
|
|
127
|
+
}
|
|
128
|
+
cleanup() {
|
|
129
|
+
this.openHandles.forEach(to => { clearTimeout(to); });
|
|
130
|
+
}
|
|
124
131
|
}
|
|
125
132
|
exports.Daum8MockSimulator = Daum8MockSimulator;
|
|
126
133
|
function parseProgramListNewData(buffer) {
|
|
@@ -174,7 +181,8 @@ class Daum8iMockBinding extends binding_mock_1.MockPortBinding {
|
|
|
174
181
|
this.simulator._isSimulateACKTimeout = false;
|
|
175
182
|
}
|
|
176
183
|
else {
|
|
177
|
-
setTimeout(() => { this.processData(buffer); }, 5);
|
|
184
|
+
const to = setTimeout(() => { this.processData(buffer); }, 5);
|
|
185
|
+
this.simulator.addHandle(to);
|
|
178
186
|
}
|
|
179
187
|
this.writeOperation = null;
|
|
180
188
|
}))();
|
|
@@ -230,12 +238,13 @@ class Daum8iMockBinding extends binding_mock_1.MockPortBinding {
|
|
|
230
238
|
else if (c === 0x15) {
|
|
231
239
|
this.simulator.onNAK();
|
|
232
240
|
if (this.prevCommand) {
|
|
233
|
-
const
|
|
234
|
-
setTimeout(() => {
|
|
241
|
+
const toVal = this.simulator.timeoutNAKRetry || 1000;
|
|
242
|
+
const to = setTimeout(() => {
|
|
235
243
|
this.emitData(this.prevCommand);
|
|
236
244
|
this.waitingForCommand = false;
|
|
237
245
|
this.waitingForAck = true;
|
|
238
|
-
},
|
|
246
|
+
}, toVal);
|
|
247
|
+
this.simulator.addHandle(to);
|
|
239
248
|
}
|
|
240
249
|
}
|
|
241
250
|
}
|
|
@@ -294,7 +303,8 @@ class Daum8iMockBinding extends binding_mock_1.MockPortBinding {
|
|
|
294
303
|
if (payload.length > 0) {
|
|
295
304
|
const power = Number(payload.toString());
|
|
296
305
|
this.simulator.power = power;
|
|
297
|
-
setTimeout(() => { this.simulator.currentPower = power; }, 1000);
|
|
306
|
+
const to = setTimeout(() => { this.simulator.currentPower = power; }, 1000);
|
|
307
|
+
this.simulator.addHandle(to);
|
|
298
308
|
}
|
|
299
309
|
this.emitData(this.createResponse('S23', Buffer.from(this.simulator.power.toString())));
|
|
300
310
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default abstract class DaumSerialComms {
|
|
2
|
+
serial: any;
|
|
3
|
+
abstract getPort(): string;
|
|
4
|
+
abstract pauseLogging(): void;
|
|
5
|
+
abstract resumeLogging(): void;
|
|
6
|
+
abstract isConnected(): boolean;
|
|
7
|
+
abstract connect(): Promise<boolean>;
|
|
8
|
+
abstract close(): Promise<boolean>;
|
|
9
|
+
abstract setTargetSlope(slope: number): Promise<void>;
|
|
10
|
+
abstract setTargetPower(power: number): Promise<void>;
|
|
11
|
+
}
|
|
@@ -2,10 +2,12 @@ import { DeviceProperties } from "../../../types/device";
|
|
|
2
2
|
import { EventLogger } from "gd-eventlog";
|
|
3
3
|
import SerialComms from "../comms";
|
|
4
4
|
import { Command } from "../../../types/command";
|
|
5
|
-
import
|
|
5
|
+
import ICyclingMode, { CyclingMode, IncyclistBikeData } from "../../../modes/types";
|
|
6
6
|
import { SerialDeviceSettings, SerialIncyclistDevice } from "../../adapter";
|
|
7
7
|
import { DeviceData } from "../../../types/data";
|
|
8
8
|
import SerialInterface from "../../serial-interface";
|
|
9
|
+
import { ControllableDevice } from "../../../base/adpater";
|
|
10
|
+
import { IncyclistDeviceAdapter } from "../../../types/adapter";
|
|
9
11
|
export interface KettlerRacerCommand extends Command {
|
|
10
12
|
}
|
|
11
13
|
export interface KettlerExtendedBikeData {
|
|
@@ -21,11 +23,13 @@ export interface KettlerBikeData {
|
|
|
21
23
|
time: number;
|
|
22
24
|
power: number;
|
|
23
25
|
}
|
|
24
|
-
export
|
|
26
|
+
export declare class KettlerControl<P extends DeviceProperties> extends ControllableDevice<P> {
|
|
27
|
+
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
28
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
29
|
+
sendInitCommands(): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
export default class KettlerRacerAdapter extends SerialIncyclistDevice<KettlerControl<DeviceProperties>, DeviceProperties> {
|
|
25
32
|
private id;
|
|
26
|
-
private ignoreHrm;
|
|
27
|
-
private ignoreBike;
|
|
28
|
-
private ignorePower;
|
|
29
33
|
private iv;
|
|
30
34
|
private requests;
|
|
31
35
|
private data;
|
|
@@ -40,7 +44,7 @@ export default class KettlerRacerAdapter extends SerialIncyclistDevice {
|
|
|
40
44
|
isPower(): boolean;
|
|
41
45
|
isHrm(): boolean;
|
|
42
46
|
getProtocolName(): string;
|
|
43
|
-
isSame(device:
|
|
47
|
+
isSame(device: IncyclistDeviceAdapter): boolean;
|
|
44
48
|
setID(id: any): void;
|
|
45
49
|
getID(): string;
|
|
46
50
|
getName(): string;
|
|
@@ -84,6 +88,4 @@ export default class KettlerRacerAdapter extends SerialIncyclistDevice {
|
|
|
84
88
|
close(): Promise<boolean>;
|
|
85
89
|
waitForOpened(retries?: boolean): Promise<boolean>;
|
|
86
90
|
waitForClosed(): Promise<boolean>;
|
|
87
|
-
getSupportedCyclingModes(): any[];
|
|
88
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
89
91
|
}
|
|
@@ -12,14 +12,30 @@ 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.KettlerControl = void 0;
|
|
15
16
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
17
|
const comms_1 = __importDefault(require("../comms"));
|
|
17
18
|
const utils_1 = require("../../../utils/utils");
|
|
18
19
|
const power_meter_1 = __importDefault(require("../../../modes/power-meter"));
|
|
19
|
-
const
|
|
20
|
+
const kettler_erg_1 = __importDefault(require("../../../modes/kettler-erg"));
|
|
20
21
|
const adapter_1 = require("../../adapter");
|
|
21
22
|
const capabilities_1 = require("../../../types/capabilities");
|
|
23
|
+
const adpater_1 = require("../../../base/adpater");
|
|
22
24
|
const PROTOCOL_NAME = 'Kettler Racer';
|
|
25
|
+
class KettlerControl extends adpater_1.ControllableDevice {
|
|
26
|
+
getSupportedCyclingModes() {
|
|
27
|
+
return [power_meter_1.default, kettler_erg_1.default];
|
|
28
|
+
}
|
|
29
|
+
getDefaultCyclingMode() {
|
|
30
|
+
return new kettler_erg_1.default(this.adapter);
|
|
31
|
+
}
|
|
32
|
+
sendInitCommands() {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return true;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.KettlerControl = KettlerControl;
|
|
23
39
|
class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
24
40
|
constructor(settings, props) {
|
|
25
41
|
super(settings, props);
|
|
@@ -566,11 +582,5 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
566
582
|
}
|
|
567
583
|
});
|
|
568
584
|
}
|
|
569
|
-
getSupportedCyclingModes() {
|
|
570
|
-
return [power_meter_1.default, erg_1.default];
|
|
571
|
-
}
|
|
572
|
-
getDefaultCyclingMode() {
|
|
573
|
-
return new erg_1.default(this);
|
|
574
|
-
}
|
|
575
585
|
}
|
|
576
586
|
exports.default = KettlerRacerAdapter;
|
|
@@ -78,7 +78,6 @@ class SinglePathScanner {
|
|
|
78
78
|
if (found) {
|
|
79
79
|
this.isFound = true;
|
|
80
80
|
const name = adapter.getName();
|
|
81
|
-
yield adapter.close();
|
|
82
81
|
resolve(Object.assign(Object.assign({}, adapterSettings), { name }));
|
|
83
82
|
}
|
|
84
83
|
yield (0, utils_1.sleep)(100);
|
|
@@ -321,7 +320,7 @@ class SerialInterface extends events_1.default {
|
|
|
321
320
|
const adapter = adapter_factory_1.default.getInstance().createInstance(device);
|
|
322
321
|
const path = adapter.getPort();
|
|
323
322
|
this.inUse.push(path);
|
|
324
|
-
yield adapter.
|
|
323
|
+
yield adapter.pause();
|
|
325
324
|
detected.push(device);
|
|
326
325
|
this.emit('device', device);
|
|
327
326
|
}
|