/**
|
* PTZ 公共方法,引用之前需要先定义curCamera对象
|
* 执行命令编码
|
* 云台控制命令 1=上,2=下,3=左,4=右,5=左上,6=左下,7=右上,8=右下,0=停止,9=变倍小,10 = 变倍加,11 = 变焦停
|
* 预置位命令 1=设置,2=执行,3=删除
|
* 数据将curCamera对象封装为APi 对象发送给云平台
|
*/
|
|
function getParam(command, preset) {
|
return {
|
playType: curCamera.playType,
|
ptzType: curCamera.ptzType,
|
snapType: curCamera.snapType,
|
cameraId: curCamera.id,
|
cameraName: curCamera.name,
|
ip: curCamera.ip,
|
sn: curCamera.sn,
|
webPort: curCamera.webPort,
|
ctrlPort: curCamera.controlPort,
|
channel: curCamera.chanNum,
|
loginId: curCamera.loginId,
|
pwd: curCamera.pwd,
|
mediaAddr: curCamera.mediaAddr,
|
urlIn: curCamera.urlIn,
|
urlOut: curCamera.urlOut,
|
command: command,
|
preset: preset
|
}
|
}
|
|
//云台控制
|
function ptzControl(command) {
|
// layer.msg('开始调用云台……', {icon: 1, time: 1200,offset:'rb'});
|
const param = getParam(command, null);
|
const url = "../../basic/security/ptz-media";
|
sendControlCommand(url, param);
|
}
|
|
//预置位控制
|
function presetControl(command) {
|
//layer.msg('开始执行……', {icon: 1, time: 1200,offset:'rb'});
|
const preset = $("#preset").val();
|
const param = getParam(command, preset);
|
const url = "../../basic/security/ptz-media";
|
sendControlCommand(url, param);
|
}
|
|
//停止移动
|
function moveStop() {
|
//layer.msg('开始调用云台……', {icon: 1, time: 1200,offset:'rb'});
|
const param = getParam(0, null);
|
const url = "../../basic/security/ptz-media";
|
sendControlCommand(url, param);
|
}
|
|
//变焦停
|
function zoomStop() {
|
//doNothing
|
}
|
|
//发送控制命令
|
function sendControlCommand(url, param) {
|
$.ajax({
|
type: "POST",
|
url: url,
|
dataType: 'JSON',
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(param),
|
success: function (data) {
|
if (data.code === "ERROR") {
|
layer.msg('执行失败', {icon: 2, time: 1500,offset:'rb'});
|
} else {
|
layer.msg('执行成功', {icon: 1, time: 1200,offset:'rb'});
|
}
|
}
|
})
|
}
|