diff --git a/libs/jain-sip-ri-1.3.0-91.jar b/libs/jain-sip-ri-1.3.0-92.jar similarity index 100% rename from libs/jain-sip-ri-1.3.0-91.jar rename to libs/jain-sip-ri-1.3.0-92.jar diff --git a/pom.xml b/pom.xml index 8f3118f8..3c4edf18 100644 --- a/pom.xml +++ b/pom.xml @@ -122,9 +122,9 @@ javax.sip jain-sip-ri - 1.3.0-91 - system - ${basedir}/libs/jain-sip-ri-1.3.0-91.jar + 1.3.0-92 + org.dom4j @@ -177,6 +177,16 @@ 1.8 1.8 + + + ${project.basedir}/libs + WEB-INF/lib + true + + **/*.jar + + + diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 7d5d10ce..923f211a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -64,6 +64,18 @@ public interface ISIPCommander { */ public boolean ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed); + /** + * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令 + * + * @param device 控制设备 + * @param channelId 预览通道 + * @param cmdCode 指令码 + * @param parameter1 数据1 + * @param parameter2 数据2 + * @param combineCode2 组合码2 + */ + public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2); + /** * 请求预览视频流 * 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 a33678c4..4ac0c735 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 @@ -163,6 +163,32 @@ public class SIPCommander implements ISIPCommander { return builder.toString(); } + /** + * 云台指令码计算 + * + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 + * @param moveSpeed 镜头移动速度 默认 0XFF (0-255) + * @param zoomSpeed 镜头缩放速度 默认 0X1 (0-255) + */ + public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) { + StringBuilder builder = new StringBuilder("A50F01"); + String strTmp; + strTmp = String.format("%02X", cmdCode); + builder.append(strTmp, 0, 2); + strTmp = String.format("%02X", parameter1); + builder.append(strTmp, 0, 2); + strTmp = String.format("%02X", parameter2); + builder.append(strTmp, 0, 2); + strTmp = String.format("%X", combineCode2); + builder.append(strTmp, 0, 1).append("0"); + //计算校验码 + int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + parameter1 + parameter2 + (combineCode2 & 0XF0)) % 0X100; + strTmp = String.format("%02X", checkCode); + builder.append(strTmp, 0, 2); + return builder.toString(); + } /** * 云台控制,支持方向与缩放控制 @@ -201,6 +227,41 @@ public class SIPCommander implements ISIPCommander { return false; } + /** + * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令 + * + * @param device 控制设备 + * @param channelId 预览通道 + * @param cmdCode 指令码 + * @param parameter1 数据1 + * @param parameter2 数据2 + * @param combineCode2 组合码2 + */ + @Override + public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) { + try { + String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); + System.out.println("控制字符串:" + cmdStr); + StringBuffer ptzXml = new StringBuffer(200); + ptzXml.append("\r\n"); + ptzXml.append("\r\n"); + ptzXml.append("DeviceControl\r\n"); + ptzXml.append("" + (int)((Math.random()*9+1)*100000) + "\r\n"); + ptzXml.append("" + channelId + "\r\n"); + ptzXml.append("" + cmdStr + "\r\n"); + ptzXml.append("\r\n"); + ptzXml.append("\r\n"); + ptzXml.append("\r\n"); + + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtzTag", "ToPtzTag"); + + transmitRequest(device, request); + return true; + } catch (SipException | ParseException | InvalidArgumentException e) { + e.printStackTrace(); + } + return false; + } /** * 请求预览视频流 * diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java index 8c0ecfba..34a02ee2 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java @@ -138,7 +138,7 @@ public class DeviceController { DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId); if (deviceChannel == null) { PageResult deviceChannelPageResult = new PageResult<>(); - new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK); + return new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK); } PageResult pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count); 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 87e6bf28..1a90977b 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 @@ -40,14 +40,35 @@ public class PtzController { * @return */ @PostMapping("/ptz/{deviceId}/{channelId}") - public ResponseEntity ptz(@PathVariable String deviceId,@PathVariable String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed){ + public ResponseEntity ptz(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed){ if (logger.isDebugEnabled()) { - logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,leftRight:%d ,upDown:%d ,inOut:%d ,moveSpeed:%d ,zoomSpeed:%d",deviceId, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed)); + logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed)); } Device device = storager.queryVideoDevice(deviceId); - cmder.ptzCmd(device, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed); + cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed); + return new ResponseEntity("success",HttpStatus.OK); + } + // public ResponseEntity ptz(@PathVariable String deviceId,@PathVariable String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed){ + + // if (logger.isDebugEnabled()) { + // logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,leftRight:%d ,upDown:%d ,inOut:%d ,moveSpeed:%d ,zoomSpeed:%d",deviceId, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed)); + // } + // Device device = storager.queryVideoDevice(deviceId); + + // cmder.ptzCmd(device, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed); + // return new ResponseEntity("success",HttpStatus.OK); + // } + @PostMapping("/frontEndCommand/{deviceId}/{channelId}") + public ResponseEntity frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){ + + if (logger.isDebugEnabled()) { + logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d parameter1:%d parameter2:%d",deviceId, channelId, cmdCode, parameter1, parameter2)); + } + Device device = storager.queryVideoDevice(deviceId); + + cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2); return new ResponseEntity("success",HttpStatus.OK); } } diff --git a/web_src/src/components/gb28181/devicePlayer.vue b/web_src/src/components/gb28181/devicePlayer.vue index 8c23ced4..493f5d59 100644 --- a/web_src/src/components/gb28181/devicePlayer.vue +++ b/web_src/src/components/gb28181/devicePlayer.vue @@ -40,7 +40,7 @@ - + @@ -55,32 +55,61 @@ -
+
-
+
-
+
-
+
-
+
-
-
+
+
+
+
+ + 预置位编号 + + 设置 + 调用 + 删除 + 巡航速度 + + 设置 + 停留时间 + + 设置 + 巡航组编号 + + 添加点 + 删除点 + 删除组 + 巡航 + 扫描速度 + + 设置 + 扫描组编号 + + 左边界 + 右边界 + 扫描 + 停止 +
-
@@ -152,7 +181,12 @@ export default { timeVal: 0, timeMin: 0, timeMax: 1440, - + presetPos: 1, + cruisingSpeed: 100, + cruisingTime: 5, + cruisingGroup: 0, + scanSpeed: 100, + scanGroup: 0, }; }, methods: { @@ -291,14 +325,41 @@ export default { let that = this; this.$axios({ method: 'post', - url: '/api/ptz/' + this.deviceId + '/' + this.channelId + '?leftRight=' + leftRight + '&upDown=' + upDown + - '&inOut=' + zoom + '&moveSpeed=50&zoomSpeed=50' + // url: '/api/ptz/' + this.deviceId + '/' + this.channelId + '?leftRight=' + leftRight + '&upDown=' + upDown + + // '&inOut=' + zoom + '&moveSpeed=50&zoomSpeed=50' + url: '/api/ptz/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + (zoom * 16 + upDown * 4 + leftRight) + '&horizonSpeed=30&verticalSpeed=30&zoomSpeed=' + (2 * 16) }).then(function (res) {}); }, //////////////////////播放器事件处理////////////////////////// videoError: function (e) { console.log("播放器错误:" + JSON.stringify(e)); }, + presetPosition: function (cmdCode, presetPos) { + console.log('预置位控制:' + this.presetPos + ' : 0x' + cmdCode.toString(16)); + let that = this; + this.$axios({ + method: 'post', + url: '/api/frontEndCommand/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=0¶meter2=' + presetPos + '&combindCode2=0' + }).then(function (res) {}); + }, + setSpeedOrTime: function (cmdCode, groupNum, parameter) { + let that = this; + let parameter2 = parameter % 256; + let combindCode2 = Math.floor(parameter / 256) * 16; + console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter2.toString(16) + ' 0x' + combindCode2.toString(16)); + this.$axios({ + method: 'post', + url: '/api/frontEndCommand/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=' + groupNum + '¶meter2=' + parameter2 + '&combindCode2=' + combindCode2 + }).then(function (res) {}); + }, + setCommand: function (cmdCode, groupNum, parameter) { + let that = this; + console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter.toString(16) + ' 0x0'); + this.$axios({ + method: 'post', + url: '/api/frontEndCommand/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=' + groupNum + '¶meter2=' + parameter + '&combindCode2=0' + }).then(function (res) {}); + }, formatTooltip: function (val) { var h = parseInt(val / 60); var hStr = h < 10 ? ("0" + h) : h; @@ -356,11 +417,20 @@ export default { height: 6.25rem; max-width: 6.25rem; max-height: 6.25rem; - margin: 0 auto; border-radius: 100%; + margin-top: 2.5rem; + margin-left: 0.5rem; float: left; } +.control-panel { + position: relative; + top: 0; + left: 5rem; + height: 11rem; + max-height: 11rem; +} + .control-btn { display: flex; justify-content: center; @@ -393,8 +463,8 @@ export default { .control-round-inner { position: absolute; - left: 15%; - top: 15%; + left: 13%; + top: 13%; display: flex; justify-content: center; align-items: center;