|
|
|
@ -1,12 +1,15 @@
|
|
|
|
package com.zhehekeji.web.lib.hik;
|
|
|
|
package com.zhehekeji.web.lib.hik;
|
|
|
|
|
|
|
|
|
|
|
|
import com.sun.jna.NativeLong;
|
|
|
|
import com.sun.jna.NativeLong;
|
|
|
|
|
|
|
|
import com.sun.jna.Pointer;
|
|
|
|
import com.sun.jna.ptr.IntByReference;
|
|
|
|
import com.sun.jna.ptr.IntByReference;
|
|
|
|
import com.zhehekeji.common.util.PathUtil;
|
|
|
|
import com.zhehekeji.common.util.PathUtil;
|
|
|
|
import com.zhehekeji.core.util.Assert;
|
|
|
|
import com.zhehekeji.core.util.Assert;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.entity.Camera;
|
|
|
|
import com.zhehekeji.web.lib.CameraConnMap;
|
|
|
|
import com.zhehekeji.web.lib.CameraConnMap;
|
|
|
|
import com.zhehekeji.web.lib.CameraControlModule;
|
|
|
|
import com.zhehekeji.web.lib.CameraControlModule;
|
|
|
|
import com.zhehekeji.web.lib.joyware.NetSDKLib;
|
|
|
|
import com.zhehekeji.web.lib.joyware.NetSDKLib;
|
|
|
|
|
|
|
|
import com.zhehekeji.web.pojo.camera.CameraPtzPojo;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.*;
|
|
|
|
@ -18,6 +21,8 @@ import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Timer;
|
|
|
|
import java.util.Timer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.zhehekeji.web.lib.hik.HCNetSDK.NET_DVR_GET_PTZPOS;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 云台控制接口实现
|
|
|
|
* 云台控制接口实现
|
|
|
|
* 主要有 :八个方向控制、变倍、变焦、光圈功能
|
|
|
|
* 主要有 :八个方向控制、变倍、变焦、光圈功能
|
|
|
|
@ -76,6 +81,40 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
|
|
|
|
int lUserId = CameraConnMap.getConnId(cameraId).intValue();
|
|
|
|
int lUserId = CameraConnMap.getConnId(cameraId).intValue();
|
|
|
|
return HikLoginModuleImpl.hcNetsdk.NET_DVR_PTZControl_Other(lUserId, 1, HCNetSDK.PAN_LEFT, 1);
|
|
|
|
return HikLoginModuleImpl.hcNetsdk.NET_DVR_PTZControl_Other(lUserId, 1, HCNetSDK.PAN_LEFT, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public CameraPtzPojo ptzGetDVRConfig(Integer lUserID) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CameraPtzPojo cameraPtzPojo = new CameraPtzPojo();
|
|
|
|
|
|
|
|
int lUserId = CameraConnMap.getConnId(lUserID).intValue();
|
|
|
|
|
|
|
|
HCNetSDK.NET_DVR_PTZPOS netDvrPtzpos = new HCNetSDK.NET_DVR_PTZPOS();
|
|
|
|
|
|
|
|
Pointer pointer = netDvrPtzpos.getPointer();
|
|
|
|
|
|
|
|
IntByReference intByReference = new IntByReference(1);
|
|
|
|
|
|
|
|
boolean b_GetPTZ = HikLoginModuleImpl.hcNetsdk.NET_DVR_GetDVRConfig(lUserId, NET_DVR_GET_PTZPOS,1,pointer,netDvrPtzpos.size(),intByReference);
|
|
|
|
|
|
|
|
if (b_GetPTZ == false) {
|
|
|
|
|
|
|
|
System.out.println("获取PTZ坐标信息失败,错误码:" +HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError());
|
|
|
|
|
|
|
|
cameraPtzPojo.setGetSuccess(false);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cameraPtzPojo.setGetSuccess(true);
|
|
|
|
|
|
|
|
netDvrPtzpos.read();
|
|
|
|
|
|
|
|
cameraPtzPojo.setWPanPos(hexToDegree(netDvrPtzpos.wPanPos));
|
|
|
|
|
|
|
|
cameraPtzPojo.setWTiltPos(hexToDegree(netDvrPtzpos.wTiltPos));
|
|
|
|
|
|
|
|
cameraPtzPojo.setWZoomPos(hexToDegree(netDvrPtzpos.wZoomPos));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cameraPtzPojo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static double hexToDegree(short hex) {
|
|
|
|
|
|
|
|
String value = Integer.toHexString(hex);
|
|
|
|
|
|
|
|
Integer v = Integer.parseInt(value);
|
|
|
|
|
|
|
|
int integerPart = v / 10;
|
|
|
|
|
|
|
|
int decimalPart = v % 10;
|
|
|
|
|
|
|
|
return integerPart + decimalPart / 10.0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
hexToDegree((short)10322);
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 向右
|
|
|
|
* 向右
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|