Commit 31e340e8e2eb5d7761a1ae8baa4a0a5e774dba59

Authored by 648540858
1 parent b445128f

修改云台控制接口使其更加直观

src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
1 1 package com.genersoft.iot.vmp.gb28181.event;
2 2  
3   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
4 3 import org.slf4j.Logger;
5 4 import org.slf4j.LoggerFactory;
6 5 import org.springframework.scheduling.annotation.Scheduled;
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java
... ... @@ -44,7 +44,7 @@ public class PtzController {
44 44 * 云台控制
45 45 * @param deviceId 设备id
46 46 * @param channelId 通道id
47   - * @param cmdCode 指令码
  47 + * @param command 控制指令
48 48 * @param horizonSpeed 水平移动速度
49 49 * @param verticalSpeed 垂直移动速度
50 50 * @param zoomSpeed 缩放速度
... ... @@ -54,19 +54,56 @@ public class PtzController {
54 54 @ApiImplicitParams({
55 55 @ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
56 56 @ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
57   - @ApiImplicitParam(name = "cmdCode", value = "指令码", dataTypeClass = Integer.class),
  57 + @ApiImplicitParam(name = "command", value = "控制指令,允许值: left, right, up, down, upleft, upright, downleft, downright, zoomin, zoomout, stop", dataTypeClass = Integer.class),
58 58 @ApiImplicitParam(name = "horizonSpeed", value = "水平速度", dataTypeClass = Integer.class),
59 59 @ApiImplicitParam(name = "verticalSpeed", value = "垂直速度", dataTypeClass = Integer.class),
60 60 @ApiImplicitParam(name = "zoomSpeed", value = "缩放速度", dataTypeClass = Integer.class),
61 61 })
62 62 @PostMapping("/control/{deviceId}/{channelId}")
63   - public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed){
  63 + public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){
64 64  
65 65 if (logger.isDebugEnabled()) {
66   - logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed));
  66 + logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,command:%s ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed));
67 67 }
68 68 Device device = storager.queryVideoDevice(deviceId);
69   -
  69 + int cmdCode = 0;
  70 + switch (command){
  71 + case "left":
  72 + cmdCode = 2;
  73 + break;
  74 + case "right":
  75 + cmdCode = 1;
  76 + break;
  77 + case "up":
  78 + cmdCode = 8;
  79 + break;
  80 + case "down":
  81 + cmdCode = 4;
  82 + break;
  83 + case "upleft":
  84 + cmdCode = 10;
  85 + break;
  86 + case "upright":
  87 + cmdCode = 9;
  88 + break;
  89 + case "downleft":
  90 + cmdCode = 6;
  91 + break;
  92 + case "downright":
  93 + cmdCode = 5;
  94 + break;
  95 + case "zoomin":
  96 + cmdCode = 16;
  97 + break;
  98 + case "zoomout":
  99 + cmdCode = 32;
  100 + break;
  101 + case "stop":
  102 + cmdCode = 0;
  103 + break;
  104 + default:
  105 + break;
  106 + }
70 107 cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed);
71 108 return new ResponseEntity<String>("success",HttpStatus.OK);
72 109 }
... ...
web_src/src/components/dialog/devicePlayer.vue
... ... @@ -60,27 +60,27 @@
60 60 <el-tab-pane label="云台控制" name="control" v-if="showPtz">
61 61 <div style="display: flex; justify-content: left;">
62 62 <div class="control-wrapper">
63   - <div class="control-btn control-top" @mousedown="ptzCamera(0, 2, 0)" @mouseup="ptzCamera(0, 0, 0)">
  63 + <div class="control-btn control-top" @mousedown="ptzCamera('up')" @mouseup="ptzCamera('stop')">
64 64 <i class="el-icon-caret-top"></i>
65 65 <div class="control-inner-btn control-inner"></div>
66 66 </div>
67   - <div class="control-btn control-left" @mousedown="ptzCamera(2, 0, 0)" @mouseup="ptzCamera(0, 0, 0)">
  67 + <div class="control-btn control-left" @mousedown="ptzCamera('left')" @mouseup="ptzCamera('stop')">
68 68 <i class="el-icon-caret-left"></i>
69 69 <div class="control-inner-btn control-inner"></div>
70 70 </div>
71   - <div class="control-btn control-bottom" @mousedown="ptzCamera(0, 1, 0)" @mouseup="ptzCamera(0, 0, 0)">
  71 + <div class="control-btn control-bottom" @mousedown="ptzCamera('down')" @mouseup="ptzCamera('stop')">
