incyclist-devices 2.0.34 → 2.0.36

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 (54) hide show
  1. package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +2 -2
  2. package/lib/antv2/modes/ant-fe-erg-mode.d.ts +2 -2
  3. package/lib/antv2/modes/ant-fe-st-mode.d.ts +2 -2
  4. package/lib/base/adpater.d.ts +2 -1
  5. package/lib/base/adpater.js +7 -6
  6. package/lib/interfaces.d.ts +1 -1
  7. package/lib/modes/ble-erg-mode.d.ts +2 -2
  8. package/lib/modes/ble-st-mode.d.ts +2 -2
  9. package/lib/modes/cycling-mode.d.ts +7 -7
  10. package/lib/modes/power-base.d.ts +3 -3
  11. package/lib/modes/power-base.js +3 -2
  12. package/lib/modes/power-meter.d.ts +2 -2
  13. package/lib/serial/comms.d.ts +62 -0
  14. package/lib/serial/comms.js +280 -0
  15. package/lib/serial/daum/DaumAdapter.d.ts +13 -8
  16. package/lib/serial/daum/DaumAdapter.js +49 -12
  17. package/lib/serial/daum/ERGCyclingMode.d.ts +2 -2
  18. package/lib/serial/daum/ERGCyclingMode.js +1 -1
  19. package/lib/serial/daum/SmartTrainerCyclingMode.d.ts +3 -2
  20. package/lib/serial/daum/SmartTrainerCyclingMode.js +10 -5
  21. package/lib/serial/daum/classic/adapter.d.ts +4 -6
  22. package/lib/serial/daum/classic/adapter.js +5 -23
  23. package/lib/serial/daum/classic/comms.d.ts +33 -65
  24. package/lib/serial/daum/classic/comms.js +148 -332
  25. package/lib/serial/daum/classic/mock.js +5 -3
  26. package/lib/serial/daum/classic/modes/daum-classic.d.ts +2 -2
  27. package/lib/serial/daum/classic/modes/daum-classic.js +1 -1
  28. package/lib/serial/daum/classic/types.d.ts +59 -0
  29. package/lib/serial/daum/classic/types.js +2 -0
  30. package/lib/serial/daum/classic/utils.d.ts +11 -10
  31. package/lib/serial/daum/classic/utils.js +33 -68
  32. package/lib/serial/daum/premium/adapter.d.ts +4 -7
  33. package/lib/serial/daum/premium/adapter.js +7 -30
  34. package/lib/serial/daum/premium/comms.d.ts +28 -105
  35. package/lib/serial/daum/premium/comms.js +262 -466
  36. package/lib/serial/daum/premium/consts.d.ts +6 -0
  37. package/lib/serial/daum/premium/consts.js +9 -0
  38. package/lib/serial/daum/premium/mock.d.ts +32 -1
  39. package/lib/serial/daum/premium/mock.js +131 -8
  40. package/lib/serial/daum/premium/modes/daum-classic.d.ts +2 -2
  41. package/lib/serial/daum/premium/modes/daum-classic.js +1 -1
  42. package/lib/serial/daum/premium/types.d.ts +35 -1
  43. package/lib/serial/daum/premium/types.js +29 -0
  44. package/lib/serial/daum/premium/utils.d.ts +11 -18
  45. package/lib/serial/daum/premium/utils.js +25 -18
  46. package/lib/serial/serial-interface.js +17 -10
  47. package/lib/types/adapter.d.ts +2 -0
  48. package/lib/types/device.d.ts +11 -0
  49. package/lib/types/route.d.ts +0 -5
  50. package/lib/types/route.js +0 -7
  51. package/lib/utils/calculations.js +1 -5
  52. package/lib/utils/utils.d.ts +2 -1
  53. package/lib/utils/utils.js +39 -3
  54. package/package.json +3 -2
@@ -5,11 +5,6 @@ export type Point = {
5
5
  distance: number;
6
6
  slope?: number;
7
7
  };
