incyclist-services 1.3.12 → 1.3.14
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.
|
@@ -18,6 +18,7 @@ export declare class DeviceRideService extends EventEmitter {
|
|
|
18
18
|
protected simulatorEnforced: boolean;
|
|
19
19
|
protected logger: EventLogger;
|
|
20
20
|
protected debug: any;
|
|
21
|
+
protected promiseSendUpdate: Promise<UpdateRequest | void>[];
|
|
21
22
|
protected deviceDataHandler: any;
|
|
22
23
|
static getInstance(): DeviceRideService;
|
|
23
24
|
constructor();
|
|
@@ -26,6 +27,7 @@ export declare class DeviceRideService extends EventEmitter {
|
|
|
26
27
|
protected waitForInit(): Promise<void>;
|
|
27
28
|
lazyInit(): Promise<void>;
|
|
28
29
|
getAdapterStateInfo(adapterInfo: AdapterInfo): AdapterStateInfo;
|
|
30
|
+
getData(): DeviceData;
|
|
29
31
|
protected getAdapterList(onlySelected?: boolean): AdapterRideInfo[];
|
|
30
32
|
prepareEppRoute(props: RideServiceDeviceProperties): PreparedRoute;
|
|
31
33
|
waitForPreviousStartToFinish(): Promise<boolean>;
|
|
@@ -53,7 +55,9 @@ export declare class DeviceRideService extends EventEmitter {
|
|
|
53
55
|
protected verifySelected(selectedDevices: any, capability: IncyclistCapability): void;
|
|
54
56
|
onData(deviceSettings: DeviceSettings, data: DeviceData): void;
|
|
55
57
|
private getEnabledCapabilities;
|
|
56
|
-
|
|
58
|
+
isUpdateBusy(): boolean;
|
|
59
|
+
waitForUpdateFinish(): Promise<void>;
|
|
60
|
+
sendUpdate(request: UpdateRequest): Promise<void>;
|
|
57
61
|
getCyclingMode(udid?: string): CyclingMode;
|
|
58
62
|
resetCyclingMode(sendInit?: boolean): Promise<void>;
|
|
59
63
|
onCyclingModeChanged(udid: string, mode: string, settings: any): Promise<void>;
|
|
@@ -80,6 +80,9 @@ class DeviceRideService extends events_1.default {
|
|
|
80
80
|
const isStarted = adapter.isStarted();
|
|
81
81
|
return { udid, name, isControl, capabilities, isStarted };
|
|
82
82
|
}
|
|
83
|
+
getData() {
|
|
84
|
+
return this.data;
|
|
85
|
+
}
|
|
83
86
|
getAdapterList(onlySelected = true) {
|
|
84
87
|
var _a;
|
|
85
88
|
if (onlySelected) {
|
|
@@ -830,13 +833,32 @@ class DeviceRideService extends events_1.default {
|
|
|
830
833
|
}
|
|
831
834
|
return { enabledCapabilities, toBeReplaced };
|
|
832
835
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
836
|
+
isUpdateBusy() {
|
|
837
|
+
return this.promiseSendUpdate !== undefined && this.promiseSendUpdate !== null;
|
|
838
|
+
}
|
|
839
|
+
waitForUpdateFinish() {
|
|
840
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
841
|
+
if (this.promiseSendUpdate) {
|
|
842
|
+
try {
|
|
843
|
+
yield Promise.allSettled(this.promiseSendUpdate);
|
|
844
|
+
}
|
|
845
|
+
catch (_a) { }
|
|
839
846
|
}
|
|
847
|
+
return;
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
sendUpdate(request) {
|
|
851
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
852
|
+
const adapters = this.getAdapterList();
|
|
853
|
+
this.promiseSendUpdate = [];
|
|
854
|
+
adapters === null || adapters === void 0 ? void 0 : adapters.forEach(ai => {
|
|
855
|
+
if (ai.adapter && ai.adapter.isControllable()) {
|
|
856
|
+
const d = ai.adapter;
|
|
857
|
+
this.promiseSendUpdate.push(d.sendUpdate(request));
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
yield this.waitForUpdateFinish();
|
|
861
|
+
this.promiseSendUpdate = undefined;
|
|
840
862
|
});
|
|
841
863
|
}
|
|
842
864
|
getCyclingMode(udid) {
|
|
@@ -29,10 +29,14 @@ class IncyclistXMLParser extends xml_1.XMLParser {
|
|
|
29
29
|
const gpxFile = Object.assign({}, fileInfo);
|
|
30
30
|
const xmlName = fileInfo.name;
|
|
31
31
|
const fileName = data['gpx-file-path'] || xmlName.replace('xml', 'gpx');
|
|
32
|
-
if (fileName.startsWith('
|
|
32
|
+
if (fileName.startsWith('file') || fileName.startsWith('/') || fileName.startsWith('\\') || fileName.startsWith('.')) {
|
|
33
33
|
gpxFile.type = 'file';
|
|
34
34
|
gpxFile.filename = fileName;
|
|
35
35
|
}
|
|
36
|
+
else if (fileName.startsWith('http')) {
|
|
37
|
+
gpxFile.type = 'url';
|
|
38
|
+
gpxFile.url = fileName;
|
|
39
|
+
}
|
|
36
40
|
else {
|
|
37
41
|
if (fileInfo.type === 'url') {
|
|
38
42
|
gpxFile.url = gpxFile.url.replace(xmlName, fileName);
|
|
@@ -38,6 +38,7 @@ export declare class WorkoutRide extends IncyclistService {
|
|
|
38
38
|
getWorkout(): Workout;
|
|
39
39
|
getObserver(): Observer;
|
|
40
40
|
protected update(startIfInitialized?: boolean): void;
|
|
41
|
+
protected resetLimits(): Promise<void>;
|
|
41
42
|
protected resetTimes(): void;
|
|
42
43
|
protected setCurrentLimits(trainingTime?: number): void;
|
|
43
44
|
protected getZoomParameters(time: number): {
|
|
@@ -33,6 +33,15 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
33
33
|
}
|
|
34
34
|
return useValue ? value : void 0;
|
|
35
35
|
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
36
45
|
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
46
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
47
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
@@ -42,6 +51,7 @@ exports.getWorkoutRide = exports.useWorkoutRide = exports.WorkoutRide = void 0;
|
|
|
42
51
|
const service_1 = require("../../base/service");
|
|
43
52
|
const types_1 = require("../../base/types");
|
|
44
53
|
const observer_1 = require("../../base/types/observer");
|
|
54
|
+
const devices_1 = require("../../devices");
|
|
45
55
|
const settings_1 = require("../../settings");
|
|
46
56
|
const utils_1 = require("../../utils");
|
|
47
57
|
const valid_1 = require("../../utils/valid");
|
|
@@ -97,6 +107,7 @@ let WorkoutRide = (() => {
|
|
|
97
107
|
this.tsCurrent = ts;
|
|
98
108
|
this.offset = 0;
|
|
99
109
|
this.manualTimeOffset = 0;
|
|
110
|
+
this.currentLimits = undefined;
|
|
100
111
|
this.emit('started');
|
|
101
112
|
this.logEvent({ message: 'workout started', settings: this.settings });
|
|
102
113
|
if (!this.updateInterval) {
|
|
@@ -314,6 +325,28 @@ let WorkoutRide = (() => {
|
|
|
314
325
|
this.logError(err, 'update');
|
|
315
326
|
}
|
|
316
327
|
}
|
|
328
|
+
resetLimits() {
|
|
329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
const rideService = (0, devices_1.useDeviceRide)();
|
|
331
|
+
rideService.resetCyclingMode();
|
|
332
|
+
const mode = rideService.getCyclingMode();
|
|
333
|
+
const data = rideService.getData();
|
|
334
|
+
const isERG = mode ? mode.constructor.supportsERGMode() : false;
|
|
335
|
+
if (!this.currentLimits || !mode)
|
|
336
|
+
return;
|
|
337
|
+
yield rideService.waitForUpdateFinish();
|
|
338
|
+
if (isERG) {
|
|
339
|
+
rideService.sendUpdate({ targetPower: data.power });
|
|
340
|
+
}
|
|
341
|
+
else if (data.slope !== undefined) {
|
|
342
|
+
rideService.sendUpdate({ slope: data.slope });
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
const initRequests = mode.getBikeInitRequest();
|
|
346
|
+
rideService.sendUpdate(initRequests);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
317
350
|
resetTimes() {
|
|
318
351
|
this.manualTimeOffset = 0;
|
|
319
352
|
this.tsStart = undefined;
|
|
@@ -412,7 +445,7 @@ let WorkoutRide = (() => {
|
|
|
412
445
|
this.state = 'idle';
|
|
413
446
|
this.resetTimes();
|
|
414
447
|
this.manualPowerOffset = 0;
|
|
415
|
-
this.
|
|
448
|
+
this.resetLimits();
|
|
416
449
|
}
|
|
417
450
|
emit(eventName, ...args) {
|
|
418
451
|
if (!this.observer)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.26"
|
|
6
6
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"axios": "^1.6.1",
|
|
46
|
-
"incyclist-devices": "^2.2.
|
|
46
|
+
"incyclist-devices": "^2.2.2",
|
|
47
47
|
"promise.any": "^2.0.6",
|
|
48
48
|
"tcx-builder": "^1.1.1",
|
|
49
49
|
"uuid": "^9.0.0",
|