incyclist-services 1.0.16 → 1.0.17
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.
|
@@ -87,7 +87,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
87
87
|
this.adapters[d.udid] = incyclist_devices_1.AdapterFactory.create(d.settings);
|
|
88
88
|
}
|
|
89
89
|
catch (err) {
|
|
90
|
-
this.
|
|
90
|
+
this.logEvent({ message: 'error', fn: 'init()->Adapterfactory.create()', error: err.message, udid: d.udid, settings: d.settings, devices: this.settings.devices, stack: err.stack, });
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
const { capabilities } = this.settings;
|
|
@@ -294,18 +294,22 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
294
294
|
this.emitCapabiltyChanged();
|
|
295
295
|
}
|
|
296
296
|
select(udid, capability, props) {
|
|
297
|
-
var _a, _b, _c;
|
|
297
|
+
var _a, _b, _c, _d;
|
|
298
298
|
this.logEvent({ message: 'select device', udid, capability, props });
|
|
299
299
|
const { noRecursive = false, legacy = false } = props || {};
|
|
300
300
|
const deviceSettings = (_b = (_a = this.settings.devices) === null || _a === void 0 ? void 0 : _a.find(d => d.udid === udid)) === null || _b === void 0 ? void 0 : _b.settings;
|
|
301
301
|
if (!deviceSettings)
|
|
302
302
|
return;
|
|
303
303
|
const adapter = this.adapters[udid] || incyclist_devices_1.AdapterFactory.create(deviceSettings);
|
|
304
|
+
if (!adapter) {
|
|
305
|
+
this.logEvent({ message: 'error: could not find adapter', fn: 'select', udid, capability, adapters: (_c = Object.keys(this.adapters)) === null || _c === void 0 ? void 0 : _c.join(',') });
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
304
308
|
if (capability === 'bike' && !adapter.isControllable())
|
|
305
309
|
return;
|
|
306
310
|
const isControl = adapter.hasCapability(incyclist_devices_1.IncyclistCapability.Control) || (legacy && capability === 'bike');
|
|
307
311
|
this.addToCapability(udid, capability);
|
|
308
|
-
const capSettings = (
|
|
312
|
+
const capSettings = (_d = this.settings.capabilities) === null || _d === void 0 ? void 0 : _d.find(c => c.capability === capability);
|
|
309
313
|
capSettings.selected = udid;
|
|
310
314
|
if (capSettings.disabled)
|
|
311
315
|
delete capSettings.disabled;
|
|
@@ -530,7 +534,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
530
534
|
this.getSelected(incyclist_devices_1.IncyclistCapability.Speed) !== undefined);
|
|
531
535
|
}
|
|
532
536
|
getModeSettings(requestedUdid, requestedMode) {
|
|
533
|
-
var _a, _b;
|
|
537
|
+
var _a, _b, _c;
|
|
534
538
|
const { capabilities, devices } = this.settings;
|
|
535
539
|
if (!this.isInitialized())
|
|
536
540
|
return;
|
|
@@ -546,6 +550,10 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
546
550
|
let mode, modes, settings;
|
|
547
551
|
let modeObj;
|
|
548
552
|
const adapter = incyclist_devices_1.AdapterFactory.create(device.settings);
|
|
553
|
+
if (!adapter) {
|
|
554
|
+
this.logEvent({ message: 'Error: could not find adapter', requestedUdid, requestedMode, devices, adapters: (_c = Object.keys(this.adapters)) === null || _c === void 0 ? void 0 : _c.join(',') });
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
549
557
|
mode = requestedMode || device.mode;
|
|
550
558
|
if (adapter.getSupportedCyclingModes) {
|
|
551
559
|
modes = adapter.getSupportedCyclingModes();
|
|
@@ -338,7 +338,7 @@ class DeviceRideService extends events_1.default {
|
|
|
338
338
|
startProps.timeout = 30000;
|
|
339
339
|
}
|
|
340
340
|
if (startType === 'start') {
|
|
341
|
-
if (ai.adapter.isControllable()) {
|
|
341
|
+
if (ai.adapter && ai.adapter.isControllable()) {
|
|
342
342
|
const d = ai.adapter;
|
|
343
343
|
let mode, settings;
|
|
344
344
|
if (!this.simulatorEnforced) {
|
|
@@ -508,7 +508,7 @@ class DeviceRideService extends events_1.default {
|
|
|
508
508
|
sendUpdate(request) {
|
|
509
509
|
const adapters = this.getAdapterList();
|
|
510
510
|
adapters === null || adapters === void 0 ? void 0 : adapters.forEach(ai => {
|
|
511
|
-
if (ai.adapter.isControllable()) {
|
|
511
|
+
if (ai.adapter && ai.adapter.isControllable()) {
|
|
512
512
|
const d = ai.adapter;
|
|
513
513
|
d.sendUpdate(request);
|
|
514
514
|
}
|