incyclist-devices 1.4.98 → 1.4.100

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 (128) hide show
  1. package/LICENSE +0 -0
  2. package/lib/CyclingMode.d.ts +76 -76
  3. package/lib/CyclingMode.js +79 -79
  4. package/lib/Device.d.ts +92 -92
  5. package/lib/Device.js +71 -71
  6. package/lib/DeviceProtocol.d.ts +74 -74
  7. package/lib/DeviceProtocol.js +41 -41
  8. package/lib/DeviceRegistry.d.ts +8 -8
  9. package/lib/DeviceRegistry.js +33 -33
  10. package/lib/DeviceSupport.d.ts +34 -34
  11. package/lib/DeviceSupport.js +78 -78
  12. package/lib/ant/AntAdapter.d.ts +50 -50
  13. package/lib/ant/AntAdapter.js +109 -109
  14. package/lib/ant/AntScanner.d.ts +60 -60
  15. package/lib/ant/AntScanner.js +651 -651
  16. package/lib/ant/antfe/AntFEAdapter.d.ts +83 -83
  17. package/lib/ant/antfe/AntFEAdapter.js +652 -652
  18. package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +9 -9
  19. package/lib/ant/antfe/ant-fe-adv-st-mode.js +51 -51
  20. package/lib/ant/antfe/ant-fe-erg-mode.d.ts +6 -6
  21. package/lib/ant/antfe/ant-fe-erg-mode.js +14 -14
  22. package/lib/ant/antfe/ant-fe-st-mode.d.ts +5 -5
  23. package/lib/ant/antfe/ant-fe-st-mode.js +13 -13
  24. package/lib/ant/anthrm/AntHrmAdapter.d.ts +16 -16
  25. package/lib/ant/anthrm/AntHrmAdapter.js +130 -130
  26. package/lib/ant/antpwr/pwr-adapter.d.ts +49 -49
  27. package/lib/ant/antpwr/pwr-adapter.js +251 -251
  28. package/lib/ant/utils.d.ts +1 -1
  29. package/lib/ant/utils.js +23 -23
  30. package/lib/ble/ble-device.d.ts +63 -63
  31. package/lib/ble/ble-device.js +442 -442
  32. package/lib/ble/ble-erg-mode.d.ts +18 -18
  33. package/lib/ble/ble-erg-mode.js +132 -127
  34. package/lib/ble/ble-interface.d.ts +100 -99
  35. package/lib/ble/ble-interface.js +717 -712
  36. package/lib/ble/ble-peripheral.d.ts +36 -36
  37. package/lib/ble/ble-peripheral.js +200 -200
  38. package/lib/ble/ble-st-mode.d.ts +15 -15
  39. package/lib/ble/ble-st-mode.js +102 -102
  40. package/lib/ble/ble.d.ts +129 -129
  41. package/lib/ble/ble.js +86 -86
  42. package/lib/ble/consts.d.ts +14 -14
  43. package/lib/ble/consts.js +17 -17
  44. package/lib/ble/fm.d.ts +125 -125
  45. package/lib/ble/fm.js +739 -739
  46. package/lib/ble/hrm.d.ts +48 -48
  47. package/lib/ble/hrm.js +134 -134
  48. package/lib/ble/incyclist-protocol.d.ts +31 -31
  49. package/lib/ble/incyclist-protocol.js +147 -147
  50. package/lib/ble/pwr.d.ts +89 -89
  51. package/lib/ble/pwr.js +321 -321
  52. package/lib/ble/tacx.d.ts +90 -90
  53. package/lib/ble/tacx.js +731 -730
  54. package/lib/ble/wahoo-kickr.d.ts +98 -98
  55. package/lib/ble/wahoo-kickr.js +496 -496
  56. package/lib/calculations.d.ts +13 -13
  57. package/lib/calculations.js +150 -150
  58. package/lib/daum/DaumAdapter.d.ts +66 -66
  59. package/lib/daum/DaumAdapter.js +396 -396
  60. package/lib/daum/DaumPowerMeterCyclingMode.d.ts +8 -8
  61. package/lib/daum/DaumPowerMeterCyclingMode.js +21 -21
  62. package/lib/daum/ERGCyclingMode.d.ts +26 -26
  63. package/lib/daum/ERGCyclingMode.js +201 -201
  64. package/lib/daum/SmartTrainerCyclingMode.d.ts +41 -41
  65. package/lib/daum/SmartTrainerCyclingMode.js +344 -344
  66. package/lib/daum/classic/DaumClassicAdapter.d.ts +18 -18
  67. package/lib/daum/classic/DaumClassicAdapter.js +146 -146
  68. package/lib/daum/classic/DaumClassicCyclingMode.d.ts +13 -13
  69. package/lib/daum/classic/DaumClassicCyclingMode.js +97 -97
  70. package/lib/daum/classic/DaumClassicProtocol.d.ts +27 -27
  71. package/lib/daum/classic/DaumClassicProtocol.js +185 -185
  72. package/lib/daum/classic/bike.d.ts +64 -64
  73. package/lib/daum/classic/bike.js +456 -456
  74. package/lib/daum/classic/utils.d.ts +13 -13
  75. package/lib/daum/classic/utils.js +143 -143
  76. package/lib/daum/constants.d.ts +19 -19
  77. package/lib/daum/constants.js +22 -22
  78. package/lib/daum/premium/DaumClassicCyclingMode.d.ts +14 -14
  79. package/lib/daum/premium/DaumClassicCyclingMode.js +86 -86
  80. package/lib/daum/premium/DaumPremiumAdapter.d.ts +12 -12
  81. package/lib/daum/premium/DaumPremiumAdapter.js +131 -131
  82. package/lib/daum/premium/DaumPremiumProtocol.d.ts +32 -32
  83. package/lib/daum/premium/DaumPremiumProtocol.js +207 -207
  84. package/lib/daum/premium/bike.d.ts +123 -123
  85. package/lib/daum/premium/bike.js +894 -894
  86. package/lib/daum/premium/tcpserial.d.ts +33 -33
  87. package/lib/daum/premium/tcpserial.js +123 -123
  88. package/lib/daum/premium/utils.d.ts +62 -62
  89. package/lib/daum/premium/utils.js +376 -376
  90. package/lib/kettler/comms.d.ts +59 -59
  91. package/lib/kettler/comms.js +242 -242
  92. package/lib/kettler/ergo-racer/ERGCyclingMode.d.ts +25 -25
  93. package/lib/kettler/ergo-racer/ERGCyclingMode.js +144 -145
  94. package/lib/kettler/ergo-racer/adapter.d.ts +101 -101
  95. package/lib/kettler/ergo-racer/adapter.js +639 -639
  96. package/lib/kettler/ergo-racer/protocol.d.ts +41 -41
  97. package/lib/kettler/ergo-racer/protocol.js +203 -203
  98. package/lib/modes/power-base.d.ts +20 -20
  99. package/lib/modes/power-base.js +70 -70
  100. package/lib/modes/power-meter.d.ts +20 -20
  101. package/lib/modes/power-meter.js +78 -78
  102. package/lib/modes/simulator.d.ts +29 -29
  103. package/lib/modes/simulator.js +140 -140
  104. package/lib/simulator/Simulator.d.ts +69 -69
  105. package/lib/simulator/Simulator.js +288 -288
  106. package/lib/types/command.d.ts +8 -8
  107. package/lib/types/command.js +2 -2
  108. package/lib/types/route.d.ts +24 -24
  109. package/lib/types/route.js +9 -9
  110. package/lib/types/user.d.ts +11 -11
  111. package/lib/types/user.js +9 -9
  112. package/lib/utils.d.ts +14 -14
  113. package/lib/utils.js +114 -114
  114. package/package.json +46 -46
  115. package/lib/ant/antfe/ant-fe-st-mode copy.d.ts +0 -7
  116. package/lib/ant/antfe/ant-fe-st-mode copy.js +0 -54
  117. package/lib/ant/antpwr/AntPWRAdapter.d.ts +0 -24
  118. package/lib/ant/antpwr/AntPWRAdapter.js +0 -252
  119. package/lib/daum/PowerMeterCyclingMode.d.ts +0 -18
  120. package/lib/daum/PowerMeterCyclingMode.js +0 -78
  121. package/lib/daum/classic/ERGCyclingMode.d.ts +0 -23
  122. package/lib/daum/classic/ERGCyclingMode.js +0 -171
  123. package/lib/daum/indoorbike.d.ts +0 -24
  124. package/lib/daum/indoorbike.js +0 -178
  125. package/lib/kettler/ergo-racer/modes/power-meter.d.ts +0 -18
  126. package/lib/kettler/ergo-racer/modes/power-meter.js +0 -86
  127. package/lib/simulator/simulator-mode.d.ts +0 -28
  128. package/lib/simulator/simulator-mode.js +0 -120
