incyclist-services 1.0.32 → 1.0.34
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.
|
@@ -681,7 +681,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
681
681
|
if (capability) {
|
|
682
682
|
capabilites = (_b = this.settings) === null || _b === void 0 ? void 0 : _b.capabilities.filter(c => c.capability === capability);
|
|
683
683
|
}
|
|
684
|
-
return capabilites.filter(c => c.capability !== 'bike' && !(c.disabled === true)).map(c => {
|
|
684
|
+
return capabilites.filter(c => c.capability !== 'bike' && !(c.disabled === true) && c.selected).map(c => {
|
|
685
685
|
const { capability, selected } = c;
|
|
686
686
|
return { capability: capability, selected };
|
|
687
687
|
});
|
|
@@ -5,7 +5,7 @@ import { AdapterInfo, DeviceConfigurationService, IncyclistDeviceSettings } from
|
|
|
5
5
|
import { AdapterRideInfo, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./model";
|
|
6
6
|
import { UserSettingsService } from "../../settings";
|
|
7
7
|
import { EventLogger } from 'gd-eventlog';
|
|
8
|
-
import { CyclingMode, DeviceData, DeviceSettings, IncyclistDeviceAdapter, UpdateRequest } from "incyclist-devices";
|
|
8
|
+
import { CyclingMode, DeviceData, DeviceSettings, IncyclistCapability, IncyclistDeviceAdapter, UpdateRequest } from "incyclist-devices";
|
|
9
9
|
export declare class DeviceRideService extends EventEmitter {
|
|
10
10
|
protected static _instance: DeviceRideService;
|
|
11
11
|
protected configurationService: DeviceConfigurationService;
|
|
@@ -46,6 +46,7 @@ export declare class DeviceRideService extends EventEmitter {
|
|
|
46
46
|
stop(udid?: string): Promise<boolean>;
|
|
47
47
|
pause(): void;
|
|
48
48
|
resume(): void;
|
|
49
|
+
protected verifySelected(selectedDevices: any, capability: IncyclistCapability): void;
|
|
49
50
|
onData(deviceSettings: DeviceSettings, data: DeviceData): void;
|
|
50
51
|
sendUpdate(request: UpdateRequest): void;
|
|
51
52
|
getCyclingMode(udid?: string): CyclingMode;
|
|
@@ -500,6 +500,22 @@ class DeviceRideService extends events_1.default {
|
|
|
500
500
|
ai.adapter.on('data', this.deviceDataHandler);
|
|
501
501
|
});
|
|
502
502
|
}
|
|
503
|
+
verifySelected(selectedDevices, capability) {
|
|
504
|
+
if (selectedDevices.find(sd => sd.capability === capability) === undefined) {
|
|
505
|
+
const verify = (toCheck) => {
|
|
506
|
+
const found = selectedDevices.find(sd => sd.capability === toCheck);
|
|
507
|
+
if (found) {
|
|
508
|
+
const additional = (0, clone_1.default)(found);
|
|
509
|
+
additional.capability = capability;
|
|
510
|
+
selectedDevices.push(additional);
|
|
511
|
+
}
|
|
512
|
+
return found;
|
|
513
|
+
};
|
|
514
|
+
const added = verify(incyclist_devices_1.IncyclistCapability.Control);
|
|
515
|
+
if (!added && capability !== incyclist_devices_1.IncyclistCapability.Power)
|
|
516
|
+
verify(incyclist_devices_1.IncyclistCapability.Power);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
503
519
|
onData(deviceSettings, data) {
|
|
504
520
|
const adapters = this.getAdapterList();
|
|
505
521
|
const adapterInfo = adapters === null || adapters === void 0 ? void 0 : adapters.find(ai => ai.adapter.isEqual(deviceSettings));
|
|
@@ -507,23 +523,10 @@ class DeviceRideService extends events_1.default {
|
|
|
507
523
|
return;
|
|
508
524
|
adapters === null || adapters === void 0 ? void 0 : adapters.forEach(ai => ai.capabilities = ai.adapter.getCapabilities());
|
|
509
525
|
const selectedDevices = this.configurationService.getSelectedDevices();
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
const speed = (0, clone_1.default)(control);
|
|
514
|
-
speed.capability = incyclist_devices_1.IncyclistCapability.Speed;
|
|
515
|
-
selectedDevices.push(speed);
|
|
516
|
-
}
|
|
517
|
-
else {
|
|
518
|
-
const power = selectedDevices.find(sd => sd.capability === incyclist_devices_1.IncyclistCapability.Power);
|
|
519
|
-
const speed = (0, clone_1.default)(power);
|
|
520
|
-
speed.capability = incyclist_devices_1.IncyclistCapability.Speed;
|
|
521
|
-
selectedDevices.push(speed);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
526
|
+
this.verifySelected(selectedDevices, incyclist_devices_1.IncyclistCapability.Speed);
|
|
527
|
+
this.verifySelected(selectedDevices, incyclist_devices_1.IncyclistCapability.Cadence);
|
|
528
|
+
this.verifySelected(selectedDevices, incyclist_devices_1.IncyclistCapability.Power);
|
|
524
529
|
const enabledCapabilities = selectedDevices.filter(sd => sd.selected === adapterInfo.udid).map(c => c.capability);
|
|
525
|
-
const hasControl = (adapters === null || adapters === void 0 ? void 0 : adapters.find(ai => ai.capabilities.includes(incyclist_devices_1.IncyclistCapability.Control))) !== undefined;
|
|
526
|
-
const hasPower = (adapters === null || adapters === void 0 ? void 0 : adapters.find(ai => ai.capabilities.includes(incyclist_devices_1.IncyclistCapability.Power))) !== undefined;
|
|
527
530
|
this.logEvent({ message: 'Data Update', device: adapterInfo.adapter.getName(), data, enabledCapabilities });
|
|
528
531
|
enabledCapabilities.forEach(capability => {
|
|
529
532
|
switch (capability) {
|
|
@@ -538,10 +541,6 @@ class DeviceRideService extends events_1.default {
|
|
|
538
541
|
break;
|
|
539
542
|
case incyclist_devices_1.IncyclistCapability.Cadence:
|
|
540
543
|
this.data.cadence = data.cadence;
|
|
541
|
-
if (hasControl && !hasPower) {
|
|
542
|
-
this.data.speed = data.speed;
|
|
543
|
-
this.data.power = data.power;
|
|
544
|
-
}
|
|
545
544
|
break;
|
|
546
545
|
case incyclist_devices_1.IncyclistCapability.Control:
|
|
547
546
|
this.data.deviceDistanceCounter = data.deviceDistanceCounter;
|