| | |
| | | import com.ruoyi.utils.sdk.common.SdkErrorCodeEnum; |
| | | import com.ruoyi.utils.sdk.dhsdk.common.ErrorCode; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.ToolKits; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.EM_NEW_CONFIG; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.NET_EM_CFG_OPERATE_TYPE; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.structure.CFG_INFRARED_INFO; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.structure.CFG_VIDEO_IN_FOCUS; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.structure.DH_OUT_PTZ_VIEW_RANGE_STATUS; |
| | | import com.ruoyi.utils.sdk.dhsdk.module.*; |
| | | import com.sun.jna.Native; |
| | | import com.sun.jna.Pointer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.text.DecimalFormat; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.concurrent.PriorityBlockingQueue; |
| | | |
| | | import static com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib.*; |
| | |
| | | //删除管理通道 |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | log.error("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | return AjaxResult.warn(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | GlobalVariable.loginMap.remove(camera.getId()); |
| | |
| | | //启动队列处理器 |
| | | queueHandler.process(camera.getId()); |
| | | } |
| | | return AjaxResult.success("登录成功"); |
| | | return AjaxResult.success("设备登录成功"); |
| | | } catch (Exception ex) { |
| | | log.error("登录异常:" + ex.getMessage()); |
| | | return AjaxResult.error("登录异常:" + ex.getMessage()); |
| | | log.error("设备登录异常:" + ex.getMessage()); |
| | | return AjaxResult.error("设备登录异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | //删除管理通道 |
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId()); |
| | | log.error("设备[" + camera.getIp() + ":" + camera.getPort() + "]登录失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | return AjaxResult.warn(getErrorCodePrint()); |
| | | } |
| | | if (GlobalVariable.loginMap.containsKey(camera.getId())) { |
| | | GlobalVariable.loginMap.remove(camera.getId()); |
| | |
| | | |
| | | //创建引导队列 |
| | | private void createGuideQueue(ArdCameras camera) { |
| | | if (camera.getCamAlarmGuideEnable() != null) { |
| | | if (camera.getCamAlarmGuideEnable() == 1) { |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | //启动队列处理器 |
| | | queueHandler.process(camera.getId()); |
| | | } |
| | | } |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | //启动队列处理器 |
| | | queueHandler.process(camera.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | Integer speed = cmd.getSpeed(); |
| | | Integer code = cmd.getCode(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | NetSDKLib.LLong loginId = (NetSDKLib.LLong) GlobalVariable.loginMap.get(cameraId); |
| | | int dwStop; |
| | |
| | | boolean bool = PtzControlModule.ptzControl(loginId, chanNo - 1, dwPTZCommand, speed, speed, 0, dwStop); |
| | | if (!bool) { |
| | | log.error("控制失败,请稍后重试" + getErrorCodePrint()); |
| | | return AjaxResult.error(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | return AjaxResult.warn(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | return AjaxResult.success("云台控制成功"); |
| | | } |
| | |
| | | Map<String, Object> ptzMap = new HashMap<>(); |
| | | String cameraId = cmd.getCameraId(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | NetSDKLib.LLong loginId = (NetSDKLib.LLong) GlobalVariable.loginMap.get(cameraId); |
| | | NetSDKLib.NET_PTZ_LOCATION_INFO dh_ptz_location_info = new NetSDKLib.NET_PTZ_LOCATION_INFO(); |
| | |
| | | if (!b) { |
| | | int code = netsdk.CLIENT_GetLastError(); |
| | | log.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置ptz失败:" + getErrorCodePrint()); |
| | | } |
| | | DecimalFormat df = new DecimalFormat("0.0");//设置保留位数 |
| | | String nPTZPan = df.format((float) dh_ptz_location_info.nPTZPan / 10); |
| | |
| | | Integer chanNo = cmd.getChanNo(); |
| | | Map<String, Double> ptz = cmd.getPtzMap(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | | if (ptz.get("p") == null || ptz.get("t") == null || ptz.get("z") == null) { |
| | | return AjaxResult.error("ptz参数不能为空"); |
| | | return AjaxResult.warn("ptz参数不能为空"); |
| | | } |
| | | int p = (int) (ptz.get("p") * 10); |
| | | int t = (int) (ptz.get("t") * 10); |
| | |
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0); |
| | | if (!bool) { |
| | | log.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置ptz失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("设置ptz成功"); |
| | | } catch (Exception ex) { |
| | |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | boolean bool = NetSDKLib.NETSDK_INSTANCE.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RESETZERO, 0, 0, 0, 0); |
| | | if (!bool) { |
| | | log.error("设置零方位角失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置ptz失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("设置零方位角成功"); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult localCapture(CameraCmd cmd) { |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | String imagePath = FileUtils.createFile("D:/LocalCaptureTemp/" + cameraId + ".jpeg"); |
| | | fCaptureReceiveCB1 m_CaptureReceiveCB = new fCaptureReceiveCB1(imagePath); |
| | | CapturePictureModule.setSnapRevCallBack(m_CaptureReceiveCB); |
| | | boolean b = CapturePictureModule.remoteCapturePicture(loginId, chanNo - 1); |
| | | if (!b) { |
| | | return AjaxResult.warn("本地抓图失败"); |
| | | } |
| | | Thread.sleep(200); |
| | | byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath)); |
| | | //OutputStream outputStream = response.getOutputStream(); |
| | | //outputStream.write(imageBytes); |
| | | // 创建ByteBuffer并将字节数组写入其中 |
| | | //ByteBuffer jpegBuffer = ByteBuffer.wrap(imageBytes); |
| | | //Base64.Encoder decoder = Base64.getEncoder(); |
| | | //String png_base64 = decoder.encodeToString(jpegBuffer.array());//转换成base64串 |
| | | return AjaxResult.success(imageBytes); |
| | | } catch (Exception ex) { |
| | | return AjaxResult.error("本地抓图异常:" + ex); |
| | | } |
| | | } |
| | | |
| | | //本地录像开始 |
| | | @Override |
| | | public AjaxResult localRecordStart(CameraCmd cmd) { |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | //if (GlobalVariable.previewMap.containsKey(cameraId)) { |
| | | // lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId)); |
| | | // RealPlayModule.stopRealPlay(lRealHandle); |
| | | // GlobalVariable.previewMap.remove(cameraId); |
| | | // log.debug("停止当前录像"); |
| | | //} |
| | | String path = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4"); |
| | | LLong lRealHandle = RealPlayModule.startRealPlay(loginId, chanNo - 1, path); |
| | | if (lRealHandle.longValue() <= 0) { |
| | | log.error("取流失败" + getErrorCodePrint()); |
| | | } |
| | | log.debug("本地录像开始取流成功"); |
| | | //GlobalVariable.previewMap.put(cameraId, lRealHandle.intValue()); |
| | | //GlobalVariable.threadMap.put(cameraId, Thread.currentThread().getName()); |
| | | //if (!netsdk.CLIENT_SaveRealData(lRealHandle, path)) { |
| | | // log.error("保存视频文件到临时文件夹失败 错误码为: " +getErrorCodePrint()); |
| | | // return false; |
| | | //} |
| | | log.debug("本地录像开始"); |
| | | return AjaxResult.success("本地录像开始", lRealHandle); |
| | | } catch (Exception ex) { |
| | | log.error("本地录像开始异常" + ex.getMessage()); |
| | | return AjaxResult.error("本地录像开始异常" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | //本地录像停止 |
| | | @Override |
| | | public AjaxResult localRecordStop(CameraCmd cmd) { |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | LLong lRealHandle = new LLong(cmd.getRecordId()); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | |
| | | RealPlayModule.stopRealPlay(lRealHandle); |
| | | log.debug("本地录像停止"); |
| | | String recordPath = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4"); |
| | | byte[] imageBytes = Files.readAllBytes(Paths.get(recordPath)); |
| | | // OutputStream outputStream = response.getOutputStream(); |
| | | // outputStream.write(imageBytes); |
| | | return AjaxResult.success(imageBytes); |
| | | //if (GlobalVariable.previewMap.containsKey(cameraId)) { |
| | | // lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId)); |
| | | // RealPlayModule.stopRealPlay(lRealHandle); |
| | | // GlobalVariable.previewMap.remove(cameraId); |
| | | // log.debug("本地录像停止"); |
| | | // String recordPath = FileUtils.createFile("D:/LocalRecordTemp/" + cameraId + ".mp4"); |
| | | // byte[] imageBytes = Files.readAllBytes(Paths.get(recordPath)); |
| | | // // OutputStream outputStream = response.getOutputStream(); |
| | | // // outputStream.write(imageBytes); |
| | | // return AjaxResult.success(imageBytes); |
| | | //} |
| | | //else { |
| | | // return AjaxResult.error("设备未开始录像"); |
| | | //} |
| | | } catch (Exception ex) { |
| | | log.error("本地录像停止异常" + ex.getMessage()); |
| | | return AjaxResult.error("本地录像停止异常" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @描述 短时录像 |
| | |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | |
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0); |
| | | if (!bool) { |
| | | log.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("设置ptz失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置ptz失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("引导目标位置成功"); |
| | | } catch (Exception ex) { |
| | |
| | | Integer chanNo = cmd.getChanNo(); |
| | | Integer PresetIndex = cmd.getPresetIndex(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | | |
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NET_PTZ_POINT_MOVE_CONTROL, 0, PresetIndex, 0, 0); |
| | | if (!bool) { |
| | | log.error("转至预置点失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("转至预置点失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("转至预置点失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("转至预置点成功"); |
| | | } catch (Exception ex) { |
| | |
| | | Integer chanNo = cmd.getChanNo(); |
| | | Integer PresetIndex = cmd.getPresetIndex(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NET_PTZ_POINT_SET_CONTROL, 0, PresetIndex, 0, 0); |
| | | if (!bool) { |
| | | log.error("设置预置点失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("设置预置点失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置预置点失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("设置预置点成功"); |
| | | } catch (Exception ex) { |
| | |
| | | Integer chanNo = cmd.getChanNo(); |
| | | boolean enable = cmd.isEnable(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | |
| | | boolean bool = ConfigModule.SetDevConfig(loginId, chanNo - 1, NetSDKLib.CFG_CMD_VIDEOIN_FOCUS, cfg_video_in_focus); |
| | | if (!bool) { |
| | | log.error("切换聚焦模式失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("切换聚焦模式失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("切换聚焦模式失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("切换聚焦模式成功"); |
| | | } catch (Exception ex) { |
| | |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | |
| | | boolean bool = ConfigModule.GetConfig(loginId, chanNo - 1, emCfgOpType, focusModeInfo); |
| | | if (!bool) { |
| | | log.error("获取聚焦模式失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("获取聚焦模式失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("获取聚焦模式失败:" + getErrorCodePrint()); |
| | | } |
| | | //System.out.println("配置类型:" + focusModeInfo.emCfgType); // 具体信息,参考库里的枚举 |
| | | //System.out.println("聚焦模式:" + focusModeInfo.emFocusMode); |
| | |
| | | return AjaxResult.success("该功能未实现"); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult captureJPEGPicture(CameraCmd cmd) { |
| | | return AjaxResult.success("该功能未实现"); |
| | | } |
| | | |
| | | //切换透雾 |
| | | @Override |
| | |
| | | Integer chanNo = cmd.getChanNo(); |
| | | boolean enable = cmd.isEnable(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | |
| | | boolean bool = ConfigModule.SetDevConfig(loginId, chanNo - 1, command, netVideoinDefogInfo); |
| | | if (!bool) { |
| | | log.error("切换透雾失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("切换透雾失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("切换透雾失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("切换透雾成功"); |
| | | } catch (Exception ex) { |
| | |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | |
| | | boolean bool = ConfigModule.SetDevConfig(loginId, chanNo - 1, CFG_CMD_INFRARED_CONFIG, cfg_infrared_info); |
| | | if (!bool) { |
| | | log.error("切换红外失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("切换红外失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("切换红外失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("切换红外成功"); |
| | | } catch (Exception ex) { |
| | |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | NET_PTZ_LOCATION_INFO net_ptz_location_info = new NET_PTZ_LOCATION_INFO(); |
| | |
| | | boolean bool = ConfigModule.queryDevState(loginId, NET_DEVSTATE_PTZ_LOCATION, net_ptz_location_info); |
| | | if (!bool) { |
| | | log.error("获取聚焦值失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("获取聚焦值失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("获取聚焦值失败:" + getErrorCodePrint()); |
| | | } |
| | | result = net_ptz_location_info.nFocusMapValue; |
| | | return AjaxResult.success(result); |
| | |
| | | Integer chanNo = cmd.getChanNo(); |
| | | boolean enable = cmd.isEnable(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | |
| | | boolean bool = ConfigModule.SetDevConfig(loginId, chanNo - 1, CFG_CMD_LIGHTING, cfg_lighting_info); |
| | | if (!bool) { |
| | | log.error("设置聚焦值失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("设置聚焦值失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("设置聚焦值失败:" + getErrorCodePrint()); |
| | | } |
| | | return AjaxResult.success("设置聚焦值成功"); |
| | | } catch (Exception ex) { |
| | |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return AjaxResult.error("设备未登录"); |
| | | return AjaxResult.warn("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | DH_OUT_PTZ_VIEW_RANGE_STATUS dh_out_ptz_view_range_status = new DH_OUT_PTZ_VIEW_RANGE_STATUS(); |
| | | boolean b = ConfigModule.queryDevState(loginId, NET_DEVSTATE_PTZ_VIEW_RANGE, dh_out_ptz_view_range_status); |
| | | if (!b) { |
| | | log.error("获取云台可视域失败:" + getErrorCodePrint()); |
| | | return AjaxResult.error("获取云台可视域失败:" + getErrorCodePrint()); |
| | | return AjaxResult.warn("获取云台可视域失败:" + getErrorCodePrint()); |
| | | } |
| | | float nAngelH = (float) dh_out_ptz_view_range_status.nAngelH / 10; |
| | | float nAngelV = (float) dh_out_ptz_view_range_status.nAngelV / 10; |
| | |
| | | } |
| | | } |
| | | |
| | | // 抓图接收回调:当抓图成功,sdk会调用该函数 |
| | | public static class fCaptureReceiveCB1 implements NetSDKLib.fSnapRev { |
| | | private String picPath; |
| | | |
| | | public fCaptureReceiveCB1(String picPath) { |
| | | this.picPath = picPath; |
| | | } |
| | | |
| | | public void invoke(LLong lLoginID, Pointer pBuf, int RevLen, int EncodeType, int CmdSerial, Pointer dwUser) { |
| | | if (pBuf != null && RevLen > 0) { |
| | | byte[] buf = pBuf.getByteArray(0, RevLen); |
| | | //存储到本地 |
| | | InputStream input = new ByteArrayInputStream(buf); |
| | | OutputStream output = null; |
| | | try { |
| | | output = new FileOutputStream(picPath); |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | while ((bytesRead = input.read(buffer)) != -1) { |
| | | output.write(buffer, 0, bytesRead); |
| | | } |
| | | input.close(); |
| | | output.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |