From 730a64be077b51add311b9d880bb23f5162253ec Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: Tue, 5 Jan 2021 14:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BD=95=E5=83=8F=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=8C=E4=BC=98=E5=8C=96=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transmit/cmd/impl/SIPCommander.java | 31 ++++++++++++------- .../iot/vmp/vmanager/ptz/PtzController.java | 17 +++++----- .../vmp/vmanager/record/RecordController.java | 13 ++++++-- web_src/src/components/videoList.vue | 1 + 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 13b83d16..e1d474ff 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -188,19 +188,29 @@ public class SIPCommander implements ISIPCommander { * @param moveSpeed 镜头移动速度 默认 0XFF (0-255) * @param zoomSpeed 镜头缩放速度 默认 0X1 (0-255) */ - public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) { + + /** + * 云台指令码计算 + * + * @param cmdCode 指令码 + * @param horizonSpeed 水平移动速度 + * @param verticalSpeed 垂直移动速度 + * @param zoomSpeed 缩放速度 + * @return + */ + public static String frontEndCmdString(int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed) { StringBuilder builder = new StringBuilder("A50F01"); String strTmp; strTmp = String.format("%02X", cmdCode); builder.append(strTmp, 0, 2); - strTmp = String.format("%02X", parameter1); + strTmp = String.format("%02X", horizonSpeed); builder.append(strTmp, 0, 2); - strTmp = String.format("%02X", parameter2); + strTmp = String.format("%02X", verticalSpeed); builder.append(strTmp, 0, 2); - strTmp = String.format("%X", combineCode2); + strTmp = String.format("%X", zoomSpeed); builder.append(strTmp, 0, 1).append("0"); //计算校验码 - int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + parameter1 + parameter2 + (combineCode2 & 0XF0)) % 0X100; + int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + horizonSpeed + verticalSpeed + (zoomSpeed & 0XF0)) % 0X100; strTmp = String.format("%02X", checkCode); builder.append(strTmp, 0, 2); return builder.toString(); @@ -249,14 +259,14 @@ public class SIPCommander implements ISIPCommander { * @param device 控制设备 * @param channelId 预览通道 * @param cmdCode 指令码 - * @param parameter1 数据1 - * @param parameter2 数据2 - * @param combineCode2 组合码2 + * @param horizonSpeed 水平移动速度 + * @param verticalSpeed 垂直移动速度 + * @param zoomSpeed 缩放速度 */ @Override - public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) { + public boolean frontEndCmd(Device device, String channelId, int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed) { try { - String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); + String cmdStr= frontEndCmdString(cmdCode, horizonSpeed, verticalSpeed, zoomSpeed); System.out.println("控制字符串:" + cmdStr); StringBuffer ptzXml = new StringBuffer(200); ptzXml.append("\r\n"); @@ -701,7 +711,6 @@ public class SIPCommander implements ISIPCommander { Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), "ViaRecordInfoBranch", "FromRecordInfoTag", null); - transmitRequest(device, request); } catch (SipException | ParseException | InvalidArgumentException e) { e.printStackTrace(); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java index 1a90977b..4c41e16f 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java @@ -29,15 +29,14 @@ public class PtzController { private IVideoManagerStorager storager; /*** - * http://localhost:8080/api/ptz/34020000001320000002_34020000001320000008?leftRight=1&upDown=0&inOut=0&moveSpeed=50&zoomSpeed=0 - * @param deviceId - * @param channelId - * @param leftRight - * @param upDown - * @param inOut - * @param moveSpeed - * @param zoomSpeed - * @return + * 云台控制 + * @param deviceId 设备id + * @param channelId 通道id + * @param cmdCode 指令码 + * @param horizonSpeed 水平移动速度 + * @param verticalSpeed 垂直移动速度 + * @param zoomSpeed 缩放速度 + * @return String 控制结果 */ @PostMapping("/ptz/{deviceId}/{channelId}") public ResponseEntity ptz(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed){ diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java index 502087ef..519d299e 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.vmanager.record; +import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -32,7 +33,7 @@ public class RecordController { @Autowired private DeferredResultHolder resultHolder; - + @GetMapping("/record/{deviceId}/{channelId}") public DeferredResult> recordinfo(@PathVariable String deviceId,@PathVariable String channelId, String startTime, String endTime){ @@ -42,9 +43,17 @@ public class RecordController { Device device = storager.queryVideoDevice(deviceId); cmder.recordInfoQuery(device, channelId, startTime, endTime); - DeferredResult> result = new DeferredResult>(); + // 指定超时时间 1分钟30秒 + DeferredResult> result = new DeferredResult>(90*1000L); // 录像查询以channelId作为deviceId查询 resultHolder.put(DeferredResultHolder.CALLBACK_CMD_RECORDINFO+channelId, result); + result.onTimeout(()->{ + RequestMessage msg = new RequestMessage(); + msg.setDeviceId(deviceId); + msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO); + msg.setData("timeout"); + resultHolder.invokeResult(msg); + }); return result; } } diff --git a/web_src/src/components/videoList.vue b/web_src/src/components/videoList.vue index 9e036961..46b4aacf 100644 --- a/web_src/src/components/videoList.vue +++ b/web_src/src/components/videoList.vue @@ -182,6 +182,7 @@ type: 'success' }); } + that.initData() that.$refs[itemData.deviceId + 'refbtn' ].loading = false; }).catch(function(e) { console.error(e)