incyclist-devices 2.1.0 → 2.1.2
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 -15
- package/lib/antv2/adapter.d.ts +15 -15
- package/lib/antv2/adapter.js +67 -21
- package/lib/antv2/ant-interface.d.ts +3 -11
- package/lib/antv2/ant-interface.js +1 -1
- package/lib/antv2/base/adapter.d.ts +69 -0
- package/lib/antv2/base/adapter.js +439 -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/base/interface.d.ts +46 -0
- package/lib/antv2/base/interface.js +337 -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 +73 -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 +21 -30
- package/lib/antv2/fe/adapter.js +139 -251
- package/lib/antv2/hr/adapter.d.ts +6 -15
- 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 +5 -3
- package/lib/antv2/pwr/adapter.d.ts +9 -33
- package/lib/antv2/pwr/adapter.js +19 -140
- package/lib/antv2/types.d.ts +32 -4
- package/lib/base/adpater.d.ts +39 -60
- package/lib/base/adpater.js +139 -161
- package/lib/base/consts.d.ts +4 -0
- package/lib/base/consts.js +9 -0
- package/lib/ble/adapter-factory.d.ts +10 -11
- package/lib/ble/base/adapter.d.ts +7 -14
- package/lib/ble/base/adapter.js +2 -36
- package/lib/ble/ble-interface.d.ts +5 -7
- package/lib/ble/cp/adapter.d.ts +6 -8
- package/lib/ble/cp/adapter.js +8 -27
- package/lib/ble/elite/adapter.d.ts +7 -8
- package/lib/ble/elite/adapter.js +5 -25
- package/lib/ble/fm/adapter.d.ts +6 -7
- package/lib/ble/fm/adapter.js +13 -34
- package/lib/ble/hr/adapter.d.ts +5 -8
- package/lib/ble/hr/adapter.js +2 -2
- package/lib/ble/peripheral-cache.d.ts +2 -3
- 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 +5 -6
- package/lib/index.js +4 -9
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ant-fe-adv-st-mode.d.ts +1 -1
- package/lib/modes/antble-erg.d.ts +1 -1
- package/lib/modes/antble-smarttrainer.d.ts +2 -2
- package/lib/modes/base.d.ts +5 -5
- package/lib/modes/daum-classic-standard.d.ts +3 -2
- package/lib/modes/daum-erg.d.ts +3 -3
- package/lib/modes/daum-premium-standard.d.ts +3 -2
- package/lib/modes/daum-smarttrainer.d.ts +3 -2
- package/lib/modes/kettler-erg.d.ts +3 -3
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +2 -2
- package/lib/modes/power-meter.d.ts +3 -2
- package/lib/modes/simulator.d.ts +2 -1
- package/lib/modes/types.d.ts +2 -13
- package/lib/serial/SinglePathScanner.d.ts +17 -0
- package/lib/serial/SinglePathScanner.js +87 -0
- package/lib/serial/adapter-factory.d.ts +6 -6
- package/lib/serial/adapter.d.ts +6 -11
- 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 +12 -24
- package/lib/serial/daum/DaumAdapter.js +40 -59
- 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 +8 -20
- package/lib/serial/daum/classic/adapter.js +28 -58
- package/lib/serial/daum/classic/comms.d.ts +4 -6
- package/lib/serial/daum/classic/comms.js +2 -2
- 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.js +5 -4
- 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 -19
- package/lib/serial/daum/consts.js +0 -22
- package/lib/serial/daum/premium/adapter.d.ts +8 -11
- package/lib/serial/daum/premium/adapter.js +27 -53
- package/lib/serial/daum/premium/comms.d.ts +4 -7
- package/lib/serial/daum/premium/comms.js +23 -22
- package/lib/serial/daum/premium/mock.d.ts +1 -1
- package/lib/serial/daum/premium/mock.js +2 -2
- 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 +4 -1
- package/lib/serial/daum/types.js +9 -1
- 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 -18
- package/lib/serial/kettler/ergo-racer/adapter.js +9 -21
- 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 +3 -76
- 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 +10 -13
- package/lib/simulator/Simulator.js +11 -23
- package/lib/types/Command.d.ts +8 -0
- package/lib/types/Command.js +2 -0
- package/lib/types/adapter.d.ts +22 -33
- package/lib/types/adapter.js +0 -68
- 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 -0
- package/lib/utils/utils.js +39 -4
- package/package.json +1 -1
|
@@ -1,27 +1,4 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,35 +12,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
13
|
};
|
|
37
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.DaumClassicControl = void 0;
|
|
39
15
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
40
16
|
const utils_1 = require("../../../utils/utils");
|
|
41
|
-
const DaumAdapter_1 =
|
|
17
|
+
const DaumAdapter_1 = __importDefault(require("../DaumAdapter"));
|
|
42
18
|
const daum_classic_standard_1 = __importDefault(require("../../../modes/daum-classic-standard"));
|
|
43
19
|
const comms_1 = __importDefault(require("./comms"));
|
|
44
|
-
const serial_interface_1 = __importDefault(require("../../serial-interface"));
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const supported = super.getSupportedCyclingModes();
|
|
50
|
-
supported.push(daum_classic_standard_1.default);
|
|
51
|
-
return supported;
|
|
52
|
-
}
|
|
53
|
-
getDefaultCyclingMode() {
|
|
54
|
-
return new daum_classic_standard_1.default(this.adapter);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.DaumClassicControl = DaumClassicControl;
|
|
20
|
+
const serial_interface_1 = __importDefault(require("../../base/serial-interface"));
|
|
21
|
+
const daum_erg_1 = __importDefault(require("../../../modes/daum-erg"));
|
|
22
|
+
const daum_smarttrainer_1 = __importDefault(require("../../../modes/daum-smarttrainer"));
|
|
23
|
+
const daum_power_1 = __importDefault(require("../../../modes/daum-power"));
|
|
24
|
+
const consts_1 = require("./consts");
|
|
58
25
|
class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
59
26
|
constructor(settings, props) {
|
|
60
27
|
super(settings, props);
|
|
61
|
-
this.setControl(new DaumClassicControl(this, props));
|
|
62
28
|
const logger = new gd_eventlog_1.EventLogger('DaumClassic');
|
|
63
29
|
const commProps = Object.assign(Object.assign({}, this.getBikeProps(settings)), { logger });
|
|
64
|
-
this.
|
|
30
|
+
this.comms = new comms_1.default(commProps);
|
|
65
31
|
this.logger = logger;
|
|
66
|
-
this.name = PROTOCOL_NAME;
|
|
32
|
+
this.name = consts_1.PROTOCOL_NAME;
|
|
67
33
|
this.initData();
|
|
68
34
|
}
|
|
69
35
|
getBikeProps(props) {
|
|
@@ -87,7 +53,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
87
53
|
this.name = name;
|
|
88
54
|
}
|
|
89
55
|
getProtocolName() {
|
|
90
|
-
return PROTOCOL_NAME;
|
|
56
|
+
return consts_1.PROTOCOL_NAME;
|
|
91
57
|
}
|
|
92
58
|
performCheck() {
|
|
93
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -104,9 +70,9 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
104
70
|
return;
|
|
105
71
|
}
|
|
106
72
|
this.stopped = false;
|
|
107
|
-
const address = yield this.
|
|
73
|
+
const address = yield this.getComms().getAddress();
|
|
108
74
|
info.bikeNo = address === null || address === void 0 ? void 0 : address.bike;
|
|
109
|
-
const version = yield this.
|
|
75
|
+
const version = yield this.getComms().getVersion();
|
|
110
76
|
info.serialNo = version === null || version === void 0 ? void 0 : version.serialNo;
|
|
111
77
|
info.cockpit = version === null || version === void 0 ? void 0 : version.cockpit;
|
|
112
78
|
this.setName('Daum ' + info.cockpit);
|
|
@@ -130,41 +96,41 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
130
96
|
this.stopUpdatePull();
|
|
131
97
|
this.setBikeProps(props);
|
|
132
98
|
const user = this.getUser();
|
|
133
|
-
const { gear = DEFAULT_GEAR } = props;
|
|
99
|
+
const { gear = consts_1.DEFAULT_GEAR } = props;
|
|
134
100
|
this.initData();
|
|
135
101
|
let startState = {};
|
|
136
102
|
return (0, utils_1.runWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
137
103
|
try {
|
|
138
|
-
this.logEvent({ message: 'start attempt', isRelaunch, isConnected: this.
|
|
139
|
-
if (!isRelaunch && !this.
|
|
104
|
+
this.logEvent({ message: 'start attempt', isRelaunch, isConnected: this.getComms().isConnected() });
|
|
105
|
+
if (!isRelaunch && !this.getComms().isConnected()) {
|
|
140
106
|
yield this.verifyConnection();
|
|
141
107
|
}
|
|
142
|
-
yield this.
|
|
108
|
+
yield this.getComms().resetDevice();
|
|
143
109
|
if (!startState.setProg) {
|
|
144
|
-
yield this.
|
|
110
|
+
yield this.getComms().setProg(0);
|
|
145
111
|
startState.setProg = true;
|
|
146
112
|
}
|
|
147
113
|
if (!startState.setPerson) {
|
|
148
|
-
yield this.
|
|
114
|
+
yield this.getComms().setPerson(user);
|
|
149
115
|
startState.setPerson = true;
|
|
150
116
|
}
|
|
151
117
|
if (!startState.setBikeType) {
|
|
152
118
|
const bikeType = this.getCyclingMode().getSetting('bikeType') || 'race';
|
|
153
|
-
yield this.
|
|
119
|
+
yield this.getComms().setBikeType(bikeType.toLowerCase());
|
|
154
120
|
startState.setBikeType = true;
|
|
155
121
|
}
|
|
156
122
|
if (!startState.startProg) {
|
|
157
|
-
yield this.
|
|
123
|
+
yield this.getComms().startProg();
|
|
158
124
|
startState.startProg = true;
|
|
159
125
|
}
|
|
160
126
|
if (!startState.setGear) {
|
|
161
|
-
yield this.
|
|
127
|
+
yield this.getComms().setGear(this.deviceData.gear || gear);
|
|
162
128
|
startState.setGear = true;
|
|
163
129
|
}
|
|
164
130
|
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
165
131
|
yield this.sendRequest(startRequest);
|
|
166
132
|
startState.checkRunData = true;
|
|
167
|
-
const data = yield this.
|
|
133
|
+
const data = yield this.getComms().runData();
|
|
168
134
|
if (startRequest.targetPower && startRequest.targetPower !== 25 && data.power === 25) {
|
|
169
135
|
throw new Error('invalid device response: runData');
|
|
170
136
|
}
|
|
@@ -187,17 +153,21 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
187
153
|
if (this.stopped)
|
|
188
154
|
return;
|
|
189
155
|
yield this.verifyConnection();
|
|
190
|
-
return this.
|
|
156
|
+
return this.getComms().runData();
|
|
191
157
|
});
|
|
192
158
|
}
|
|
193
159
|
getDeviceInfo() {
|
|
194
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
161
|
if (this.stopped)
|
|
196
162
|
return;
|
|
197
|
-
const version = yield this.
|
|
163
|
+
const version = yield this.getComms().getVersion();
|
|
198
164
|
return version || {};
|
|
199
165
|
});
|
|
200
166
|
}
|
|
201
167
|
}
|
|
202
|
-
DaumClassicAdapter.NAME = PROTOCOL_NAME;
|
|
168
|
+
DaumClassicAdapter.NAME = consts_1.PROTOCOL_NAME;
|
|
169
|
+
DaumClassicAdapter.controllers = {
|
|
170
|
+
modes: [daum_erg_1.default, daum_smarttrainer_1.default, daum_power_1.default, daum_classic_standard_1.default],
|
|
171
|
+
default: daum_classic_standard_1.default
|
|
172
|
+
};
|
|
203
173
|
exports.default = DaumClassicAdapter;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { User } from '../../../types/user';
|
|
2
1
|
import { ClassicBikeResponse, DaumClassicCommsState, DaumClassicRequest, DaumClassicResponse, GetVersionReponse, ProgResponse, SetGearRepsonse, SetPowerRepsonse, SetProgResponse, SetSlopeRepsonse, checkCockpitReponse } from './types';
|
|
3
|
-
import SerialPortComms from '../../comms';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { SerialCommProps } from '../../comm';
|
|
2
|
+
import SerialPortComms from '../../base/comms';
|
|
3
|
+
import { DaumSerialComms } from '../types';
|
|
4
|
+
import { SerialCommProps } from '../../types';
|
|
5
|
+
import { DeviceType, IncyclistBikeData, User } from '../../../types';
|
|
8
6
|
export default class Daum8008 extends SerialPortComms<DaumClassicCommsState, DaumClassicRequest, DaumClassicResponse> implements DaumSerialComms {
|
|
9
7
|
protected bikeNo: number;
|
|
10
8
|
constructor(props: SerialCommProps);
|
|
@@ -13,9 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const utils_1 = require("../../../utils/utils");
|
|
16
|
-
const comms_1 = __importDefault(require("../../comms"));
|
|
17
|
-
const types_1 = require("../premium/types");
|
|
16
|
+
const comms_1 = __importDefault(require("../../base/comms"));
|
|
18
17
|
const utils_2 = require("./utils");
|
|
18
|
+
const types_1 = require("../types");
|
|
19
19
|
const ByteLength = require('@serialport/parser-byte-length');
|
|
20
20
|
const TIMEOUT_SEND = 2000;
|
|
21
21
|
class Daum8008 extends comms_1.default {
|
|
@@ -14,9 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.DaumClassicMockBinding = exports.DaumClassicSimulator = exports.DaumClassicMockImpl = exports.DaumClassicMock = void 0;
|
|
16
16
|
const binding_mock_1 = require("@serialport/binding-mock");
|
|
17
|
-
const __1 = require("../../");
|
|
18
17
|
const utils_1 = require("../../../utils/utils");
|
|
19
18
|
const calculations_1 = __importDefault(require("../../../utils/calculations"));
|
|
19
|
+
const serialport_1 = __importDefault(require("../../base/serialport"));
|
|
20
|
+
const serial_interface_1 = __importDefault(require("../../base/serial-interface"));
|
|
20
21
|
exports.DaumClassicMock = {
|
|
21
22
|
reset() {
|
|
22
23
|
DaumClassicMockImpl.getInstance().reset();
|
|
@@ -43,8 +44,8 @@ class DaumClassicMockImpl {
|
|
|
43
44
|
}
|
|
44
45
|
static reset() {
|
|
45
46
|
DaumClassicMockImpl._instance = undefined;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
serialport_1.default._instance = undefined;
|
|
48
|
+
serial_interface_1.default._instances = [];
|
|
48
49
|
}
|
|
49
50
|
constructor() {
|
|
50
51
|
this.simulators = new Map();
|
|
@@ -64,7 +65,7 @@ class DaumClassicMockImpl {
|
|
|
64
65
|
}
|
|
65
66
|
list() {
|
|
66
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return binding_mock_1.MockBinding.list();
|
|
68
|
+
return yield binding_mock_1.MockBinding.list();
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
open(options) {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { IncyclistBikeData } from "
|
|
2
|
-
import { DaumBikeData, DeviceProperties } from "../../../types/device";
|
|
1
|
+
import { DeviceProperties, IncyclistBikeData } from "../../../types";
|
|
3
2
|
import { Queue } from "../../../utils/utils";
|
|
4
|
-
import { Request, Response } from "../../comms";
|
|
5
|
-
export
|
|
6
|
-
path: string;
|
|
7
|
-
ifaceName?: string;
|
|
8
|
-
};
|
|
9
|
-
export interface DaumClassicDeviceProperties extends DeviceProperties {
|
|
3
|
+
import { Request, Response } from "../../base/comms";
|
|
4
|
+
export interface DaumClassicProperties extends DeviceProperties {
|
|
10
5
|
gear?: number;
|
|
11
6
|
}
|
|
12
7
|
export interface DaumClassicRequest extends Request {
|
|
@@ -18,8 +13,11 @@ export interface DaumClassicResponse extends Response {
|
|
|
18
13
|
data?: Uint8Array;
|
|
19
14
|
error?: Error;
|
|
20
15
|
}
|
|
21
|
-
export
|
|
22
|
-
|
|
16
|
+
export type DaumClassicStartInfo = {
|
|
17
|
+
bikeNo?: number;
|
|
18
|
+
serialNo?: string;
|
|
19
|
+
cockpit?: string;
|
|
20
|
+
};
|
|
23
21
|
export type ResponseType = 'Response' | 'Error';
|
|
24
22
|
export type DaumClassicCommsState = {
|
|
25
23
|
data: Queue<DaumClassicResponse>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IncyclistBikeData } from '
|
|
2
|
-
import { DeviceType } from '../../../types/device';
|
|
1
|
+
import { DeviceType, IncyclistBikeData } from '../../../types';
|
|
3
2
|
export declare const DEFAULT_AGE = 30;
|
|
4
3
|
export declare const DEFAULT_USER_WEIGHT = 75;
|
|
5
4
|
export declare const DEFAULT_BIKE_WEIGHT = 10;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const ACTUAL_BIKE_TYPE: {
|
|
2
|
-
ALLROUND: string;
|
|
3
|
-
RACE: string;
|
|
4
|
-
MOUNTAIN: string;
|
|
5
|
-
TRIATHLON: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const BIKE_INTERFACE: {
|
|
8
|
-
SERIAL: string;
|
|
9
|
-
ANT: string;
|
|
10
|
-
BLE: string;
|
|
11
|
-
BLUETOOTH: string;
|
|
12
|
-
TCPIP: string;
|
|
13
|
-
};
|
|
14
|
-
export declare const BIKE_TRAINING_STATE: {
|
|
15
|
-
IDLE: string;
|
|
16
|
-
STARTING: string;
|
|
17
|
-
BUSY: string;
|
|
18
|
-
STOPPING: string;
|
|
19
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BIKE_TRAINING_STATE = exports.BIKE_INTERFACE = exports.ACTUAL_BIKE_TYPE = void 0;
|
|
4
|
-
exports.ACTUAL_BIKE_TYPE = {
|
|
5
|
-
ALLROUND: 'allround',
|
|
6
|
-
RACE: 'race',
|
|
7
|
-
MOUNTAIN: 'mountain',
|
|
8
|
-
TRIATHLON: 'triathlon'
|
|
9
|
-
};
|
|
10
|
-
exports.BIKE_INTERFACE = {
|
|
11
|
-
SERIAL: 'serial',
|
|
12
|
-
ANT: 'ant',
|
|
13
|
-
BLE: 'ble',
|
|
14
|
-
BLUETOOTH: 'bluetooth',
|
|
15
|
-
TCPIP: 'tcpip',
|
|
16
|
-
};
|
|
17
|
-
exports.BIKE_TRAINING_STATE = {
|
|
18
|
-
IDLE: 'idle',
|
|
19
|
-
STARTING: 'starting',
|
|
20
|
-
BUSY: 'busy',
|
|
21
|
-
STOPPING: 'stopping'
|
|
22
|
-
};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SerialCommProps } from '../../comm';
|
|
3
|
-
import DaumAdapter, { DaumControl } from '../DaumAdapter';
|
|
1
|
+
import DaumAdapter from '../DaumAdapter';
|
|
4
2
|
import Daum8i from './comms';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export default class DaumPremiumAdapter extends DaumAdapter<DaumPremiumControl, SerialDeviceSettings, Daum8iDeviceProperties, Daum8i> {
|
|
3
|
+
import { DaumPremiumDeviceProperties } from './types';
|
|
4
|
+
import { SerialDeviceSettings, SerialCommProps } from "../../types";
|
|
5
|
+
import { ControllerConfig, IncyclistBikeData } from '../../../types';
|
|
6
|
+
export default class DaumPremiumAdapter extends DaumAdapter<SerialDeviceSettings, DaumPremiumDeviceProperties, Daum8i> {
|
|
11
7
|
static NAME: string;
|
|
8
|
+
protected static controllers: ControllerConfig;
|
|
12
9
|
commProps: SerialCommProps;
|
|
13
|
-
constructor(settings: SerialDeviceSettings, props?:
|
|
10
|
+
constructor(settings: SerialDeviceSettings, props?: DaumPremiumDeviceProperties);
|
|
14
11
|
getBikeProps(props: SerialDeviceSettings): {
|
|
15
12
|
serial: any;
|
|
16
13
|
path: string;
|
|
@@ -23,7 +20,7 @@ export default class DaumPremiumAdapter extends DaumAdapter<DaumPremiumControl,
|
|
|
23
20
|
performCheck(): Promise<boolean>;
|
|
24
21
|
getStartRetries(): number;
|
|
25
22
|
getStartRetryTimeout(): number;
|
|
26
|
-
performStart(props?:
|
|
23
|
+
performStart(props?: DaumPremiumDeviceProperties, _isRelaunch?: boolean): Promise<boolean>;
|
|
27
24
|
requiresProgramUpload(): boolean;
|
|
28
25
|
getCurrentBikeData(): Promise<IncyclistBikeData>;
|
|
29
26
|
getDeviceInfo(): Promise<any>;
|
|
@@ -1,27 +1,4 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,35 +12,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
13
|
};
|
|
37
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.DaumPremiumControl = void 0;
|
|
39
15
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
40
|
-
const
|
|
41
|
-
const __1 = require("../..");
|
|
42
|
-
const serial_interface_1 = require("../../serial-interface");
|
|
16
|
+
const serial_interface_1 = __importDefault(require("../../base/serial-interface"));
|
|
43
17
|
const utils_1 = require("../../../utils/utils");
|
|
44
|
-
const DaumAdapter_1 =
|
|
18
|
+
const DaumAdapter_1 = __importDefault(require("../DaumAdapter"));
|
|
45
19
|
const comms_1 = __importDefault(require("./comms"));
|
|
20
|
+
const types_1 = require("../../types");
|
|
21
|
+
const types_2 = require("../../../types");
|
|
46
22
|
const daum_premium_standard_1 = __importDefault(require("../../../modes/daum-premium-standard"));
|
|
23
|
+
const daum_erg_1 = __importDefault(require("../../../modes/daum-erg"));
|
|
24
|
+
const daum_smarttrainer_1 = __importDefault(require("../../../modes/daum-smarttrainer"));
|
|
25
|
+
const daum_power_1 = __importDefault(require("../../../modes/daum-power"));
|
|
47
26
|
const PROTOCOL_NAME = "Daum Premium";
|
|
48
27
|
const DAUM_PREMIUM_DEFAULT_PORT = 51955;
|
|
49
28
|
const START_RETRY_TIMEOUT = 1500;
|
|
50
29
|
const DEFAULT_GEAR = 10;
|
|
51
30
|
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;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.DaumPremiumControl = DaumPremiumControl;
|
|
60
31
|
class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
61
32
|
constructor(settings, props) {
|
|
62
33
|
super(settings, props);
|
|
63
|
-
this.setControl(new DaumPremiumControl(this, props));
|
|
64
34
|
const logger = new gd_eventlog_1.EventLogger('DaumPremium');
|
|
65
35
|
const commProps = Object.assign(Object.assign({}, this.getBikeProps(settings)), { logger });
|
|
66
|
-
this.
|
|
36
|
+
this.comms = new comms_1.default(commProps);
|
|
67
37
|
this.logger = logger;
|
|
68
38
|
this.initData();
|
|
69
39
|
}
|
|
@@ -71,14 +41,14 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
71
41
|
const { host, port = DAUM_PREMIUM_DEFAULT_PORT, interface: ifaceName } = props;
|
|
72
42
|
let serial;
|
|
73
43
|
if (ifaceName && typeof ifaceName === 'string') {
|
|
74
|
-
serial =
|
|
44
|
+
serial = serial_interface_1.default.getInstance({ ifaceName });
|
|
75
45
|
}
|
|
76
46
|
else {
|
|
77
47
|
serial = props.interface;
|
|
78
48
|
}
|
|
79
49
|
if (!serial || !serial.binding)
|
|
80
50
|
throw new Error(`unknonwn interface: ${ifaceName}`);
|
|
81
|
-
if (serial.getName() ===
|
|
51
|
+
if (serial.getName() === types_1.SerialInterfaceType.TCPIP) {
|
|
82
52
|
const path = `${host}:${port}`;
|
|
83
53
|
return { serial, path };
|
|
84
54
|
}
|
|
@@ -100,13 +70,13 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
100
70
|
}
|
|
101
71
|
getInterface() {
|
|
102
72
|
var _a;
|
|
103
|
-
return (_a = this.
|
|
73
|
+
return (_a = this.comms) === null || _a === void 0 ? void 0 : _a.getInterface();
|
|
104
74
|
}
|
|
105
75
|
getProtocolName() {
|
|
106
76
|
return PROTOCOL_NAME;
|
|
107
77
|
}
|
|
108
78
|
isEqual(settings) {
|
|
109
|
-
if (this.getInterface() ===
|
|
79
|
+
if (this.getInterface() === types_2.INTERFACE.TCPIP) {
|
|
110
80
|
const as = this.settings;
|
|
111
81
|
if (settings.interface !== this.getInterface())
|
|
112
82
|
return false;
|
|
@@ -133,8 +103,8 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
133
103
|
this.stopped = false;
|
|
134
104
|
this.started = false;
|
|
135
105
|
this.paused = false;
|
|
136
|
-
info.deviceType = yield this.
|
|
137
|
-
info.version = yield this.
|
|
106
|
+
info.deviceType = yield this.comms.getDeviceType();
|
|
107
|
+
info.version = yield this.comms.getProtocolVersion();
|
|
138
108
|
this.logEvent({ message: "checking device success", port: this.getPort(), info });
|
|
139
109
|
this.pause();
|
|
140
110
|
resolve(true);
|
|
@@ -164,33 +134,33 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
164
134
|
if (!info.connected)
|
|
165
135
|
throw new Error('not connected');
|
|
166
136
|
if (!info.deviceType) {
|
|
167
|
-
info.deviceType = yield this.
|
|
137
|
+
info.deviceType = yield this.getComms().getDeviceType();
|
|
168
138
|
}
|
|
169
139
|
if (!info.version) {
|
|
170
|
-
info.version = yield this.
|
|
140
|
+
info.version = yield this.getComms().getProtocolVersion();
|
|
171
141
|
}
|
|
172
142
|
const user = this.getUser();
|
|
173
143
|
const { route, onStatusUpdate, gear } = props;
|
|
174
144
|
if (this.requiresProgramUpload()) {
|
|
175
145
|
const bikeType = this.getCyclingMode().getSetting('bikeType');
|
|
176
146
|
if (!info.upload) {
|
|
177
|
-
info.upload = yield this.
|
|
147
|
+
info.upload = yield this.getComms().programUpload(bikeType, route, onStatusUpdate);
|
|
178
148
|
if (!info.upload)
|
|
179
149
|
throw new Error('Epp Upload failed');
|
|
180
150
|
}
|
|
181
151
|
if (!info.started) {
|
|
182
152
|
const programId = route ? route.programId : 0;
|
|
183
|
-
info.started = yield this.
|
|
153
|
+
info.started = yield this.getComms().startProgram(programId);
|
|
184
154
|
if (!info.started) {
|
|
185
155
|
throw new Error('Epp start failed');
|
|
186
156
|
}
|
|
187
157
|
}
|
|
188
158
|
}
|
|
189
159
|
if (!info.person && this.getCyclingMode().getModeProperty('setPersonSupport')) {
|
|
190
|
-
info.person = yield this.
|
|
160
|
+
info.person = yield this.getComms().setPerson(user);
|
|
191
161
|
}
|
|
192
162
|
if (!this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
193
|
-
info.gear = yield this.
|
|
163
|
+
info.gear = yield this.getComms().setGear(this.deviceData.gear || gear || DEFAULT_GEAR);
|
|
194
164
|
}
|
|
195
165
|
return;
|
|
196
166
|
}
|
|
@@ -217,16 +187,20 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
217
187
|
getCurrentBikeData() {
|
|
218
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
189
|
yield this.verifyConnection();
|
|
220
|
-
return this.
|
|
190
|
+
return this.getComms().getTrainingData();
|
|
221
191
|
});
|
|
222
192
|
}
|
|
223
193
|
getDeviceInfo() {
|
|
224
194
|
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
const deviceType = yield this.
|
|
226
|
-
const version = yield this.
|
|
195
|
+
const deviceType = yield this.getComms().getDeviceType();
|
|
196
|
+
const version = yield this.getComms().getProtocolVersion();
|
|
227
197
|
return { deviceType, version };
|
|
228
198
|
});
|
|
229
199
|
}
|
|
230
200
|
}
|
|
231
201
|
DaumPremiumAdapter.NAME = PROTOCOL_NAME;
|
|
202
|
+
DaumPremiumAdapter.controllers = {
|
|
203
|
+
modes: [daum_erg_1.default, daum_smarttrainer_1.default, daum_power_1.default, daum_premium_standard_1.default],
|
|
204
|
+
default: daum_erg_1.default
|
|
205
|
+
};
|
|
232
206
|
exports.default = DaumPremiumAdapter;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ReservedCommands } from './utils';
|
|
3
|
-
import { User } from "../../../types
|
|
4
|
-
import {
|
|
5
|
-
import { OnDeviceStartCallback } from "./types";
|
|
6
|
-
import SerialPortComms from "../../comms";
|
|
7
|
-
import { DaumPremiumCommsState, DaumPremiumRequest, ResponseObject } from "./types";
|
|
8
|
-
import { IncyclistBikeData } from "../../..";
|
|
9
|
-
import DaumSerialComms from "../types";
|
|
3
|
+
import { User, IncyclistBikeData } from "../../../types";
|
|
4
|
+
import { DaumSerialComms } from "../types";
|
|
5
|
+
import { OnDeviceStartCallback, DaumPremiumCommsState, DaumPremiumRequest, ResponseObject, Route } from "./types";
|
|
6
|
+
import SerialPortComms from "../../base/comms";
|
|
10
7
|
export default class Daum8i extends SerialPortComms<DaumPremiumCommsState, DaumPremiumRequest, ResponseObject> implements DaumSerialComms {
|
|
11
8
|
validatePath(path: string): string;
|
|
12
9
|
getDefaultLoggerName(): string;
|