Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 3x 3x 3x 3x 3x 3x | import { HttpClient } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import {
CameraConfiguration,
DepthCamera,
TrackingConfigState
} from '@reflex/shared-types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { LogService } from 'src/app/log/log.service';
import { BASE_URL } from 'src/shared/tokens/base-url.token';
import { SignalRBaseService } from './signalR.base.service';
@Injectable({
providedIn: 'root'
})
export class TrackingService extends SignalRBaseService<TrackingConfigState> {
private readonly http = inject(HttpClient);
private readonly baseUrl: string;
private readonly cameraRoute = 'api/Tracking/';
private readonly selectedCameraRoute = `${this.cameraRoute}SelectedCamera/`;
private readonly selectedCameraConfigRoute = `${this.cameraRoute}SelectedCameraConfig/`;
private readonly configRoute = `${this.cameraRoute}Configurations/`;
private readonly toggleTrackingRoute = `${this.cameraRoute}ToggleTracking/`;
private readonly setDepthImagePreviewStateRoute = `${this.cameraRoute}SetDepthImagePreview/`;
private readonly getAutostartEnabledRoute = `${this.cameraRoute}GetAutoStartEnabled`;
private readonly setAutostartRoute = `${this.cameraRoute}SetAutoStart`;
public constructor() {
const baseUrl = inject(BASE_URL);
const logService = inject(LogService);
super(`${baseUrl}trkhub`, 'trackingState', logService);
this.baseUrl = baseUrl;
}
public getCameras(): Observable<Array<DepthCamera>> {
return this.http.get<Array<DepthCamera>>(this.baseUrl + this.cameraRoute);
}
public getSelectedCamera(): Observable<DepthCamera> {
return this.http.get<DepthCamera>(this.baseUrl + this.selectedCameraRoute);
}
public getSelectedCameraConfig(): Observable<CameraConfiguration> {
return this.http.get<CameraConfiguration>(
this.baseUrl + this.selectedCameraConfigRoute
);
}
public getConfigurationsForCamera(
cameraIdx: number
): Observable<Array<CameraConfiguration>> {
return this.http.get<Array<CameraConfiguration>>(
`${this.baseUrl}${this.configRoute}${cameraIdx}`
);
}
public queryAutostartEnabled(): Observable<string> {
return this.http.get(this.baseUrl + this.getAutostartEnabledRoute, {
responseType: 'text'
});
}
public setAutostartEnabled(enabled: boolean): Observable<boolean> {
return this.http.put<boolean>(
this.baseUrl + this.setAutostartRoute,
enabled,
{ headers: this.headers }
);
}
public toggleCamera(
cameraIdx: number,
configIdx: number
): Observable<number> {
return this.http.put<number>(
`${this.baseUrl}${this.toggleTrackingRoute}${cameraIdx}`,
configIdx,
{ headers: this.headers }
);
}
public setDepthImagePreviewState(newState: boolean): Observable<boolean> {
const result = this.http.put<number>(
`${this.baseUrl}${this.setDepthImagePreviewStateRoute}`,
newState,
{ headers: this.headers }
);
return result.pipe(map((response: number) => response === 202));
}
}
|