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.
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +2 -2
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +2 -2
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +2 -2
- package/lib/base/adpater.d.ts +2 -1
- package/lib/base/adpater.js +7 -6
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ble-erg-mode.d.ts +2 -2
- package/lib/modes/ble-st-mode.d.ts +2 -2
- package/lib/modes/cycling-mode.d.ts +7 -7
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +3 -2
- package/lib/modes/power-meter.d.ts +2 -2
- package/lib/serial/comms.d.ts +62 -0
- package/lib/serial/comms.js +280 -0
- package/lib/serial/daum/DaumAdapter.d.ts +13 -8
- package/lib/serial/daum/DaumAdapter.js +49 -12
- package/lib/serial/daum/ERGCyclingMode.d.ts +2 -2
- package/lib/serial/daum/ERGCyclingMode.js +1 -1
- package/lib/serial/daum/SmartTrainerCyclingMode.d.ts +3 -2
- package/lib/serial/daum/SmartTrainerCyclingMode.js +10 -5
- package/lib/serial/daum/classic/adapter.d.ts +4 -6
- package/lib/serial/daum/classic/adapter.js +5 -23
- package/lib/serial/daum/classic/comms.d.ts +33 -65
- package/lib/serial/daum/classic/comms.js +148 -332
- package/lib/serial/daum/classic/mock.js +5 -3
- package/lib/serial/daum/classic/modes/daum-classic.d.ts +2 -2
- package/lib/serial/daum/classic/modes/daum-classic.js +1 -1
- package/lib/serial/daum/classic/types.d.ts +59 -0
- package/lib/serial/daum/classic/types.js +2 -0
- package/lib/serial/daum/classic/utils.d.ts +11 -10
- package/lib/serial/daum/classic/utils.js +33 -68
- package/lib/serial/daum/premium/adapter.d.ts +4 -7
- package/lib/serial/daum/premium/adapter.js +7 -30
- package/lib/serial/daum/premium/comms.d.ts +28 -105
- package/lib/serial/daum/premium/comms.js +262 -466
- package/lib/serial/daum/premium/consts.d.ts +6 -0
- package/lib/serial/daum/premium/consts.js +9 -0
- package/lib/serial/daum/premium/mock.d.ts +32 -1
- package/lib/serial/daum/premium/mock.js +131 -8
- package/lib/serial/daum/premium/modes/daum-classic.d.ts +2 -2
- package/lib/serial/daum/premium/modes/daum-classic.js +1 -1
- package/lib/serial/daum/premium/types.d.ts +35 -1
- package/lib/serial/daum/premium/types.js +29 -0
- package/lib/serial/daum/premium/utils.d.ts +11 -18
- package/lib/serial/daum/premium/utils.js +25 -18
- package/lib/serial/serial-interface.js +17 -10
- package/lib/types/adapter.d.ts +2 -0
- package/lib/types/device.d.ts +11 -0
- package/lib/types/route.d.ts +0 -5
- package/lib/types/route.js +0 -7
- package/lib/utils/calculations.js +1 -5
- package/lib/utils/utils.d.ts +2 -1
- package/lib/utils/utils.js +39 -3
- package/package.json +3 -2
package/lib/types/route.d.ts
CHANGED
package/lib/types/route.js
CHANGED
|
@@ -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']
|
|
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;
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -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>;
|
package/lib/utils/utils.js
CHANGED
|
@@ -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
|
|
102
|
+
return this.data.length;
|
|
103
103
|
}
|
|
104
104
|
clear() {
|
|
105
105
|
this.data = [];
|
|
106
106
|
}
|
|
107
107
|
isEmpty() {
|
|
108
|
-
return this.
|
|
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.
|
|
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/"
|