incyclist-services 1.3.58 → 1.3.60

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.
@@ -68,7 +68,7 @@ export declare class ActivityRideService extends IncyclistService {
68
68
  slope: number;
69
69
  heartrate: number;
70
70
  cadence: number;
71
- timeRemaining: number;
71
+ timeRemaining: any;
72
72
  distanceRemaining: number;
73
73
  };
74
74
  protected getAverageValues(): {
@@ -188,6 +188,8 @@ let ActivityRideService = (() => {
188
188
  delete this.current.endPos;
189
189
  }
190
190
  getDashboardDisplayProperties() {
191
+ if (!this.current)
192
+ return [];
191
193
  try {
192
194
  const currentValues = this.getCurrentValues();
193
195
  const { time } = currentValues;
@@ -226,20 +228,23 @@ let ActivityRideService = (() => {
226
228
  return info;
227
229
  }
228
230
  getCurrentValues() {
229
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
231
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
230
232
  const distance = ((_b = (_a = this.activity) === null || _a === void 0 ? void 0 : _a.distance) !== null && _b !== void 0 ? _b : 0) / 1000;
231
- const speed = ((_c = this.current.deviceData.speed) !== null && _c !== void 0 ? _c : 0);
232
- const power = ((_d = this.current.deviceData.power) !== null && _d !== void 0 ? _d : 0);
233
- const slope = (_e = this.current.position) === null || _e === void 0 ? void 0 : _e.slope;
234
- const heartrate = this.current.deviceData.heartrate;
235
- const cadence = ((_f = this.current.deviceData.cadence) !== null && _f !== void 0 ? _f : 0);
236
- const time = (_h = (_g = this.activity) === null || _g === void 0 ? void 0 : _g.time) !== null && _h !== void 0 ? _h : 0;
233
+ const speed = ((_d = (_c = this.current.deviceData) === null || _c === void 0 ? void 0 : _c.speed) !== null && _d !== void 0 ? _d : 0);
234
+ const power = ((_f = (_e = this.current.deviceData) === null || _e === void 0 ? void 0 : _e.power) !== null && _f !== void 0 ? _f : 0);
235
+ const slope = (_g = this.current.position) === null || _g === void 0 ? void 0 : _g.slope;
236
+ const heartrate = (_h = this.current.deviceData) === null || _h === void 0 ? void 0 : _h.heartrate;
237
+ const cadence = ((_k = (_j = this.current.deviceData) === null || _j === void 0 ? void 0 : _j.cadence) !== null && _k !== void 0 ? _k : 0);
238
+ const time = (_m = (_l = this.activity) === null || _l === void 0 ? void 0 : _l.time) !== null && _m !== void 0 ? _m : 0;
237
239
  let distanceRemaining = (this.getTotalDistance() / 1000 - distance);
238
240
  if (isNaN(distanceRemaining))
239
241
  distanceRemaining = undefined;
240
242
  if (distanceRemaining < 0)
241
243
  distanceRemaining = 0;
242
- const timeRemaining = this.durationCalculator.getRemainingTime({ route: this.current.route, speed: this.current.deviceData.speed, routePos: this.activity.distance + ((_j = this.activity.startPos) !== null && _j !== void 0 ? _j : 0), endPos: this.current.endPos });
244
+ let timeRemaining;
245
+ if (speed > 0) {
246
+ timeRemaining = this.durationCalculator.getRemainingTime({ route: this.current.route, speed: (_o = this.current.deviceData) === null || _o === void 0 ? void 0 : _o.speed, routePos: this.activity.distance + ((_q = (_p = this.activity) === null || _p === void 0 ? void 0 : _p.startPos) !== null && _q !== void 0 ? _q : 0), endPos: (_r = this.current) === null || _r === void 0 ? void 0 : _r.endPos });
247
+ }
243
248
  return { distance, time, speed, power, slope, heartrate, cadence, timeRemaining, distanceRemaining };
244
249
  }
245
250
  getAverageValues() {
@@ -0,0 +1,2 @@
1
+ export * from './Injection';
2
+ export * from '../types/singleton';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Injection"), exports);
18
+ __exportStar(require("../types/singleton"), exports);
@@ -614,6 +614,8 @@ class DeviceConfigurationService extends events_1.default {
614
614
  const info = [];
615
615
  udids.forEach(udid => {
616
616
  const adapter = this.adapters[udid];
617
+ if (!adapter)
618
+ return;
617
619
  info.push({ udid, adapter, capabilities: adapter.getCapabilities() });
618
620
  });
619
621
  return info;
@@ -626,6 +628,8 @@ class DeviceConfigurationService extends events_1.default {
626
628
  if (!devices.find(d => d.udid === c.selected))
627
629
  return;
628
630
  const adapter = this.adapters[c.selected];
631
+ if (!adapter)
632
+ return;
629
633
  const idx = adapters.findIndex(a => a.udid === c.selected);
630
634
  if (idx === -1) {
631
635
  adapters.push({ udid: c.selected, adapter, capabilities: [c.capability] });
@@ -1,34 +1,26 @@
1
- import EventEmitter from "events";
2
- import { DeviceAccessService } from "../access/service";
3
- import { AdapterInfo, DeviceConfigurationService, IncyclistDeviceSettings } from "../configuration";
1
+ import { AdapterInfo, IncyclistDeviceSettings } from "../configuration";
4
2
  import { AdapterRideInfo, AdapterStateInfo, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./model";
5
- import { UserSettingsService } from "../../settings";
6
3
  import { EventLogger } from 'gd-eventlog';
7
4
  import { CyclingMode, DeviceData, DeviceSettings, IncyclistCapability, IncyclistDeviceAdapter, UpdateRequest } from "incyclist-devices";
8
- export declare class DeviceRideService extends EventEmitter {
9
- protected static _instance: DeviceRideService;
10
- protected configurationService: DeviceConfigurationService;
11
- protected userSettings: UserSettingsService;
12
- protected accessService: DeviceAccessService;
5
+ import { IncyclistService } from "../../base/service";
6
+ export declare class DeviceRideService extends IncyclistService {
13
7
  protected initizialized: boolean;
14
8
  protected adapters: AdapterRideInfo[];
15
9
  protected startPromises: Promise<boolean>[];
16
10
  protected data: DeviceData;
17
11
  protected simulatorEnforced: boolean;
18
12
  protected logger: EventLogger;
19
- protected debug: any;
20
13
  protected promiseSendUpdate: Promise<UpdateRequest | void>[];
21
14
  protected originalMode: CyclingMode;
22
15
  protected deviceDataHandler: any;
23
- static getInstance(): DeviceRideService;
24
16
  constructor();
25
- logEvent(event: any): void;
26
- setDebug(enabled: boolean): void;
27
17
  protected waitForInit(): Promise<void>;
28
18
  lazyInit(): Promise<void>;
29
19
  getAdapterStateInfo(adapterInfo: AdapterInfo): AdapterStateInfo;
30
20
  getData(): DeviceData;
31
- protected getAdapterList(onlySelected?: boolean): AdapterRideInfo[];
21
+ protected getSelectedAdapters(): AdapterRideInfo[];
22
+ protected getAllAdapters(): AdapterRideInfo[];
23
+ protected getConfiguredAdapters(onlySelected?: boolean): AdapterRideInfo[];
32
24
  prepareEppRoute(props: RideServiceDeviceProperties): PreparedRoute;
33
25
  waitForPreviousStartToFinish(): Promise<boolean>;
34
26
  startCheck(filter: RideServiceCheckFilter): Promise<void>;
@@ -76,5 +68,9 @@ export declare class DeviceRideService extends EventEmitter {
76
68
  onDeviceDeleted(settings: IncyclistDeviceSettings): void;
77
69
  enforceSimulator(enforced?: boolean): void;
78
70
  canEnforceSimulator(): boolean;
71
+ protected storeOriginalCyclingMode(): void;
72
+ protected getDeviceConfiguration(): import("../configuration").DeviceConfigurationService;
73
+ protected getUserSettings(): import("../../settings").UserSettingsService;
74
+ protected getDeviceAccess(): import("../access/service").DeviceAccessService;
79
75
  }
80
76
  export declare const useDeviceRide: () => DeviceRideService;