incyclist-services 1.0.22 → 1.0.24
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.
|
@@ -60,6 +60,7 @@ export declare class DeviceConfigurationService extends EventEmitter {
|
|
|
60
60
|
disableInterface(ifName: string): void;
|
|
61
61
|
setInterfaceSettings(ifName: any, settings: InterfaceSetting): void;
|
|
62
62
|
emitInterfaceChanged(ifName: string): void;
|
|
63
|
+
emitDeviceDeleted(settings: IncyclistDeviceSettings): void;
|
|
63
64
|
}
|
|
64
65
|
export declare const useDeviceConfiguration: () => DeviceConfigurationService;
|
|
65
66
|
export {};
|
|
@@ -474,6 +474,7 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
474
474
|
this.emitCapabiltyChanged();
|
|
475
475
|
this.updateUserSettings();
|
|
476
476
|
}
|
|
477
|
+
this.emitDeviceDeleted(deviceSettings);
|
|
477
478
|
}
|
|
478
479
|
deleteFromDeviceList(udid) {
|
|
479
480
|
const { devices = [] } = this.settings || {};
|
|
@@ -724,6 +725,9 @@ class DeviceConfigurationService extends events_1.default {
|
|
|
724
725
|
this.emit('interface-changed', ifName, setting, this.settings.interfaces);
|
|
725
726
|
}
|
|
726
727
|
}
|
|
728
|
+
emitDeviceDeleted(settings) {
|
|
729
|
+
this.emit('device-deleted', settings);
|
|
730
|
+
}
|
|
727
731
|
}
|
|
728
732
|
exports.DeviceConfigurationService = DeviceConfigurationService;
|
|
729
733
|
const useDeviceConfiguration = () => DeviceConfigurationService.getInstance();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from "events";
|
|
3
|
-
import { DeviceData, DeviceSettings } from "incyclist-devices";
|
|
3
|
+
import { DeviceData, DeviceSettings, ControllableDeviceAdapter } from "incyclist-devices";
|
|
4
4
|
import { DeviceAccessService } from "../access/service";
|
|
5
|
-
import { AdapterInfo, DeviceConfigurationService } from "../configuration";
|
|
5
|
+
import { AdapterInfo, DeviceConfigurationService, IncyclistDeviceSettings } from "../configuration";
|
|
6
6
|
import CyclingMode, { UpdateRequest } from "incyclist-devices/lib/modes/cycling-mode";
|
|
7
7
|
import { AdapterRideInfo, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./model";
|
|
8
8
|
import { UserSettingsService } from "../../settings";
|
|
@@ -37,6 +37,7 @@ export declare class DeviceRideService extends EventEmitter {
|
|
|
37
37
|
protected waitForPreviousStartToFinish(): Promise<boolean>;
|
|
38
38
|
startCheck(filter: RideServiceCheckFilter): Promise<void>;
|
|
39
39
|
protected getAdapters(filter: RideServiceCheckFilter): AdapterRideInfo[];
|
|
40
|
+
setSerialPortInUse(adapter: ControllableDeviceAdapter): void;
|
|
40
41
|
protected startAdapters(adapters: AdapterRideInfo[], startType: 'start' | 'check', props?: RideServiceDeviceProperties): Promise<boolean>;
|
|
41
42
|
start(props: RideServiceDeviceProperties): Promise<boolean>;
|
|
42
43
|
cancelStart(): Promise<boolean>;
|
|
@@ -48,6 +49,7 @@ export declare class DeviceRideService extends EventEmitter {
|
|
|
48
49
|
sendUpdate(request: UpdateRequest): void;
|
|
49
50
|
getCyclingMode(udid?: string): CyclingMode;
|
|
50
51
|
onCyclingModeChanged(udid: string, mode: string, settings: any): Promise<void>;
|
|
52
|
+
onDeviceDeleted(settings: IncyclistDeviceSettings): void;
|
|
51
53
|
enforceSimulator(enforced?: boolean): void;
|
|
52
54
|
}
|
|
53
55
|
export declare const useDeviceRide: () => DeviceRideService;
|
|
@@ -64,7 +64,9 @@ class DeviceRideService extends events_1.default {
|
|
|
64
64
|
}
|
|
65
65
|
this.adapters = (_a = this.configurationService.getAdapters()) === null || _a === void 0 ? void 0 : _a.map(ai => Object.assign({}, Object.assign(Object.assign({}, ai), { isStarted: false })));
|
|
66
66
|
const handleModeChange = this.onCyclingModeChanged.bind(this);
|
|
67
|
+
const handleDeviceDeleted = this.onDeviceDeleted.bind(this);
|
|
67
68
|
this.configurationService.on('mode-changed', handleModeChange);
|
|
69
|
+
this.configurationService.on('device-deleted', handleDeviceDeleted);
|
|
68
70
|
this.userSettings = (0, settings_1.useUserSettings)();
|
|
69
71
|
});
|
|
70
72
|
}
|
|
@@ -326,6 +328,13 @@ class DeviceRideService extends events_1.default {
|
|
|
326
328
|
}
|
|
327
329
|
return adapters || [];
|
|
328
330
|
}
|
|
331
|
+
setSerialPortInUse(adapter) {
|
|
332
|
+
if (adapter.getInterface() === 'serial' || adapter.getInterface() === 'tcpip') {
|
|
333
|
+
const device = adapter;
|
|
334
|
+
const serial = device.getSerialInterface();
|
|
335
|
+
serial.setInUse(device.getPort());
|
|
336
|
+
}
|
|
337
|
+
}
|
|
329
338
|
startAdapters(adapters, startType, props) {
|
|
330
339
|
return __awaiter(this, void 0, void 0, function* () {
|
|
331
340
|
const { forceErgMode, startPos, realityFactor, rideMode, route } = props || {};
|
|
@@ -386,6 +395,8 @@ class DeviceRideService extends events_1.default {
|
|
|
386
395
|
yield ai.adapter.pause().catch(console.log);
|
|
387
396
|
ai.adapter.off('data', this.deviceDataHandler);
|
|
388
397
|
}
|
|
398
|
+
if (ai.adapter.isControllable())
|
|
399
|
+
this.setSerialPortInUse(ai.adapter);
|
|
389
400
|
return success;
|
|
390
401
|
}))
|
|
391
402
|
.catch(err => {
|
|
@@ -443,6 +454,10 @@ class DeviceRideService extends events_1.default {
|
|
|
443
454
|
}
|
|
444
455
|
stop(udid) {
|
|
445
456
|
return __awaiter(this, void 0, void 0, function* () {
|
|
457
|
+
if (!udid)
|
|
458
|
+
this.logEvent({ message: 'stop devices' });
|
|
459
|
+
else
|
|
460
|
+
this.logEvent({ message: 'stop device', udid });
|
|
446
461
|
const adapters = this.getAdapterList();
|
|
447
462
|
this.emit('stop-ride');
|
|
448
463
|
const promises = adapters === null || adapters === void 0 ? void 0 : adapters.filter(ai => udid ? ai.udid === udid : true).map(ai => {
|
|
@@ -543,6 +558,13 @@ class DeviceRideService extends events_1.default {
|
|
|
543
558
|
}
|
|
544
559
|
});
|
|
545
560
|
}
|
|
561
|
+
onDeviceDeleted(settings) {
|
|
562
|
+
if (settings.interface === 'serial' || settings.interface === 'tcpip') {
|
|
563
|
+
const device = incyclist_devices_1.AdapterFactory.create(settings);
|
|
564
|
+
const serial = device.getSerialInterface();
|
|
565
|
+
serial.releaseInUse(device.getPort());
|
|
566
|
+
}
|
|
567
|
+
}
|
|
546
568
|
enforceSimulator(enforced = true) {
|
|
547
569
|
this.simulatorEnforced = enforced;
|
|
548
570
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.24"
|
|
6
6
|
},
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"jest": "^29.6.4",
|
|
15
15
|
"jsdoc": "^4.0.2",
|
|
16
16
|
"ts-jest": "^29.1.1",
|
|
17
|
-
"typedoc": "^0.
|
|
17
|
+
"typedoc": "^0.25.1",
|
|
18
18
|
"typedoc-plugin-markdown": "^3.15.4",
|
|
19
19
|
"typedoc-plugin-no-inherit": "^1.4.0",
|
|
20
|
-
"typescript": "^5.
|
|
20
|
+
"typescript": "^5.2.2"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"lint": "eslint . --ext .ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"lib": "./src"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"incyclist-devices": "^2.0.
|
|
40
|
+
"incyclist-devices": "^2.0.32",
|
|
41
41
|
"uuid": "^9.0.0"
|
|
42
42
|
}
|
|
43
43
|
}
|