incyclist-devices 1.5.38 → 2.0.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/README.MD +238 -0
- package/lib/adapters.d.ts +7 -0
- package/lib/adapters.js +49 -0
- package/lib/antv2/adapter-factory.d.ts +21 -10
- package/lib/antv2/adapter-factory.js +51 -33
- package/lib/antv2/adapter.d.ts +65 -0
- package/lib/antv2/adapter.js +310 -0
- package/lib/antv2/ant-interface.d.ts +17 -11
- package/lib/antv2/ant-interface.js +41 -31
- package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +1 -1
- package/lib/antv2/{ant-binding.js → binding.js} +1 -1
- package/lib/antv2/fe/adapter.d.ts +28 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +106 -90
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +15 -0
- package/lib/antv2/hr/adapter.js +76 -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 +24 -0
- package/lib/antv2/pwr/adapter.js +141 -0
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/sensor-factory.d.ts +2 -2
- package/lib/antv2/types.d.ts +22 -0
- package/lib/antv2/types.js +5 -0
- package/lib/antv2/utils.d.ts +4 -0
- package/lib/antv2/utils.js +192 -0
- package/lib/base/adpater.d.ts +68 -0
- package/lib/base/adpater.js +183 -0
- package/lib/ble/adapter-factory.d.ts +33 -0
- package/lib/ble/adapter-factory.js +105 -0
- package/lib/ble/base/adapter.d.ts +53 -0
- package/lib/ble/base/adapter.js +290 -0
- package/lib/ble/base/comms-utils.d.ts +7 -0
- package/lib/ble/base/comms-utils.js +91 -0
- package/lib/ble/{ble-device.d.ts → base/comms.d.ts} +31 -16
- package/lib/ble/{ble-device.js → base/comms.js} +193 -55
- package/lib/ble/bindings/index.d.ts +2 -0
- package/lib/ble/bindings/index.js +8 -0
- package/lib/ble/bindings/linux.d.ts +15 -0
- package/lib/ble/bindings/linux.js +39 -0
- package/lib/ble/bindings/mock.d.ts +9 -0
- package/lib/ble/bindings/mock.js +108 -0
- package/lib/ble/bindings/types.d.ts +57 -0
- package/lib/ble/bindings/types.js +96 -0
- package/lib/ble/ble-interface.d.ts +38 -59
- package/lib/ble/ble-interface.js +254 -462
- package/lib/ble/ble-peripheral.d.ts +7 -5
- package/lib/ble/ble-peripheral.js +52 -21
- package/lib/ble/consts.d.ts +3 -0
- package/lib/ble/consts.js +4 -1
- package/lib/ble/cp/adapter.d.ts +22 -0
- package/lib/ble/cp/adapter.js +111 -0
- package/lib/ble/cp/comm.d.ts +31 -0
- package/lib/ble/cp/comm.js +125 -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 +19 -0
- package/lib/ble/elite/adapter.js +120 -0
- package/lib/ble/elite/comms.d.ts +32 -0
- package/lib/ble/elite/comms.js +126 -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 +22 -0
- package/lib/ble/fm/adapter.js +249 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +34 -277
- 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 +30 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +14 -0
- package/lib/ble/hr/adapter.js +45 -0
- package/lib/ble/hr/comm.d.ts +19 -0
- package/lib/ble/hr/comm.js +56 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/mock.d.ts +7 -0
- package/lib/ble/hr/mock.js +47 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +9 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/peripheral-cache.d.ts +43 -0
- package/lib/ble/peripheral-cache.js +107 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +99 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +11 -43
- package/lib/ble/{tacx.js → tacx/comms.js} +23 -155
- 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 +128 -0
- package/lib/ble/types.js +2 -0
- package/lib/ble/utils.d.ts +17 -0
- package/lib/ble/utils.js +54 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +95 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +11 -44
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +29 -129
- 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/index.d.ts +15 -0
- package/lib/index.js +34 -0
- package/lib/interfaces.d.ts +7 -0
- package/lib/interfaces.js +27 -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 +8 -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 +21 -0
- package/lib/serial/adapter.js +61 -0
- package/lib/serial/bindings/tcp.d.ts +45 -0
- package/lib/serial/bindings/tcp.js +284 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +14 -23
- package/lib/{daum → serial/daum}/DaumAdapter.js +57 -97
- 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 +25 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +107 -47
- 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} +215 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +289 -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 +14 -28
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +102 -169
- 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 +60 -0
- package/lib/serial/serial-interface.js +309 -0
- package/lib/simulator/Simulator.d.ts +12 -25
- package/lib/simulator/Simulator.js +26 -87
- package/lib/types/adapter.d.ts +39 -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 +32 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +18 -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 +16 -14
- 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/antv2/pwr.js +0 -171
- package/lib/ble/ble.d.ts +0 -129
- package/lib/ble/ble.js +0 -86
- 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/device.d.ts +0 -94
- package/lib/device.js +0 -76
- 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/{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
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { INTERFACE } from './types/device';
|
|
2
|
+
import InterfaceFactory from './interfaces';
|
|
3
|
+
import AdapterFactory from './adapters';
|
|
4
|
+
import { IncyclistInterface, InterfaceProps } from './types/interface';
|
|
5
|
+
import { IncyclistDeviceAdapter, Bike as Controllable } from './types/adapter';
|
|
6
|
+
import { ControllableDevice as ControllableDeviceAdapter } from './base/adpater';
|
|
7
|
+
import { IncyclistCapability } from './types/capabilities';
|
|
8
|
+
import { DeviceData } from './types/data';
|
|
9
|
+
import { DeviceSettings } from './types/device';
|
|
10
|
+
import CyclingMode from './modes/cycling-mode';
|
|
11
|
+
export * from './modes/cycling-mode';
|
|
12
|
+
export * from './serial';
|
|
13
|
+
export * from './ble';
|
|
14
|
+
export * from './antv2';
|
|
15
|
+
export { IncyclistInterface, INTERFACE, InterfaceFactory, InterfaceProps, DeviceSettings, CyclingMode, AdapterFactory, IncyclistDeviceAdapter, Controllable, ControllableDeviceAdapter, DeviceData, IncyclistCapability, };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.IncyclistCapability = exports.ControllableDeviceAdapter = exports.AdapterFactory = exports.InterfaceFactory = exports.INTERFACE = void 0;
|
|
21
|
+
const device_1 = require("./types/device");
|
|
22
|
+
Object.defineProperty(exports, "INTERFACE", { enumerable: true, get: function () { return device_1.INTERFACE; } });
|
|
23
|
+
const interfaces_1 = __importDefault(require("./interfaces"));
|
|
24
|
+
exports.InterfaceFactory = interfaces_1.default;
|
|
25
|
+
const adapters_1 = __importDefault(require("./adapters"));
|
|
26
|
+
exports.AdapterFactory = adapters_1.default;
|
|
27
|
+
const adpater_1 = require("./base/adpater");
|
|
28
|
+
Object.defineProperty(exports, "ControllableDeviceAdapter", { enumerable: true, get: function () { return adpater_1.ControllableDevice; } });
|
|
29
|
+
const capabilities_1 = require("./types/capabilities");
|
|
30
|
+
Object.defineProperty(exports, "IncyclistCapability", { enumerable: true, get: function () { return capabilities_1.IncyclistCapability; } });
|
|
31
|
+
__exportStar(require("./modes/cycling-mode"), exports);
|
|
32
|
+
__exportStar(require("./serial"), exports);
|
|
33
|
+
__exportStar(require("./ble"), exports);
|
|
34
|
+
__exportStar(require("./antv2"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InterfaceProps } from "./types/interface";
|
|
2
|
+
import { SerialInterface } from "./serial";
|
|
3
|
+
import AntInterface from "./antv2/ant-interface";
|
|
4
|
+
import { BleInterface } from "./ble";
|
|
5
|
+
export default class InterfaceFactory {
|
|
6
|
+
static create(ifaceName: string, props?: InterfaceProps): AntInterface | BleInterface | SerialInterface;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const serial_1 = require("./serial");
|
|
7
|
+
const ant_interface_1 = __importDefault(require("./antv2/ant-interface"));
|
|
8
|
+
const device_1 = require("./types/device");
|
|
9
|
+
const ble_1 = require("./ble");
|
|
10
|
+
class InterfaceFactory {
|
|
11
|
+
static create(ifaceName, props) {
|
|
12
|
+
switch (ifaceName) {
|
|
13
|
+
case device_1.INTERFACE.SERIAL:
|
|
14
|
+
case device_1.INTERFACE.TCPIP:
|
|
15
|
+
const serialProps = props;
|
|
16
|
+
serialProps.ifaceName = ifaceName;
|
|
17
|
+
return serial_1.SerialInterface.getInstance(serialProps);
|
|
18
|
+
case device_1.INTERFACE.ANT:
|
|
19
|
+
const antProps = props;
|
|
20
|
+
return ant_interface_1.default.getInstance(antProps);
|
|
21
|
+
case device_1.INTERFACE.BLE:
|
|
22
|
+
const bleProps = props;
|
|
23
|
+
return ble_1.BleInterface.getInstance(bleProps);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = InterfaceFactory;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import PowerBasedCyclingModeBase from "
|
|
1
|
+
import { IncyclistDeviceAdapter } from "../types/adapter";
|
|
2
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "./cycling-mode";
|
|
3
|
+
import PowerBasedCyclingModeBase from "./power-base";
|
|
4
4
|
export default class BleERGCyclingMode extends PowerBasedCyclingModeBase implements CyclingMode {
|
|
5
5
|
static isERG: boolean;
|
|
6
6
|
prevRequest: UpdateRequest;
|
|
7
7
|
hasBikeUpdate: boolean;
|
|
8
8
|
chain: number[];
|
|
9
9
|
cassette: number[];
|
|
10
|
-
constructor(adapter:
|
|
10
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: any);
|
|
11
11
|
getName(): string;
|
|
12
12
|
getDescription(): string;
|
|
13
13
|
getProperties(): CyclingModeProperty[];
|
|
@@ -3,8 +3,8 @@ 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 power_base_1 = __importDefault(require("
|
|
6
|
+
const cycling_mode_1 = require("./cycling-mode");
|
|
7
|
+
const power_base_1 = __importDefault(require("./power-base"));
|
|
8
8
|
const config = {
|
|
9
9
|
name: "ERG",
|
|
10
10
|
description: "Calculates speed based on power and slope. Power targets are set by workout or remain stable throughout the workout",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "../cycling-mode";
|
|
2
|
-
import { DeviceAdapter } from "../device";
|
|
1
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "../modes/cycling-mode";
|
|
3
2
|
import PowerBasedCyclingModeBase from "../modes/power-base";
|
|
3
|
+
import { IncyclistDeviceAdapter } from "../types/adapter";
|
|
4
4
|
export default class FtmsCyclingMode extends PowerBasedCyclingModeBase implements CyclingMode {
|
|
5
5
|
prevRequest: UpdateRequest;
|
|
6
6
|
hasBikeUpdate: boolean;
|
|
7
|
-
constructor(adapter:
|
|
7
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: any);
|
|
8
8
|
getName(): string;
|
|
9
9
|
getDescription(): string;
|
|
10
10
|
getProperties(): CyclingModeProperty[];
|
|
@@ -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 cycling_mode_1 = require("../cycling-mode");
|
|
6
|
+
const cycling_mode_1 = require("../modes/cycling-mode");
|
|
7
7
|
const power_base_1 = __importDefault(require("../modes/power-base"));
|
|
8
8
|
const config = {
|
|
9
9
|
name: "Smart Trainer",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { IncyclistDeviceAdapter } from "../types/adapter";
|
|
2
|
+
export type UpdateRequest = {
|
|
3
3
|
slope?: number;
|
|
4
4
|
minPower?: number;
|
|
5
5
|
maxPower?: number;
|
|
@@ -17,7 +17,7 @@ export declare enum CyclingModeProperyType {
|
|
|
17
17
|
SingleSelect = "SingleSelect",
|
|
18
18
|
MultiSelect = "MultiSelect"
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export type CyclingModeProperty = {
|
|
21
21
|
key: string;
|
|
22
22
|
name: string;
|
|
23
23
|
description: string;
|
|
@@ -27,7 +27,7 @@ export declare type CyclingModeProperty = {
|
|
|
27
27
|
default?: any;
|
|
28
28
|
options?: any[];
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type IncyclistBikeData = {
|
|
31
31
|
isPedalling: boolean;
|
|
32
32
|
power: number;
|
|
33
33
|
pedalRpm: number;
|
|
@@ -38,7 +38,7 @@ export declare type IncyclistBikeData = {
|
|
|
38
38
|
gear?: number;
|
|
39
39
|
slope?: number;
|
|
40
40
|
};
|
|
41
|
-
export
|
|
41
|
+
export type Settings = {
|
|
42
42
|
[key: string]: any;
|
|
43
43
|
};
|
|
44
44
|
export default interface CyclingMode {
|
|
@@ -57,11 +57,11 @@ export default interface CyclingMode {
|
|
|
57
57
|
getModeProperty(name: string): any;
|
|
58
58
|
}
|
|
59
59
|
export declare class CyclingModeBase implements CyclingMode {
|
|
60
|
-
adapter:
|
|
60
|
+
adapter: IncyclistDeviceAdapter;
|
|
61
61
|
settings: Settings;
|
|
62
62
|
properties: Settings;
|
|
63
|
-
constructor(adapter:
|
|
64
|
-
setAdapter(adapter:
|
|
63
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: any);
|
|
64
|
+
setAdapter(adapter: IncyclistDeviceAdapter): void;
|
|
65
65
|
getBikeInitRequest(): UpdateRequest;
|
|
66
66
|
getName(): string;
|
|
67
67
|
getDescription(): string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IncyclistBikeData, Settings, CyclingModeBase } from '
|
|
2
|
-
import { DeviceAdapter } from '../device';
|
|
1
|
+
import { IncyclistBikeData, Settings, CyclingModeBase } from './cycling-mode';
|
|
3
2
|
import { EventLogger } from 'gd-eventlog';
|
|
3
|
+
import { IncyclistDeviceAdapter } from '../types/adapter';
|
|
4
4
|
export default class PowerBasedCyclingModeBase extends CyclingModeBase {
|
|
5
5
|
data: IncyclistBikeData;
|
|
6
6
|
prevUpdateTS: number;
|
|
7
7
|
logger: EventLogger;
|
|
8
|
-
constructor(adapter:
|
|
8
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: Settings);
|
|
9
9
|
initLogger(defaultLogName: any): void;
|
|
10
10
|
getWeight(): any;
|
|
11
11
|
getTimeSinceLastUpdate(): number;
|
package/lib/modes/power-base.js
CHANGED
|
@@ -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
|
|
8
|
-
const calculations_1 = __importDefault(require("../calculations"));
|
|
6
|
+
const cycling_mode_1 = require("./cycling-mode");
|
|
7
|
+
const adpater_1 = require("../base/adpater");
|
|
8
|
+
const calculations_1 = __importDefault(require("../utils/calculations"));
|
|
9
9
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
10
10
|
class PowerBasedCyclingModeBase extends cycling_mode_1.CyclingModeBase {
|
|
11
11
|
constructor(adapter, props) {
|
|
@@ -21,7 +21,7 @@ class PowerBasedCyclingModeBase extends cycling_mode_1.CyclingModeBase {
|
|
|
21
21
|
}
|
|
22
22
|
getWeight() {
|
|
23
23
|
const a = this.adapter;
|
|
24
|
-
const m = (a && a.getWeight && a.getWeight()) ? a.getWeight() :
|
|
24
|
+
const m = (a && a.getWeight && a.getWeight()) ? a.getWeight() : adpater_1.DEFAULT_BIKE_WEIGHT + adpater_1.DEFAULT_USER_WEIGHT;
|
|
25
25
|
return m;
|
|
26
26
|
}
|
|
27
27
|
getTimeSinceLastUpdate() {
|
|
@@ -35,6 +35,10 @@ class PowerBasedCyclingModeBase extends cycling_mode_1.CyclingModeBase {
|
|
|
35
35
|
const vPrev = (prevData.speed || 0) / 3.6;
|
|
36
36
|
const EkinPrev = 1 / 2 * m * vPrev * vPrev;
|
|
37
37
|
let powerToMaintainSpeed = calculations_1.default.calculatePower(m, vPrev, slope, props);
|
|
38
|
+
if (t >= 30) {
|
|
39
|
+
const speed = calculations_1.default.calculateSpeed(m, power, slope, props);
|
|
40
|
+
return { speed, distance: 0 };
|
|
41
|
+
}
|
|
38
42
|
const powerDelta = powerToMaintainSpeed - power;
|
|
39
43
|
const Ekin = EkinPrev - powerDelta * t;
|
|
40
44
|
if (Ekin > 0) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from '../cycling-mode';
|
|
1
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from '../modes/cycling-mode';
|
|
2
2
|
import PowerBasedCyclingModeBase from './power-base';
|
|
3
|
-
import {
|
|
3
|
+
import { IncyclistDeviceAdapter } from '../types/adapter';
|
|
4
4
|
export declare const config: {
|
|
5
5
|
name: string;
|
|
6
6
|
description: string;
|
|
7
7
|
properties: any[];
|
|
8
8
|
};
|
|
9
9
|
export default class PowerMeterCyclingMode extends PowerBasedCyclingModeBase implements CyclingMode {
|
|
10
|
-
constructor(adapter:
|
|
10
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: Settings);
|
|
11
11
|
getName(): string;
|
|
12
12
|
getDescription(): string;
|
|
13
13
|
getProperties(): CyclingModeProperty[];
|
package/lib/modes/simulator.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EventLogger } from "gd-eventlog";
|
|
2
|
-
import { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "../cycling-mode";
|
|
2
|
+
import { CyclingModeProperty, IncyclistBikeData, UpdateRequest } from "../modes/cycling-mode";
|
|
3
3
|
import { Simulator } from "../simulator/Simulator";
|
|
4
4
|
import PowerBasedCyclingModeBase from "./power-base";
|
|
5
|
-
export
|
|
5
|
+
export type ERGEvent = {
|
|
6
6
|
rpmUpdated?: boolean;
|
|
7
7
|
gearUpdated?: boolean;
|
|
8
8
|
starting?: boolean;
|
package/lib/modes/simulator.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
7
|
-
const cycling_mode_1 = require("../cycling-mode");
|
|
7
|
+
const cycling_mode_1 = require("../modes/cycling-mode");
|
|
8
8
|
const power_base_1 = __importDefault(require("./power-base"));
|
|
9
9
|
const MIN_SPEED = 10;
|
|
10
10
|
const config = {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SerialIncyclistDevice, SerialDeviceSettings } from './adapter';
|
|
2
|
+
export default class SerialAdapterFactory {
|
|
3
|
+
static _instance: SerialAdapterFactory;
|
|
4
|
+
adapters: {
|
|
5
|
+
protocol: string;
|
|
6
|
+
AdapterClass: typeof SerialIncyclistDevice;
|
|
7
|
+
}[];
|
|
8
|
+
static getInstance(): SerialAdapterFactory;
|
|
9
|
+
constructor();
|
|
10
|
+
registerAdapter(protocol: string, AdapterClass: typeof SerialIncyclistDevice): void;
|
|
11
|
+
createInstance(props: SerialDeviceSettings, settings?: any): SerialIncyclistDevice;
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class SerialAdapterFactory {
|
|
4
|
+
static getInstance() {
|
|
5
|
+
if (!SerialAdapterFactory._instance)
|
|
6
|
+
SerialAdapterFactory._instance = new SerialAdapterFactory();
|
|
7
|
+
return SerialAdapterFactory._instance;
|
|
8
|
+
}
|
|
9
|
+
constructor() {
|
|
10
|
+
this.adapters = [];
|
|
11
|
+
}
|
|
12
|
+
registerAdapter(protocol, AdapterClass) {
|
|
13
|
+
const existing = this.adapters.findIndex(a => a.protocol === protocol);
|
|
14
|
+
if (existing !== -1)
|
|
15
|
+
this.adapters[existing].AdapterClass = AdapterClass;
|
|
16
|
+
else
|
|
17
|
+
this.adapters.push({ protocol, AdapterClass });
|
|
18
|
+
}
|
|
19
|
+
createInstance(props, settings) {
|
|
20
|
+
const { protocol } = props;
|
|
21
|
+
if (!protocol)
|
|
22
|
+
return null;
|
|
23
|
+
const adapter = this.adapters.find(a => a.protocol === protocol);
|
|
24
|
+
if (!adapter)
|
|
25
|
+
return null;
|
|
26
|
+
const { AdapterClass } = adapter;
|
|
27
|
+
return new AdapterClass(props, settings);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = SerialAdapterFactory;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DeviceProperties, DeviceSettings } from "../types/device";
|
|
2
|
+
import { ControllableDevice } from "../base/adpater";
|
|
3
|
+
import SerialInterface from "./serial-interface";
|
|
4
|
+
export interface SerialDeviceSettings extends DeviceSettings {
|
|
5
|
+
protocol: string;
|
|
6
|
+
host?: string;
|
|
7
|
+
port?: string;
|
|
8
|
+
interface: string | SerialInterface;
|
|
9
|
+
}
|
|
10
|
+
export declare class SerialIncyclistDevice extends ControllableDevice {
|
|
11
|
+
pullFrequency: number;
|
|
12
|
+
check(): Promise<boolean>;
|
|
13
|
+
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
|
14
|
+
isEqual(settings: SerialDeviceSettings): boolean;
|
|
15
|
+
getPort(): string;
|
|
16
|
+
getUniqueName(): string;
|
|
17
|
+
getInterface(): string;
|
|
18
|
+
setMaxUpdateFrequency(ms: number): void;
|
|
19
|
+
setPullFrequency(ms: number): void;
|
|
20
|
+
getPullFrequency(): number;
|
|
21
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SerialIncyclistDevice = void 0;
|
|
13
|
+
const adpater_1 = require("../base/adpater");
|
|
14
|
+
const DEFAULT_PULL_FREQUENCY = 1000;
|
|
15
|
+
class SerialIncyclistDevice extends adpater_1.ControllableDevice {
|
|
16
|
+
check() {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () { throw new Error('not implemnted'); });
|
|
18
|
+
}
|
|
19
|
+
;
|
|
20
|
+
constructor(settings, props) {
|
|
21
|
+
super(settings, props);
|
|
22
|
+
this.pullFrequency = DEFAULT_PULL_FREQUENCY;
|
|
23
|
+
}
|
|
24
|
+
isEqual(settings) {
|
|
25
|
+
if (settings.interface !== this.getInterface())
|
|
26
|
+
return false;
|
|
27
|
+
const s = this.settings;
|
|
28
|
+
if (settings.protocol !== s.protocol)
|
|
29
|
+
return false;
|
|
30
|
+
if (settings.port !== s.port)
|
|
31
|
+
return false;
|
|
32
|
+
if (settings.host && (!s.host || s.host !== settings.host))
|
|
33
|
+
return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
getPort() {
|
|
37
|
+
const settings = this.settings;
|
|
38
|
+
return settings.port;
|
|
39
|
+
}
|
|
40
|
+
getUniqueName() {
|
|
41
|
+
return `${this.getName()} (${this.getPort()})`;
|
|
42
|
+
}
|
|
43
|
+
getInterface() {
|
|
44
|
+
return 'serial';
|
|
45
|
+
}
|
|
46
|
+
setMaxUpdateFrequency(ms) {
|
|
47
|
+
if (ms <= this.pullFrequency)
|
|
48
|
+
this.updateFrequency = -1;
|
|
49
|
+
else
|
|
50
|
+
this.updateFrequency = ms;
|
|
51
|
+
}
|
|
52
|
+
setPullFrequency(ms) {
|
|
53
|
+
this.pullFrequency = ms;
|
|
54
|
+
if (this.updateFrequency <= this.pullFrequency)
|
|
55
|
+
this.updateFrequency = -1;
|
|
56
|
+
}
|
|
57
|
+
getPullFrequency() {
|
|
58
|
+
return this.pullFrequency;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.SerialIncyclistDevice = SerialIncyclistDevice;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { BindingPortInterface, OpenOptions, PortStatus, PortInfo, SetOptions, UpdateOptions, BindingInterface } from "@serialport/bindings-interface";
|
|
4
|
+
import { EventLogger } from 'gd-eventlog';
|
|
5
|
+
import net from 'net';
|
|
6
|
+
export interface TCPOpenOptions extends OpenOptions {
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare interface TCPBindingInterface<T extends BindingPortInterface = BindingPortInterface, R extends OpenOptions = OpenOptions, P extends PortInfo = PortInfo> extends BindingInterface<TCPPortBinding, TCPOpenOptions> {
|
|
10
|
+
list(port?: number): Promise<P[]>;
|
|
11
|
+
}
|
|
12
|
+
export declare class CanceledError extends Error {
|
|
13
|
+
canceled: true;
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
export declare function scanPort(host: string, port: number): Promise<boolean>;
|
|
17
|
+
export declare function scanSubNet(sn: string, port: number): Promise<string[]>;
|
|
18
|
+
export declare function getSubnets(): string[];
|
|
19
|
+
export declare const TCPBinding: TCPBindingInterface;
|
|
20
|
+
export declare class TCPPortBinding implements BindingPortInterface {
|
|
21
|
+
openOptions: Required<OpenOptions>;
|
|
22
|
+
socket: any;
|
|
23
|
+
logger: EventLogger;
|
|
24
|
+
writeOperation: null | Promise<any>;
|
|
25
|
+
data: Buffer;
|
|
26
|
+
private pendingRead;
|
|
27
|
+
constructor(socket: net.Socket, options: Required<OpenOptions>);
|
|
28
|
+
get isOpen(): boolean;
|
|
29
|
+
onData(data: Buffer): void;
|
|
30
|
+
onError(err: Error): void;
|
|
31
|
+
close(): Promise<void>;
|
|
32
|
+
read(buffer: Buffer, offset: number, length: number): Promise<{
|
|
33
|
+
buffer: Buffer;
|
|
34
|
+
bytesRead: number;
|
|
35
|
+
}>;
|
|
36
|
+
write(buffer: Buffer): Promise<void>;
|
|
37
|
+
update(options: UpdateOptions): Promise<void>;
|
|
38
|
+
set(options: SetOptions): Promise<void>;
|
|
39
|
+
get(): Promise<PortStatus>;
|
|
40
|
+
getBaudRate(): Promise<{
|
|
41
|
+
baudRate: number;
|
|
42
|
+
}>;
|
|
43
|
+
flush(): Promise<void>;
|
|
44
|
+
drain(): Promise<void>;
|
|
45
|
+
}
|