72 72 <i class="el-icon-caret-bottom"></i>
73 73 <div class="control-inner-btn control-inner"></div>
74 74 </div>
75   - <div class="control-btn control-right" @mousedown="ptzCamera(1, 0, 0)" @mouseup="ptzCamera(0, 0, 0)">
  75 + <div class="control-btn control-right" @mousedown="ptzCamera('right')" @mouseup="ptzCamera('stop')">
76 76 <i class="el-icon-caret-right"></i>
77 77 <div class="control-inner-btn control-inner"></div>
78 78 </div>
79 79 <div class="control-round">
80 80 <div class="control-round-inner"><i class="fa fa-pause-circle"></i></div>
81 81 </div>
82   - <div style="position: absolute; left: 7.25rem; top: 1.25rem" @mousedown="ptzCamera(0, 0, 1)" @mouseup="ptzCamera(0, 0, 0)"><i class="el-icon-zoom-in control-zoom-btn" style="font-size: 1.875rem;"></i></div>
83   - <div style="position: absolute; left: 7.25rem; top: 3.25rem; font-size: 1.875rem;" @mousedown="ptzCamera(0, 0, 2)" @mouseup="ptzCamera(0, 0, 0)"><i class="el-icon-zoom-out control-zoom-btn"></i></div>
  82 + <div style="position: absolute; left: 7.25rem; top: 1.25rem" @mousedown="ptzCamera('zoomin')" @mouseup="ptzCamera('stop')"><i class="el-icon-zoom-in control-zoom-btn" style="font-size: 1.875rem;"></i></div>
  83 + <div style="position: absolute; left: 7.25rem; top: 3.25rem; font-size: 1.875rem;" @mousedown="ptzCamera('zoomout')" @mouseup="ptzCamera('stop')"><i class="el-icon-zoom-out control-zoom-btn"></i></div>
84 84 <div class="contro-speed" style="position: absolute; left: 4px; top: 7rem; width: 9rem;">
85 85 <el-slider v-model="controSpeed" :max="255"></el-slider>
86 86 </div>
... ... @@ -113,7 +113,7 @@
113 113 <el-button style="position: absolute; left: 11rem; top: 9rem; width: 5rem" size="mini" icon="el-icon-d-arrow-left" @click="setCommand(137, scanGroup, 1)">左边界</el-button>
114 114 <el-button style="position: absolute; left: 16rem; top: 9rem; width: 5rem" size="mini" icon="el-icon-d-arrow-right" @click="setCommand(137, scanGroup, 2)">右边界</el-button>
115 115 <el-button style="position: absolute; left: 27rem; top: 7rem; width: 5rem" size="mini" type="primary" icon="el-icon-video-camera-solid" @click="setCommand(137, scanGroup, 0)">扫描</el-button>
116   - <el-button style="position: absolute; left: 27rem; top: 9rem; width: 5rem" size="mini" type="danger" icon="el-icon-switch-button" @click="ptzCamera(0, 0, 0)">停止</el-button>
  116 + <el-button style="position: absolute; left: 27rem; top: 9rem; width: 5rem" size="mini" type="danger" icon="el-icon-switch-button" @click="ptzCamera('stop')">停止</el-button>
117 117 </el-button-group>
118 118 </div>
119 119 </div>
... ... @@ -493,14 +493,14 @@ export default {
493 493 if (callback) callback()
494 494 });
495 495 },
496   - ptzCamera: function (leftRight, upDown, zoom) {
497   - console.log('云台控制:' + leftRight + ' : ' + upDown + " : " + zoom);
  496 + ptzCamera: function (command) {
  497 + console.log('云台控制:' + command);
498 498 let that = this;
499 499 this.$axios({
500 500 method: 'post',
501 501 // url: '/api/ptz/' + this.deviceId + '/' + this.channelId + '?leftRight=' + leftRight + '&upDown=' + upDown +
502 502 // '&inOut=' + zoom + '&moveSpeed=50&zoomSpeed=50'
503   - url: '/api/ptz/control/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + (zoom * 16 + upDown * 4 + leftRight) + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed
  503 + url: '/api/ptz/control/' + this.deviceId + '/' + this.channelId + '?command=' + command + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed
504 504 }).then(function (res) {});
505 505 },
506 506 //////////////////////播放器事件处理//////////////////////////
... ...