| | |
| | | import com.whyc.dto.TempPoint; |
| | | import com.whyc.hik.Commom.osSelect; |
| | | import com.whyc.hik.NetSDKDemo.HCNetSDK; |
| | | import com.whyc.pojo.db_batt.BattCamera; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.FileOutputStream; |
| | |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.util.*; |
| | | |
| | | import static com.whyc.hik.NetSDKDemo.HCNetSDK.NET_DVR_CHECK_USER_STATUS; |
| | | |
| | | @Service |
| | | public class HikTempUtil { |
| | |
| | | public static List<Integer> lUserIDs = new LinkedList<>(); |
| | | public static Map<String,Integer> ipLUserIdMap = new HashMap<>(); |
| | | public static FExceptionCallBack_Imp fExceptionCallBack; |
| | | public static List<IpInfo> ipInfoList = new LinkedList<>(); |
| | | static { |
| | | //TODO 暂时定义,后续要改成对应的 |
| | | ipInfoList.add(new IpInfo("192.168.10.11","1")); |
| | | ipInfoList.add(new IpInfo("192.168.10.12","2")); |
| | | ipInfoList.add(new IpInfo("192.168.10.13","3")); |
| | | ipInfoList.add(new IpInfo("192.168.10.14","4")); |
| | | ipInfoList.add(new IpInfo("192.168.10.15","5")); |
| | | ipInfoList.add(new IpInfo("192.168.10.16","6")); |
| | | ipInfoList.add(new IpInfo("192.168.10.17","7")); |
| | | ipInfoList.add(new IpInfo("192.168.10.18","8")); |
| | | } |
| | | |
| | | public static List<BattCamera> cameraInfoList = new LinkedList<>(); |
| | | |
| | | public static Response getTempPoint(String ip){ |
| | | Integer lUserID = ipLUserIdMap.get(ip); |
| | | boolean isOnline = hCNetSDK.NET_DVR_RemoteControl(lUserID, NET_DVR_CHECK_USER_STATUS, null, 0); |
| | | if (!isOnline){ //设备不在线,说明跟设备的连接已经失败,重新建立连接 |
| | | lUserID = loginDevice(ip, (short) 8000, "admin", "fg001@hdw"); |
| | | if(lUserID == -1){ |
| | | return new Response().set(1,false,"登录失败,无法建立与设备的连接,请检查网络"); |
| | | }else{ |
| | | ipLUserIdMap.put(ip,lUserID); |
| | | } |
| | | } |
| | | //hCNetSDK.NET_DVR_STDXMLConfig(lUserID, "<?xml version=\"1.0\" encoding=\"GB2312\"?><GetDeviceInfo><dwSize>0</dwSize></GetDeviceInfo>", "GetDeviceInfo", 1000); |
| | | |
| | | /*========== 红外 抓图测温 Start==========*/ |
| | |
| | | return new Response().setII(1,true,tempPointMap,null); |
| | | } |
| | | |
| | | public static void init(){ |
| | | public static void init(List<BattCamera> list){ |
| | | cameraInfoList = list; |
| | | if (hCNetSDK == null) { |
| | | if (!createSDKInstance()) { |
| | | System.out.println("Load SDK fail"); |
| | |
| | | //登录设备,每一台设备只需要登录一次 |
| | | //lUserID = TestDemo.loginDevice("10.9.137.21", (short) 8000, "admin", "Cpfwb518+"); |
| | | //int lUserID = HikTempUtil.loginDevice("192.168.10.16", (short) 8000, "admin", "fg001@hdw"); |
| | | for (int i = 0; i < ipInfoList.size(); i++) { |
| | | String ip = ipInfoList.get(i).getIp(); |
| | | for (int i = 0; i < cameraInfoList.size(); i++) { |
| | | String ip = cameraInfoList.get(i).getCameraIp(); |
| | | int lUserID = HikTempUtil.loginDevice(ip, (short) 8000, "admin", "fg001@hdw"); |
| | | lUserIDs.add(lUserID); |
| | | ipLUserIdMap.put(ip,lUserID); |