incyclist-devices 1.5.10 → 1.5.12

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.
Files changed (136) hide show
  1. package/LICENSE +0 -0
  2. package/lib/DeviceSupport.d.ts +36 -36
  3. package/lib/DeviceSupport.js +82 -82
  4. package/lib/ant/AntAdapter.d.ts +50 -50
  5. package/lib/ant/AntAdapter.js +109 -109
  6. package/lib/ant/AntScanner.d.ts +60 -60
  7. package/lib/ant/AntScanner.js +651 -651
  8. package/lib/ant/antfe/AntFEAdapter.d.ts +83 -83
  9. package/lib/ant/antfe/AntFEAdapter.js +652 -652
  10. package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +9 -9
  11. package/lib/ant/antfe/ant-fe-adv-st-mode.js +51 -51
  12. package/lib/ant/antfe/ant-fe-erg-mode.d.ts +6 -6
  13. package/lib/ant/antfe/ant-fe-erg-mode.js +14 -14
  14. package/lib/ant/antfe/ant-fe-st-mode.d.ts +5 -5
  15. package/lib/ant/antfe/ant-fe-st-mode.js +13 -13
  16. package/lib/ant/anthrm/AntHrmAdapter.d.ts +16 -16
  17. package/lib/ant/anthrm/AntHrmAdapter.js +130 -130
  18. package/lib/ant/antpwr/pwr-adapter.d.ts +49 -49
  19. package/lib/ant/antpwr/pwr-adapter.js +251 -251
  20. package/lib/ant/utils.d.ts +1 -1
  21. package/lib/ant/utils.js +23 -23
  22. package/lib/antv2/AntAdapter.d.ts +48 -0
  23. package/lib/antv2/AntAdapter.js +104 -0
  24. package/lib/antv2/adapter-factory.d.ts +11 -11
  25. package/lib/antv2/adapter-factory.js +40 -40
  26. package/lib/antv2/ant-binding.d.ts +13 -13
  27. package/lib/antv2/ant-binding.js +27 -27
  28. package/lib/antv2/ant-device.d.ts +51 -51
  29. package/lib/antv2/ant-device.js +115 -115
  30. package/lib/antv2/ant-interface.d.ts +37 -37
  31. package/lib/antv2/ant-interface.js +255 -255
  32. package/lib/antv2/fe.d.ts +29 -29
  33. package/lib/antv2/fe.js +262 -262
  34. package/lib/antv2/hr.d.ts +18 -18
  35. package/lib/antv2/hr.js +93 -93
  36. package/lib/antv2/incyclist-protocol.d.ts +37 -37
  37. package/lib/antv2/incyclist-protocol.js +126 -126
  38. package/lib/antv2/pwr.d.ts +28 -28
  39. package/lib/antv2/pwr.js +163 -163
  40. package/lib/antv2/sensor-factory.d.ts +5 -5
  41. package/lib/antv2/sensor-factory.js +20 -20
  42. package/lib/ble/ble-device.d.ts +63 -63
  43. package/lib/ble/ble-device.js +444 -444
  44. package/lib/ble/ble-erg-mode.d.ts +18 -18
  45. package/lib/ble/ble-erg-mode.js +132 -132
  46. package/lib/ble/ble-interface.d.ts +100 -100
  47. package/lib/ble/ble-interface.js +721 -721
  48. package/lib/ble/ble-peripheral.d.ts +36 -36
  49. package/lib/ble/ble-peripheral.js +200 -200
  50. package/lib/ble/ble-st-mode.d.ts +15 -15
  51. package/lib/ble/ble-st-mode.js +95 -95
  52. package/lib/ble/ble.d.ts +129 -129
  53. package/lib/ble/ble.js +86 -86
  54. package/lib/ble/consts.d.ts +14 -14
  55. package/lib/ble/consts.js +17 -17
  56. package/lib/ble/elite.d.ts +90 -90
  57. package/lib/ble/elite.js +322 -322
  58. package/lib/ble/fm.d.ts +125 -125
  59. package/lib/ble/fm.js +745 -745
  60. package/lib/ble/hrm.d.ts +48 -48
  61. package/lib/ble/hrm.js +134 -134
  62. package/lib/ble/incyclist-protocol.d.ts +31 -31
  63. package/lib/ble/incyclist-protocol.js +153 -153
  64. package/lib/ble/pwr.d.ts +89 -89
  65. package/lib/ble/pwr.js +321 -321
  66. package/lib/ble/tacx.d.ts +92 -90
  67. package/lib/ble/tacx.js +763 -731
  68. package/lib/ble/wahoo-kickr.d.ts +98 -98
  69. package/lib/ble/wahoo-kickr.js +496 -496
  70. package/lib/calculations.d.ts +13 -13
  71. package/lib/calculations.js +150 -150
  72. package/lib/cycling-mode.d.ts +76 -76
  73. package/lib/cycling-mode.js +79 -79
  74. package/lib/daum/DaumAdapter.d.ts +66 -66
  75. package/lib/daum/DaumAdapter.js +396 -396
  76. package/lib/daum/DaumPowerMeterCyclingMode.d.ts +8 -8
  77. package/lib/daum/DaumPowerMeterCyclingMode.js +21 -21
  78. package/lib/daum/ERGCyclingMode.d.ts +26 -26
  79. package/lib/daum/ERGCyclingMode.js +201 -201
  80. package/lib/daum/SmartTrainerCyclingMode.d.ts +41 -41
  81. package/lib/daum/SmartTrainerCyclingMode.js +344 -344
  82. package/lib/daum/classic/DaumClassicAdapter.d.ts +22 -18
  83. package/lib/daum/classic/DaumClassicAdapter.js +183 -146
  84. package/lib/daum/classic/DaumClassicCyclingMode.d.ts +13 -13
  85. package/lib/daum/classic/DaumClassicCyclingMode.js +97 -97
  86. package/lib/daum/classic/DaumClassicProtocol.d.ts +27 -27
  87. package/lib/daum/classic/DaumClassicProtocol.js +185 -185
  88. package/lib/daum/classic/bike.d.ts +68 -64
  89. package/lib/daum/classic/bike.js +467 -456
  90. package/lib/daum/classic/utils.d.ts +13 -13
  91. package/lib/daum/classic/utils.js +143 -143
  92. package/lib/daum/constants.d.ts +19 -19
  93. package/lib/daum/constants.js +22 -22
  94. package/lib/daum/premium/DaumClassicCyclingMode.d.ts +14 -14
  95. package/lib/daum/premium/DaumClassicCyclingMode.js +86 -86
  96. package/lib/daum/premium/DaumPremiumAdapter.d.ts +16 -14
  97. package/lib/daum/premium/DaumPremiumAdapter.js +163 -139
  98. package/lib/daum/premium/DaumPremiumProtocol.d.ts +32 -32
  99. package/lib/daum/premium/DaumPremiumProtocol.js +207 -207
  100. package/lib/daum/premium/bike.d.ts +127 -123
  101. package/lib/daum/premium/bike.js +904 -894
  102. package/lib/daum/premium/tcpserial.d.ts +33 -33
  103. package/lib/daum/premium/tcpserial.js +123 -123
  104. package/lib/daum/premium/utils.d.ts +62 -62
  105. package/lib/daum/premium/utils.js +376 -376
  106. package/lib/device.d.ts +92 -92
  107. package/lib/device.js +71 -71
  108. package/lib/kettler/comms.d.ts +59 -59
  109. package/lib/kettler/comms.js +242 -242
  110. package/lib/kettler/ergo-racer/ERGCyclingMode.d.ts +25 -25
  111. package/lib/kettler/ergo-racer/ERGCyclingMode.js +144 -144
  112. package/lib/kettler/ergo-racer/adapter.d.ts +101 -101
  113. package/lib/kettler/ergo-racer/adapter.js +639 -639
  114. package/lib/kettler/ergo-racer/protocol.d.ts +41 -41
  115. package/lib/kettler/ergo-racer/protocol.js +203 -203
  116. package/lib/modes/power-base.d.ts +20 -20
  117. package/lib/modes/power-base.js +70 -70
  118. package/lib/modes/power-meter.d.ts +20 -20
  119. package/lib/modes/power-meter.js +78 -78
  120. package/lib/modes/simulator.d.ts +29 -29
  121. package/lib/modes/simulator.js +140 -140
  122. package/lib/protocol.d.ts +74 -74
  123. package/lib/protocol.js +41 -41
  124. package/lib/registry.d.ts +8 -8
  125. package/lib/registry.js +33 -33
  126. package/lib/simulator/Simulator.d.ts +69 -69
  127. package/lib/simulator/Simulator.js +288 -288
  128. package/lib/types/command.d.ts +8 -8
  129. package/lib/types/command.js +2 -2
  130. package/lib/types/route.d.ts +24 -24
  131. package/lib/types/route.js +9 -9
  132. package/lib/types/user.d.ts +11 -11
  133. package/lib/types/user.js +9 -9
  134. package/lib/utils.d.ts +14 -14
  135. package/lib/utils.js +114 -114
  136. package/package.json +47 -47
