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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
|
|
3
|
+
import { BindingInterface } from '@serialport/bindings-interface';
|
|
4
|
+
export type MockProps = {
|
|
5
|
+
interface: string;
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
8
|
+
export interface DaumClassicMockBindingInterface extends BindingInterface<DaumClassicMockBinding> {
|
|
9
|
+
reset(): void;
|
|
10
|
+
createPort(path: string, opt?: CreatePortOptions): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const DaumClassicMock: MockBindingInterface;
|
|
13
|
+
export declare class DaumClassicMockImpl {
|
|
14
|
+
static _instance: DaumClassicMockImpl;
|
|
15
|
+
static getInstance(): DaumClassicMockImpl;
|
|
16
|
+
static reset(): void;
|
|
17
|
+
simulators: Map<string, DaumClassicSimulator>;
|
|
18
|
+
ports: {
|
|
19
|
+
path: string;
|
|
20
|
+
binding: DaumClassicMockBinding;
|
|
21
|
+
}[];
|
|
22
|
+
constructor();
|
|
23
|
+
setSimulator(path: string, simulator: DaumClassicSimulator): void;
|
|
24
|
+
getSimulator(path: any): DaumClassicSimulator;
|
|
25
|
+
reset(): void;
|
|
26
|
+
createPort(path: string, options?: CreatePortOptions): void;
|
|
27
|
+
list(): Promise<import("@serialport/bindings-interface").PortInfo[]>;
|
|
28
|
+
open(options: any): Promise<DaumClassicMockBinding>;
|
|
29
|
+
}
|
|
30
|
+
export type DaumClassicUser = {
|
|
31
|
+
weight: number;
|
|
32
|
+
length?: number;
|
|
33
|
+
age?: number;
|
|
34
|
+
sex?: number;
|
|
35
|
+
personNo?: number;
|
|
36
|
+
pctFat?: number;
|
|
37
|
+
coachingLevel?: number;
|
|
38
|
+
coachingFrequency?: number;
|
|
39
|
+
powerLimit?: number;
|
|
40
|
+
hrLimit?: number;
|
|
41
|
+
timeLimit?: number;
|
|
42
|
+
distLimit?: number;
|
|
43
|
+
kcalLimit?: number;
|
|
44
|
+
};
|
|
45
|
+
interface BikeData {
|
|
46
|
+
cockpitVersion: number;
|
|
47
|
+
isPedalling: boolean;
|
|
48
|
+
bikeType: number;
|
|
49
|
+
person: DaumClassicUser;
|
|
50
|
+
}
|
|
51
|
+
export declare class DaumClassicSimulator {
|
|
52
|
+
selectedBike: number;
|
|
53
|
+
bikes: BikeData[];
|
|
54
|
+
cadence: number;
|
|
55
|
+
gear: number;
|
|
56
|
+
slope: number;
|
|
57
|
+
progNo: number;
|
|
58
|
+
heartrate: number;
|
|
59
|
+
distance: number;
|
|
60
|
+
isPowerMode: boolean;
|
|
61
|
+
targetPower: number;
|
|
62
|
+
currentPower: number;
|
|
63
|
+
_timeoutResponse: number;
|
|
64
|
+
_simulateNoReponseCnt: number;
|
|
65
|
+
_simulateIllegalResponseCnt: number;
|
|
66
|
+
constructor();
|
|
67
|
+
reset(): void;
|
|
68
|
+
simulateTimeout(ms: number): void;
|
|
69
|
+
simulateNoResponse(cnt?: number): void;
|
|
70
|
+
simulateIllegalResponse(cnt?: number): void;
|
|
71
|
+
isPedalling(): 0 | 1;
|
|
72
|
+
}
|
|
73
|
+
export declare class DaumClassicMockBinding extends MockPortBinding {
|
|
74
|
+
prevCommand: Buffer;
|
|
75
|
+
simulator: DaumClassicSimulator;
|
|
76
|
+
handlers: Map<number, (payload: Buffer) => void>;
|
|
77
|
+
constructor(parent: MockPortBinding);
|
|
78
|
+
getPath(): string;
|
|
79
|
+
initHandlers(): void;
|
|
80
|
+
write(buffer: Buffer): Promise<void>;
|
|
81
|
+
emitData(data: string | Buffer): void;
|
|
82
|
+
onCheckCockpit(payload: Buffer): void;
|
|
83
|
+
onGetAddress(_payload: Buffer): void;
|
|
84
|
+
onGetVersion(payload: Buffer): void;
|
|
85
|
+
onResetDevice(payload: Buffer): void;
|
|
86
|
+
onStartProg(payload: Buffer): void;
|
|
87
|
+
onStopProg(payload: Buffer): void;
|
|
88
|
+
onSetProg(payload: Buffer): void;
|
|
89
|
+
onSetBikeType(payload: Buffer): void;
|
|
90
|
+
onSetPerson(payload: Buffer): void;
|
|
91
|
+
onRunData(payload: Buffer): void;
|
|
92
|
+
onSetGear(payload: Buffer): void;
|
|
93
|
+
onSetPower(payload: Buffer): void;
|
|
94
|
+
onSetSlope(payload: Buffer): void;
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,365 @@
|
|
|
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.DaumClassicMockBinding = exports.DaumClassicSimulator = exports.DaumClassicMockImpl = exports.DaumClassicMock = void 0;
|
|
16
|
+
const binding_mock_1 = require("@serialport/binding-mock");
|
|
17
|
+
const __1 = require("../../");
|
|
18
|
+
const utils_1 = require("../../../utils/utils");
|
|
19
|
+
const calculations_1 = __importDefault(require("../../../utils/calculations"));
|
|
20
|
+
exports.DaumClassicMock = {
|
|
21
|
+
reset() {
|
|
22
|
+
DaumClassicMockImpl.getInstance().reset();
|
|
23
|
+
},
|
|
24
|
+
createPort(path, options = {}) {
|
|
25
|
+
return DaumClassicMockImpl.getInstance().createPort(path, options);
|
|
26
|
+
},
|
|
27
|
+
list() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return DaumClassicMockImpl.getInstance().list();
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
open(options) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return DaumClassicMockImpl.getInstance().open(options);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
class DaumClassicMockImpl {
|
|
39
|
+
static getInstance() {
|
|
40
|
+
if (!DaumClassicMockImpl._instance)
|
|
41
|
+
DaumClassicMockImpl._instance = new DaumClassicMockImpl();
|
|
42
|
+
return DaumClassicMockImpl._instance;
|
|
43
|
+
}
|
|
44
|
+
static reset() {
|
|
45
|
+
DaumClassicMockImpl._instance = undefined;
|
|
46
|
+
__1.SerialPortProvider._instance = undefined;
|
|
47
|
+
__1.SerialInterface._instances = [];
|
|
48
|
+
}
|
|
49
|
+
constructor() {
|
|
50
|
+
this.simulators = new Map();
|
|
51
|
+
this.ports = [];
|
|
52
|
+
}
|
|
53
|
+
setSimulator(path, simulator) {
|
|
54
|
+
this.simulators.set(path, simulator);
|
|
55
|
+
}
|
|
56
|
+
getSimulator(path) {
|
|
57
|
+
return this.simulators.get(path);
|
|
58
|
+
}
|
|
59
|
+
reset() {
|
|
60
|
+
binding_mock_1.MockBinding.reset();
|
|
61
|
+
}
|
|
62
|
+
createPort(path, options = {}) {
|
|
63
|
+
return binding_mock_1.MockBinding.createPort(path, options);
|
|
64
|
+
}
|
|
65
|
+
list() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return binding_mock_1.MockBinding.list();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
open(options) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const port = yield binding_mock_1.MockBinding.open(options);
|
|
73
|
+
return new DaumClassicMockBinding(port);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.DaumClassicMockImpl = DaumClassicMockImpl;
|
|
78
|
+
const DEFAULT_BIKE_DATA = {
|
|
79
|
+
cockpitVersion: 3,
|
|
80
|
+
isPedalling: false,
|
|
81
|
+
bikeType: 0,
|
|
82
|
+
person: { weight: 75, length: 180, age: 30, sex: 0 }
|
|
83
|
+
};
|
|
84
|
+
class DaumClassicSimulator {
|
|
85
|
+
constructor() {
|
|
86
|
+
this.selectedBike = 0;
|
|
87
|
+
this.bikes = [];
|
|
88
|
+
this._timeoutResponse = 0;
|
|
89
|
+
this._simulateNoReponseCnt = 0;
|
|
90
|
+
this._simulateIllegalResponseCnt = 0;
|
|
91
|
+
for (let i = 0; i < 10; i++)
|
|
92
|
+
this.bikes.push(Object.assign({}, DEFAULT_BIKE_DATA));
|
|
93
|
+
this.reset();
|
|
94
|
+
}
|
|
95
|
+
reset() {
|
|
96
|
+
this.cadence = 0;
|
|
97
|
+
this.slope = 0;
|
|
98
|
+
this.gear = 1;
|
|
99
|
+
this.progNo = 0;
|
|
100
|
+
this.heartrate = 0;
|
|
101
|
+
this.distance = 0;
|
|
102
|
+
this.targetPower = 25;
|
|
103
|
+
this.currentPower = 25;
|
|
104
|
+
this.isPowerMode = false;
|
|
105
|
+
this._timeoutResponse = 0;
|
|
106
|
+
this._simulateNoReponseCnt = 0;
|
|
107
|
+
this._simulateIllegalResponseCnt = 0;
|
|
108
|
+
}
|
|
109
|
+
simulateTimeout(ms) {
|
|
110
|
+
this._timeoutResponse = ms;
|
|
111
|
+
}
|
|
112
|
+
simulateNoResponse(cnt = 1) {
|
|
113
|
+
this._simulateNoReponseCnt += cnt;
|
|
114
|
+
}
|
|
115
|
+
simulateIllegalResponse(cnt = 1) {
|
|
116
|
+
this._simulateIllegalResponseCnt += cnt;
|
|
117
|
+
}
|
|
118
|
+
isPedalling() {
|
|
119
|
+
if (this.cadence && this.cadence > 0)
|
|
120
|
+
return 1;
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.DaumClassicSimulator = DaumClassicSimulator;
|
|
125
|
+
class DaumClassicMockBinding extends binding_mock_1.MockPortBinding {
|
|
126
|
+
constructor(parent) {
|
|
127
|
+
super(parent.port, parent.openOptions);
|
|
128
|
+
this.prevCommand = null;
|
|
129
|
+
this.simulator = DaumClassicMockImpl.getInstance().getSimulator(this.getPath());
|
|
130
|
+
if (!this.simulator) {
|
|
131
|
+
this.simulator = new DaumClassicSimulator();
|
|
132
|
+
DaumClassicMockImpl.getInstance().setSimulator(this.getPath(), this.simulator);
|
|
133
|
+
}
|
|
134
|
+
this.initHandlers();
|
|
135
|
+
}
|
|
136
|
+
getPath() {
|
|
137
|
+
return this.port.info.path;
|
|
138
|
+
}
|
|
139
|
+
initHandlers() {
|
|
140
|
+
this.handlers = new Map();
|
|
141
|
+
this.handlers.set(0x10, this.onCheckCockpit.bind(this));
|
|
142
|
+
this.handlers.set(0x11, this.onGetAddress.bind(this));
|
|
143
|
+
this.handlers.set(0x73, this.onGetVersion.bind(this));
|
|
144
|
+
this.handlers.set(0x12, this.onResetDevice.bind(this));
|
|
145
|
+
this.handlers.set(0x21, this.onStartProg.bind(this));
|
|
146
|
+
this.handlers.set(0x22, this.onStopProg.bind(this));
|
|
147
|
+
this.handlers.set(0x23, this.onSetProg.bind(this));
|
|
148
|
+
this.handlers.set(0x69, this.onSetBikeType.bind(this));
|
|
149
|
+
this.handlers.set(0x24, this.onSetPerson.bind(this));
|
|
150
|
+
this.handlers.set(0x40, this.onRunData.bind(this));
|
|
151
|
+
this.handlers.set(0x53, this.onSetGear.bind(this));
|
|
152
|
+
this.handlers.set(0x51, this.onSetPower.bind(this));
|
|
153
|
+
this.handlers.set(0x55, this.onSetSlope.bind(this));
|
|
154
|
+
}
|
|
155
|
+
write(buffer) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
158
|
+
throw new TypeError('"buffer" is not a Buffer');
|
|
159
|
+
}
|
|
160
|
+
if (!this.isOpen || !this.port) {
|
|
161
|
+
throw new Error('Port is not open');
|
|
162
|
+
}
|
|
163
|
+
if (this.writeOperation) {
|
|
164
|
+
throw new Error('Overlapping writes are not supported and should be queued by the serialport object');
|
|
165
|
+
}
|
|
166
|
+
if (buffer.length == 0)
|
|
167
|
+
return;
|
|
168
|
+
this.writeOperation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
yield (0, utils_1.resolveNextTick)();
|
|
170
|
+
if (!this.isOpen || !this.port) {
|
|
171
|
+
throw new Error('Write canceled');
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const cmd = buffer.readUInt8(0);
|
|
175
|
+
const handler = this.handlers.get(cmd);
|
|
176
|
+
const payload = buffer.subarray(1);
|
|
177
|
+
if (this.simulator._simulateNoReponseCnt > 0) {
|
|
178
|
+
this.simulator._simulateNoReponseCnt--;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const to = this.simulator._timeoutResponse || 5;
|
|
182
|
+
if (handler)
|
|
183
|
+
setTimeout(() => { handler(payload); }, to);
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
}
|
|
187
|
+
this.writeOperation = null;
|
|
188
|
+
}))();
|
|
189
|
+
return this.writeOperation;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
emitData(data) {
|
|
193
|
+
if (!this.isOpen || !this.port)
|
|
194
|
+
return;
|
|
195
|
+
super.emitData(data);
|
|
196
|
+
}
|
|
197
|
+
onCheckCockpit(payload) {
|
|
198
|
+
const bikeNo = payload.readUInt8(0);
|
|
199
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
200
|
+
const response = Buffer.from([0x10, bikeNo, this.simulator.bikes[bikeNo].cockpitVersion]);
|
|
201
|
+
this.emitData(response);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
onGetAddress(_payload) {
|
|
205
|
+
const response = Buffer.from([0x11, this.simulator.selectedBike]);
|
|
206
|
+
this.emitData(response);
|
|
207
|
+
}
|
|
208
|
+
onGetVersion(payload) {
|
|
209
|
+
const bikeNo = payload.readUInt8(0);
|
|
210
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
211
|
+
const response = Buffer.from([0x73, bikeNo, this.simulator.bikes[bikeNo].cockpitVersion]);
|
|
212
|
+
this.emitData(response);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
onResetDevice(payload) {
|
|
216
|
+
const bikeNo = payload.readUInt8(0);
|
|
217
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
218
|
+
const response = Buffer.from([0x12, bikeNo]);
|
|
219
|
+
this.simulator.bikes[bikeNo] = DEFAULT_BIKE_DATA;
|
|
220
|
+
this.emitData(response);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
onStartProg(payload) {
|
|
224
|
+
const bikeNo = payload.readUInt8(0);
|
|
225
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
226
|
+
const isPedalling = this.simulator.isPedalling();
|
|
227
|
+
const response = Buffer.from([0x21, bikeNo, isPedalling ? 1 : 0]);
|
|
228
|
+
this.emitData(response);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
onStopProg(payload) {
|
|
232
|
+
const bikeNo = payload.readUInt8(0);
|
|
233
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
234
|
+
const isPedalling = this.simulator.isPedalling();
|
|
235
|
+
const response = Buffer.from([0x22, bikeNo, isPedalling]);
|
|
236
|
+
this.emitData(response);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
onSetProg(payload) {
|
|
240
|
+
const bikeNo = payload.readUInt8(0);
|
|
241
|
+
const progNo = payload.readUInt8(1);
|
|
242
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
243
|
+
const isPedalling = this.simulator.isPedalling();
|
|
244
|
+
this.simulator.progNo = progNo;
|
|
245
|
+
const response = Buffer.from([0x23, bikeNo, progNo, isPedalling]);
|
|
246
|
+
this.emitData(response);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
onSetBikeType(payload) {
|
|
250
|
+
const bikeNo = payload.readUInt8(0);
|
|
251
|
+
const bikeType = payload.readUInt8(3);
|
|
252
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
253
|
+
const { isPedalling } = this.simulator.bikes[bikeNo];
|
|
254
|
+
this.simulator.bikes[bikeNo].bikeType = bikeType;
|
|
255
|
+
const response = Buffer.from([0x69, bikeNo, bikeType]);
|
|
256
|
+
this.emitData(response);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
onSetPerson(payload) {
|
|
260
|
+
const bikeNo = payload.readUInt8(0);
|
|
261
|
+
const personNo = payload.readUInt8(1);
|
|
262
|
+
const age = payload.readUInt8(2);
|
|
263
|
+
const sex = payload.readUInt8(3);
|
|
264
|
+
const length = payload.readUint8(4);
|
|
265
|
+
const weight = payload.readUint8(5);
|
|
266
|
+
const pctFat = payload.readUint8(6);
|
|
267
|
+
const coachingLevel = payload.readUint8(7);
|
|
268
|
+
const coachingFrequency = payload.readUint8(8);
|
|
269
|
+
const powerLimit = payload.readUint8(9);
|
|
270
|
+
const hrLimit = payload.readUint8(10);
|
|
271
|
+
const timeLimit = payload.readUint8(11);
|
|
272
|
+
const distLimit = payload.readUint8(12);
|
|
273
|
+
const kcalLimit = payload.readUint8(13);
|
|
274
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
275
|
+
this.simulator.bikes[bikeNo].person = {
|
|
276
|
+
personNo, age, sex, length, weight, pctFat,
|
|
277
|
+
coachingLevel, coachingFrequency, powerLimit,
|
|
278
|
+
hrLimit, timeLimit, distLimit, kcalLimit
|
|
279
|
+
};
|
|
280
|
+
const isPedalling = this.simulator.isPedalling();
|
|
281
|
+
let response;
|
|
282
|
+
if (this.simulator._simulateIllegalResponseCnt > 0) {
|
|
283
|
+
response = Buffer.from([0x24, bikeNo, personNo, age, sex,
|
|
284
|
+
length, weight, pctFat, coachingLevel, coachingFrequency,
|
|
285
|
+
powerLimit + 10, hrLimit, timeLimit, distLimit, kcalLimit,
|
|
286
|
+
isPedalling]);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
response = Buffer.from([0x24, bikeNo, personNo, age, sex,
|
|
290
|
+
length, weight, pctFat, coachingLevel, coachingFrequency,
|
|
291
|
+
powerLimit, hrLimit, timeLimit, distLimit, kcalLimit,
|
|
292
|
+
isPedalling]);
|
|
293
|
+
}
|
|
294
|
+
this.emitData(response);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
onRunData(payload) {
|
|
298
|
+
const { cadence, gear, slope, heartrate, distance, progNo, isPowerMode, currentPower } = this.simulator;
|
|
299
|
+
const bike = this.simulator.bikes[this.simulator.selectedBike];
|
|
300
|
+
const { person, bikeType } = bike;
|
|
301
|
+
const { personNo, weight } = person;
|
|
302
|
+
const bikeNo = payload.readUInt8(0);
|
|
303
|
+
const isPedalling = this.simulator.isPedalling() + 128;
|
|
304
|
+
let speed, power;
|
|
305
|
+
speed = calculations_1.default.calculateSpeedDaum(gear, cadence, bikeType);
|
|
306
|
+
if (isPowerMode) {
|
|
307
|
+
power = currentPower;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
power = calculations_1.default.calculatePower(weight + 10, speed / 3.6, slope, { bikeType });
|
|
311
|
+
}
|
|
312
|
+
if (power < 25)
|
|
313
|
+
power = 25;
|
|
314
|
+
if (cadence === 0)
|
|
315
|
+
power = 0;
|
|
316
|
+
power = Math.round(power / 5);
|
|
317
|
+
const dist1 = distance / 1000 - Math.floor(distance / 1000 / 256);
|
|
318
|
+
const dist2 = Math.floor(distance / 1000 / 256);
|
|
319
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
320
|
+
const response = Buffer.from([0x40, bikeNo, progNo, personNo,
|
|
321
|
+
isPedalling, power, cadence, Math.floor(speed),
|
|
322
|
+
dist1, dist2, 0, 0, 0, 0, heartrate, 0, gear, 0, 0
|
|
323
|
+
]);
|
|
324
|
+
this.emitData(response);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
onSetGear(payload) {
|
|
328
|
+
const bikeNo = payload.readUInt8(0);
|
|
329
|
+
const gear = payload.readUInt8(1);
|
|
330
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
331
|
+
this.simulator.gear = gear;
|
|
332
|
+
const response = Buffer.from([0x53, bikeNo, gear]);
|
|
333
|
+
this.emitData(response);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
onSetPower(payload) {
|
|
337
|
+
const bikeNo = payload.readUInt8(0);
|
|
338
|
+
const power = payload.readUInt8(1);
|
|
339
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
340
|
+
this.simulator.targetPower = power;
|
|
341
|
+
this.simulator.isPowerMode = true;
|
|
342
|
+
setTimeout(() => { this.simulator.currentPower = power; }, 1000);
|
|
343
|
+
const response = Buffer.from([0x51, bikeNo, power]);
|
|
344
|
+
this.emitData(response);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
onSetSlope(payload) {
|
|
348
|
+
const bike = this.simulator.bikes[this.simulator.selectedBike];
|
|
349
|
+
const { person } = bike;
|
|
350
|
+
const { personNo } = person;
|
|
351
|
+
const { currentPower, cadence } = this.simulator;
|
|
352
|
+
const bikeNo = payload.readUInt8(0);
|
|
353
|
+
const slope = payload.readFloatLE(1);
|
|
354
|
+
const retVal0 = payload.readUInt8(1);
|
|
355
|
+
const isPedalling = this.simulator.isPedalling() + 128;
|
|
356
|
+
const power = cadence > 0 ? Math.floor(currentPower / 5) : 0;
|
|
357
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
358
|
+
this.simulator.slope = slope;
|
|
359
|
+
this.simulator.isPowerMode = false;
|
|
360
|
+
const response = Buffer.from([0x55, bikeNo, retVal0, personNo, isPedalling, power]);
|
|
361
|
+
this.emitData(response);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
exports.DaumClassicMockBinding = DaumClassicMockBinding;
|
package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "
|
|
2
|
-
import SmartTrainerCyclingMode from "
|
|
3
|
-
import DaumAdapter from "
|
|
1
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "../../../../modes/cycling-mode";
|
|
2
|
+
import SmartTrainerCyclingMode from "../../SmartTrainerCyclingMode";
|
|
3
|
+
import DaumAdapter from "../../DaumAdapter";
|
|
4
4
|
export default class DaumClassicCyclingMode extends SmartTrainerCyclingMode implements CyclingMode {
|
|
5
5
|
constructor(adapter: DaumAdapter, props?: Settings);
|
|
6
6
|
getName(): string;
|
package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js}
RENAMED
|
@@ -4,8 +4,8 @@ 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("
|
|
8
|
-
const SmartTrainerCyclingMode_1 = __importDefault(require("
|
|
7
|
+
const cycling_mode_1 = require("../../../../modes/cycling-mode");
|
|
8
|
+
const SmartTrainerCyclingMode_1 = __importDefault(require("../../SmartTrainerCyclingMode"));
|
|
9
9
|
const config = {
|
|
10
10
|
name: "Daum Classic",
|
|
11
11
|
description: "The device calculates speed and power based on slope. Incyclist will not modify any values recived from the device\nThis mode will not respect maximum power and/or workout limits",
|
|
@@ -2,7 +2,7 @@ export declare const DEFAULT_AGE = 30;
|
|
|
2
2
|
export declare const DEFAULT_USER_WEIGHT = 75;
|
|
3
3
|
export declare const DEFAULT_BIKE_WEIGHT = 10;
|
|
4
4
|
export declare function getCockpit(c: any): "Cardio" | "Fitness" | "Vita De Luxe" | "8008" | "8008 TRS" | "8080" | "Therapie" | "8008 TRS Pro" | "8008 TRS3" | "ergo_lyps Cardio Pro" | "Unknown";
|
|
5
|
-
export declare function getBikeType(type: any):
|
|
5
|
+
export declare function getBikeType(type: any): 0 | 1;
|
|
6
6
|
export declare function getGender(sex: any): 1 | 2;
|
|
7
7
|
export declare function getLength(length: any): number;
|
|
8
8
|
export declare function getWeight(weight?: any): number;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DeviceProperties } from '../../../types/device';
|
|
2
|
+
import { SerialDeviceSettings } from '../../adapter';
|
|
3
|
+
import { SerialCommProps } from '../../comm';
|
|
4
|
+
import DaumAdapter from '../DaumAdapter';
|
|
5
|
+
import { Daum8iDeviceProperties } from './types';
|
|
6
|
+
export default class DaumPremiumAdapter extends DaumAdapter {
|
|
7
|
+
static NAME: string;
|
|
8
|
+
commProps: SerialCommProps;
|
|
9
|
+
_startRetryTimeout: number;
|
|
10
|
+
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
|
11
|
+
getName(): string;
|
|
12
|
+
getUniqueName(): string;
|
|
13
|
+
getPort(): any;
|
|
14
|
+
getInterface(): string;
|
|
15
|
+
getProtocolName(): string;
|
|
16
|
+
isEqual(settings: SerialDeviceSettings): boolean;
|
|
17
|
+
getSupportedCyclingModes(): Array<any>;
|
|
18
|
+
check(): Promise<boolean>;
|
|
19
|
+
pause(): Promise<boolean>;
|
|
20
|
+
resume(): Promise<boolean>;
|
|
21
|
+
startRide(props?: Daum8iDeviceProperties): Promise<boolean>;
|
|
22
|
+
start(props?: Daum8iDeviceProperties): Promise<boolean>;
|
|
23
|
+
launch(props?: Daum8iDeviceProperties, isRelaunch?: boolean): Promise<boolean>;
|
|
24
|
+
getCurrentBikeData(): Promise<any>;
|
|
25
|
+
}
|