packagecom.lg.haikang.hkdevice.Controller;
importcn.hutool.core.util.XmlUtil;
importcom.lg.haikang.hkdevice.demo.HCNetSDK;
importcom.sun.jna.NativeLong;
importcom.sun.jna.Pointer;
importcom.sun.jna.examples.win32.W32API;
importcom.sun.jna.ptr.IntByReference;
importorg.w3c.dom.Document;
importjavax.swing.*;
importjava.io.IOException;
importjava.io.UnsupportedEncodingException;
importjava.net.DatagramPacket;
importjava.net.DatagramSocket;
public classTest11 {
staticHCNetSDK hCNetSDK= HCNetSDK.INSTANCE;
staticHCNetSDK.NET_DVR_DEVICEINFO_V30 m_strDeviceInfo;//设备信息HCNetSDK.NET_DVR_STREAM_INFO strStreamInfo;//流ID信息// NET_DVR_BARRIERGATE_COND m_struGateCond={0}; //出入口控制参数配置条件// NET_DVR_ENTRANCE_CFG m_struEntrance={0}; //出入口控制参数// DWORD dwStatus = 0;
static intlUserID;//用户句柄intlAlarmHandle=-1;//报警布防句柄NativeLong lListenHandle;//报警监听句柄
FMSGCallBack fMSFCallBack;//报警回调函数实现
//暴漏事件监听端口 该设备不支持public intjt(){
inta= hCNetSDK.NET_DVR_StartListen_V30("192.168.168.99",(short) 9000,fMSFCallBack,null);
System.out.println(a+"监听句柄");
returna;
}
//布防publicString bf() {
if(lUserID== -1)
{
JOptionPane.showMessageDialog(null, "请先注册");
return"请先注册";
}
System.out.println(lAlarmHandle+"布防句柄");
if(lAlarmHandle< 0)//尚未布防,需要布防{
if(fMSFCallBack== null)
{
fMSFCallBack= newFMSGCallBack();
Pointer pUser = null;
if(!hCNetSDK.NET_DVR_SetDVRMessageCallBack_V30(fMSFCallBack, pUser))
{
System.out.println("设置回调函数失败!");
}
}
HCNetSDK.NET_DVR_SETUPALARM_PARAM m_strAlarmInfo = newHCNetSDK.NET_DVR_SETUPALARM_PARAM();
m_strAlarmInfo.dwSize=m_strAlarmInfo.size();
m_strAlarmInfo.byLevel=0; //布防优先级:0-一等级(高),1-二等级(中),2-三等级(低)
m_strAlarmInfo.byAlarmInfoType=1; //0-老报警信息(NET_DVR_PLATE_RESULT),1-新报警信息(NET_ITS_PLATE_RESULT)m_strAlarmInfo.write();
//建立报警上传通道,获取报警等信息。 代lAlarmHandle= hCNetSDK.NET_DVR_SetupAlarmChan_V41(lUserID, m_strAlarmInfo);
if(lAlarmHandle== -1)
{
System.out.println("布防失败,错误码:"+ hCNetSDK.NET_DVR_GetLastError());
JOptionPane.showMessageDialog(null, "布防失败");
return"布防失败";
}
else{
JOptionPane.showMessageDialog(null, "布防成功");
return"布防成功";
}
}
return"布防未知";
}
//SDK初始化public staticString sdkInit(){
booleaninitSuc = hCNetSDK.NET_DVR_Init();
if(initSuc != true)
{
//http://192.168.10.51:18336/doc/page/main.aspJOptionPane.showMessageDialog(null, "初始化失败");
System.out.println("初始化失败");
return"初始化失败";
}
System.out.println("初始化成功");
return"初始化成功";
}
public longlogin(){
// String m_sDeviceIP ="192.168.10.68";String m_sDeviceIP ="192.168.10.51";
// int iPort=8000;// int iPort=18336;intiPort=25225;
String UserName="admin";
String Password ="haikang123";
intbUseAsynLogin=0;
m_strDeviceInfo= newHCNetSDK.NET_DVR_DEVICEINFO_V30();
//int iPort = Integer.parseInt(jTextFieldPortNumber.getText());lUserID= hCNetSDK.NET_DVR_Login_V30(m_sDeviceIP,
(short) iPort, UserName, Password, m_strDeviceInfo);
// /* lUserID = hCNetSDK.NET_DVR_Login_V40(m_sDeviceIP,// (short) iPort, UserName, Password, m_strDeviceInfo);*/
longuserID = lUserID;
System.out.println(userID+"用户登陆句柄,"+&