|
|
|
|
@ -25,6 +25,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlUpEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL,
|
|
|
|
|
@ -39,6 +40,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlDownEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL,
|
|
|
|
|
@ -53,6 +55,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlLeftEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL,
|
|
|
|
|
@ -67,6 +70,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlRightEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL,
|
|
|
|
|
@ -81,6 +85,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlLeftUpEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP,
|
|
|
|
|
@ -95,6 +100,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlRightUpEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP,
|
|
|
|
|
@ -109,6 +115,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlLeftDownEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN,
|
|
|
|
|
@ -123,6 +130,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
|
|
|
|
|
lParam1, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlRightDownEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN,
|
|
|
|
|
@ -137,6 +145,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
|
|
|
|
|
0, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlZoomAddEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL,
|
|
|
|
|
@ -151,6 +160,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
|
|
|
|
|
0, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlZoomDecEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL,
|
|
|
|
|
@ -165,6 +175,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
|
|
|
|
|
0, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlFocusAddEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL,
|
|
|
|
|
@ -179,6 +190,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
|
|
|
|
|
0, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlFocusDecEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL,
|
|
|
|
|
@ -193,6 +205,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
|
|
|
|
|
0, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlIrisAddEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL,
|
|
|
|
|
@ -207,6 +220,7 @@ public class PtzControlModule {
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
|
|
|
|
|
0, lParam2, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean ptzControlIrisDecEnd(Integer cameraId, int nChannelID) {
|
|
|
|
|
return LoginModule.netsdk.CLIENT_DHPTZControlEx(CameraConnMap.getConnId(cameraId), nChannelID,
|
|
|
|
|
NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL,
|
|
|
|
|
@ -256,26 +270,25 @@ public class PtzControlModule {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置预置点
|
|
|
|
|
*
|
|
|
|
|
* @param ptzId 预置点ID
|
|
|
|
|
* @param name 预置点的名称
|
|
|
|
|
* @param cameraId 球机ID,来获取登录句柄
|
|
|
|
|
*/
|
|
|
|
|
public static void ptz(Integer ptzId, String name, Integer cameraId) {
|
|
|
|
|
int dwzCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_SET_CONTROL;
|
|
|
|
|
int nPressetIndex = ptzId;
|
|
|
|
|
Boolean ok = LoginModule.netsdk.CLIENT_DHPTZControlEx2(CameraConnMap.getConnId(cameraId), 0, dwzCommand, 0, ptzId, 0, 0, ToolKits.GetGBKStringToPointer(name));
|
|
|
|
|
Assert.isTrue(ok, "设置失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 转至 预置点
|
|
|
|
|
*
|
|
|
|
|
* @param ptzId
|
|
|
|
|
* @param cameraId
|
|
|
|
|
*/
|
|
|
|
|
public static void toPtz(Integer ptzId, Integer cameraId) {
|
|
|
|
|
int dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_MOVE_CONTROL;
|
|
|
|
|
|
|
|
|
|
int nPresetIndex = ptzId;
|
|
|
|
|
Boolean ok = LoginModule.netsdk.CLIENT_DHPTZControlEx2(CameraConnMap.getConnId(cameraId), 0, dwPTZCommand, 0, ptzId, 0, 0, null);
|
|
|
|
|
if (!ok) {
|
|
|
|
|
log.error("转至预置点 失败 cameraId:{},ptzId:{}", cameraId, ptzId);
|
|
|
|
|
@ -284,13 +297,14 @@ public class PtzControlModule {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 转至 预置点
|
|
|
|
|
* @param ptzId
|
|
|
|
|
*
|
|
|
|
|
* @param cameraId
|
|
|
|
|
*/
|
|
|
|
|
public static void toPtzSlow(Integer ptzId,Integer cameraId){
|
|
|
|
|
public static void toPtzSlow(Integer cameraId,Integer x) {
|
|
|
|
|
int dwPTZCommand = NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_MOVE_ABSOLUTELY;
|
|
|
|
|
NetSDKLib.PTZ_CONTROL_ABSOLUTELY absolutely = new NetSDKLib.PTZ_CONTROL_ABSOLUTELY();
|
|
|
|
|
absolutely.stuPosition.nPositionX = 3600;
|
|
|
|
|
|
|
|
|
|
absolutely.stuPosition.nPositionX = x;
|
|
|
|
|
absolutely.stuPosition.nPositionY = 0;
|
|
|
|
|
absolutely.stuSpeed.fPositionX = 0.2f;
|
|
|
|
|
absolutely.stuSpeed.fPositionY = 0.2f;
|
|
|
|
|
@ -299,13 +313,52 @@ public class PtzControlModule {
|
|
|
|
|
Boolean ok = LoginModule.netsdk.CLIENT_DHPTZControlEx2(CameraConnMap.getConnId(cameraId), 0, dwPTZCommand,
|
|
|
|
|
0, 0, 0, 0, absolutely.getPointer());
|
|
|
|
|
if (!ok) {
|
|
|
|
|
log.error("失败 cameraId:{},ptzId:{}",cameraId,ptzId);
|
|
|
|
|
log.error("失败 cameraId:{}", cameraId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 旋转360度
|
|
|
|
|
* @param cameraId
|
|
|
|
|
*/
|
|
|
|
|
public static void turn360(Integer cameraId){
|
|
|
|
|
Thread thread = new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
int nType = NetSDKLib.NET_DEVSTATE_PTZ_LOCATION;
|
|
|
|
|
NetSDKLib.NET_PTZ_LOCATION_INFO ptzLocationInfo = new NetSDKLib.NET_PTZ_LOCATION_INFO();
|
|
|
|
|
IntByReference intRetLen = new IntByReference();
|
|
|
|
|
|
|
|
|
|
ptzLocationInfo.write();
|
|
|
|
|
System.out.println("size:"+ptzLocationInfo.size());
|
|
|
|
|
boolean bRet = LoginModule.netsdk.CLIENT_QueryDevState(CameraConnMap.getConnId(cameraId), nType, ptzLocationInfo.getPointer(), ptzLocationInfo.size(), intRetLen, 3000);
|
|
|
|
|
ptzLocationInfo.read();
|
|
|
|
|
|
|
|
|
|
if (bRet) {
|
|
|
|
|
System.out.println("xParam:" + ptzLocationInfo.nPTZPan); // 云台水平运动位置,有效范围:[0,3600]
|
|
|
|
|
System.out.println("yParam:" + ptzLocationInfo.nPTZTilt); // 云台垂直运动位置,有效范围:[-1800,1800]
|
|
|
|
|
System.out.println("zoomParam:" + ptzLocationInfo.nPTZZoom);
|
|
|
|
|
int qq = (ptzLocationInfo.nPTZPan + 1799) % 3600;
|
|
|
|
|
System.out.println(qq);
|
|
|
|
|
toPtzSlow(cameraId,qq);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(5000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
qq = (qq + 1799) % 3600;
|
|
|
|
|
System.out.println(qq);
|
|
|
|
|
toPtzSlow(cameraId,qq);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
System.err.println( " { error code: ( 0x80000000|" + (LoginModule.netsdk.CLIENT_GetLastError() & 0x7fffffff) +" ). 参考 LastError.java }");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
thread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|