Эх сурвалжийг харах

1. 修复接口错误
2. 修复移动速度代码部分生成逻辑

kindring 2 жил өмнө
parent
commit
bea98cd3f1

+ 3 - 3
src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java

@@ -142,7 +142,7 @@ public class SipUtils {
         int moveSpeed =0 ;
         int moveSpeed =0 ;
         moveSpeed |= 0x00;
         moveSpeed |= 0x00;
         int zoomSpeed =0 ;
         int zoomSpeed =0 ;
-        moveSpeed |= speed;
+        zoomSpeed |= speed;
         StringBuilder builder = new StringBuilder("A50F01");
         StringBuilder builder = new StringBuilder("A50F01");
         //A5 0F 01 01 ff ff
         //A5 0F 01 01 ff ff
         String strTmp;
         String strTmp;
@@ -151,8 +151,8 @@ public class SipUtils {
         strTmp = String.format("%02X", moveSpeed);// 云台  +- => 15
         strTmp = String.format("%02X", moveSpeed);// 云台  +- => 15
         builder.append(strTmp, 0, 2);
         builder.append(strTmp, 0, 2);
         builder.append(strTmp, 0, 2);
         builder.append(strTmp, 0, 2);
-        strTmp = String.format("%X", zoomSpeed);// 镜头 abcd => 00 15
-        builder.append(strTmp, 0, 1).append("0");
+        strTmp = String.format("%02X", zoomSpeed);// 镜头 abcd => 00 15
+        builder.append(strTmp, 0, 2);
         //计算校验码
         //计算校验码
         int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + moveSpeed + moveSpeed + (zoomSpeed /*<< 4*/ & 0XF0)) % 0X100;
         int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + moveSpeed + moveSpeed + (zoomSpeed /*<< 4*/ & 0XF0)) % 0X100;
         strTmp = String.format("%02X", checkCode);
         strTmp = String.format("%02X", checkCode);

+ 13 - 5
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java

@@ -115,16 +115,17 @@ public class PtzController {
 	@Operation(summary = "云台控制新接口")
 	@Operation(summary = "云台控制新接口")
 	@Parameter(name = "deviceId", description = "设备国标编号", required = true)
 	@Parameter(name = "deviceId", description = "设备国标编号", required = true)
 	@Parameter(name = "channelId", description = "通道国标编号", required = true)
 	@Parameter(name = "channelId", description = "通道国标编号", required = true)
-	@Parameter(name = "command", description = "控制指令,允许值: left, right, up, down, stop", required = true)
-	@Parameter(name = "speed", description = "移动速度", required = false)
+	@Parameter(name = "c", description = "控制指令,允许值: left, right, up, down, stop", required = true)
+	@Parameter(name = "step", description = "移动速度", required = false)
 	@PostMapping("/c/{deviceId}/{channelId}")
 	@PostMapping("/c/{deviceId}/{channelId}")
-	public void newPTZ(@PathVariable String deviceId,@PathVariable String channelId, String command,int speed){
+	public void newPTZ(@PathVariable String deviceId,@PathVariable String channelId, String c,String step){
 		if (logger.isDebugEnabled()) {
 		if (logger.isDebugEnabled()) {
-			logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,command:%s ,speed:%d ",deviceId, channelId, command, speed));
+			logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,c:%s ,speed:%d ",deviceId, channelId, c, step));
 		}
 		}
+		logger.info("设备云台控制 API调用,deviceId:{} ,channelId:{} ,command:{} ,speed:{} ",deviceId, channelId, c, step);
 		Device device = storager.queryVideoDevice(deviceId);
 		Device device = storager.queryVideoDevice(deviceId);
 		int cmdCode = 0;
 		int cmdCode = 0;
-		switch (command){
+		switch (c){
 			case "left":
 			case "left":
 				cmdCode = 3;
 				cmdCode = 3;
 				break;
 				break;
@@ -142,6 +143,13 @@ public class PtzController {
 			default:
 			default:
 				break;
 				break;
 		}
 		}
+		int defaultValue = 0; // 默认值
+		int speed;
+		try {
+			speed = Integer.parseInt(step);
+		} catch (NumberFormatException e) {
+			speed = defaultValue;
+		}
 		try {
 		try {
 			cmder.ptzCmdNew(device, channelId, cmdCode,speed);
 			cmder.ptzCmdNew(device, channelId, cmdCode,speed);
 		} catch (SipException | InvalidArgumentException | ParseException e) {
 		} catch (SipException | InvalidArgumentException | ParseException e) {