incyclist-devices 2.0.38 → 2.1.0
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/antv2/adapter-factory.d.ts +4 -2
- package/lib/antv2/adapter.d.ts +3 -20
- package/lib/antv2/adapter.js +2 -92
- package/lib/antv2/fe/adapter.d.ts +9 -5
- package/lib/antv2/fe/adapter.js +25 -14
- package/lib/antv2/hr/adapter.d.ts +2 -1
- package/lib/antv2/pwr/adapter.d.ts +9 -5
- package/lib/antv2/pwr/adapter.js +19 -8
- package/lib/antv2/types.d.ts +2 -1
- package/lib/base/adpater.d.ts +31 -13
- package/lib/base/adpater.js +84 -28
- package/lib/ble/adapter-factory.d.ts +10 -9
- package/lib/ble/base/adapter.d.ts +9 -20
- package/lib/ble/base/adapter.js +13 -69
- package/lib/ble/ble-interface.d.ts +5 -4
- package/lib/ble/cp/adapter.d.ts +5 -8
- package/lib/ble/cp/adapter.js +26 -10
- package/lib/ble/elite/adapter.d.ts +6 -5
- package/lib/ble/elite/adapter.js +26 -2
- package/lib/ble/fm/adapter.d.ts +10 -9
- package/lib/ble/fm/adapter.js +38 -11
- package/lib/ble/hr/adapter.d.ts +5 -3
- package/lib/ble/peripheral-cache.d.ts +3 -2
- package/lib/ble/tacx/adapter.d.ts +2 -2
- package/lib/ble/wahoo/adapter.d.ts +2 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +4 -2
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ant-fe-adv-st-mode.d.ts +12 -0
- package/lib/modes/ant-fe-adv-st-mode.js +83 -0
- package/lib/modes/antble-erg.d.ts +31 -0
- package/lib/modes/antble-erg.js +28 -0
- package/lib/modes/antble-smarttrainer.d.ts +23 -0
- package/lib/modes/antble-smarttrainer.js +65 -0
- package/lib/modes/base.d.ts +29 -0
- package/lib/modes/{cycling-mode.js → base.js} +23 -26
- package/lib/modes/daum-classic-standard.d.ts +16 -0
- package/lib/modes/daum-classic-standard.js +54 -0
- package/lib/modes/daum-erg.d.ts +49 -0
- package/lib/{serial/daum/ERGCyclingMode.js → modes/daum-erg.js} +45 -73
- package/lib/modes/daum-power.d.ts +5 -0
- package/lib/{serial/daum/DaumPowerMeterCyclingMode.js → modes/daum-power.js} +1 -10
- package/lib/modes/daum-premium-standard.d.ts +23 -0
- package/lib/{serial/daum/premium/modes/daum-classic.js → modes/daum-premium-standard.js} +26 -38
- package/lib/modes/daum-smarttrainer.d.ts +82 -0
- package/lib/{serial/daum/SmartTrainerCyclingMode.js → modes/daum-smarttrainer.js} +23 -26
- package/lib/modes/kettler-erg.d.ts +44 -0
- package/lib/{serial/kettler/ergo-racer/modes/erg.js → modes/kettler-erg.js} +12 -23
- package/lib/modes/power-base.d.ts +28 -3
- package/lib/modes/power-base.js +182 -5
- package/lib/modes/power-meter.d.ts +10 -16
- package/lib/modes/power-meter.js +15 -54
- package/lib/modes/simulator.d.ts +37 -10
- package/lib/modes/simulator.js +14 -46
- package/lib/modes/{cycling-mode.d.ts → types.d.ts} +22 -19
- package/lib/modes/types.js +56 -0
- package/lib/serial/adapter-factory.d.ts +7 -5
- package/lib/serial/adapter.d.ts +2 -2
- package/lib/serial/adapter.js +5 -2
- package/lib/serial/daum/DaumAdapter.d.ts +27 -24
- package/lib/serial/daum/DaumAdapter.js +200 -128
- package/lib/serial/daum/classic/adapter.d.ts +20 -21
- package/lib/serial/daum/classic/adapter.js +83 -157
- package/lib/serial/daum/classic/comms.d.ts +19 -13
- package/lib/serial/daum/classic/comms.js +39 -12
- package/lib/serial/daum/classic/mock.d.ts +4 -0
- package/lib/serial/daum/classic/mock.js +14 -4
- package/lib/serial/daum/premium/adapter.d.ts +16 -11
- package/lib/serial/daum/premium/adapter.js +98 -95
- package/lib/serial/daum/premium/comms.d.ts +4 -1
- package/lib/serial/daum/premium/comms.js +25 -17
- package/lib/serial/daum/premium/mock.d.ts +4 -0
- package/lib/serial/daum/premium/mock.js +15 -5
- package/lib/serial/daum/types.d.ts +11 -0
- package/lib/serial/daum/types.js +5 -0
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +10 -8
- package/lib/serial/kettler/ergo-racer/adapter.js +17 -7
- package/lib/serial/serial-interface.js +1 -2
- package/lib/simulator/Simulator.d.ts +14 -17
- package/lib/simulator/Simulator.js +18 -47
- package/lib/types/adapter.d.ts +29 -8
- package/lib/types/adapter.js +68 -0
- package/lib/utils/utils.d.ts +1 -1
- package/package.json +3 -3
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/antv2/modes/ant-fe-adv-st-mode.js +0 -51
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +0 -6
- package/lib/antv2/modes/ant-fe-erg-mode.js +0 -14
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +0 -5
- package/lib/antv2/modes/ant-fe-st-mode.js +0 -13
- package/lib/modes/ble-erg-mode.d.ts +0 -18
- package/lib/modes/ble-erg-mode.js +0 -148
- package/lib/modes/ble-st-mode.d.ts +0 -15
- package/lib/modes/ble-st-mode.js +0 -96
- package/lib/serial/daum/DaumPowerMeterCyclingMode.d.ts +0 -8
- package/lib/serial/daum/ERGCyclingMode.d.ts +0 -26
- package/lib/serial/daum/SmartTrainerCyclingMode.d.ts +0 -42
- package/lib/serial/daum/classic/modes/daum-classic.d.ts +0 -13
- package/lib/serial/daum/classic/modes/daum-classic.js +0 -97
- package/lib/serial/daum/premium/modes/daum-classic.d.ts +0 -14
- package/lib/serial/kettler/ergo-racer/modes/erg.d.ts +0 -25
- /package/lib/serial/daum/{constants.d.ts → consts.d.ts} +0 -0
- /package/lib/serial/daum/{constants.js → consts.js} +0 -0
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ICyclingMode, { IncyclistBikeData, Settings, UpdateRequest } from './types';
|
|
2
2
|
import PowerBasedCyclingModeBase from './power-base';
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
constructor(adapter:
|
|
11
|
-
getName(): string;
|
|
12
|
-
getDescription(): string;
|
|
13
|
-
getProperties(): CyclingModeProperty[];
|
|
14
|
-
getProperty(name: string): CyclingModeProperty;
|
|
3
|
+
import { IncyclistDeviceAdapter } from '..';
|
|
4
|
+
export default class PowerMeterCyclingMode extends PowerBasedCyclingModeBase implements ICyclingMode {
|
|
5
|
+
protected static config: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
properties: any[];
|
|
9
|
+
};
|
|
10
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: Settings);
|
|
15
11
|
getBikeInitRequest(): UpdateRequest;
|
|
16
12
|
sendBikeUpdate(request?: UpdateRequest): UpdateRequest;
|
|
17
|
-
|
|
18
|
-
log: boolean;
|
|
19
|
-
}): IncyclistBikeData;
|
|
13
|
+
copyBikeData(data: IncyclistBikeData, bikeData: IncyclistBikeData): IncyclistBikeData;
|
|
20
14
|
}
|
package/lib/modes/power-meter.js
CHANGED
|
@@ -3,76 +3,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.config = void 0;
|
|
7
6
|
const power_base_1 = __importDefault(require("./power-base"));
|
|
8
|
-
const MIN_SPEED = 10;
|
|
9
|
-
exports.config = {
|
|
10
|
-
name: 'PowerMeter',
|
|
11
|
-
description: 'Power and cadence are taken from device. Speed is calculated from power and current slope\nThis mode will not respect maximum power and/or workout limits',
|
|
12
|
-
properties: []
|
|
13
|
-
};
|
|
14
7
|
class PowerMeterCyclingMode extends power_base_1.default {
|
|
15
8
|
constructor(adapter, props) {
|
|
16
9
|
super(adapter, props);
|
|
17
10
|
this.initLogger('PowerMeterMode');
|
|
18
|
-
this.data =
|
|
19
|
-
}
|
|
20
|
-
getName() {
|
|
21
|
-
return exports.config.name;
|
|
22
|
-
}
|
|
23
|
-
getDescription() {
|
|
24
|
-
return exports.config.description;
|
|
25
|
-
}
|
|
26
|
-
getProperties() {
|
|
27
|
-
return exports.config.properties;
|
|
28
|
-
}
|
|
29
|
-
getProperty(name) {
|
|
30
|
-
return exports.config.properties.find(p => p.name === name);
|
|
11
|
+
this.data.slope = 0;
|
|
31
12
|
}
|
|
32
13
|
getBikeInitRequest() {
|
|
33
14
|
return {};
|
|
34
15
|
}
|
|
35
16
|
sendBikeUpdate(request = {}) {
|
|
36
|
-
|
|
37
|
-
const
|
|
17
|
+
this.logger.logEvent({ message: "processing update request", request });
|
|
18
|
+
const prevData = this.data;
|
|
19
|
+
const prevSlope = prevData.slope;
|
|
38
20
|
if (request.slope && request.slope !== prevSlope) {
|
|
39
21
|
this.data.slope = request.slope;
|
|
40
|
-
this.updateData(this.data,
|
|
22
|
+
this.updateData(this.data, false);
|
|
41
23
|
}
|
|
42
|
-
this.logger.logEvent({ message: "processing update request", request });
|
|
43
24
|
return {};
|
|
44
25
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let power = bikeData.power || 0;
|
|
50
|
-
const slope = prevData.slope || 0;
|
|
51
|
-
const distanceInternal = prevData.distanceInternal || 0;
|
|
52
|
-
if (power > 0) {
|
|
53
|
-
data.isPedalling = true;
|
|
54
|
-
}
|
|
55
|
-
const m = this.getWeight();
|
|
56
|
-
const t = this.getTimeSinceLastUpdate();
|
|
57
|
-
const { speed, distance } = this.calculateSpeedAndDistance(power, slope, m, t);
|
|
58
|
-
data.power = Math.round(power);
|
|
59
|
-
data.slope = slope;
|
|
60
|
-
if (power === 0 && speed < MIN_SPEED) {
|
|
61
|
-
data.speed = Math.round(prevData.speed - 1) < 0 ? 0 : Math.round(prevData.speed - 1);
|
|
62
|
-
data.distanceInternal = distanceInternal + data.speed / 3.6 * t;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
data.speed = speed;
|
|
66
|
-
data.distanceInternal = distanceInternal + distance;
|
|
67
|
-
}
|
|
68
|
-
if (props.log)
|
|
69
|
-
this.logger.logEvent({ message: "updateData result", data, bikeData, prevSpeed: prevData.speed, stopped: speed < MIN_SPEED });
|
|
70
|
-
this.data = data;
|
|
26
|
+
copyBikeData(data, bikeData) {
|
|
27
|
+
const newData = super.copyBikeData(data, bikeData);
|
|
28
|
+
if (bikeData.power > 0) {
|
|
29
|
+
newData.isPedalling = true;
|
|
71
30
|
}
|
|
72
|
-
|
|
73
|
-
this.logger.logEvent({ message: 'error', fn: 'updateData()', error: err.message || err });
|
|
74
|
-
}
|
|
75
|
-
return this.data;
|
|
31
|
+
return newData;
|
|
76
32
|
}
|
|
77
33
|
}
|
|
34
|
+
PowerMeterCyclingMode.config = {
|
|
35
|
+
name: 'PowerMeter',
|
|
36
|
+
description: 'Power and cadence are taken from device. Speed is calculated from power and current slope\nThis mode will not respect maximum power and/or workout limits',
|
|
37
|
+
properties: []
|
|
38
|
+
};
|
|
78
39
|
exports.default = PowerMeterCyclingMode;
|
package/lib/modes/simulator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventLogger } from "gd-eventlog";
|
|
2
|
-
import {
|
|
2
|
+
import { CyclingModeProperyType, IncyclistBikeData, UpdateRequest } from "./types";
|
|
3
3
|
import { Simulator } from "../simulator/Simulator";
|
|
4
4
|
import PowerBasedCyclingModeBase from "./power-base";
|
|
5
5
|
export type ERGEvent = {
|
|
@@ -9,21 +9,48 @@ export type ERGEvent = {
|
|
|
9
9
|
tsStart?: number;
|
|
10
10
|
};
|
|
11
11
|
export default class SimulatorCyclingMode extends PowerBasedCyclingModeBase {
|
|
12
|
-
static
|
|
12
|
+
protected static config: {
|
|
13
|
+
isERG: boolean;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
properties: ({
|
|
17
|
+
key: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
type: CyclingModeProperyType;
|
|
21
|
+
options: string[];
|
|
22
|
+
default: string;
|
|
23
|
+
min?: undefined;
|
|
24
|
+
max?: undefined;
|
|
25
|
+
condition?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
key: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
type: CyclingModeProperyType;
|
|
31
|
+
default: number;
|
|
32
|
+
min: number;
|
|
33
|
+
max: number;
|
|
34
|
+
options?: undefined;
|
|
35
|
+
condition?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
key: string;
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
condition: (s: any) => boolean;
|
|
41
|
+
type: CyclingModeProperyType;
|
|
42
|
+
default: number;
|
|
43
|
+
min: number;
|
|
44
|
+
max: number;
|
|
45
|
+
options?: undefined;
|
|
46
|
+
})[];
|
|
47
|
+
};
|
|
13
48
|
logger: EventLogger;
|
|
14
49
|
data: IncyclistBikeData;
|
|
15
50
|
prevRequest: UpdateRequest;
|
|
16
51
|
prevUpdateTS: number;
|
|
17
|
-
hasBikeUpdate: boolean;
|
|
18
|
-
chain: number[];
|
|
19
|
-
cassette: number[];
|
|
20
52
|
event: ERGEvent;
|
|
21
53
|
constructor(adapter: Simulator, props?: any);
|
|
22
|
-
getName(): string;
|
|
23
|
-
getDescription(): string;
|
|
24
|
-
getProperties(): CyclingModeProperty[];
|
|
25
|
-
getProperty(name: string): CyclingModeProperty;
|
|
26
54
|
getBikeInitRequest(): UpdateRequest;
|
|
27
|
-
sendBikeUpdate(request: UpdateRequest): UpdateRequest;
|
|
28
55
|
updateData(bikeData: IncyclistBikeData): IncyclistBikeData;
|
|
29
56
|
}
|
package/lib/modes/simulator.js
CHANGED
|
@@ -3,62 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const cycling_mode_1 = require("../modes/cycling-mode");
|
|
6
|
+
const types_1 = require("./types");
|
|
8
7
|
const power_base_1 = __importDefault(require("./power-base"));
|
|
9
8
|
const MIN_SPEED = 10;
|
|
10
|
-
const config = {
|
|
11
|
-
name: "Simulator",
|
|
12
|
-
description: "Simulates a ride with constant speed or power output",
|
|
13
|
-
properties: [
|
|
14
|
-
{ key: 'mode', name: 'Simulation Type', description: '', type: cycling_mode_1.CyclingModeProperyType.SingleSelect, options: ['Speed', 'Power'], default: 'Power' },
|
|
15
|
-
{ key: 'delay', name: 'Start Delay', description: 'Delay (in s) at start of training', type: cycling_mode_1.CyclingModeProperyType.Integer, default: 2, min: 0, max: 30 },
|
|
16
|
-
{ key: 'power', name: 'Power', description: 'Power (in W) at start of training', condition: (s) => !s.mode || s.mode === 'Power', type: cycling_mode_1.CyclingModeProperyType.Integer, default: 150, min: 25, max: 800 },
|
|
17
|
-
{ key: 'speed', name: 'Speed', description: 'Speed (in km/h) at start of training', condition: (s) => s.mode === 'Speed', type: cycling_mode_1.CyclingModeProperyType.Integer, default: 30, min: 5, max: 50 },
|
|
18
|
-
{ key: 'bikeType', name: 'Bike Type', description: '', type: cycling_mode_1.CyclingModeProperyType.SingleSelect, options: ['Race', 'Mountain', 'Triathlon'], default: 'Race' }
|
|
19
|
-
]
|
|
20
|
-
};
|
|
21
9
|
class SimulatorCyclingMode extends power_base_1.default {
|
|
22
10
|
constructor(adapter, props) {
|
|
23
11
|
super(adapter, props);
|
|
24
12
|
this.prevUpdateTS = 0;
|
|
25
|
-
this.hasBikeUpdate = false;
|
|
26
13
|
this.event = {};
|
|
27
|
-
this.
|
|
28
|
-
this.data = {};
|
|
29
|
-
this.logger.logEvent({ message: 'constructor', props });
|
|
30
|
-
}
|
|
31
|
-
getName() {
|
|
32
|
-
return config.name;
|
|
33
|
-
}
|
|
34
|
-
getDescription() {
|
|
35
|
-
return config.description;
|
|
36
|
-
}
|
|
37
|
-
getProperties() {
|
|
38
|
-
return config.properties;
|
|
39
|
-
}
|
|
40
|
-
getProperty(name) {
|
|
41
|
-
return config.properties.find(p => p.name === name);
|
|
14
|
+
this.initLogger('SIMMode');
|
|
42
15
|
}
|
|
43
16
|
getBikeInitRequest() {
|
|
44
17
|
return {};
|
|
45
18
|
}
|
|
46
|
-
sendBikeUpdate(request) {
|
|
47
|
-
this.logger.logEvent({ message: 'bike update request', request });
|
|
48
|
-
const r = request || { refresh: true };
|
|
49
|
-
if (r.refresh) {
|
|
50
|
-
if (Object.keys(r).length === 1)
|
|
51
|
-
return this.prevRequest || {};
|
|
52
|
-
delete r.refresh;
|
|
53
|
-
}
|
|
54
|
-
if (request.slope !== undefined) {
|
|
55
|
-
if (!this.data)
|
|
56
|
-
this.data = {};
|
|
57
|
-
this.data.slope = request.slope;
|
|
58
|
-
}
|
|
59
|
-
this.prevRequest = request ? JSON.parse(JSON.stringify(request)) : {};
|
|
60
|
-
return r;
|
|
61
|
-
}
|
|
62
19
|
updateData(bikeData) {
|
|
63
20
|
const prevData = JSON.parse(JSON.stringify(this.data || {}));
|
|
64
21
|
const prevSpeed = prevData.speed;
|
|
@@ -136,5 +93,16 @@ class SimulatorCyclingMode extends power_base_1.default {
|
|
|
136
93
|
return data;
|
|
137
94
|
}
|
|
138
95
|
}
|
|
139
|
-
SimulatorCyclingMode.
|
|
96
|
+
SimulatorCyclingMode.config = {
|
|
97
|
+
isERG: true,
|
|
98
|
+
name: "Simulator",
|
|
99
|
+
description: "Simulates a ride with constant speed or power output",
|
|
100
|
+
properties: [
|
|
101
|
+
{ key: 'mode', name: 'Simulation Type', description: '', type: types_1.CyclingModeProperyType.SingleSelect, options: ['Speed', 'Power'], default: 'Power' },
|
|
102
|
+
{ key: 'delay', name: 'Start Delay', description: 'Delay (in s) at start of training', type: types_1.CyclingModeProperyType.Integer, default: 2, min: 0, max: 30 },
|
|
103
|
+
{ key: 'power', name: 'Power', description: 'Power (in W) at start of training', condition: (s) => !s.mode || s.mode === 'Power', type: types_1.CyclingModeProperyType.Integer, default: 150, min: 25, max: 800 },
|
|
104
|
+
{ key: 'speed', name: 'Speed', description: 'Speed (in km/h) at start of training', condition: (s) => s.mode === 'Speed', type: types_1.CyclingModeProperyType.Integer, default: 30, min: 5, max: 50 },
|
|
105
|
+
{ key: 'bikeType', name: 'Bike Type', description: '', type: types_1.CyclingModeProperyType.SingleSelect, options: ['Race', 'Mountain', 'Triathlon'], default: 'Race' }
|
|
106
|
+
]
|
|
107
|
+
};
|
|
140
108
|
exports.default = SimulatorCyclingMode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBike } from "../types/adapter";
|
|
2
2
|
export type UpdateRequest = {
|
|
3
3
|
slope?: number;
|
|
4
4
|
minPower?: number;
|
|
@@ -41,14 +41,14 @@ export type IncyclistBikeData = {
|
|
|
41
41
|
export type Settings = {
|
|
42
42
|
[key: string]: any;
|
|
43
43
|
};
|
|
44
|
-
export default interface
|
|
44
|
+
export default interface ICyclingMode {
|
|
45
45
|
getName(): string;
|
|
46
46
|
getDescription(): string;
|
|
47
|
+
getProperties(): CyclingModeProperty[];
|
|
48
|
+
getProperty(name: string): CyclingModeProperty;
|
|
47
49
|
getBikeInitRequest(): UpdateRequest;
|
|
48
50
|
sendBikeUpdate(request: UpdateRequest): UpdateRequest;
|
|
49
51
|
updateData(data: IncyclistBikeData): IncyclistBikeData;
|
|
50
|
-
getProperties(): CyclingModeProperty[];
|
|
51
|
-
getProperty(name: string): CyclingModeProperty;
|
|
52
52
|
setSettings(settings: any): any;
|
|
53
53
|
setSetting(name: string, value: any): void;
|
|
54
54
|
getSetting(name: string): any;
|
|
@@ -56,23 +56,26 @@ export default interface CyclingMode {
|
|
|
56
56
|
setModeProperty(name: string, value: any): void;
|
|
57
57
|
getModeProperty(name: string): any;
|
|
58
58
|
}
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
export type CyclingModeConfig = {
|
|
60
|
+
isERG?: boolean;
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
properties: CyclingModeProperty[];
|
|
64
|
+
};
|
|
65
|
+
export declare class CyclingMode implements ICyclingMode {
|
|
66
|
+
constructor(_adapter: IBike, _props?: any);
|
|
67
|
+
static supportsERGMode(): boolean;
|
|
66
68
|
getName(): string;
|
|
67
69
|
getDescription(): string;
|
|
68
|
-
sendBikeUpdate(request: UpdateRequest): UpdateRequest;
|
|
69
|
-
updateData(data: IncyclistBikeData): IncyclistBikeData;
|
|
70
70
|
getProperties(): CyclingModeProperty[];
|
|
71
|
-
getProperty(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
getProperty(_name: string): CyclingModeProperty;
|
|
72
|
+
getBikeInitRequest(): UpdateRequest;
|
|
73
|
+
sendBikeUpdate(_request: UpdateRequest): UpdateRequest;
|
|
74
|
+
updateData(_data: IncyclistBikeData): IncyclistBikeData;
|
|
75
|
+
setSettings(_settings: any): void;
|
|
76
|
+
setSetting(_name: string, _value: any): void;
|
|
77
|
+
getSetting(_name: string): void;
|
|
75
78
|
getSettings(): Settings;
|
|
76
|
-
setModeProperty(
|
|
77
|
-
getModeProperty(
|
|
79
|
+
setModeProperty(_name: string, _value: any): void;
|
|
80
|
+
getModeProperty(_name: string): void;
|
|
78
81
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CyclingMode = exports.CyclingModeProperyType = void 0;
|
|
4
|
+
var CyclingModeProperyType;
|
|
5
|
+
(function (CyclingModeProperyType) {
|
|
6
|
+
CyclingModeProperyType["Integer"] = "Integer";
|
|
7
|
+
CyclingModeProperyType["Boolean"] = "Boolean";
|
|
8
|
+
CyclingModeProperyType["Float"] = "Float";
|
|
9
|
+
CyclingModeProperyType["String"] = "String";
|
|
10
|
+
CyclingModeProperyType["SingleSelect"] = "SingleSelect";
|
|
11
|
+
CyclingModeProperyType["MultiSelect"] = "MultiSelect";
|
|
12
|
+
})(CyclingModeProperyType || (exports.CyclingModeProperyType = CyclingModeProperyType = {}));
|
|
13
|
+
class CyclingMode {
|
|
14
|
+
constructor(_adapter, _props) { }
|
|
15
|
+
static supportsERGMode() { return false; }
|
|
16
|
+
getName() {
|
|
17
|
+
throw new Error("Method not implemented.");
|
|
18
|
+
}
|
|
19
|
+
getDescription() {
|
|
20
|
+
throw new Error("Method not implemented.");
|
|
21
|
+
}
|
|
22
|
+
getProperties() {
|
|
23
|
+
throw new Error("Method not implemented.");
|
|
24
|
+
}
|
|
25
|
+
getProperty(_name) {
|
|
26
|
+
throw new Error("Method not implemented.");
|
|
27
|
+
}
|
|
28
|
+
getBikeInitRequest() {
|
|
29
|
+
throw new Error("Method not implemented.");
|
|
30
|
+
}
|
|
31
|
+
sendBikeUpdate(_request) {
|
|
32
|
+
throw new Error("Method not implemented.");
|
|
33
|
+
}
|
|
34
|
+
updateData(_data) {
|
|
35
|
+
throw new Error("Method not implemented.");
|
|
36
|
+
}
|
|
37
|
+
setSettings(_settings) {
|
|
38
|
+
throw new Error("Method not implemented.");
|
|
39
|
+
}
|
|
40
|
+
setSetting(_name, _value) {
|
|
41
|
+
throw new Error("Method not implemented.");
|
|
42
|
+
}
|
|
43
|
+
getSetting(_name) {
|
|
44
|
+
throw new Error("Method not implemented.");
|
|
45
|
+
}
|
|
46
|
+
getSettings() {
|
|
47
|
+
throw new Error("Method not implemented.");
|
|
48
|
+
}
|
|
49
|
+
setModeProperty(_name, _value) {
|
|
50
|
+
throw new Error("Method not implemented.");
|
|
51
|
+
}
|
|
52
|
+
getModeProperty(_name) {
|
|
53
|
+
throw new Error("Method not implemented.");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CyclingMode = CyclingMode;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { ControllableDevice } from '../base/adpater';
|
|
2
|
+
import { DeviceProperties } from '../types/device';
|
|
1
3
|
import { SerialIncyclistDevice, SerialDeviceSettings } from './adapter';
|
|
2
4
|
export default class SerialAdapterFactory {
|
|
3
5
|
static _instance: SerialAdapterFactory;
|
|
4
|
-
adapters: {
|
|
6
|
+
adapters: Array<{
|
|
5
7
|
protocol: string;
|
|
6
|
-
AdapterClass: typeof SerialIncyclistDevice
|
|
7
|
-
}
|
|
8
|
+
AdapterClass: typeof SerialIncyclistDevice<ControllableDevice<DeviceProperties>, DeviceProperties>;
|
|
9
|
+
}>;
|
|
8
10
|
static getInstance(): SerialAdapterFactory;
|
|
9
11
|
constructor();
|
|
10
|
-
registerAdapter(protocol: string, AdapterClass: typeof SerialIncyclistDevice): void;
|
|
11
|
-
createInstance(props: SerialDeviceSettings, settings?: any): SerialIncyclistDevice
|
|
12
|
+
registerAdapter(protocol: string, AdapterClass: typeof SerialIncyclistDevice<ControllableDevice<DeviceProperties>, DeviceProperties>): void;
|
|
13
|
+
createInstance(props: SerialDeviceSettings, settings?: any): SerialIncyclistDevice<ControllableDevice<DeviceProperties>, DeviceProperties>;
|
|
12
14
|
}
|
package/lib/serial/adapter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeviceProperties, DeviceSettings } from "../types/device";
|
|
2
|
-
import { ControllableDevice } from "../base/adpater";
|
|
2
|
+
import IncyclistDevice, { ControllableDevice } from "../base/adpater";
|
|
3
3
|
import SerialInterface from "./serial-interface";
|
|
4
4
|
export interface SerialDeviceSettings extends DeviceSettings {
|
|
5
5
|
protocol: string;
|
|
@@ -7,7 +7,7 @@ export interface SerialDeviceSettings extends DeviceSettings {
|
|
|
7
7
|
port?: string;
|
|
8
8
|
interface: string | SerialInterface;
|
|
9
9
|
}
|
|
10
|
-
export declare class SerialIncyclistDevice extends ControllableDevice {
|
|
10
|
+
export declare class SerialIncyclistDevice<C extends ControllableDevice<P>, P extends DeviceProperties> extends IncyclistDevice<C, P> {
|
|
11
11
|
pullFrequency: number;
|
|
12
12
|
check(): Promise<boolean>;
|
|
13
13
|
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
package/lib/serial/adapter.js
CHANGED
|
@@ -8,11 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.SerialIncyclistDevice = void 0;
|
|
13
|
-
const adpater_1 = require("../base/adpater");
|
|
16
|
+
const adpater_1 = __importDefault(require("../base/adpater"));
|
|
14
17
|
const DEFAULT_PULL_FREQUENCY = 1000;
|
|
15
|
-
class SerialIncyclistDevice extends adpater_1.
|
|
18
|
+
class SerialIncyclistDevice extends adpater_1.default {
|
|
16
19
|
check() {
|
|
17
20
|
return __awaiter(this, void 0, void 0, function* () { throw new Error('not implemnted'); });
|
|
18
21
|
}
|
|
@@ -1,54 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import CyclingMode, { IncyclistBikeData } from '../../modes/cycling-mode';
|
|
3
|
-
import { Bike } from '../../types/adapter';
|
|
1
|
+
import ICyclingMode, { CyclingMode, IncyclistBikeData } from '../../modes/types';
|
|
4
2
|
import { DeviceProperties } from '../../types/device';
|
|
5
3
|
import { SerialDeviceSettings, SerialIncyclistDevice } from '../adapter';
|
|
6
4
|
import { DeviceData } from '../../types/data';
|
|
5
|
+
import SerialInterface from '../serial-interface';
|
|
6
|
+
import DaumSerialComms from './types';
|
|
7
|
+
import { ControllableDevice } from '../../base/adpater';
|
|
8
|
+
import { IncyclistDeviceAdapter } from '../../types/adapter';
|
|
7
9
|
export interface IDaumAdapter {
|
|
8
10
|
getCurrentBikeData(): Promise<IncyclistBikeData>;
|
|
9
11
|
}
|
|
10
|
-
export declare
|
|
11
|
-
|
|
12
|
+
export declare class DaumControl<P extends DeviceProperties> extends ControllableDevice<P> {
|
|
13
|
+
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
14
|
+
getDefaultCyclingMode(): ICyclingMode;
|
|
15
|
+
sendInitCommands(): Promise<boolean>;
|
|
12
16
|
}
|
|
13
|
-
export default class DaumAdapter<S extends SerialDeviceSettings, P extends DeviceProperties> extends
|
|
14
|
-
bike:
|
|
15
|
-
ignoreHrm: boolean;
|
|
16
|
-
ignoreBike: boolean;
|
|
17
|
-
ignorePower: boolean;
|
|
17
|
+
export default class DaumAdapter<DC extends DaumControl<P>, S extends SerialDeviceSettings, P extends DeviceProperties, C extends DaumSerialComms> extends SerialIncyclistDevice<DC, P> implements IDaumAdapter {
|
|
18
|
+
bike: C;
|
|
18
19
|
distanceInternal: number;
|
|
19
|
-
paused: boolean;
|
|
20
|
-
stopped: boolean;
|
|
21
20
|
cyclingData: IncyclistBikeData;
|
|
22
21
|
deviceData: DeviceData;
|
|
23
|
-
currentRequest: any;
|
|
24
22
|
requests: Array<any>;
|
|
25
23
|
iv: any;
|
|
26
|
-
logger: EventLogger;
|
|
27
24
|
tsPrevData: number;
|
|
28
25
|
adapterTime: number;
|
|
29
26
|
requestBusy: boolean;
|
|
30
27
|
updateBusy: boolean;
|
|
28
|
+
startPromise: Promise<boolean>;
|
|
29
|
+
checkPromise: Promise<boolean>;
|
|
31
30
|
constructor(settings: S, props?: P);
|
|
32
|
-
|
|
31
|
+
getPort(): string;
|
|
32
|
+
getSerialInterface(): SerialInterface;
|
|
33
33
|
sendInitCommands(): Promise<boolean>;
|
|
34
|
-
getSupportedCyclingModes(): Array<any>;
|
|
35
|
-
getCyclingMode(): CyclingMode;
|
|
36
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
37
34
|
getCurrentBikeData(): Promise<IncyclistBikeData>;
|
|
38
|
-
getBike():
|
|
35
|
+
getBike(): C;
|
|
39
36
|
isEqual(settings: SerialDeviceSettings): boolean;
|
|
40
|
-
isSame(device:
|
|
37
|
+
isSame(device: IncyclistDeviceAdapter): boolean;
|
|
41
38
|
isStopped(): boolean;
|
|
42
39
|
initData(): void;
|
|
43
40
|
pause(): Promise<boolean>;
|
|
44
41
|
resume(): Promise<boolean>;
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
waitForPrevCheckFinished(): Promise<void>;
|
|
43
|
+
check(): Promise<boolean>;
|
|
44
|
+
performCheck(): Promise<boolean>;
|
|
45
|
+
waitForPrevStartFinished(): Promise<void>;
|
|
46
|
+
start(props?: P): Promise<boolean>;
|
|
47
|
+
performStart(props?: P, isRelaunch?: boolean): Promise<boolean>;
|
|
47
48
|
startUpdatePull(): void;
|
|
49
|
+
stopUpdatePull(): void;
|
|
48
50
|
connect(): Promise<boolean>;
|
|
49
51
|
close(): Promise<boolean>;
|
|
50
|
-
|
|
52
|
+
verifyConnection(): Promise<void>;
|
|
51
53
|
reconnect(): Promise<boolean>;
|
|
54
|
+
logEvent(event: any): void;
|
|
52
55
|
stop(): Promise<boolean>;
|
|
53
56
|
canSendUpdate(): boolean;
|
|
54
57
|
sendUpdate(request: any): Promise<unknown>;
|
|
@@ -60,5 +63,5 @@ export default class DaumAdapter<S extends SerialDeviceSettings, P extends Devic
|
|
|
60
63
|
sendRequest(request: any): Promise<any>;
|
|
61
64
|
refreshRequests(): void;
|
|
62
65
|
processClientRequest(request: any): Promise<unknown>;
|
|
63
|
-
|
|
66
|
+
getDeviceInfo(): Promise<any>;
|
|
64
67
|
}
|