incyclist-services 1.7.31 → 1.7.33
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/cjs/activities/ride/service.js +48 -9
- package/lib/cjs/devices/configuration/service.js +4 -0
- package/lib/cjs/devices/ride/service.js +32 -0
- package/lib/cjs/ride/display/service.js +3 -0
- package/lib/esm/activities/ride/service.js +48 -9
- package/lib/esm/devices/configuration/service.js +4 -0
- package/lib/esm/devices/ride/service.js +32 -0
- package/lib/esm/ride/display/service.js +3 -0
- package/lib/types/activities/ride/service.d.ts +2 -0
- package/lib/types/devices/access/service.d.ts +1 -1
- package/lib/types/devices/configuration/service.d.ts +1 -0
- package/lib/types/devices/ride/service.d.ts +6 -1
- package/package.json +2 -2
|
@@ -61,6 +61,8 @@ const utils_2 = require("../base/utils");
|
|
|
61
61
|
const decorators_1 = require("../../base/decorators");
|
|
62
62
|
const i18n_1 = require("../../i18n");
|
|
63
63
|
const utils_3 = require("../list/utils");
|
|
64
|
+
const sleep_1 = require("../../utils/sleep");
|
|
65
|
+
const node_events_1 = require("node:events");
|
|
64
66
|
const SAVE_INTERVAL = 5000;
|
|
65
67
|
let ActivityRideService = (() => {
|
|
66
68
|
let _classDecorators = [types_1.Singleton];
|
|
@@ -69,12 +71,15 @@ let ActivityRideService = (() => {
|
|
|
69
71
|
let _classThis;
|
|
70
72
|
let _classSuper = service_1.IncyclistService;
|
|
71
73
|
let _instanceExtraInitializers = [];
|
|
74
|
+
let _getBindings_decorators;
|
|
72
75
|
let _getUnitConverter_decorators;
|
|
73
76
|
var ActivityRideService = class extends _classSuper {
|
|
74
77
|
static { _classThis = this; }
|
|
75
78
|
static {
|
|
76
79
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
80
|
+
_getBindings_decorators = [decorators_1.Injectable];
|
|
77
81
|
_getUnitConverter_decorators = [decorators_1.Injectable];
|
|
82
|
+
__esDecorate(this, null, _getBindings_decorators, { kind: "method", name: "getBindings", static: false, private: false, access: { has: obj => "getBindings" in obj, get: obj => obj.getBindings }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
78
83
|
__esDecorate(this, null, _getUnitConverter_decorators, { kind: "method", name: "getUnitConverter", static: false, private: false, access: { has: obj => "getUnitConverter" in obj, get: obj => obj.getUnitConverter }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
79
84
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
80
85
|
ActivityRideService = _classThis = _classDescriptor.value;
|
|
@@ -243,15 +248,17 @@ let ActivityRideService = (() => {
|
|
|
243
248
|
const display = Math.floor(time / 3) % 2;
|
|
244
249
|
const avgMaxStats = (display === 0) ? this.getAverageValues() : this.getMaximumValues();
|
|
245
250
|
const info = this.buildDashboardInfo(currentValues, avgMaxStats, display);
|
|
246
|
-
let showLog =
|
|
251
|
+
let showLog = this.state !== 'paused';
|
|
247
252
|
try {
|
|
248
253
|
const infoStr = JSON.stringify(info);
|
|
249
|
-
showLog = infoStr !== this.current.info;
|
|
254
|
+
showLog = (showLog || this.current.isAutoResume) && (infoStr !== this.current.info);
|
|
250
255
|
this.current.info = infoStr;
|
|
251
256
|
}
|
|
252
257
|
catch { }
|
|
253
|
-
if (showLog)
|
|
258
|
+
if (showLog) {
|
|
259
|
+
console.log('# here', this.state);
|
|
254
260
|
this.logEvent({ message: 'Dashboard update', items: info.map(i => `${i.title}:${i.data[0]?.value ?? ''}:${i.data[1]?.value ?? ''}${i.data[1]?.label ? '(' + i.data[1]?.label + ')' : ''}`).join('|') });
|
|
261
|
+
}
|
|
255
262
|
return info;
|
|
256
263
|
}
|
|
257
264
|
catch (err) {
|
|
@@ -458,19 +465,36 @@ let ActivityRideService = (() => {
|
|
|
458
465
|
this.saveObserver.emit(event, ...args);
|
|
459
466
|
};
|
|
460
467
|
const run = async () => {
|
|
468
|
+
let cntCompleted = 0;
|
|
461
469
|
let success = false;
|
|
470
|
+
const localEmitter = new node_events_1.EventEmitter();
|
|
471
|
+
const incCompleted = () => {
|
|
472
|
+
cntCompleted++;
|
|
473
|
+
if (cntCompleted >= 2) {
|
|
474
|
+
localEmitter.emit('completed');
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
localEmitter.once('completed', () => {
|
|
478
|
+
(0, sleep_1.sleep)(0).then(() => {
|
|
479
|
+
delete this.saveObserver;
|
|
480
|
+
});
|
|
481
|
+
});
|
|
462
482
|
try {
|
|
463
483
|
emit('start', success);
|
|
464
484
|
await this._save();
|
|
465
485
|
let format = undefined;
|
|
466
486
|
let uploadSuccess = false;
|
|
467
487
|
let convertSuccess = await this.convert('TCX');
|
|
488
|
+
incCompleted();
|
|
468
489
|
if (convertSuccess) {
|
|
469
490
|
format = 'TCX';
|
|
470
|
-
this.convert('FIT')
|
|
491
|
+
this.convert('FIT')
|
|
492
|
+
.then(incCompleted)
|
|
493
|
+
.catch(incCompleted);
|
|
471
494
|
}
|
|
472
495
|
else {
|
|
473
496
|
convertSuccess = await this.convert('FIT');
|
|
497
|
+
cntCompleted++;
|
|
474
498
|
if (convertSuccess)
|
|
475
499
|
format = 'FIT';
|
|
476
500
|
}
|
|
@@ -481,12 +505,10 @@ let ActivityRideService = (() => {
|
|
|
481
505
|
this.isSaveDone = true;
|
|
482
506
|
}
|
|
483
507
|
catch {
|
|
508
|
+
cntCompleted++;
|
|
484
509
|
success = false;
|
|
485
510
|
}
|
|
486
511
|
emit('done', success);
|
|
487
|
-
(0, utils_1.waitNextTick)().then(() => {
|
|
488
|
-
delete this.saveObserver;
|
|
489
|
-
});
|
|
490
512
|
return success;
|
|
491
513
|
};
|
|
492
514
|
this.saveObserver = new observer_1.PromiseObserver(run());
|
|
@@ -824,6 +846,18 @@ let ActivityRideService = (() => {
|
|
|
824
846
|
}
|
|
825
847
|
}
|
|
826
848
|
}
|
|
849
|
+
async getTargetFileName(format) {
|
|
850
|
+
let fileName = this.activity.fileName.replace('json', format);
|
|
851
|
+
if (fileName.startsWith('mmkv:/db_')) {
|
|
852
|
+
const fs = this.getFileSystemBinding();
|
|
853
|
+
const appDir = this.getBindings().appInfo.getAppDir();
|
|
854
|
+
const activitiesDir = this.getBindings().path.join(appDir, 'activities');
|
|
855
|
+
await fs.ensureDir(activitiesDir);
|
|
856
|
+
const baseName = fileName.split('/').pop();
|
|
857
|
+
fileName = this.getBindings().path.join(activitiesDir, baseName);
|
|
858
|
+
}
|
|
859
|
+
return fileName;
|
|
860
|
+
}
|
|
827
861
|
async convert(format) {
|
|
828
862
|
const emit = (event, ...args) => {
|
|
829
863
|
if (this.saveObserver)
|
|
@@ -844,19 +878,21 @@ let ActivityRideService = (() => {
|
|
|
844
878
|
data = await base_1.ActivityConverter.convert(this.activity, format);
|
|
845
879
|
emit('convert.done', format, true);
|
|
846
880
|
if (format.toLowerCase() === 'fit') {
|
|
847
|
-
const fileName = this.
|
|
881
|
+
const fileName = await this.getTargetFileName('fit');
|
|
848
882
|
await fs.writeFile(fileName, Buffer.from(data));
|
|
849
883
|
this.activity.fitFileName = fileName;
|
|
850
884
|
}
|
|
851
885
|
if (format.toLowerCase() === 'tcx') {
|
|
852
|
-
const fileName = this.
|
|
886
|
+
const fileName = await this.getTargetFileName('tcx');
|
|
853
887
|
await fs.writeFile(fileName, Buffer.from(data));
|
|
854
888
|
this.activity.tcxFileName = fileName;
|
|
855
889
|
}
|
|
856
890
|
await this._save();
|
|
891
|
+
emit('save.done', format, true);
|
|
857
892
|
return true;
|
|
858
893
|
}
|
|
859
894
|
catch (err) {
|
|
895
|
+
console.log('# convert error', err.message);
|
|
860
896
|
emit('convert.error', format, err);
|
|
861
897
|
return false;
|
|
862
898
|
}
|
|
@@ -1236,6 +1272,9 @@ let ActivityRideService = (() => {
|
|
|
1236
1272
|
getFileSystemBinding() {
|
|
1237
1273
|
return (0, api_1.getBindings)().fs;
|
|
1238
1274
|
}
|
|
1275
|
+
getBindings() {
|
|
1276
|
+
return (0, api_1.getBindings)();
|
|
1277
|
+
}
|
|
1239
1278
|
getUnitConversionShortcuts() {
|
|
1240
1279
|
const c = this.getUnitConverter();
|
|
1241
1280
|
const C = c.convert.bind(c);
|
|
@@ -540,6 +540,10 @@ let DeviceConfigurationService = (() => {
|
|
|
540
540
|
confirmWifiInterface() {
|
|
541
541
|
this.getUserSettings().set('wifiConfirmed', true);
|
|
542
542
|
}
|
|
543
|
+
getEnabledInterfaces() {
|
|
544
|
+
const config = this.settings?.interfaces ?? [];
|
|
545
|
+
return config.filter(i => i?.enabled).map(i => i.name);
|
|
546
|
+
}
|
|
543
547
|
getInterfaceSettings(ifName) {
|
|
544
548
|
if (!this.settings)
|
|
545
549
|
this.settings = { interfaces: [] };
|
|
@@ -94,6 +94,7 @@ let DeviceRideService = (() => {
|
|
|
94
94
|
lastDataInfo = {};
|
|
95
95
|
reconnectBusy;
|
|
96
96
|
prevUpdate;
|
|
97
|
+
logPaused = false;
|
|
97
98
|
constructor() {
|
|
98
99
|
super('DeviceRide');
|
|
99
100
|
this.initizialized = false;
|
|
@@ -133,6 +134,32 @@ let DeviceRideService = (() => {
|
|
|
133
134
|
getData() {
|
|
134
135
|
return this.data;
|
|
135
136
|
}
|
|
137
|
+
pauseLogging() {
|
|
138
|
+
console.log('# PAUSE LOGGING');
|
|
139
|
+
this.logPaused = true;
|
|
140
|
+
const interfaces = this.getEnabledInterfaces();
|
|
141
|
+
interfaces.forEach(i => i.pauseLogging());
|
|
142
|
+
this.getAllAdapters()
|
|
143
|
+
.map(ai => ai.adapter)
|
|
144
|
+
.filter(a => a !== undefined)
|
|
145
|
+
.forEach(a => a.pauseLogging());
|
|
146
|
+
}
|
|
147
|
+
resumeLogging() {
|
|
148
|
+
console.log('# RESUME LOGGING');
|
|
149
|
+
this.logPaused = false;
|
|
150
|
+
const interfaces = this.getEnabledInterfaces();
|
|
151
|
+
interfaces.forEach(i => i.resumeLogging());
|
|
152
|
+
this.getAllAdapters()
|
|
153
|
+
.map(ai => ai.adapter)
|
|
154
|
+
.filter(a => a !== undefined)
|
|
155
|
+
.forEach(a => a.resumeLogging());
|
|
156
|
+
}
|
|
157
|
+
getEnabledInterfaces() {
|
|
158
|
+
const config = this.getDeviceConfiguration();
|
|
159
|
+
const access = this.getDeviceAccess();
|
|
160
|
+
const names = config.getEnabledInterfaces() ?? [];
|
|
161
|
+
return names.map(i => access.getInterface(i)).filter(n => n !== undefined);
|
|
162
|
+
}
|
|
136
163
|
getRideAdapters() {
|
|
137
164
|
if (this.rideAdapters?.length)
|
|
138
165
|
return this.rideAdapters;
|
|
@@ -1302,6 +1329,11 @@ let DeviceRideService = (() => {
|
|
|
1302
1329
|
return true;
|
|
1303
1330
|
return (0, settings_1.useUserSettings)().isNewUser();
|
|
1304
1331
|
}
|
|
1332
|
+
logEvent(event) {
|
|
1333
|
+
if (this.logPaused)
|
|
1334
|
+
return;
|
|
1335
|
+
super.logEvent(event);
|
|
1336
|
+
}
|
|
1305
1337
|
cleanInternalCache() {
|
|
1306
1338
|
delete this.rideAdapters;
|
|
1307
1339
|
}
|
|
@@ -191,6 +191,7 @@ let RideDisplayService = (() => {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
pause(requester = 'user') {
|
|
194
|
+
console.log('# PAUSE', requester);
|
|
194
195
|
try {
|
|
195
196
|
if (this.state !== 'Active')
|
|
196
197
|
return;
|
|
@@ -199,6 +200,7 @@ let RideDisplayService = (() => {
|
|
|
199
200
|
this.getCoaches().pauseRide();
|
|
200
201
|
if (requester === 'user') {
|
|
201
202
|
this.getActivityRide().pause(false);
|
|
203
|
+
this.getDeviceRide().pauseLogging();
|
|
202
204
|
}
|
|
203
205
|
this.getWorkoutRide().pause();
|
|
204
206
|
this.displayService.pause();
|
|
@@ -219,6 +221,7 @@ let RideDisplayService = (() => {
|
|
|
219
221
|
this.getCoaches().resumeRide();
|
|
220
222
|
if (requester === 'user') {
|
|
221
223
|
this.getActivityRide().resume('user');
|
|
224
|
+
this.getDeviceRide().resumeLogging();
|
|
222
225
|
}
|
|
223
226
|
this.getWorkoutRide().resume();
|
|
224
227
|
this.pauseReason = 'device';
|
|
@@ -55,6 +55,8 @@ import { buildSummary } from "../base/utils";
|
|
|
55
55
|
import { Injectable } from "../../base/decorators";
|
|
56
56
|
import { useUnitConverter } from "../../i18n";
|
|
57
57
|
import { createUIActivityDetails } from "../list/utils";
|
|
58
|
+
import { sleep } from "../../utils/sleep";
|
|
59
|
+
import { EventEmitter } from "node:events";
|
|
58
60
|
const SAVE_INTERVAL = 5000;
|
|
59
61
|
let ActivityRideService = (() => {
|
|
60
62
|
let _classDecorators = [Singleton];
|
|
@@ -63,12 +65,15 @@ let ActivityRideService = (() => {
|
|
|
63
65
|
let _classThis;
|
|
64
66
|
let _classSuper = IncyclistService;
|
|
65
67
|
let _instanceExtraInitializers = [];
|
|
68
|
+
let _getBindings_decorators;
|
|
66
69
|
let _getUnitConverter_decorators;
|
|
67
70
|
var ActivityRideService = class extends _classSuper {
|
|
68
71
|
static { _classThis = this; }
|
|
69
72
|
static {
|
|
70
73
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
74
|
+
_getBindings_decorators = [Injectable];
|
|
71
75
|
_getUnitConverter_decorators = [Injectable];
|
|
76
|
+
__esDecorate(this, null, _getBindings_decorators, { kind: "method", name: "getBindings", static: false, private: false, access: { has: obj => "getBindings" in obj, get: obj => obj.getBindings }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
72
77
|
__esDecorate(this, null, _getUnitConverter_decorators, { kind: "method", name: "getUnitConverter", static: false, private: false, access: { has: obj => "getUnitConverter" in obj, get: obj => obj.getUnitConverter }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
73
78
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
74
79
|
ActivityRideService = _classThis = _classDescriptor.value;
|
|
@@ -237,15 +242,17 @@ let ActivityRideService = (() => {
|
|
|
237
242
|
const display = Math.floor(time / 3) % 2;
|
|
238
243
|
const avgMaxStats = (display === 0) ? this.getAverageValues() : this.getMaximumValues();
|
|
239
244
|
const info = this.buildDashboardInfo(currentValues, avgMaxStats, display);
|
|
240
|
-
let showLog =
|
|
245
|
+
let showLog = this.state !== 'paused';
|
|
241
246
|
try {
|
|
242
247
|
const infoStr = JSON.stringify(info);
|
|
243
|
-
showLog = infoStr !== this.current.info;
|
|
248
|
+
showLog = (showLog || this.current.isAutoResume) && (infoStr !== this.current.info);
|
|
244
249
|
this.current.info = infoStr;
|
|
245
250
|
}
|
|
246
251
|
catch { }
|
|
247
|
-
if (showLog)
|
|
252
|
+
if (showLog) {
|
|
253
|
+
console.log('# here', this.state);
|
|
248
254
|
this.logEvent({ message: 'Dashboard update', items: info.map(i => `${i.title}:${i.data[0]?.value ?? ''}:${i.data[1]?.value ?? ''}${i.data[1]?.label ? '(' + i.data[1]?.label + ')' : ''}`).join('|') });
|
|
255
|
+
}
|
|
249
256
|
return info;
|
|
250
257
|
}
|
|
251
258
|
catch (err) {
|
|
@@ -452,19 +459,36 @@ let ActivityRideService = (() => {
|
|
|
452
459
|
this.saveObserver.emit(event, ...args);
|
|
453
460
|
};
|
|
454
461
|
const run = async () => {
|
|
462
|
+
let cntCompleted = 0;
|
|
455
463
|
let success = false;
|
|
464
|
+
const localEmitter = new EventEmitter();
|
|
465
|
+
const incCompleted = () => {
|
|
466
|
+
cntCompleted++;
|
|
467
|
+
if (cntCompleted >= 2) {
|
|
468
|
+
localEmitter.emit('completed');
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
localEmitter.once('completed', () => {
|
|
472
|
+
sleep(0).then(() => {
|
|
473
|
+
delete this.saveObserver;
|
|
474
|
+
});
|
|
475
|
+
});
|
|
456
476
|
try {
|
|
457
477
|
emit('start', success);
|
|
458
478
|
await this._save();
|
|
459
479
|
let format = undefined;
|
|
460
480
|
let uploadSuccess = false;
|
|
461
481
|
let convertSuccess = await this.convert('TCX');
|
|
482
|
+
incCompleted();
|
|
462
483
|
if (convertSuccess) {
|
|
463
484
|
format = 'TCX';
|
|
464
|
-
this.convert('FIT')
|
|
485
|
+
this.convert('FIT')
|
|
486
|
+
.then(incCompleted)
|
|
487
|
+
.catch(incCompleted);
|
|
465
488
|
}
|
|
466
489
|
else {
|
|
467
490
|
convertSuccess = await this.convert('FIT');
|
|
491
|
+
cntCompleted++;
|
|
468
492
|
if (convertSuccess)
|
|
469
493
|
format = 'FIT';
|
|
470
494
|
}
|
|
@@ -475,12 +499,10 @@ let ActivityRideService = (() => {
|
|
|
475
499
|
this.isSaveDone = true;
|
|
476
500
|
}
|
|
477
501
|
catch {
|
|
502
|
+
cntCompleted++;
|
|
478
503
|
success = false;
|
|
479
504
|
}
|
|
480
505
|
emit('done', success);
|
|
481
|
-
waitNextTick().then(() => {
|
|
482
|
-
delete this.saveObserver;
|
|
483
|
-
});
|
|
484
506
|
return success;
|
|
485
507
|
};
|
|
486
508
|
this.saveObserver = new PromiseObserver(run());
|
|
@@ -818,6 +840,18 @@ let ActivityRideService = (() => {
|
|
|
818
840
|
}
|
|
819
841
|
}
|
|
820
842
|
}
|
|
843
|
+
async getTargetFileName(format) {
|
|
844
|
+
let fileName = this.activity.fileName.replace('json', format);
|
|
845
|
+
if (fileName.startsWith('mmkv:/db_')) {
|
|
846
|
+
const fs = this.getFileSystemBinding();
|
|
847
|
+
const appDir = this.getBindings().appInfo.getAppDir();
|
|
848
|
+
const activitiesDir = this.getBindings().path.join(appDir, 'activities');
|
|
849
|
+
await fs.ensureDir(activitiesDir);
|
|
850
|
+
const baseName = fileName.split('/').pop();
|
|
851
|
+
fileName = this.getBindings().path.join(activitiesDir, baseName);
|
|
852
|
+
}
|
|
853
|
+
return fileName;
|
|
854
|
+
}
|
|
821
855
|
async convert(format) {
|
|
822
856
|
const emit = (event, ...args) => {
|
|
823
857
|
if (this.saveObserver)
|
|
@@ -838,19 +872,21 @@ let ActivityRideService = (() => {
|
|
|
838
872
|
data = await ActivityConverter.convert(this.activity, format);
|
|
839
873
|
emit('convert.done', format, true);
|
|
840
874
|
if (format.toLowerCase() === 'fit') {
|
|
841
|
-
const fileName = this.
|
|
875
|
+
const fileName = await this.getTargetFileName('fit');
|
|
842
876
|
await fs.writeFile(fileName, Buffer.from(data));
|
|
843
877
|
this.activity.fitFileName = fileName;
|
|
844
878
|
}
|
|
845
879
|
if (format.toLowerCase() === 'tcx') {
|
|
846
|
-
const fileName = this.
|
|
880
|
+
const fileName = await this.getTargetFileName('tcx');
|
|
847
881
|
await fs.writeFile(fileName, Buffer.from(data));
|
|
848
882
|
this.activity.tcxFileName = fileName;
|
|
849
883
|
}
|
|
850
884
|
await this._save();
|
|
885
|
+
emit('save.done', format, true);
|
|
851
886
|
return true;
|
|
852
887
|
}
|
|
853
888
|
catch (err) {
|
|
889
|
+
console.log('# convert error', err.message);
|
|
854
890
|
emit('convert.error', format, err);
|
|
855
891
|
return false;
|
|
856
892
|
}
|
|
@@ -1230,6 +1266,9 @@ let ActivityRideService = (() => {
|
|
|
1230
1266
|
getFileSystemBinding() {
|
|
1231
1267
|
return getBindings().fs;
|
|
1232
1268
|
}
|
|
1269
|
+
getBindings() {
|
|
1270
|
+
return getBindings();
|
|
1271
|
+
}
|
|
1233
1272
|
getUnitConversionShortcuts() {
|
|
1234
1273
|
const c = this.getUnitConverter();
|
|
1235
1274
|
const C = c.convert.bind(c);
|
|
@@ -534,6 +534,10 @@ let DeviceConfigurationService = (() => {
|
|
|
534
534
|
confirmWifiInterface() {
|
|
535
535
|
this.getUserSettings().set('wifiConfirmed', true);
|
|
536
536
|
}
|
|
537
|
+
getEnabledInterfaces() {
|
|
538
|
+
const config = this.settings?.interfaces ?? [];
|
|
539
|
+
return config.filter(i => i?.enabled).map(i => i.name);
|
|
540
|
+
}
|
|
537
541
|
getInterfaceSettings(ifName) {
|
|
538
542
|
if (!this.settings)
|
|
539
543
|
this.settings = { interfaces: [] };
|
|
@@ -88,6 +88,7 @@ let DeviceRideService = (() => {
|
|
|
88
88
|
lastDataInfo = {};
|
|
89
89
|
reconnectBusy;
|
|
90
90
|
prevUpdate;
|
|
91
|
+
logPaused = false;
|
|
91
92
|
constructor() {
|
|
92
93
|
super('DeviceRide');
|
|
93
94
|
this.initizialized = false;
|
|
@@ -127,6 +128,32 @@ let DeviceRideService = (() => {
|
|
|
127
128
|
getData() {
|
|
128
129
|
return this.data;
|
|
129
130
|
}
|
|
131
|
+
pauseLogging() {
|
|
132
|
+
console.log('# PAUSE LOGGING');
|
|
133
|
+
this.logPaused = true;
|
|
134
|
+
const interfaces = this.getEnabledInterfaces();
|
|
135
|
+
interfaces.forEach(i => i.pauseLogging());
|
|
136
|
+
this.getAllAdapters()
|
|
137
|
+
.map(ai => ai.adapter)
|
|
138
|
+
.filter(a => a !== undefined)
|
|
139
|
+
.forEach(a => a.pauseLogging());
|
|
140
|
+
}
|
|
141
|
+
resumeLogging() {
|
|
142
|
+
console.log('# RESUME LOGGING');
|
|
143
|
+
this.logPaused = false;
|
|
144
|
+
const interfaces = this.getEnabledInterfaces();
|
|
145
|
+
interfaces.forEach(i => i.resumeLogging());
|
|
146
|
+
this.getAllAdapters()
|
|
147
|
+
.map(ai => ai.adapter)
|
|
148
|
+
.filter(a => a !== undefined)
|
|
149
|
+
.forEach(a => a.resumeLogging());
|
|
150
|
+
}
|
|
151
|
+
getEnabledInterfaces() {
|
|
152
|
+
const config = this.getDeviceConfiguration();
|
|
153
|
+
const access = this.getDeviceAccess();
|
|
154
|
+
const names = config.getEnabledInterfaces() ?? [];
|
|
155
|
+
return names.map(i => access.getInterface(i)).filter(n => n !== undefined);
|
|
156
|
+
}
|
|
130
157
|
getRideAdapters() {
|
|
131
158
|
if (this.rideAdapters?.length)
|
|
132
159
|
return this.rideAdapters;
|
|
@@ -1296,6 +1323,11 @@ let DeviceRideService = (() => {
|
|
|
1296
1323
|
return true;
|
|
1297
1324
|
return useUserSettings().isNewUser();
|
|
1298
1325
|
}
|
|
1326
|
+
logEvent(event) {
|
|
1327
|
+
if (this.logPaused)
|
|
1328
|
+
return;
|
|
1329
|
+
super.logEvent(event);
|
|
1330
|
+
}
|
|
1299
1331
|
cleanInternalCache() {
|
|
1300
1332
|
delete this.rideAdapters;
|
|
1301
1333
|
}
|
|
@@ -188,6 +188,7 @@ let RideDisplayService = (() => {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
pause(requester = 'user') {
|
|
191
|
+
console.log('# PAUSE', requester);
|
|
191
192
|
try {
|
|
192
193
|
if (this.state !== 'Active')
|
|
193
194
|
return;
|
|
@@ -196,6 +197,7 @@ let RideDisplayService = (() => {
|
|
|
196
197
|
this.getCoaches().pauseRide();
|
|
197
198
|
if (requester === 'user') {
|
|
198
199
|
this.getActivityRide().pause(false);
|
|
200
|
+
this.getDeviceRide().pauseLogging();
|
|
199
201
|
}
|
|
200
202
|
this.getWorkoutRide().pause();
|
|
201
203
|
this.displayService.pause();
|
|
@@ -216,6 +218,7 @@ let RideDisplayService = (() => {
|
|
|
216
218
|
this.getCoaches().resumeRide();
|
|
217
219
|
if (requester === 'user') {
|
|
218
220
|
this.getActivityRide().resume('user');
|
|
221
|
+
this.getDeviceRide().resumeLogging();
|
|
219
222
|
}
|
|
220
223
|
this.getWorkoutRide().resume();
|
|
221
224
|
this.pauseReason = 'device';
|
|
@@ -175,6 +175,7 @@ export declare class ActivityRideService extends IncyclistService {
|
|
|
175
175
|
protected _save(): Promise<void>;
|
|
176
176
|
protected getSaveInterval(): number;
|
|
177
177
|
protected updateRepo(): Promise<void>;
|
|
178
|
+
protected getTargetFileName(format: string): Promise<string>;
|
|
178
179
|
protected convert(format: string): Promise<boolean>;
|
|
179
180
|
protected upload(format: string): Promise<boolean>;
|
|
180
181
|
protected getRepo(): ActivitiesRepository;
|
|
@@ -203,6 +204,7 @@ export declare class ActivityRideService extends IncyclistService {
|
|
|
203
204
|
protected getActivityUploadFactory(): ActivityUploadFactory;
|
|
204
205
|
protected getActivityConverterfactory(): ActivityConverterFactory;
|
|
205
206
|
protected getFileSystemBinding(): import("../../api").IFileSystem;
|
|
207
|
+
protected getBindings(): import("../../api").IncyclistBindings;
|
|
206
208
|
protected getUnitConversionShortcuts(): any[];
|
|
207
209
|
protected getUnitConverter(): import("../../i18n").UnitConverterService;
|
|
208
210
|
}
|
|
@@ -18,7 +18,7 @@ export declare class DeviceAccessService extends IncyclistService {
|
|
|
18
18
|
getInterfaceInfo(ifaceName: string): InterfaceInfo;
|
|
19
19
|
enrichWithAccessState(interfaces: InterfaceSetting[]): EnrichedInterfaceSetting[];
|
|
20
20
|
initInterface(ifaceName: string, binding: any, props?: InterfaceAccessProps): void;
|
|
21
|
-
|
|
21
|
+
getInterface(ifaceName: string): IncyclistInterface;
|
|
22
22
|
connect(ifaceName?: string): Promise<boolean>;
|
|
23
23
|
private getScanTimeout;
|
|
24
24
|
disconnect(ifaceName?: string): Promise<boolean>;
|
|
@@ -56,6 +56,7 @@ export declare class DeviceConfigurationService extends IncyclistService {
|
|
|
56
56
|
}>;
|
|
57
57
|
initWifiInterface(): void;
|
|
58
58
|
confirmWifiInterface(): void;
|
|
59
|
+
getEnabledInterfaces(): Array<string>;
|
|
59
60
|
getInterfaceSettings(ifName: string): InterfaceSetting;
|
|
60
61
|
isInterfaceEnabled(ifName: string): boolean;
|
|
61
62
|
enableInterface(ifName: string): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdapterInfo, IncyclistDeviceSettings } from "../configuration";
|
|
2
2
|
import { AdapterRideInfo, AdapterStateInfo, LegacyRoute, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./types";
|
|
3
|
-
import { CyclingMode, DeviceData, DeviceSettings, ICyclingMode, IncyclistCapability, IncyclistDeviceAdapter, UpdateRequest } from "incyclist-devices";
|
|
3
|
+
import { CyclingMode, DeviceData, DeviceSettings, ICyclingMode, IncyclistCapability, IncyclistDeviceAdapter, IncyclistInterface, UpdateRequest } from "incyclist-devices";
|
|
4
4
|
import { IncyclistService } from "../../base/service";
|
|
5
5
|
import { Route } from "../../routes/base/model/route";
|
|
6
6
|
import { RouteApiDetail } from "../../routes/base/api/types";
|
|
@@ -24,11 +24,15 @@ export declare class DeviceRideService extends IncyclistService {
|
|
|
24
24
|
protected lastDataInfo: Record<string, number>;
|
|
25
25
|
protected reconnectBusy: boolean;
|
|
26
26
|
protected prevUpdate: UpdateRequest;
|
|
27
|
+
protected logPaused: boolean;
|
|
27
28
|
constructor();
|
|
28
29
|
protected waitForInit(): Promise<void>;
|
|
29
30
|
lazyInit(): Promise<void>;
|
|
30
31
|
getAdapterStateInfo(adapterInfo: AdapterRideInfo): AdapterStateInfo;
|
|
31
32
|
getData(): DeviceData;
|
|
33
|
+
pauseLogging(): void;
|
|
34
|
+
resumeLogging(): void;
|
|
35
|
+
protected getEnabledInterfaces(): Array<IncyclistInterface>;
|
|
32
36
|
protected getRideAdapters(): AdapterRideInfo[];
|
|
33
37
|
protected getAllAdapters(): AdapterRideInfo[];
|
|
34
38
|
protected getConfiguredAdapters(onlySelected?: boolean): AdapterRideInfo[];
|
|
@@ -121,6 +125,7 @@ export declare class DeviceRideService extends IncyclistService {
|
|
|
121
125
|
onDeviceDeleted(settings: IncyclistDeviceSettings): void;
|
|
122
126
|
enforceSimulator(enforced?: boolean): void;
|
|
123
127
|
canEnforceSimulator(): boolean;
|
|
128
|
+
logEvent(event: any): void;
|
|
124
129
|
protected cleanInternalCache(): void;
|
|
125
130
|
protected storeOriginalCyclingMode(): void;
|
|
126
131
|
protected subscribeDeviceEvents(adapter: IncyclistDeviceAdapter): void;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.33",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.27"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"axios": "^1.13.6",
|
|
9
|
-
"incyclist-devices": "^3.0.
|
|
9
|
+
"incyclist-devices": "^3.0.11",
|
|
10
10
|
"promise.any": "^2.0.6",
|
|
11
11
|
"semver": "^7.7.4",
|
|
12
12
|
"tcx-builder": "^1.1.1",
|