8
- export declare enum RouteType {
9
- FREE_RIDE = "free ride",
10
- FOLLOW_ROUTE = "follow route",
11
- VIDEO = "video"
12
- }
13
8
  export type Route = {
14
9
  programId: number;
15
10
  points: Point[];
@@ -1,9 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RouteType = void 0;
4
- var RouteType;
5
- (function (RouteType) {
6
- RouteType["FREE_RIDE"] = "free ride";
7
- RouteType["FOLLOW_ROUTE"] = "follow route";
8
- RouteType["VIDEO"] = "video";
9
- })(RouteType || (exports.RouteType = RouteType = {}));
@@ -22,8 +22,6 @@ class C {
22
22
  throw new IllegalArgumentException("m must be a positive number");
23
23
  if (power === undefined || power === null || power < 0)
24
24
  throw new IllegalArgumentException("power must be a positive number");
25
- if (slope === undefined || slope === null)
26
- slope = 0;
27
25
  const _rho = props.rho || rho;
28
26
  const _cRR = props.cRR || cRR;
29
27
  const _cwA = props.cwA || cwABike[props.bikeType || 'race'] || cwABike.race;
@@ -64,11 +62,9 @@ class C {
64
62
  throw new IllegalArgumentException("m must be a positive number");
65
63
  if (v === undefined || v === null || v < 0)
66
64
  throw new IllegalArgumentException("v must be a positive number");
67
- if (slope === undefined || slope === null)
68
- slope = 0;
69
65
  let _rho = props.rho || rho;
70
66
  let _cRR = props.cRR || cRR;
71
- let _cwA = props.cwA || cwABike[props.bikeType || 'race'] || cwABike.race;
67
+ let _cwA = props.cwA || cwABike[props.bikeType || 'race'];
72
68
  let sl = Math.sin(Math.atan(slope / 100));
73
69
  let P = (0.5 * _rho * _cwA) * Math.pow(v, 3.0) + (sl + _cRR) * m * g * v;
74
70
  return P;
@@ -5,7 +5,7 @@ export declare function floatVal(d?: number | string): number;
5
5
  export declare function intVal(d?: number | string): number;
6
6
  export declare function hexstr(arr: any, start?: any, len?: any): string;
7
7
  export declare class Queue<T> {
8
- data: Array<T>;
8
+ protected data: Array<T>;
9
9
  constructor(values?: Array<T>);
10
10
  size(): number;
11
11
  clear(): void;
@@ -13,3 +13,4 @@ export declare class Queue<T> {
13
13
  dequeue(): T;
14
14
  enqueue(value: T): void;
15
15
  }
16
+ export declare function waitWithTimeout(promise: Promise<any>, timeout: number, onTimeout?: () => void): Promise<any>;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Queue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.resolveNextTick = exports.sleep = void 0;
12
+ exports.waitWithTimeout = exports.Queue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.resolveNextTick = exports.sleep = void 0;
13
13
  const sleep = (ms) => {
14
14
  return new Promise(resolve => setTimeout(resolve, ms));
15
15
  };
@@ -99,13 +99,13 @@ class Queue {
99
99
  this.data = values;
100
100
  }
101
101
  size() {
102
- return this.data ? this.data.length : 0;
102
+ return this.data.length;
103
103
  }
104
104
  clear() {
105
105
  this.data = [];
106
106
  }
107
107
  isEmpty() {
108
- return this.data === undefined || this.data.length === 0;
108
+ return this.size() === 0;
109
109
  }
110
110
  dequeue() {
111
111
  const removed = this.data.splice(0, 1);
@@ -116,3 +116,39 @@ class Queue {
116
116
  }
117
117
  }
118
118
  exports.Queue = Queue;
119
+ function waitWithTimeout(promise, timeout, onTimeout) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ let to;
122
+ let hasTimedOut = false;
123
+ const toPromise = (ms) => {
124
+ return new Promise((resolve, reject) => {
125
+ to = setTimeout(() => {
126
+ hasTimedOut = true;
127
+ if (!onTimeout) {
128
+ reject(new Error('Timeout'));
129
+ }
130
+ else {
131
+ try {
132
+ onTimeout();
133
+ resolve();
134
+ }
135
+ catch (err) {
136
+ reject(err);
137
+ }
138
+ }
139
+ }, ms);
140
+ });
141
+ };
142
+ let res;
143
+ try {
144
+ res = yield Promise.race([promise, toPromise(timeout)]);
145
+ }
146
+ catch (err) {
147
+ if (err.message === 'Timeout' && hasTimedOut)
148
+ throw err;
149
+ }
150
+ clearTimeout(to);
151
+ return res;
152
+ });
153
+ }
154
+ exports.waitWithTimeout = waitWithTimeout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.34",
3
+ "version": "2.0.36",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",
@@ -29,7 +29,8 @@
29
29
  "build": "tsc",
30
30
  "test": "jest --coverage",
31
31
  "test:ci": "jest --coverage --forceExit",
32
- "dev": "tsc --watch"
32
+ "dev": "tsc --watch",
33
+ "postversion": "git push && git push --tags"
33
34
  },
34
35
  "files": [
35
36
  "lib/"