import { ApiClientFactory } from '../core/api.client.factory'; import { cloudConsoleReq } from '../model/cloudConsole.model'; export class CloudConsole { constructor(private factory: ApiClientFactory) {} /* 获取云控制台的版本 */ async loadcloudConsoleVersion(projectId: string, deviceId: string): Promise { const url = `api/ptz/projects/${projectId}/devices/${deviceId}/version`; const result = await this.factory.entity.get(url); return result; } /* 新版本 云控制台操作,cmd=: STOP,//停止 UP,//上转, DOWN,// 下转, LEFT,//左转, RIGHT,//右转, ZOOM_IN,//焦距变大, ZOOM_OUT,//焦距变小, LEFT_UP,//左上 , LEFT_DOWN,//左下, RIGHT_UP,//右上, RIGHT_DOWN,//右下, FOCUS_EAR,//焦点前调, FOCUS_FAR,//焦点后移, IRIS_ENLARGE,//光圈扩大, IRIS_REDUCE;//光圈缩小 */ async setCloudConsole(projectId: string, deviceId: string, cmd: string, sourceType: string): Promise { const url = `/api/ptz/projects/${projectId}/devices/${deviceId}`; const result = await this.factory.entity.post(url, { cmd, sourceType }); return result; } /** * /** * 与控制台控制 * @param cloudConsoleReq * @param type // start | stop,连续转动,开始,结束,空是点击 * @returns */ async controlCloudConsole(cloudConsoleReq: cloudConsoleReq, type: string = ''): Promise { let url = `/api/ptz`; url = type ? `${url}/${type}` : url; const result = await this.factory.entity.post(url, { duration: 400, speed: 100, ...cloudConsoleReq }); return result; } async gvsControlCloudConsole(cloudConsoleReq: cloudConsoleReq, type: string = ''): Promise { let url = `/api/ptz`; url = type ? `${url}/${type}` : url; const result = await this.factory.gvsIvs.post(url, { duration: 400, speed: 100, ...cloudConsoleReq }); return result; } /** * @预置点 */ // 添加预置点 async addPresetPoint(projectId: string, deviceId: string, params: object = {}) { const url = `ptz/preset`; const result = await this.factory.surveillance.put(url, { projectId, deviceId, ...params }); return result; } // 删除 async deletePresetPoint(id: string) { const url = `ptz/preset`; const result = await this.factory.surveillance.delete(url + `/${id}`); return result; } // 删除全部 async deleteAllPresetPoint(projectId: string, deviceId: string) { const url = `ptz/preset`; const result = await this.factory.surveillance.delete(url + `?projectId=${projectId}&deviceId=${deviceId}`); return result; } // 列表 async fetchPresetPointList(projectId: string, deviceId: string) { const url = `ptz/preset`; const result = await this.factory.surveillance.get(url + `?projectId=${projectId}&deviceId=${deviceId}`); return result; } // 移动到点位 async moveToPoint(id: string) { const url = `ptz/preset/call`; const result = await this.factory.surveillance.put(url + `/${id}`); return result; } async adjust(deviceId: string, sourceType: string) { const url = `/ptz/adjust`; const result = await this.factory.surveillance.post(url, { deviceId, sourceType, }); return result; } }