incyclist-devices 1.5.38 → 2.0.0-beta.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/README.MD +0 -0
- package/lib/adapters.d.ts +6 -0
- package/lib/adapters.js +30 -0
- package/lib/antv2/adapter-factory.d.ts +20 -10
- package/lib/antv2/adapter-factory.js +49 -33
- package/lib/antv2/adapter.d.ts +64 -0
- package/lib/antv2/adapter.js +299 -0
- package/lib/antv2/ant-interface.d.ts +11 -9
- package/lib/antv2/ant-interface.js +15 -11
- package/lib/antv2/fe/adapter.d.ts +25 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +48 -72
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +14 -0
- package/lib/antv2/hr/adapter.js +73 -0
- package/lib/antv2/hr/index.d.ts +2 -0
- package/lib/antv2/hr/index.js +7 -0
- package/lib/antv2/index.d.ts +7 -0
- package/lib/antv2/index.js +20 -0
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +9 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-adv-st-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +6 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-erg-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +5 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-st-mode.js +1 -1
- package/lib/antv2/pwr/adapter.d.ts +22 -0
- package/lib/antv2/{pwr.js → pwr/adapter.js} +38 -76
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/types.d.ts +19 -0
- package/lib/antv2/types.js +2 -0
- package/lib/antv2/utils.d.ts +1 -0
- package/lib/antv2/utils.js +181 -0
- package/lib/base/adpater.d.ts +56 -0
- package/lib/base/adpater.js +144 -0
- package/lib/ble/adapter-factory.d.ts +31 -0
- package/lib/ble/adapter-factory.js +96 -0
- package/lib/ble/adapter.d.ts +41 -0
- package/lib/ble/adapter.js +188 -0
- package/lib/ble/{ble-device.d.ts → ble-comms.d.ts} +9 -4
- package/lib/ble/{ble-device.js → ble-comms.js} +23 -11
- package/lib/ble/ble-interface.d.ts +15 -24
- package/lib/ble/ble-interface.js +32 -137
- package/lib/ble/ble-peripheral.d.ts +3 -3
- package/lib/ble/ble-peripheral.js +14 -14
- package/lib/ble/ble.d.ts +9 -81
- package/lib/ble/ble.js +1 -39
- package/lib/ble/consts.d.ts +2 -0
- package/lib/ble/consts.js +3 -1
- package/lib/ble/cp/adapter.d.ts +23 -0
- package/lib/ble/cp/adapter.js +124 -0
- package/lib/ble/cp/comm.d.ts +28 -0
- package/lib/ble/cp/comm.js +140 -0
- package/lib/ble/cp/index.d.ts +4 -0
- package/lib/ble/cp/index.js +10 -0
- package/lib/ble/cp/types.d.ts +13 -0
- package/lib/ble/cp/types.js +2 -0
- package/lib/ble/elite/adapter.d.ts +20 -0
- package/lib/ble/elite/adapter.js +127 -0
- package/lib/ble/elite/comms.d.ts +28 -0
- package/lib/ble/elite/comms.js +139 -0
- package/lib/ble/elite/index.d.ts +3 -0
- package/lib/ble/elite/index.js +10 -0
- package/lib/ble/fm/adapter.d.ts +21 -0
- package/lib/ble/fm/adapter.js +190 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +3 -224
- package/lib/ble/fm/consts.d.ts +6 -0
- package/lib/ble/fm/consts.js +9 -0
- package/lib/ble/fm/index.d.ts +5 -0
- package/lib/ble/fm/index.js +13 -0
- package/lib/ble/fm/types.d.ts +25 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +17 -0
- package/lib/ble/hr/adapter.js +62 -0
- package/lib/ble/hr/comm.d.ts +15 -0
- package/lib/ble/hr/comm.js +52 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +8 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +93 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +6 -38
- package/lib/ble/{tacx.js → tacx/comms.js} +13 -112
- package/lib/ble/tacx/index.d.ts +4 -0
- package/lib/ble/tacx/index.js +10 -0
- package/lib/ble/tacx/types.d.ts +25 -0
- package/lib/ble/tacx/types.js +2 -0
- package/lib/ble/types.d.ts +101 -0
- package/lib/ble/types.js +19 -0
- package/lib/ble/utils.d.ts +7 -0
- package/lib/ble/utils.js +95 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +93 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +5 -39
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +14 -112
- package/lib/ble/wahoo/index.d.ts +4 -0
- package/lib/ble/wahoo/index.js +10 -0
- package/lib/ble/wahoo/types.d.ts +19 -0
- package/lib/ble/wahoo/types.js +2 -0
- package/lib/device.d.ts +0 -94
- package/lib/device.js +0 -76
- package/lib/index.d.ts +12 -0
- package/lib/index.js +38 -0
- package/lib/interfaces.d.ts +6 -0
- package/lib/interfaces.js +23 -0
- package/lib/{ble → modes}/ble-erg-mode.d.ts +4 -4
- package/lib/{ble → modes}/ble-erg-mode.js +2 -2
- package/lib/{ble → modes}/ble-st-mode.d.ts +3 -3
- package/lib/{ble → modes}/ble-st-mode.js +1 -1
- package/lib/{cycling-mode.d.ts → modes/cycling-mode.d.ts} +8 -8
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +4 -4
- package/lib/modes/power-meter.d.ts +3 -3
- package/lib/modes/simulator.d.ts +2 -2
- package/lib/modes/simulator.js +1 -1
- package/lib/serial/adapter-factory.d.ts +12 -0
- package/lib/serial/adapter-factory.js +30 -0
- package/lib/serial/adapter.d.ts +16 -0
- package/lib/serial/adapter.js +42 -0
- package/lib/serial/bindings/tcp.d.ts +44 -0
- package/lib/serial/bindings/tcp.js +270 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +13 -22
- package/lib/{daum → serial/daum}/DaumAdapter.js +44 -90
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.d.ts +2 -2
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.js +1 -1
- package/lib/{daum → serial/daum}/ERGCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/ERGCyclingMode.js +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.js +4 -3
- package/lib/serial/daum/classic/adapter.d.ts +29 -0
- package/lib/{daum/classic/DaumClassicAdapter.js → serial/daum/classic/adapter.js} +77 -50
- package/lib/{daum/classic/bike.d.ts → serial/daum/classic/comms.d.ts} +14 -16
- package/lib/{daum/classic/bike.js → serial/daum/classic/comms.js} +68 -152
- package/lib/serial/daum/classic/mock.d.ts +96 -0
- package/lib/serial/daum/classic/mock.js +365 -0
- package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js} +2 -2
- package/lib/{daum → serial/daum}/classic/utils.d.ts +1 -1
- package/lib/serial/daum/premium/adapter.d.ts +24 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +99 -46
- package/lib/{daum/premium/bike.d.ts → serial/daum/premium/comms.d.ts} +26 -54
- package/lib/{daum/premium/bike.js → serial/daum/premium/comms.js} +208 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +290 -0
- package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/modes/daum-classic.js} +2 -2
- package/lib/serial/daum/premium/types.d.ts +12 -0
- package/lib/serial/daum/premium/types.js +2 -0
- package/lib/{daum → serial/daum}/premium/utils.d.ts +8 -11
- package/lib/{daum → serial/daum}/premium/utils.js +22 -63
- package/lib/serial/index.d.ts +9 -0
- package/lib/serial/index.js +49 -0
- package/lib/{kettler → serial/kettler}/comms.d.ts +8 -6
- package/lib/{kettler → serial/kettler}/comms.js +71 -32
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.d.ts +13 -24
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +87 -130
- package/lib/serial/kettler/ergo-racer/mock.d.ts +66 -0
- package/lib/serial/kettler/ergo-racer/mock.js +216 -0
- package/lib/{kettler/ergo-racer/ERGCyclingMode.d.ts → serial/kettler/ergo-racer/modes/erg.d.ts} +4 -4
- package/lib/{kettler/ergo-racer/ERGCyclingMode.js → serial/kettler/ergo-racer/modes/erg.js} +2 -2
- package/lib/serial/serial-interface.d.ts +58 -0
- package/lib/serial/serial-interface.js +283 -0
- package/lib/simulator/Simulator.d.ts +10 -25
- package/lib/simulator/Simulator.js +19 -83
- package/lib/types/adapter.d.ts +32 -0
- package/lib/types/adapter.js +2 -0
- package/lib/types/capabilities.d.ts +8 -0
- package/lib/types/capabilities.js +12 -0
- package/lib/types/data.d.ts +12 -0
- package/lib/types/data.js +2 -0
- package/lib/types/device.d.ts +29 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +14 -0
- package/lib/types/interface.js +2 -0
- package/lib/types/route.d.ts +2 -2
- package/lib/types/user.d.ts +1 -1
- package/lib/{utils.d.ts → utils/utils.d.ts} +1 -0
- package/lib/{utils.js → utils/utils.js} +5 -1
- package/package.json +15 -11
- package/lib/DeviceSupport.d.ts +0 -36
- package/lib/DeviceSupport.js +0 -82
- package/lib/ant/AntAdapter.d.ts +0 -50
- package/lib/ant/AntAdapter.js +0 -109
- package/lib/ant/AntScanner.d.ts +0 -60
- package/lib/ant/AntScanner.js +0 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +0 -83
- package/lib/ant/antfe/AntFEAdapter.js +0 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +0 -6
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +0 -5
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +0 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +0 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +0 -49
- package/lib/ant/antpwr/pwr-adapter.js +0 -251
- package/lib/ant/utils.d.ts +0 -1
- package/lib/ant/utils.js +0 -23
- package/lib/antv2/AntAdapter.d.ts +0 -48
- package/lib/antv2/AntAdapter.js +0 -104
- package/lib/antv2/ant-device.d.ts +0 -59
- package/lib/antv2/ant-device.js +0 -161
- package/lib/antv2/fe.d.ts +0 -32
- package/lib/antv2/hr.d.ts +0 -18
- package/lib/antv2/hr.js +0 -102
- package/lib/antv2/incyclist-protocol.d.ts +0 -37
- package/lib/antv2/incyclist-protocol.js +0 -126
- package/lib/antv2/pwr.d.ts +0 -28
- package/lib/ble/elite.d.ts +0 -90
- package/lib/ble/elite.js +0 -322
- package/lib/ble/fm.d.ts +0 -125
- package/lib/ble/hrm.d.ts +0 -48
- package/lib/ble/hrm.js +0 -134
- package/lib/ble/incyclist-protocol.d.ts +0 -31
- package/lib/ble/incyclist-protocol.js +0 -153
- package/lib/ble/pwr.d.ts +0 -89
- package/lib/ble/pwr.js +0 -322
- package/lib/daum/classic/DaumClassicAdapter.d.ts +0 -28
- package/lib/daum/classic/DaumClassicProtocol.d.ts +0 -27
- package/lib/daum/classic/DaumClassicProtocol.js +0 -185
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -16
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +0 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +0 -207
- package/lib/daum/premium/tcpserial.d.ts +0 -33
- package/lib/daum/premium/tcpserial.js +0 -123
- package/lib/kettler/ergo-racer/protocol.d.ts +0 -41
- package/lib/kettler/ergo-racer/protocol.js +0 -203
- package/lib/protocol.d.ts +0 -74
- package/lib/protocol.js +0 -41
- package/lib/registry.d.ts +0 -8
- package/lib/registry.js +0 -33
- package/lib/serialport/bindings/tcp.d.ts +0 -20
- package/lib/serialport/bindings/tcp.js +0 -33
- package/lib/serialport/index.d.ts +0 -2
- package/lib/serialport/index.js +0 -29
- package/lib/serialport/serialport.d.ts +0 -29
- package/lib/serialport/serialport.js +0 -87
- /package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +0 -0
- /package/lib/antv2/{ant-binding.js → binding.js} +0 -0
- /package/lib/{cycling-mode.js → modes/cycling-mode.js} +0 -0
- /package/lib/{daum → serial/daum}/classic/utils.js +0 -0
- /package/lib/{daum → serial/daum}/constants.d.ts +0 -0
- /package/lib/{daum → serial/daum}/constants.js +0 -0
- /package/lib/{serialport.d.ts → serial/serialport.d.ts} +0 -0
- /package/lib/{serialport.js → serial/serialport.js} +0 -0
- /package/lib/{calculations.d.ts → utils/calculations.d.ts} +0 -0
- /package/lib/{calculations.js → utils/calculations.js} +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TCPPortBinding = exports.TCPBinding = exports.getSubnets = exports.scanSubNet = exports.scanPort = exports.CanceledError = void 0;
|
|
16
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
17
|
+
const os_1 = require("os");
|
|
18
|
+
const net_1 = __importDefault(require("net"));
|
|
19
|
+
function resolveNextTick() {
|
|
20
|
+
return new Promise(resolve => process.nextTick(() => resolve()));
|
|
21
|
+
}
|
|
22
|
+
class CanceledError extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.canceled = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.CanceledError = CanceledError;
|
|
29
|
+
function scanPort(host, port) {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
try {
|
|
32
|
+
const socket = new net_1.default.Socket();
|
|
33
|
+
const cleanup = () => {
|
|
34
|
+
try {
|
|
35
|
+
socket.destroy();
|
|
36
|
+
}
|
|
37
|
+
catch (err) { }
|
|
38
|
+
socket.removeAllListeners();
|
|
39
|
+
};
|
|
40
|
+
socket.setTimeout(1000);
|
|
41
|
+
socket.on('timeout', () => { resolve(false); ; cleanup(); });
|
|
42
|
+
socket.on('error', (err) => { resolve(false); cleanup(); });
|
|
43
|
+
socket.on('ready', () => { resolve(true); cleanup(); });
|
|
44
|
+
socket.connect(port, host);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
resolve(false);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.scanPort = scanPort;
|
|
52
|
+
function scanSubNet(sn, port) {
|
|
53
|
+
const range = [];
|
|
54
|
+
for (let i = 1; i < 255; i++)
|
|
55
|
+
range.push(i);
|
|
56
|
+
return Promise.all(range.map(j => scanPort(`${sn}.${j}`, port).then(success => success ? `${sn}.${j}` : null).catch()))
|
|
57
|
+
.then(hosts => hosts.filter(h => h !== null))
|
|
58
|
+
.catch();
|
|
59
|
+
}
|
|
60
|
+
exports.scanSubNet = scanSubNet;
|
|
61
|
+
function getSubnets() {
|
|
62
|
+
const nets = (0, os_1.networkInterfaces)();
|
|
63
|
+
const results = [];
|
|
64
|
+
const names = Object.keys(nets);
|
|
65
|
+
names.forEach(name => {
|
|
66
|
+
for (const net of nets[name]) {
|
|
67
|
+
if (net.family === 'IPv4' && !net.internal) {
|
|
68
|
+
results.push(net.address);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const address = Object.keys((0, os_1.networkInterfaces)())
|
|
73
|
+
.reduce((a, key) => [
|
|
74
|
+
...a,
|
|
75
|
+
...(0, os_1.networkInterfaces)()[key]
|
|
76
|
+
], [])
|
|
77
|
+
.filter(iface => iface.family === 'IPv4' && !iface.internal && iface.netmask === '255.255.255.0')
|
|
78
|
+
.map(iface => {
|
|
79
|
+
const parts = iface.address.split('.');
|
|
80
|
+
return `${parts[0]}.${parts[1]}.${parts[2]}`;
|
|
81
|
+
});
|
|
82
|
+
const subnets = address.filter((x, i) => i === address.indexOf(x));
|
|
83
|
+
subnets.push('127.0.0');
|
|
84
|
+
return subnets;
|
|
85
|
+
}
|
|
86
|
+
exports.getSubnets = getSubnets;
|
|
87
|
+
exports.TCPBinding = {
|
|
88
|
+
list(port) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (!port)
|
|
91
|
+
return [];
|
|
92
|
+
const subnets = getSubnets();
|
|
93
|
+
const hosts = [];
|
|
94
|
+
yield Promise.all(subnets.map(sn => scanSubNet(sn, port).then(found => { hosts.push(...found); })));
|
|
95
|
+
return hosts.map(host => ({
|
|
96
|
+
path: `${host}:${port}`,
|
|
97
|
+
manufacturer: undefined,
|
|
98
|
+
locationId: undefined,
|
|
99
|
+
pnpId: undefined,
|
|
100
|
+
productId: undefined,
|
|
101
|
+
serialNumber: undefined,
|
|
102
|
+
vendorId: undefined
|
|
103
|
+
}));
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
open(options) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const asyncOpen = () => {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
let host, port;
|
|
111
|
+
if (!options.path)
|
|
112
|
+
return reject(new TypeError('"path" is not valid'));
|
|
113
|
+
try {
|
|
114
|
+
const res = options.path.split(':');
|
|
115
|
+
if (res.length !== 2)
|
|
116
|
+
return reject(new TypeError('"path" is not valid'));
|
|
117
|
+
host = res[0];
|
|
118
|
+
port = Number(res[1]);
|
|
119
|
+
if (isNaN(port))
|
|
120
|
+
return reject(new TypeError('"path" is not valid'));
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
return reject(new TypeError('"path" is not valid'));
|
|
124
|
+
}
|
|
125
|
+
const socket = new net_1.default.Socket();
|
|
126
|
+
if (options.timeout)
|
|
127
|
+
socket.setTimeout(options.timeout);
|
|
128
|
+
socket.once('timeout', () => { reject(new Error('timeout')); });
|
|
129
|
+
socket.once('error', (err) => { reject(err); });
|
|
130
|
+
socket.once('connect', () => { resolve(socket); });
|
|
131
|
+
socket.connect(port, host);
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
const openOptions = Object.assign({ dataBits: 8, lock: true, stopBits: 1, parity: 'none', rtscts: false, xon: false, xoff: false, xany: false, hupcl: true }, options);
|
|
135
|
+
const socket = yield asyncOpen();
|
|
136
|
+
return new TCPPortBinding(socket, openOptions);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
class TCPPortBinding {
|
|
141
|
+
constructor(socket, options) {
|
|
142
|
+
this.logger = new gd_eventlog_1.EventLogger('TCPPort');
|
|
143
|
+
this.socket = socket;
|
|
144
|
+
this.openOptions = options;
|
|
145
|
+
this.pendingRead = null;
|
|
146
|
+
this.writeOperation = null;
|
|
147
|
+
this.data = null;
|
|
148
|
+
this.socket.on('data', this.onData.bind(this));
|
|
149
|
+
}
|
|
150
|
+
get isOpen() {
|
|
151
|
+
return this.socket !== null;
|
|
152
|
+
}
|
|
153
|
+
onData(data) {
|
|
154
|
+
if (!this.data)
|
|
155
|
+
this.data = Buffer.alloc(0);
|
|
156
|
+
this.data = Buffer.concat([this.data, data]);
|
|
157
|
+
if (this.pendingRead) {
|
|
158
|
+
process.nextTick(this.pendingRead);
|
|
159
|
+
this.pendingRead = null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
close() {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
if (!this.isOpen)
|
|
165
|
+
return;
|
|
166
|
+
this.data = Buffer.alloc(0);
|
|
167
|
+
const socket = this.socket;
|
|
168
|
+
socket.removeAllListeners();
|
|
169
|
+
socket.destroy();
|
|
170
|
+
socket.on('error', () => { });
|
|
171
|
+
setTimeout(() => { socket.removeAllListeners(); }, 500);
|
|
172
|
+
if (this.pendingRead) {
|
|
173
|
+
this.pendingRead(new CanceledError('port is closed'));
|
|
174
|
+
}
|
|
175
|
+
this.socket = null;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
read(buffer, offset, length) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
if (!this.isOpen) {
|
|
181
|
+
throw new Error('Port is not open');
|
|
182
|
+
}
|
|
183
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
184
|
+
throw new TypeError('"buffer" is not a Buffer');
|
|
185
|
+
}
|
|
186
|
+
if (typeof offset !== 'number' || isNaN(offset)) {
|
|
187
|
+
throw new TypeError(`"offset" is not an integer got "${isNaN(offset) ? 'NaN' : typeof offset}"`);
|
|
188
|
+
}
|
|
189
|
+
if (typeof length !== 'number' || isNaN(length)) {
|
|
190
|
+
throw new TypeError(`"length" is not an integer got "${isNaN(length) ? 'NaN' : typeof length}"`);
|
|
191
|
+
}
|
|
192
|
+
if (buffer.length < offset + length) {
|
|
193
|
+
throw new Error('buffer is too small');
|
|
194
|
+
}
|
|
195
|
+
yield resolveNextTick();
|
|
196
|
+
if (!this.data || this.data.length === 0) {
|
|
197
|
+
return new Promise((resolve, reject) => {
|
|
198
|
+
this.pendingRead = err => {
|
|
199
|
+
if (err) {
|
|
200
|
+
return reject(err);
|
|
201
|
+
}
|
|
202
|
+
this.read(buffer, offset, length).then(resolve, reject);
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
const lengthToRead = length === 65536 ? this.data.length : length;
|
|
207
|
+
const toCopy = this.data.slice(0, lengthToRead);
|
|
208
|
+
const bytesRead = toCopy.copy(buffer, offset);
|
|
209
|
+
this.data = this.data.slice(lengthToRead);
|
|
210
|
+
return ({ buffer, bytesRead });
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
write(buffer) {
|
|
214
|
+
if (!this.isOpen) {
|
|
215
|
+
throw new Error('Port is not open');
|
|
216
|
+
}
|
|
217
|
+
this.writeOperation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
yield resolveNextTick();
|
|
219
|
+
this.socket.write(buffer);
|
|
220
|
+
}))();
|
|
221
|
+
return this.writeOperation;
|
|
222
|
+
}
|
|
223
|
+
update(options) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
yield resolveNextTick();
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
set(options) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
yield resolveNextTick();
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
get() {
|
|
234
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
+
if (!this.isOpen) {
|
|
236
|
+
throw new Error('Port is not open');
|
|
237
|
+
}
|
|
238
|
+
yield resolveNextTick();
|
|
239
|
+
return {
|
|
240
|
+
cts: true,
|
|
241
|
+
dsr: false,
|
|
242
|
+
dcd: false,
|
|
243
|
+
};
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
getBaudRate() {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
return { baudRate: 9600 };
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
flush() {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
if (!this.isOpen) {
|
|
254
|
+
throw new Error('Port is not open');
|
|
255
|
+
}
|
|
256
|
+
yield resolveNextTick();
|
|
257
|
+
this.data = Buffer.alloc(0);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
drain() {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
262
|
+
if (!this.isOpen) {
|
|
263
|
+
throw new Error('Port is not open');
|
|
264
|
+
}
|
|
265
|
+
yield resolveNextTick();
|
|
266
|
+
yield this.writeOperation;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
exports.TCPPortBinding = TCPPortBinding;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { EventLogger } from 'gd-eventlog';
|
|
2
|
-
import CyclingMode, { IncyclistBikeData } from '
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import CyclingMode, { IncyclistBikeData } from '../../modes/cycling-mode';
|
|
3
|
+
import { Bike } from '../../types/adapter';
|
|
4
|
+
import { DeviceProperties } from '../../types/device';
|
|
5
|
+
import { SerialDeviceSettings, SerialIncyclistDevice } from '../adapter';
|
|
6
|
+
import { DeviceData } from '../../types/data';
|
|
5
7
|
interface DaumAdapter {
|
|
6
8
|
getCurrentBikeData(): Promise<any>;
|
|
7
9
|
}
|
|
8
|
-
export default class DaumAdapterBase extends
|
|
10
|
+
export default class DaumAdapterBase extends SerialIncyclistDevice implements DaumAdapter, Bike {
|
|
9
11
|
bike: any;
|
|
10
12
|
ignoreHrm: boolean;
|
|
11
13
|
ignoreBike: boolean;
|
|
@@ -19,40 +21,28 @@ export default class DaumAdapterBase extends IncyclistDevice implements DeviceAd
|
|
|
19
21
|
requests: Array<any>;
|
|
20
22
|
iv: any;
|
|
21
23
|
logger: EventLogger;
|
|
22
|
-
cyclingMode: CyclingMode;
|
|
23
|
-
userSettings: User;
|
|
24
|
-
bikeSettings: any;
|
|
25
24
|
tsPrevData: number;
|
|
26
25
|
adapterTime: number;
|
|
27
26
|
requestBusy: boolean;
|
|
28
27
|
updateBusy: boolean;
|
|
29
|
-
constructor(
|
|
28
|
+
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
|
30
29
|
setCyclingMode(mode: CyclingMode | string, settings?: any): void;
|
|
31
30
|
getSupportedCyclingModes(): Array<any>;
|
|
32
31
|
getCyclingMode(): CyclingMode;
|
|
33
32
|
getDefaultCyclingMode(): CyclingMode;
|
|
34
|
-
setUserSettings(userSettings: User): void;
|
|
35
|
-
setBikeSettings(bikeSettings: any): void;
|
|
36
|
-
getWeight(): number;
|
|
37
33
|
getCurrentBikeData(): Promise<any>;
|
|
38
34
|
getBike(): any;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
isHrm(): boolean;
|
|
42
|
-
isSame(device: DeviceAdapter): boolean;
|
|
43
|
-
setIgnoreHrm(ignore: any): void;
|
|
44
|
-
setIgnoreBike(ignore: any): void;
|
|
35
|
+
isEqual(settings: SerialDeviceSettings): boolean;
|
|
36
|
+
isSame(device: SerialIncyclistDevice): boolean;
|
|
45
37
|
isStopped(): boolean;
|
|
46
38
|
initData(): void;
|
|
47
|
-
start(props?:
|
|
39
|
+
start(props?: DeviceProperties): Promise<any>;
|
|
48
40
|
stopUpdatePull(): void;
|
|
49
41
|
startUpdatePull(): void;
|
|
50
|
-
connect():
|
|
51
|
-
close():
|
|
42
|
+
connect(): Promise<boolean>;
|
|
43
|
+
close(): Promise<boolean>;
|
|
52
44
|
logEvent(event: any): void;
|
|
53
45
|
stop(): Promise<boolean>;
|
|
54
|
-
pause(): Promise<boolean>;
|
|
55
|
-
resume(): Promise<boolean>;
|
|
56
46
|
sendUpdate(request: any): Promise<unknown>;
|
|
57
47
|
sendData(): void;
|
|
58
48
|
update(): Promise<void>;
|
|
@@ -63,5 +53,6 @@ export default class DaumAdapterBase extends IncyclistDevice implements DeviceAd
|
|
|
63
53
|
sendRequest(request: any): Promise<any>;
|
|
64
54
|
refreshRequests(): void;
|
|
65
55
|
processClientRequest(request: any): Promise<unknown>;
|
|
56
|
+
check(): Promise<boolean>;
|
|
66
57
|
}
|
|
67
58
|
export {};
|
|
@@ -1,23 +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
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,19 +12,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
const device_1 = __importStar(require("../device"));
|
|
35
15
|
const ERGCyclingMode_1 = __importDefault(require("./ERGCyclingMode"));
|
|
36
16
|
const SmartTrainerCyclingMode_1 = __importDefault(require("./SmartTrainerCyclingMode"));
|
|
37
17
|
const DaumPowerMeterCyclingMode_1 = __importDefault(require("./DaumPowerMeterCyclingMode"));
|
|
38
|
-
const utils_1 = require("
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
const utils_1 = require("../../utils/utils");
|
|
19
|
+
const adapter_1 = require("../adapter");
|
|
20
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
21
|
+
class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
|
|
22
|
+
constructor(settings, props) {
|
|
23
|
+
super(settings, props);
|
|
42
24
|
this.requests = [];
|
|
43
25
|
this.adapterTime = 0;
|
|
44
26
|
this.requestBusy = false;
|
|
45
27
|
this.updateBusy = false;
|
|
46
|
-
this.bike = bike;
|
|
47
28
|
this.stopped = false;
|
|
48
29
|
this.paused = false;
|
|
49
30
|
this.cyclingData = {
|
|
@@ -56,21 +37,23 @@ class DaumAdapterBase extends device_1.default {
|
|
|
56
37
|
heartrate: 0
|
|
57
38
|
};
|
|
58
39
|
this.deviceData = {};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
this.capabilities = [
|
|
41
|
+
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Speed, capabilities_1.IncyclistCapability.Cadence, capabilities_1.IncyclistCapability.Gear, capabilities_1.IncyclistCapability.HeartRate,
|
|
42
|
+
capabilities_1.IncyclistCapability.Control
|
|
43
|
+
];
|
|
63
44
|
}
|
|
64
45
|
setCyclingMode(mode, settings) {
|
|
65
|
-
let selectedMode;
|
|
46
|
+
let selectedMode = this.cyclingMode;
|
|
66
47
|
if (typeof mode === 'string') {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
48
|
+
if (!this.cyclingMode || this.cyclingMode.getName() !== mode) {
|
|
49
|
+
const supported = this.getSupportedCyclingModes();
|
|
50
|
+
const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
|
|
51
|
+
if (CyclingModeClass) {
|
|
52
|
+
this.cyclingMode = new CyclingModeClass(this, settings);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
selectedMode = this.getDefaultCyclingMode();
|
|
72
56
|
}
|
|
73
|
-
selectedMode = this.getDefaultCyclingMode();
|
|
74
57
|
}
|
|
75
58
|
else {
|
|
76
59
|
selectedMode = mode;
|
|
@@ -89,43 +72,18 @@ class DaumAdapterBase extends device_1.default {
|
|
|
89
72
|
getDefaultCyclingMode() {
|
|
90
73
|
return new ERGCyclingMode_1.default(this);
|
|
91
74
|
}
|
|
92
|
-
setUserSettings(userSettings) {
|
|
93
|
-
this.userSettings = userSettings || {};
|
|
94
|
-
if (this.bike) {
|
|
95
|
-
if (!this.bike.settings)
|
|
96
|
-
this.bike.settings = { user: {} };
|
|
97
|
-
if (!this.bike.settings.user)
|
|
98
|
-
this.bike.settings.user = {};
|
|
99
|
-
this.bike.settings.user.weight = this.userSettings.weight || device_1.DEFAULT_USER_WEIGHT;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
setBikeSettings(bikeSettings) {
|
|
103
|
-
this.bikeSettings = bikeSettings || {};
|
|
104
|
-
if (this.bike) {
|
|
105
|
-
if (!this.bike.settings)
|
|
106
|
-
this.bike.settings = {};
|
|
107
|
-
this.bike.settings.weight = this.userSettings.weight || device_1.DEFAULT_BIKE_WEIGHT;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
getWeight() {
|
|
111
|
-
const userWeight = Number(this.userSettings.weight || device_1.DEFAULT_USER_WEIGHT);
|
|
112
|
-
const bikeWeight = Number(this.bikeSettings.weight || device_1.DEFAULT_BIKE_WEIGHT);
|
|
113
|
-
return bikeWeight + userWeight;
|
|
114
|
-
}
|
|
115
75
|
getCurrentBikeData() {
|
|
116
76
|
throw new Error('Method not implemented.');
|
|
117
77
|
}
|
|
118
78
|
getBike() {
|
|
119
79
|
return this.bike;
|
|
120
80
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
isHrm() {
|
|
128
|
-
return true;
|
|
81
|
+
isEqual(settings) {
|
|
82
|
+
const as = this.settings;
|
|
83
|
+
if (settings.interface !== this.getInterface())
|
|
84
|
+
return;
|
|
85
|
+
if (settings.protocol !== as.protocol || settings.port !== as.port)
|
|
86
|
+
return false;
|
|
129
87
|
}
|
|
130
88
|
isSame(device) {
|
|
131
89
|
if (!(device instanceof DaumAdapterBase))
|
|
@@ -133,12 +91,6 @@ class DaumAdapterBase extends device_1.default {
|
|
|
133
91
|
const adapter = device;
|
|
134
92
|
return (adapter.getName() === this.getName() && adapter.getPort() === this.getPort());
|
|
135
93
|
}
|
|
136
|
-
setIgnoreHrm(ignore) {
|
|
137
|
-
this.ignoreHrm = ignore;
|
|
138
|
-
}
|
|
139
|
-
setIgnoreBike(ignore) {
|
|
140
|
-
this.ignoreBike = ignore;
|
|
141
|
-
}
|
|
142
94
|
isStopped() {
|
|
143
95
|
return this.stopped;
|
|
144
96
|
}
|
|
@@ -192,11 +144,24 @@ class DaumAdapterBase extends device_1.default {
|
|
|
192
144
|
};
|
|
193
145
|
}
|
|
194
146
|
connect() {
|
|
195
|
-
|
|
196
|
-
this.bike.
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
if (this.bike.isConnected())
|
|
149
|
+
return true;
|
|
150
|
+
try {
|
|
151
|
+
const connected = yield this.bike.connect();
|
|
152
|
+
return connected;
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
197
158
|
}
|
|
198
159
|
close() {
|
|
199
|
-
return this
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
if (!this.bike.isConnected())
|
|
162
|
+
return true;
|
|
163
|
+
return yield this.bike.close();
|
|
164
|
+
});
|
|
200
165
|
}
|
|
201
166
|
logEvent(event) {
|
|
202
167
|
if (!this.logger)
|
|
@@ -228,20 +193,6 @@ class DaumAdapterBase extends device_1.default {
|
|
|
228
193
|
}
|
|
229
194
|
});
|
|
230
195
|
}
|
|
231
|
-
pause() {
|
|
232
|
-
this.logEvent({ message: 'pause' });
|
|
233
|
-
return new Promise(resolve => {
|
|
234
|
-
this.paused = true;
|
|
235
|
-
resolve(true);
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
resume() {
|
|
239
|
-
this.logEvent({ message: 'resume' });
|
|
240
|
-
return new Promise(resolve => {
|
|
241
|
-
this.paused = false;
|
|
242
|
-
resolve(true);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
196
|
sendUpdate(request) {
|
|
246
197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
198
|
if (this.paused || this.stopped)
|
|
@@ -408,5 +359,8 @@ class DaumAdapterBase extends device_1.default {
|
|
|
408
359
|
resolve(bikeRequest);
|
|
409
360
|
}));
|
|
410
361
|
}
|
|
362
|
+
check() {
|
|
363
|
+
throw new Error('Method not implemented.');
|
|
364
|
+
}
|
|
411
365
|
}
|
|
412
366
|
exports.default = DaumAdapterBase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import CyclingMode, { UpdateRequest } from "
|
|
2
|
-
import PowerMeterCyclingMode from "
|
|
1
|
+
import CyclingMode, { UpdateRequest } from "../../modes/cycling-mode";
|
|
2
|
+
import PowerMeterCyclingMode from "../../modes/power-meter";
|
|
3
3
|
export default class DaumPowerMeterCyclingMode extends PowerMeterCyclingMode implements CyclingMode {
|
|
4
4
|
prevRequest: UpdateRequest;
|
|
5
5
|
hasBikeUpdate: boolean;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const power_meter_1 = __importDefault(require("
|
|
6
|
+
const power_meter_1 = __importDefault(require("../../modes/power-meter"));
|
|
7
7
|
class DaumPowerMeterCyclingMode extends power_meter_1.default {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "
|
|
1
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "../../modes/cycling-mode";
|
|
2
2
|
import DaumAdapter from "./DaumAdapter";
|
|
3
|
-
import PowerBasedCyclingModeBase from "
|
|
4
|
-
export
|
|
3
|
+
import PowerBasedCyclingModeBase from "../../modes/power-base";
|
|
4
|
+
export type ERGEvent = {
|
|
5
5
|
rpmUpdated?: boolean;
|
|
6
6
|
gearUpdated?: boolean;
|
|
7
7
|
starting?: boolean;
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cycling_mode_1 = require("
|
|
7
|
-
const calculations_1 = __importDefault(require("
|
|
8
|
-
const power_base_1 = __importDefault(require("
|
|
6
|
+
const cycling_mode_1 = require("../../modes/cycling-mode");
|
|
7
|
+
const calculations_1 = __importDefault(require("../../utils/calculations"));
|
|
8
|
+
const power_base_1 = __importDefault(require("../../modes/power-base"));
|
|
9
9
|
const MIN_SPEED = 10;
|
|
10
10
|
const config = {
|
|
11
11
|
name: "ERG",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventLogger } from "gd-eventlog";
|
|
2
|
-
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest, CyclingModeBase } from "
|
|
2
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest, CyclingModeBase } from "../../modes/cycling-mode";
|
|
3
3
|
import DaumAdapter from "./DaumAdapter";
|
|
4
4
|
interface STUpdateRequest extends UpdateRequest {
|
|
5
5
|
calculatedPower?: number;
|
|
@@ -19,8 +19,8 @@ interface STEvent {
|
|
|
19
19
|
}
|
|
20
20
|
export default class SmartTrainerCyclingMode extends CyclingModeBase implements CyclingMode {
|
|
21
21
|
logger: EventLogger;
|
|
22
|
-
data
|
|
23
|
-
prevRequest
|
|
22
|
+
data?: IncyclistBikeData;
|
|
23
|
+
prevRequest?: STUpdateRequest;
|
|
24
24
|
prevUpdateTS: number;
|
|
25
25
|
chain: number[];
|
|
26
26
|
cassette: number[];
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.direction = void 0;
|
|
7
7
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
8
|
-
const cycling_mode_1 = require("
|
|
9
|
-
const calculations_1 = __importDefault(require("
|
|
8
|
+
const cycling_mode_1 = require("../../modes/cycling-mode");
|
|
9
|
+
const calculations_1 = __importDefault(require("../../utils/calculations"));
|
|
10
10
|
const SEC_DELAY = 3;
|
|
11
11
|
const config = {
|
|
12
12
|
name: "SmartTrainer",
|
|
@@ -220,7 +220,8 @@ class SmartTrainerCyclingMode extends cycling_mode_1.CyclingModeBase {
|
|
|
220
220
|
this.event.gearUpdate = gear > prevData.gear ? direction.up : direction.down;
|
|
221
221
|
if (rpm !== prevData.pedalRpm)
|
|
222
222
|
this.event.rpmUpdate = true;
|
|
223
|
-
|
|
223
|
+
const adapter = this.adapter;
|
|
224
|
+
let m = adapter.getWeight();
|
|
224
225
|
let distanceInternal = prevData.distanceInternal || 0;
|
|
225
226
|
let distance = (distanceInternal / 100);
|
|
226
227
|
let ts = Date.now();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import CyclingMode from '../../../modes/cycling-mode';
|
|
2
|
+
import DaumAdapter from '../DaumAdapter';
|
|
3
|
+
import { DeviceProperties } from '../../../types/device';
|
|
4
|
+
import { SerialDeviceSettings } from '../../adapter';
|
|
5
|
+
export interface DaumClassicDeviceProperties extends DeviceProperties {
|
|
6
|
+
gear?: number;
|
|
7
|
+
}
|
|
8
|
+
export default class DaumClassicAdapter extends DaumAdapter {
|
|
9
|
+
static NAME: string;
|
|
10
|
+
name: string;
|
|
11
|
+
id: string;
|
|
12
|
+
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
|
13
|
+
setID(id: any): void;
|
|
14
|
+
getID(): string;
|
|
15
|
+
getName(): string;
|
|
16
|
+
setName(name: any): void;
|
|
17
|
+
getPort(): any;
|
|
18
|
+
getProtocolName(): string;
|
|
19
|
+
getSupportedCyclingModes(): Array<any>;
|
|
20
|
+
getDefaultCyclingMode(): CyclingMode;
|
|
21
|
+
check(): Promise<boolean>;
|
|
22
|
+
pause(): Promise<boolean>;
|
|
23
|
+
resume(): Promise<boolean>;
|
|
24
|
+
startRide(props: DaumClassicDeviceProperties): Promise<boolean>;
|
|
25
|
+
start(props: DaumClassicDeviceProperties): Promise<boolean>;
|
|
26
|
+
launch(props: DaumClassicDeviceProperties, isRelaunch?: boolean): Promise<boolean>;
|
|
27
|
+
performStart(props?: DaumClassicDeviceProperties, isRelaunch?: boolean): Promise<unknown>;
|
|
28
|
+
getCurrentBikeData(): any;
|
|
29
|
+
}
|