@@ -1,13 +1,13 @@
1
- export declare const DEFAULT_AGE = 30;
2
- export declare const DEFAULT_USER_WEIGHT = 75;
3
- export declare const DEFAULT_BIKE_WEIGHT = 10;
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): 1 | 0;
6
- export declare function getGender(sex: any): 1 | 2;
7
- export declare function getLength(length: any): number;
8
- export declare function getWeight(weight?: any): number;
9
- export declare function parseRunData(data: any): any;
10
- export declare function buildError(status: any, err: any): any;
11
- export declare function hexstr(arr: any, start?: any, len?: any): string;
12
- export declare function Float32ToHex(float32: any): any;
13
- export declare function Float32ToIntArray(float32: any): any[];
1
+ export declare const DEFAULT_AGE = 30;
2
+ export declare const DEFAULT_USER_WEIGHT = 75;
3
+ export declare const DEFAULT_BIKE_WEIGHT = 10;
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): 1 | 0;
6
+ export declare function getGender(sex: any): 1 | 2;
7
+ export declare function getLength(length: any): number;
8
+ export declare function getWeight(weight?: any): number;
9
+ export declare function parseRunData(data: any): any;
10
+ export declare function buildError(status: any, err: any): any;
11
+ export declare function hexstr(arr: any, start?: any, len?: any): string;
12
+ export declare function Float32ToHex(float32: any): any;
13
+ export declare function Float32ToIntArray(float32: any): any[];
@@ -1,143 +1,143 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Float32ToIntArray = exports.Float32ToHex = exports.hexstr = exports.buildError = exports.parseRunData = exports.getWeight = exports.getLength = exports.getGender = exports.getBikeType = exports.getCockpit = exports.DEFAULT_BIKE_WEIGHT = exports.DEFAULT_USER_WEIGHT = exports.DEFAULT_AGE = void 0;
4
- exports.DEFAULT_AGE = 30;
5
- exports.DEFAULT_USER_WEIGHT = 75;
6
- exports.DEFAULT_BIKE_WEIGHT = 10;
7
- function getCockpit(c) {
8
- switch (c) {
9
- case 10:
10
- return "Cardio";
11
- case 20:
12
- return "Fitness";
13
- case 30:
14
- return "Vita De Luxe";
15
- case 40:
16
- return "8008";
17
- case 0x2A:
18
- return "8008 TRS";
19
- case 50:
20
- return "8080";
21
- case 60:
22
- return "Therapie";
23
- case 100:
24
- return "8008 TRS Pro";
25
- case 160:
26
- return "8008 TRS3";
27
- case 0x8D:
28
- return "ergo_lyps Cardio Pro";
29
- default:
30
- return "Unknown";
31
- }
32
- }
33
- exports.getCockpit = getCockpit;
34
- function getBikeType(type) {
35
- if (type === undefined)
36
- return 0;
37
- switch (type) {
38
- case "triathlon":
39
- return 0;
40
- case "race":
41
- return 0;
42
- case "mountain":
43
- return 1;
44
- default:
45
- return 1;
46
- }
47
- }
48
- exports.getBikeType = getBikeType;
49
- function getGender(sex) {
50
- if (sex === undefined)
51
- return 2;
52
- switch (sex) {
53
- case "M":
54
- return 1;
55
- case "F":
56
- return 1;
57
- default:
58
- return 2;
59
- }
60
- }
61
- exports.getGender = getGender;
62
- function getLength(length) {
63
- if (length === undefined || length === null)
64
- return 180;
65
- let l = Math.round(length);
66
- if (l < 100)
67
- return 100;
68
- if (l > 220)
69
- return 220;
70
- return l;
71
- }
72
- exports.getLength = getLength;
73
- function getWeight(weight) {
74
- if (weight === undefined || weight === null)
75
- return 80;
76
- let m = Math.round(weight);
77
- if (isNaN(m))
78
- return 80;
79
- if (m < 10)
80
- return 10;
81
- if (m > 250)
82
- return 250;
83
- return m;
84
- }
85
- exports.getWeight = getWeight;
86
- function parseRunData(data) {
87
- const bikeData = {};
88
- bikeData.isPedalling = (data[4] > 0);
89
- bikeData.power = data[5] * 5;
90
- bikeData.cadence = data[6];
91
- bikeData.speed = data[7];
92
- bikeData.heartrate = data[14];
93
- bikeData.distance = (data[9] * 256 + data[8]) / 10;
94
- bikeData.distanceInternal = (data[9] * 256 + data[8]) * 100;
95
- bikeData.time = (data[11] * 256 + data[10]);
96
- bikeData.gear = data[16];
97
- return bikeData;
98
- }
99
- exports.parseRunData = parseRunData;
100
- function buildError(status, err) {
101
- const message = err && err.message ? err.message : err;
102
- const error = new Error(message);
103
- error.status = status;
104
- return error;
105
- }
106
- exports.buildError = buildError;
107
- function hexstr(arr, start, len) {
108
- var str = "";
109
- if (start === undefined)
110
- start = 0;
111
- if (len === undefined) {
112
- len = arr.length;
113
- }
114
- if (len - start > arr.length) {
115
- len = arr.length - start;
116
- }
117
- var j = start;
118
- for (var i = 0; i < len; i++) {
119
- var hex = Math.abs(arr[j++]).toString(16);
120
- if (i !== 0)
121
- str += " ";
122
- str += hex;
123
- }
124
- return str;
125
- }
126
- exports.hexstr = hexstr;
127
- function Float32ToHex(float32) {
128
- function getHex(i) { return ('00' + i.toString(16)).slice(-2).toUpperCase(); }
129
- var view = new DataView(new ArrayBuffer(4));
130
- view.setFloat32(0, float32);
131
- return Array.apply(null, { length: 4 }).map((_, i) => getHex(view.getUint8(i))).join('');
132
- }
133
- exports.Float32ToHex = Float32ToHex;
134
- function Float32ToIntArray(float32) {
135
- var view = new DataView(new ArrayBuffer(4));
136
- view.setFloat32(0, float32);
137
- var arr = [];
138
- for (let i = 0; i < 4; i++) {
139
- arr.push(view.getUint8(i));
140
- }
141
- return arr;
142
- }
143
- exports.Float32ToIntArray = Float32ToIntArray;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Float32ToIntArray = exports.Float32ToHex = exports.hexstr = exports.buildError = exports.parseRunData = exports.getWeight = exports.getLength = exports.getGender = exports.getBikeType = exports.getCockpit = exports.DEFAULT_BIKE_WEIGHT = exports.DEFAULT_USER_WEIGHT = exports.DEFAULT_AGE = void 0;
4
+ exports.DEFAULT_AGE = 30;
5
+ exports.DEFAULT_USER_WEIGHT = 75;
6
+ exports.DEFAULT_BIKE_WEIGHT = 10;
7
+ function getCockpit(c) {
8
+ switch (c) {
9
+ case 10:
10
+ return "Cardio";
11
+ case 20:
12
+ return "Fitness";
13
+ case 30:
14
+ return "Vita De Luxe";
15
+ case 40:
16
+ return "8008";
17
+ case 0x2A:
18
+ return "8008 TRS";
19
+ case 50:
20
+ return "8080";
21
+ case 60:
22
+ return "Therapie";
23
+ case 100:
24
+ return "8008 TRS Pro";
25
+ case 160:
26
+ return "8008 TRS3";
27
+ case 0x8D:
28
+ return "ergo_lyps Cardio Pro";
29
+ default:
30
+ return "Unknown";
31
+ }
32
+ }
33
+ exports.getCockpit = getCockpit;
34
+ function getBikeType(type) {
35
+ if (type === undefined)
36
+ return 0;
37
+ switch (type) {
38
+ case "triathlon":
39
+ return 0;
40
+ case "race":
41
+ return 0;
42
+ case "mountain":
43
+ return 1;
44
+ default:
45
+ return 1;
46
+ }
47
+ }
48
+ exports.getBikeType = getBikeType;
49
+ function getGender(sex) {
50
+ if (sex === undefined)
51
+ return 2;
52
+ switch (sex) {
53
+ case "M":
54
+ return 1;
55
+ case "F":
56
+ return 1;
57
+ default:
58
+ return 2;
59
+ }
60
+ }
61
+ exports.getGender = getGender;
62
+ function getLength(length) {
63
+ if (length === undefined || length === null)
64
+ return 180;
65
+ let l = Math.round(length);
66
+ if (l < 100)
67
+ return 100;
68
+ if (l > 220)
69
+ return 220;
70
+ return l;
71
+ }
72
+ exports.getLength = getLength;
73
+ function getWeight(weight) {
74
+ if (weight === undefined || weight === null)
75
+ return 80;
76
+ let m = Math.round(weight);
77
+ if (isNaN(m))
78
+ return 80;
79
+ if (m < 10)
80
+ return 10;
81
+ if (m > 250)
82
+ return 250;
83
+ return m;
84
+ }
85
+ exports.getWeight = getWeight;
86
+ function parseRunData(data) {
87
+ const bikeData = {};
88
+ bikeData.isPedalling = (data[4] > 0);
89
+ bikeData.power = data[5] * 5;
90
+ bikeData.cadence = data[6];
91
+ bikeData.speed = data[7];
92
+ bikeData.heartrate = data[14];
93
+ bikeData.distance = (data[9] * 256 + data[8]) / 10;
94
+ bikeData.distanceInternal = (data[9] * 256 + data[8]) * 100;
95
+ bikeData.time = (data[11] * 256 + data[10]);
96
+ bikeData.gear = data[16];
97
+ return bikeData;
98
+ }
99
+ exports.parseRunData = parseRunData;
100
+ function buildError(status, err) {
101
+ const message = err && err.message ? err.message : err;
102
+ const error = new Error(message);
103
+ error.status = status;
104
+ return error;
105
+ }
106
+ exports.buildError = buildError;
107
+ function hexstr(arr, start, len) {
108
+ var str = "";
109
+ if (start === undefined)
110
+ start = 0;
111
+ if (len === undefined) {
112
+ len = arr.length;
113
+ }
114
+ if (len - start > arr.length) {
115
+ len = arr.length - start;
116
+ }
117
+ var j = start;
118
+ for (var i = 0; i < len; i++) {
119
+ var hex = Math.abs(arr[j++]).toString(16);
120
+ if (i !== 0)
121
+ str += " ";
122
+ str += hex;
123
+ }
124
+ return str;
125
+ }
126
+ exports.hexstr = hexstr;
127
+ function Float32ToHex(float32) {
128
+ function getHex(i) { return ('00' + i.toString(16)).slice(-2).toUpperCase(); }
129
+ var view = new DataView(new ArrayBuffer(4));
130
+ view.setFloat32(0, float32);
131
+ return Array.apply(null, { length: 4 }).map((_, i) => getHex(view.getUint8(i))).join('');
132
+ }
133
+ exports.Float32ToHex = Float32ToHex;
134
+ function Float32ToIntArray(float32) {
135
+ var view = new DataView(new ArrayBuffer(4));
136
+ view.setFloat32(0, float32);
137
+ var arr = [];
138
+ for (let i = 0; i < 4; i++) {
139
+ arr.push(view.getUint8(i));
140
+ }
141
+ return arr;
142
+ }
143
+ exports.Float32ToIntArray = Float32ToIntArray;
@@ -1,19 +1,19 @@
1
- export declare const ACTUAL_BIKE_TYPE: {
2
- ALLROUND: string;
3
- RACE: string;
4
- MOUNTAIN: string;
5
- TRIATHLON: string;
6
- };
7
- export declare const BIKE_INTERFACE: {
8
- SERIAL: string;
9
- ANT: string;
10
- BLE: string;
11
- BLUETOOTH: string;
12
- TCPIP: string;
13
- };
14
- export declare const BIKE_TRAINING_STATE: {
15
- IDLE: string;
16
- STARTING: string;
17
- BUSY: string;
18
- STOPPING: string;
19
- };
1
+ export declare const ACTUAL_BIKE_TYPE: {
2
+ ALLROUND: string;
3
+ RACE: string;
4
+ MOUNTAIN: string;
5
+ TRIATHLON: string;
6
+ };
7
+ export declare const BIKE_INTERFACE: {
8
+ SERIAL: string;
9
+ ANT: string;
10
+ BLE: string;
11
+ BLUETOOTH: string;
12
+ TCPIP: string;
13
+ };
14
+ export declare const BIKE_TRAINING_STATE: {
15
+ IDLE: string;
16
+ STARTING: string;
17
+ BUSY: string;
18
+ STOPPING: string;
19
+ };
@@ -1,22 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BIKE_TRAINING_STATE = exports.BIKE_INTERFACE = exports.ACTUAL_BIKE_TYPE = void 0;
4
- exports.ACTUAL_BIKE_TYPE = {
5
- ALLROUND: 'allround',
6
- RACE: 'race',
7
- MOUNTAIN: 'mountain',
8
- TRIATHLON: 'triathlon'
9
- };
10
- exports.BIKE_INTERFACE = {
11
- SERIAL: 'serial',
12
- ANT: 'ant',
13
- BLE: 'ble',
14
- BLUETOOTH: 'bluetooth',
15
- TCPIP: 'tcpip',
16
- };
17
- exports.BIKE_TRAINING_STATE = {
18
- IDLE: 'idle',
19
- STARTING: 'starting',
20
- BUSY: 'busy',
21
- STOPPING: 'stopping'
22
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BIKE_TRAINING_STATE = exports.BIKE_INTERFACE = exports.ACTUAL_BIKE_TYPE = void 0;
4
+ exports.ACTUAL_BIKE_TYPE = {
5
+ ALLROUND: 'allround',
6
+ RACE: 'race',
7
+ MOUNTAIN: 'mountain',
8
+ TRIATHLON: 'triathlon'
9
+ };
10
+ exports.BIKE_INTERFACE = {
11
+ SERIAL: 'serial',
12
+ ANT: 'ant',
13
+ BLE: 'ble',
14
+ BLUETOOTH: 'bluetooth',
15
+ TCPIP: 'tcpip',
16
+ };
17
+ exports.BIKE_TRAINING_STATE = {
18
+ IDLE: 'idle',
19
+ STARTING: 'starting',
20
+ BUSY: 'busy',
21
+ STOPPING: 'stopping'
22
+ };
@@ -1,14 +1,14 @@
1
- import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "../../CyclingMode";
2
- import DaumAdapter from "../DaumAdapter";
3
- import DaumPowerMeterCyclingMode from "../DaumPowerMeterCyclingMode";
4
- export default class DaumClassicCyclingMode extends DaumPowerMeterCyclingMode implements CyclingMode {
5
- constructor(adapter: DaumAdapter, props?: Settings);
6
- getName(): string;
7
- getDescription(): string;
8
- getProperties(): CyclingModeProperty[];
9
- getProperty(name: string): CyclingModeProperty;
10
- getBikeInitRequest(): UpdateRequest;
11
- getSettings(): Settings;
12
- getSetting(name: string): any;
13
- updateData(data: IncyclistBikeData): IncyclistBikeData;
14
- }
1
+ import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "../../CyclingMode";
2
+ import DaumAdapter from "../DaumAdapter";
3
+ import DaumPowerMeterCyclingMode from "../DaumPowerMeterCyclingMode";
4
+ export default class DaumClassicCyclingMode extends DaumPowerMeterCyclingMode implements CyclingMode {
5
+ constructor(adapter: DaumAdapter, props?: Settings);
6
+ getName(): string;
7
+ getDescription(): string;
8
+ getProperties(): CyclingModeProperty[];
9
+ getProperty(name: string): CyclingModeProperty;
10
+ getBikeInitRequest(): UpdateRequest;
11
+ getSettings(): Settings;
12
+ getSetting(name: string): any;
13
+ updateData(data: IncyclistBikeData): IncyclistBikeData;
14
+ }
@@ -1,86 +1,86 @@
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 gd_eventlog_1 = require("gd-eventlog");
7
- const CyclingMode_1 = require("../../CyclingMode");
8
- const DaumPowerMeterCyclingMode_1 = __importDefault(require("../DaumPowerMeterCyclingMode"));
9
- const config = {
10
- name: "Daum Classic",
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",
12
- properties: [
13
- { key: 'bikeType', name: 'Bike Type', description: '', type: CyclingMode_1.CyclingModeProperyType.SingleSelect, options: ['Race', 'Mountain'], default: 'Race' },
14
- ]
15
- };
16
- class DaumClassicCyclingMode extends DaumPowerMeterCyclingMode_1.default {
17
- constructor(adapter, props) {
18
- super(adapter, props);
19
- this.logger = adapter ? adapter.logger : undefined;
20
- if (!this.logger)
21
- this.logger = new gd_eventlog_1.EventLogger('DaumClassic');
22
- this.setModeProperty('eppSupport', true);
23
- this.setModeProperty('setPersonSupport', true);
24
- }
25
- getName() {
26
- return config.name;
27
- }
28
- getDescription() {
29
- return config.description;
30
- }
31
- getProperties() {
32
- return config.properties;
33
- }
34
- getProperty(name) {
35
- return config.properties.find(p => p.name === name);
36
- }
37
- getBikeInitRequest() {
38
- return {};
39
- }
40
- getSettings() {
41
- const settings = super.getSettings();
42
- settings['setPerson'] = true;
43
- return settings;
44
- }
45
- getSetting(name) {
46
- if (name === 'setPerson')
47
- return true;
48
- return super.getSetting(name);
49
- }
50
- updateData(data) {
51
- try {
52
- const prevData = this.data || {};
53
- const prevRequest = this.prevRequest || {};
54
- const bikeData = JSON.parse(JSON.stringify(data));
55
- let power = data.power || 0;
56
- let speed = data.speed || 0;
57
- let slope = (prevData.slope !== undefined ? prevData.slope : prevRequest.slope || 0);
58
- let distanceBike = data.distanceInternal || 0;
59
- let distancePrev = prevData.distanceInternal || 0;
60
- let distanceInternal = distanceBike;
61
- let ts = Date.now();
62
- if (!bikeData.pedalRpm || bikeData.isPedalling === false) {
63
- speed = 0;
64
- power = 0;
65
- }
66
- if (distanceBike < distancePrev) {
67
- this.logger.logEvent({ message: '~~~ distance overflow', distanceBike, distancePrev });
68
- let v = speed / 3.6;
69
- let duration = this.prevUpdateTS === 0 ? 0 : ((ts - this.prevUpdateTS) / 1000);
70
- distanceInternal = distancePrev + v * duration;
71
- }
72
- data.speed = parseFloat(speed.toFixed(1));
73
- data.power = Math.round(power);
74
- data.distanceInternal = distanceInternal;
75
- data.slope = slope;
76
- this.logger.logEvent({ message: "updateData result", data, bikeData, prevRequest: {}, prevSpeed: prevData.speed });
77
- this.data = JSON.parse(JSON.stringify(data));
78
- this.prevUpdateTS = ts;
79
- }
80
- catch (err) {
81
- this.logger.logEvent({ message: 'error', fn: 'updateData()', error: err.message || err });
82
- }
83
- return data;
84
- }
85
- }
86
- exports.default = DaumClassicCyclingMode;
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 gd_eventlog_1 = require("gd-eventlog");
7
+ const CyclingMode_1 = require("../../CyclingMode");
8
+ const DaumPowerMeterCyclingMode_1 = __importDefault(require("../DaumPowerMeterCyclingMode"));
9
+ const config = {
10
+ name: "Daum Classic",
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",
12
+ properties: [
13
+ { key: 'bikeType', name: 'Bike Type', description: '', type: CyclingMode_1.CyclingModeProperyType.SingleSelect, options: ['Race', 'Mountain'], default: 'Race' },
14
+ ]
15
+ };
16
+ class DaumClassicCyclingMode extends DaumPowerMeterCyclingMode_1.default {
17
+ constructor(adapter, props) {
18
+ super(adapter, props);
19
+ this.logger = adapter ? adapter.logger : undefined;
20
+ if (!this.logger)
21
+ this.logger = new gd_eventlog_1.EventLogger('DaumClassic');
22
+ this.setModeProperty('eppSupport', true);
23
+ this.setModeProperty('setPersonSupport', true);
24
+ }
25
+ getName() {
26
+ return config.name;
27
+ }
28
+ getDescription() {
29
+ return config.description;
30
+ }
31
+ getProperties() {
32
+ return config.properties;
33
+ }
34
+ getProperty(name) {
35
+ return config.properties.find(p => p.name === name);
36
+ }
37
+ getBikeInitRequest() {
38
+ return {};
39
+ }
40
+ getSettings() {
41
+ const settings = super.getSettings();
42
+ settings['setPerson'] = true;
43
+ return settings;
44
+ }
45
+ getSetting(name) {
46
+ if (name === 'setPerson')
47
+ return true;
48
+ return super.getSetting(name);
49
+ }
50
+ updateData(data) {
51
+ try {
52
+ const prevData = this.data || {};
53
+ const prevRequest = this.prevRequest || {};
54
+ const bikeData = JSON.parse(JSON.stringify(data));
55
+ let power = data.power || 0;
56
+ let speed = data.speed || 0;
57
+ let slope = (prevData.slope !== undefined ? prevData.slope : prevRequest.slope || 0);
58
+ let distanceBike = data.distanceInternal || 0;
59
+ let distancePrev = prevData.distanceInternal || 0;
60
+ let distanceInternal = distanceBike;
61
+ let ts = Date.now();
62
+ if (!bikeData.pedalRpm || bikeData.isPedalling === false) {
63
+ speed = 0;
64
+ power = 0;
65
+ }
66
+ if (distanceBike < distancePrev) {
67
+ this.logger.logEvent({ message: '~~~ distance overflow', distanceBike, distancePrev });
68
+ let v = speed / 3.6;
69
+ let duration = this.prevUpdateTS === 0 ? 0 : ((ts - this.prevUpdateTS) / 1000);
70
+ distanceInternal = distancePrev + v * duration;
71
+ }
72
+ data.speed = parseFloat(speed.toFixed(1));
73
+ data.power = Math.round(power);
74
+ data.distanceInternal = distanceInternal;
75
+ data.slope = slope;
76
+ this.logger.logEvent({ message: "updateData result", data, bikeData, prevRequest: {}, prevSpeed: prevData.speed });
77
+ this.data = JSON.parse(JSON.stringify(data));
78
+ this.prevUpdateTS = ts;
79
+ }
80
+ catch (err) {
81
+ this.logger.logEvent({ message: 'error', fn: 'updateData()', error: err.message || err });
82
+ }
83
+ return data;
84
+ }
85
+ }
86
+ exports.default = DaumClassicCyclingMode;
@@ -1,12 +1,12 @@
1
- import DaumAdapter from '../DaumAdapter';
2
- export default class DaumPremiumDevice extends DaumAdapter {
3
- static NAME: string;
4
- constructor(protocol: any, bike: any);
5
- getName(): string;
6
- getPort(): any;
7
- getInterface(): any;
8
- getSupportedCyclingModes(): Array<any>;
9
- check(): Promise<unknown>;
10
- start(props: any): Promise<unknown>;
11
- getCurrentBikeData(): Promise<any>;
12
- }
1
+ import DaumAdapter from '../DaumAdapter';
2
+ export default class DaumPremiumDevice extends DaumAdapter {
3
+ static NAME: string;
4
+ constructor(protocol: any, bike: any);
5
+ getName(): string;
6
+ getPort(): any;
7
+ getInterface(): any;
8
+ getSupportedCyclingModes(): Array<any>;
9
+ check(): Promise<unknown>;
10
+ start(props: any): Promise<unknown>;
11
+ getCurrentBikeData(): Promise<any>;
12
+ }