@@ -1,13 +1,13 @@
1
- export declare class IllegalArgumentException extends Error {
2
- constructor(message: any);
3
- }
4
- export default class C {
5
- static calculateSpeed(m: number, power: number, slope: number, props?: any): number;
6
- static calculatePower(m: number, v: number, slope: number, props?: any): number;
7
- static calculateSpeedDaum(gear: number, rpm: number, bikeType?: string | number): number;
8
- static calculateSpeedBike(gear: number, rpm: number, chain: number[], cassette: number[], props?: {
9
- numGears?: number;
10
- wheelCirc?: number;
11
- }): number;
12
- }
13
- export declare function solveCubic(p: any, q: any): any[];
1
+ export declare class IllegalArgumentException extends Error {
2
+ constructor(message: any);
3
+ }
4
+ export default class C {
5
+ static calculateSpeed(m: number, power: number, slope: number, props?: any): number;
6
+ static calculatePower(m: number, v: number, slope: number, props?: any): number;
7
+ static calculateSpeedDaum(gear: number, rpm: number, bikeType?: string | number): number;
8
+ static calculateSpeedBike(gear: number, rpm: number, chain: number[], cassette: number[], props?: {
9
+ numGears?: number;
10
+ wheelCirc?: number;
11
+ }): number;
12
+ }
13
+ export declare function solveCubic(p: any, q: any): any[];
@@ -1,150 +1,150 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.solveCubic = exports.IllegalArgumentException = void 0;
4
- const g = 9.80665;
5
- const rho = 1.2041;
6
- const cwABike = {
7
- race: 0.35,
8
- triathlon: 0.29,
9
- mountain: 0.57
10
- };
11
- const cRR = 0.0036;
12
- class IllegalArgumentException extends Error {
13
- constructor(message) {
14
- super(message);
15
- this.name = "IllegalArgumentException";
16
- }
17
- }
18
- exports.IllegalArgumentException = IllegalArgumentException;
19
- class C {
20
- static calculateSpeed(m, power, slope, props = {}) {
21
- if (m === undefined || m === null || m < 0)
22
- throw new IllegalArgumentException("m must be a positive number");
23
- if (power === undefined || power === null || power < 0)
24
- throw new IllegalArgumentException("power must be a positive number");
25
- if (slope === undefined || slope === null)
26
- slope = 0;
27
- const _rho = props.rho || rho;
28
- const _cRR = props.cRR || cRR;
29
- const _cwA = props.cwA || cwABike[props.bikeType || 'race'] || cwABike.race;
30
- let sl = Math.atan(slope / 100);
31
- let c1 = 0.5 * _rho * _cwA;
32
- let c2 = (sl + _cRR) * m * g;
33
- let p = c2 / c1;
34
- let q = -1.0 * power / c1;
35
- var v = solveCubic(p, q).filter(value => value >= 0);
36
- if (v.length === 1)
37
- return v[0] * 3.6;
38
- if (v.length > 1) {
39
- if (props.previous) {
40
- let speed = undefined;
41
- let minDiff = undefined;
42
- v.forEach(s => {
43
- if (!minDiff) {
44
- minDiff = Math.abs(s - props.previous);
45
- speed = s;
46
- return;
47
- }
48
- const diff = Math.abs(s - props.previous);
49
- if (diff < minDiff) {
50
- minDiff = diff;
51
- speed = s;
52
- }
53
- });
54
- return speed * 3.6;
55
- }
56
- for (var i = 0; i < v.length; i++)
57
- if (v[i] > 0)
58
- return v[i] * 3.6;
59
- }
60
- return 0;
61
- }
62
- static calculatePower(m, v, slope, props = {}) {
63
- if (m === undefined || m === null || m < 0)
64
- throw new IllegalArgumentException("m must be a positive number");
65
- if (v === undefined || v === null || v < 0)
66
- throw new IllegalArgumentException("v must be a positive number");
67
- if (slope === undefined || slope === null)
68
- slope = 0;
69
- let _rho = props.rho || rho;
70
- let _cRR = props.cRR || cRR;
71
- let _cwA = props.cwA || cwABike[props.bikeType || 'race'] || cwABike.race;
72
- let sl = Math.sin(Math.atan(slope / 100));
73
- let P = (0.5 * _rho * _cwA) * Math.pow(v, 3.0) + (sl + _cRR) * m * g * v;
74
- return P;
75
- }
76
- static calculateSpeedDaum(gear, rpm, bikeType) {
77
- if (bikeType === 0 || bikeType === undefined || bikeType === "race" || bikeType === 'triathlon') {
78
- let lengthRPM = 210;
79
- let gearRatio = 1.75 + (gear - 1) * 0.098767;
80
- let distRotation = lengthRPM * gearRatio;
81
- let speed = rpm * distRotation * 0.0006;
82
- return speed;
83
- }
84
- else {
85
- let lengthRPM = 185;
86
- let gearRatio = 0.67 + (gear - 1) * 0.1485;
87
- let distRotation = lengthRPM * gearRatio;
88
- let speed = rpm * distRotation * 0.0006;
89
- return speed;
90
- }
91
- }
92
- static calculateSpeedBike(gear, rpm, chain, cassette, props) {
93
- if (chain.length !== 2 || cassette.length !== 2)
94
- throw new IllegalArgumentException("chain and cassette must be an array of 2 numbers");
95
- if (cassette[0] < 1 || cassette[1] < 1)
96
- throw new IllegalArgumentException("cassette must be an array of 2 positive numbers");
97
- const bikeProps = props || {};
98
- const minGearRatio = chain[0] / cassette[1];
99
- const maxGearRatio = chain[1] / cassette[0];
100
- const numGears = bikeProps.numGears || 28;
101
- const wheelCirc = bikeProps.wheelCirc || 2125;
102
- const gearRatio = minGearRatio + (maxGearRatio - minGearRatio) * (gear - 1) / (numGears - 1);
103
- let distRotation = wheelCirc * gearRatio / 1000;
104
- let speed = rpm * distRotation * 60 / 1000;
105
- return speed;
106
- }
107
- }
108
- exports.default = C;
109
- function acosh(x) {
110
- return Math.log(x + Math.sqrt(x * x - 1.0));
111
- }
112
- function asinh(x) {
113
- return Math.log(x + Math.sqrt(x * x + 1.0));
114
- }
115
- function sqrtN(x, n) {
116
- let exp = 1.0 / n;
117
- if (Math.sign(x) === 1 || n % 2 === 0) {
118
- return Math.pow(x, exp);
119
- }
120
- return Math.sign(x) * Math.pow(Math.abs(x), exp);
121
- }
122
- function solveCubic(p, q) {
123
- let D = Math.pow(q / 2.0, 2) + Math.pow(p / 3.0, 3);
124
- let R = Math.sign(q) * Math.sqrt(Math.abs(p) / 3.0);
125
- if (p === 0) {
126
- return [sqrtN(-1 * q, 3)];
127
- }
128
- if (D === 0) {
129
- return [3 * q / p, -3 * q / (2 * p)];
130
- }
131
- if (D < 0 && p < 0) {
132
- const results = [];
133
- let phi = Math.acos(q / (2 * Math.pow(R, 3)));
134
- results[0] = -2 * R * Math.cos(phi / 3);
135
- results[1] = -2 * R * Math.cos(phi / 3 + 2 * Math.PI / 3);
136
- results[2] = -2 * R * Math.cos(phi / 3 + 4 * Math.PI / 3);
137
- return results;
138
- }
139
- if (D > 0 && p < 0) {
140
- const results = [];
141
- let phi = acosh(q / (2 * Math.pow(R, 3)));
142
- results[0] = -2 * R * Math.cosh(phi / 3);
143
- return results;
144
- }
145
- const results = [];
146
- let phi = asinh(q / (2 * Math.pow(R, 3)));
147
- results[0] = -2 * R * Math.sinh(phi / 3);
148
- return results;
149
- }
150
- exports.solveCubic = solveCubic;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.solveCubic = exports.IllegalArgumentException = void 0;
4
+ const g = 9.80665;
5
+ const rho = 1.2041;
6
+ const cwABike = {
7
+ race: 0.35,
8
+ triathlon: 0.29,
9
+ mountain: 0.57
10
+ };
11
+ const cRR = 0.0036;
12
+ class IllegalArgumentException extends Error {
13
+ constructor(message) {
14
+ super(message);
15
+ this.name = "IllegalArgumentException";
16
+ }
17
+ }
18
+ exports.IllegalArgumentException = IllegalArgumentException;
19
+ class C {
20
+ static calculateSpeed(m, power, slope, props = {}) {
21
+ if (m === undefined || m === null || m < 0)
22
+ throw new IllegalArgumentException("m must be a positive number");
23
+ if (power === undefined || power === null || power < 0)
24
+ throw new IllegalArgumentException("power must be a positive number");
25
+ if (slope === undefined || slope === null)
26
+ slope = 0;
27
+ const _rho = props.rho || rho;
28
+ const _cRR = props.cRR || cRR;
29
+ const _cwA = props.cwA || cwABike[props.bikeType || 'race'] || cwABike.race;
30
+ let sl = Math.atan(slope / 100);
31
+ let c1 = 0.5 * _rho * _cwA;
32
+ let c2 = (sl + _cRR) * m * g;
33
+ let p = c2 / c1;
34
+ let q = -1.0 * power / c1;
35
+ var v = solveCubic(p, q).filter(value => value >= 0);
36
+ if (v.length === 1)
37
+ return v[0] * 3.6;
38
+ if (v.length > 1) {
39
+ if (props.previous) {
40
+ let speed = undefined;
41
+ let minDiff = undefined;
42
+ v.forEach(s => {
43
+ if (!minDiff) {
44
+ minDiff = Math.abs(s - props.previous);
45
+ speed = s;
46
+ return;
47
+ }
48
+ const diff = Math.abs(s - props.previous);
49
+ if (diff < minDiff) {
50
+ minDiff = diff;
51
+ speed = s;
52
+ }
53
+ });
54
+ return speed * 3.6;
55
+ }
56
+ for (var i = 0; i < v.length; i++)
57
+ if (v[i] > 0)
58
+ return v[i] * 3.6;
59
+ }
60
+ return 0;
61
+ }
62
+ static calculatePower(m, v, slope, props = {}) {
63
+ if (m === undefined || m === null || m < 0)
64
+ throw new IllegalArgumentException("m must be a positive number");
65
+ if (v === undefined || v === null || v < 0)
66
+ throw new IllegalArgumentException("v must be a positive number");
67
+ if (slope === undefined || slope === null)
68
+ slope = 0;
69
+ let _rho = props.rho || rho;
70
+ let _cRR = props.cRR || cRR;
71
+ let _cwA = props.cwA || cwABike[props.bikeType || 'race'] || cwABike.race;
72
+ let sl = Math.sin(Math.atan(slope / 100));
73
+ let P = (0.5 * _rho * _cwA) * Math.pow(v, 3.0) + (sl + _cRR) * m * g * v;
74
+ return P;
75
+ }
76
+ static calculateSpeedDaum(gear, rpm, bikeType) {
77
+ if (bikeType === 0 || bikeType === undefined || bikeType === "race" || bikeType === 'triathlon') {
78
+ let lengthRPM = 210;
79
+ let gearRatio = 1.75 + (gear - 1) * 0.098767;
80
+ let distRotation = lengthRPM * gearRatio;
81
+ let speed = rpm * distRotation * 0.0006;
82
+ return speed;
83
+ }
84
+ else {
85
+ let lengthRPM = 185;
86
+ let gearRatio = 0.67 + (gear - 1) * 0.1485;
87
+ let distRotation = lengthRPM * gearRatio;
88
+ let speed = rpm * distRotation * 0.0006;
89
+ return speed;
90
+ }
91
+ }
92
+ static calculateSpeedBike(gear, rpm, chain, cassette, props) {
93
+ if (chain.length !== 2 || cassette.length !== 2)
94
+ throw new IllegalArgumentException("chain and cassette must be an array of 2 numbers");
95
+ if (cassette[0] < 1 || cassette[1] < 1)
96
+ throw new IllegalArgumentException("cassette must be an array of 2 positive numbers");
97
+ const bikeProps = props || {};
98
+ const minGearRatio = chain[0] / cassette[1];
99
+ const maxGearRatio = chain[1] / cassette[0];
100
+ const numGears = bikeProps.numGears || 28;
101
+ const wheelCirc = bikeProps.wheelCirc || 2125;
102
+ const gearRatio = minGearRatio + (maxGearRatio - minGearRatio) * (gear - 1) / (numGears - 1);
103
+ let distRotation = wheelCirc * gearRatio / 1000;
104
+ let speed = rpm * distRotation * 60 / 1000;
105
+ return speed;
106
+ }
107
+ }
108
+ exports.default = C;
109
+ function acosh(x) {
110
+ return Math.log(x + Math.sqrt(x * x - 1.0));
111
+ }
112
+ function asinh(x) {
113
+ return Math.log(x + Math.sqrt(x * x + 1.0));
114
+ }
115
+ function sqrtN(x, n) {
116
+ let exp = 1.0 / n;
117
+ if (Math.sign(x) === 1 || n % 2 === 0) {
118
+ return Math.pow(x, exp);
119
+ }
120
+ return Math.sign(x) * Math.pow(Math.abs(x), exp);
121
+ }
122
+ function solveCubic(p, q) {
123
+ let D = Math.pow(q / 2.0, 2) + Math.pow(p / 3.0, 3);
124
+ let R = Math.sign(q) * Math.sqrt(Math.abs(p) / 3.0);
125
+ if (p === 0) {
126
+ return [sqrtN(-1 * q, 3)];
127
+ }
128
+ if (D === 0) {
129
+ return [3 * q / p, -3 * q / (2 * p)];
130
+ }
131
+ if (D < 0 && p < 0) {
132
+ const results = [];
133
+ let phi = Math.acos(q / (2 * Math.pow(R, 3)));
134
+ results[0] = -2 * R * Math.cos(phi / 3);
135
+ results[1] = -2 * R * Math.cos(phi / 3 + 2 * Math.PI / 3);
136
+ results[2] = -2 * R * Math.cos(phi / 3 + 4 * Math.PI / 3);
137
+ return results;
138
+ }
139
+ if (D > 0 && p < 0) {
140
+ const results = [];
141
+ let phi = acosh(q / (2 * Math.pow(R, 3)));
142
+ results[0] = -2 * R * Math.cosh(phi / 3);
143
+ return results;
144
+ }
145
+ const results = [];
146
+ let phi = asinh(q / (2 * Math.pow(R, 3)));
147
+ results[0] = -2 * R * Math.sinh(phi / 3);
148
+ return results;
149
+ }
150
+ exports.solveCubic = solveCubic;
@@ -1,76 +1,76 @@
1
- import { Device } from "./protocol";
2
- export declare type UpdateRequest = {
3
- slope?: number;
4
- minPower?: number;
5
- maxPower?: number;
6
- targetPower?: number;
7
- reset?: boolean;
8
- refresh?: boolean;
9
- };
10
- export declare enum CyclingModeProperyType {
11
- Integer = "Integer",
12
- Boolean = "Boolean",
13
- Float = "Float",
14
- String = "String",
15
- SingleSelect = "SingleSelect",
16
- MultiSelect = "MultiSelect"
17
- }
18
- export declare type CyclingModeProperty = {
19
- key: string;
20
- name: string;
21
- description: string;
22
- type: CyclingModeProperyType;
23
- min?: number;
24
- max?: number;
25
- default?: any;
26
- options?: any[];
27
- };
28
- export declare type IncyclistBikeData = {
29
- isPedalling: boolean;
30
- power: number;
31
- pedalRpm: number;
32
- speed: number;
33
- heartrate: number;
34
- distanceInternal: number;
35
- time?: number;
36
- gear?: number;
37
- slope?: number;
38
- };
39
- export declare type Settings = {
40
- [key: string]: any;
41
- };
42
- export default interface CyclingMode {
43
- getName(): string;
44
- getDescription(): string;
45
- getBikeInitRequest(): UpdateRequest;
46
- sendBikeUpdate(request: UpdateRequest): UpdateRequest;
47
- updateData(data: IncyclistBikeData): IncyclistBikeData;
48
- getProperties(): CyclingModeProperty[];
49
- getProperty(name: string): CyclingModeProperty;
50
- setSettings(settings: any): any;
51
- setSetting(name: string, value: any): void;
52
- getSetting(name: string): any;
53
- getSettings(): Settings;
54
- setModeProperty(name: string, value: any): void;
55
- getModeProperty(name: string): any;
56
- }
57
- export declare class CyclingModeBase implements CyclingMode {
58
- adapter: Device;
59
- settings: Settings;
60
- properties: Settings;
61
- constructor(adapter: Device, props?: any);
62
- setAdapter(adapter: Device): void;
63
- getBikeInitRequest(): UpdateRequest;
64
- getName(): string;
65
- getDescription(): string;
66
- sendBikeUpdate(request: UpdateRequest): UpdateRequest;
67
- updateData(data: IncyclistBikeData): IncyclistBikeData;
68
- getProperties(): CyclingModeProperty[];
69
- getProperty(name: string): CyclingModeProperty;
70
- setSettings(settings?: any): void;
71
- setSetting(name: string, value: any): void;
72
- getSetting(name: string): any;
73
- getSettings(): Settings;
74
- setModeProperty(name: string, value: any): void;
75
- getModeProperty(name: string): any;
76
- }
1
+ import { Device } from "./protocol";
2
+ export declare type UpdateRequest = {
3
+ slope?: number;
4
+ minPower?: number;
5
+ maxPower?: number;
6
+ targetPower?: number;
7
+ reset?: boolean;
8
+ refresh?: boolean;
9
+ };
10
+ export declare enum CyclingModeProperyType {
11
+ Integer = "Integer",
12
+ Boolean = "Boolean",
13
+ Float = "Float",
14
+ String = "String",
15
+ SingleSelect = "SingleSelect",
16
+ MultiSelect = "MultiSelect"
17
+ }
18
+ export declare type CyclingModeProperty = {
19
+ key: string;
20
+ name: string;
21
+ description: string;
22
+ type: CyclingModeProperyType;
23
+ min?: number;
24
+ max?: number;
25
+ default?: any;
26
+ options?: any[];
27
+ };
28
+ export declare type IncyclistBikeData = {
29
+ isPedalling: boolean;
30
+ power: number;
31
+ pedalRpm: number;
32
+ speed: number;
33
+ heartrate: number;
34
+ distanceInternal: number;
35
+ time?: number;
36
+ gear?: number;
37
+ slope?: number;
38
+ };
39
+ export declare type Settings = {
40
+ [key: string]: any;
41
+ };
42
+ export default interface CyclingMode {
43
+ getName(): string;
44
+ getDescription(): string;
45
+ getBikeInitRequest(): UpdateRequest;
46
+ sendBikeUpdate(request: UpdateRequest): UpdateRequest;
47
+ updateData(data: IncyclistBikeData): IncyclistBikeData;
48
+ getProperties(): CyclingModeProperty[];
49
+ getProperty(name: string): CyclingModeProperty;
50
+ setSettings(settings: any): any;
51
+ setSetting(name: string, value: any): void;
52
+ getSetting(name: string): any;
53
+ getSettings(): Settings;
54
+ setModeProperty(name: string, value: any): void;
55
+ getModeProperty(name: string): any;
56
+ }
57
+ export declare class CyclingModeBase implements CyclingMode {
58
+ adapter: Device;
59
+ settings: Settings;
60
+ properties: Settings;
61
+ constructor(adapter: Device, props?: any);
62
+ setAdapter(adapter: Device): void;
63
+ getBikeInitRequest(): UpdateRequest;
64
+ getName(): string;
65
+ getDescription(): string;
66
+ sendBikeUpdate(request: UpdateRequest): UpdateRequest;
67
+ updateData(data: IncyclistBikeData): IncyclistBikeData;
68
+ getProperties(): CyclingModeProperty[];
69
+ getProperty(name: string): CyclingModeProperty;
70
+ setSettings(settings?: any): void;
71
+ setSetting(name: string, value: any): void;
72
+ getSetting(name: string): any;
73
+ getSettings(): Settings;
74
+ setModeProperty(name: string, value: any): void;
75
+ getModeProperty(name: string): any;
76
+ }
@@ -1,79 +1,79 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CyclingModeBase = exports.CyclingModeProperyType = void 0;
4
- var CyclingModeProperyType;
5
- (function (CyclingModeProperyType) {
6
- CyclingModeProperyType["Integer"] = "Integer";
7
- CyclingModeProperyType["Boolean"] = "Boolean";
8
- CyclingModeProperyType["Float"] = "Float";
9
- CyclingModeProperyType["String"] = "String";
10
- CyclingModeProperyType["SingleSelect"] = "SingleSelect";
11
- CyclingModeProperyType["MultiSelect"] = "MultiSelect";
12
- })(CyclingModeProperyType = exports.CyclingModeProperyType || (exports.CyclingModeProperyType = {}));
13
- class CyclingModeBase {
14
- constructor(adapter, props) {
15
- this.settings = {};
16
- this.properties = {};
17
- if (!adapter)
18
- throw new Error('IllegalArgument: adapter is null');
19
- this.setAdapter(adapter);
20
- this.setSettings(props);
21
- }
22
- setAdapter(adapter) {
23
- this.adapter = adapter;
24
- }
25
- getBikeInitRequest() {
26
- return {};
27
- }
28
- getName() {
29
- throw new Error("Method not implemented.");
30
- }
31
- getDescription() {
32
- throw new Error("Method not implemented.");
33
- }
34
- sendBikeUpdate(request) {
35
- throw new Error("Method not implemented.");
36
- }
37
- updateData(data) {
38
- throw new Error("Method not implemented.");
39
- }
40
- getProperties() {
41
- throw new Error("Method not implemented.");
42
- }
43
- getProperty(name) {
44
- throw new Error("Method not implemented.");
45
- }
46
- setSettings(settings) {
47
- if (settings) {
48
- this.settings = settings;
49
- }
50
- }
51
- setSetting(name, value) {
52
- this.settings[name] = value;
53
- }
54
- getSetting(name) {
55
- const res = this.settings[name];
56
- if (res !== undefined)
57
- return res;
58
- const prop = this.getProperties().find(p => p.key === name);
59
- if (prop && prop.default !== undefined)
60
- return prop.default;
61
- return undefined;
62
- }
63
- getSettings() {
64
- return this.settings;
65
- }
66
- setModeProperty(name, value) {
67
- this.properties[name] = value;
68
- }
69
- getModeProperty(name) {
70
- const res = this.properties[name];
71
- if (res !== undefined)
72
- return res;
73
- const prop = this.getProperties().find(p => p.key === name);
74
- if (prop && prop.default !== undefined)
75
- return prop.default;
76
- return undefined;
77
- }
78
- }
79
- exports.CyclingModeBase = CyclingModeBase;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CyclingModeBase = exports.CyclingModeProperyType = void 0;
4
+ var CyclingModeProperyType;
5
+ (function (CyclingModeProperyType) {
6
+ CyclingModeProperyType["Integer"] = "Integer";
7
+ CyclingModeProperyType["Boolean"] = "Boolean";
8
+ CyclingModeProperyType["Float"] = "Float";
9
+ CyclingModeProperyType["String"] = "String";
10
+ CyclingModeProperyType["SingleSelect"] = "SingleSelect";
11
+ CyclingModeProperyType["MultiSelect"] = "MultiSelect";
12
+ })(CyclingModeProperyType = exports.CyclingModeProperyType || (exports.CyclingModeProperyType = {}));
13
+ class CyclingModeBase {
14
+ constructor(adapter, props) {
15
+ this.settings = {};
16
+ this.properties = {};
17
+ if (!adapter)
18
+ throw new Error('IllegalArgument: adapter is null');
19
+ this.setAdapter(adapter);
20
+ this.setSettings(props);
21
+ }
22
+ setAdapter(adapter) {
23
+ this.adapter = adapter;
24
+ }
25
+ getBikeInitRequest() {
26
+ return {};
27
+ }
28
+ getName() {
29
+ throw new Error("Method not implemented.");
30
+ }
31
+ getDescription() {
32
+ throw new Error("Method not implemented.");
33
+ }
34
+ sendBikeUpdate(request) {
35
+ throw new Error("Method not implemented.");
36
+ }
37
+ updateData(data) {
38
+ throw new Error("Method not implemented.");
39
+ }
40
+ getProperties() {
41
+ throw new Error("Method not implemented.");
42
+ }
43
+ getProperty(name) {
44
+ throw new Error("Method not implemented.");
45
+ }
46
+ setSettings(settings) {
47
+ if (settings) {
48
+ this.settings = settings;
49
+ }
50
+ }
51
+ setSetting(name, value) {
52
+ this.settings[name] = value;
53
+ }
54
+ getSetting(name) {
55
+ const res = this.settings[name];
56
+ if (res !== undefined)
57
+ return res;
58
+ const prop = this.getProperties().find(p => p.key === name);
59
+ if (prop && prop.default !== undefined)
60
+ return prop.default;
61
+ return undefined;
62
+ }
63
+ getSettings() {
64
+ return this.settings;
65
+ }
66
+ setModeProperty(name, value) {
67
+ this.properties[name] = value;
68
+ }
69
+ getModeProperty(name) {
70
+ const res = this.properties[name];
71
+ if (res !== undefined)
72
+ return res;
73
+ const prop = this.getProperties().find(p => p.key === name);
74
+ if (prop && prop.default !== undefined)
75
+ return prop.default;
76
+ return undefined;
77
+ }
78
+ }
79
+ exports.CyclingModeBase = CyclingModeBase;