diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java index 3b87d1cf..233050b6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PtzController.java @@ -53,7 +53,7 @@ public class PtzController { @Parameter(name = "cmdCode", description = "指令码(对应国标文档指令格式中的字节4)", required = true) @Parameter(name = "parameter1", description = "数据一(对应国标文档指令格式中的字节5, 范围0-255)", required = true) @Parameter(name = "parameter2", description = "数据二(对应国标文档指令格式中的字节6, 范围0-255)", required = true) - @Parameter(name = "combindCode2", description = "组合码二(对应国标文档指令格式中的字节7, 范围0-16)", required = true) + @Parameter(name = "combindCode2", description = "组合码二(对应国标文档指令格式中的字节7, 范围0-15)", required = true) @GetMapping("/common/{deviceId}/{channelId}") public void frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2){ @@ -62,13 +62,13 @@ public class PtzController { } if (parameter1 == null || parameter1 < 0 || parameter1 > 255) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter1 为 1-255的数字"); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter1 为 0-255的数字"); } if (parameter2 == null || parameter2 < 0 || parameter2 > 255) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter1 为 1-255的数字"); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter2 为 0-255的数字"); } - if (combindCode2 == null || combindCode2 < 0 || combindCode2 > 16) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter1 为 1-255的数字"); + if (combindCode2 == null || combindCode2 < 0 || combindCode2 > 15) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "combindCode2 为 0-15的数字"); } Device device = deviceService.getDeviceByDeviceId(deviceId); @@ -84,7 +84,7 @@ public class PtzController { @Parameter(name = "command", description = "控制指令,允许值: left, right, up, down, upleft, upright, downleft, downright, zoomin, zoomout, stop", required = true) @Parameter(name = "horizonSpeed", description = "水平速度(0-255)", required = true) @Parameter(name = "verticalSpeed", description = "垂直速度(0-255)", required = true) - @Parameter(name = "zoomSpeed", description = "缩放速度(0-16)", required = true) + @Parameter(name = "zoomSpeed", description = "缩放速度(0-15)", required = true) @GetMapping("/ptz/{deviceId}/{channelId}") public void ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, Integer horizonSpeed, Integer verticalSpeed, Integer zoomSpeed){ @@ -94,17 +94,17 @@ public class PtzController { if (horizonSpeed == null) { horizonSpeed = 100; }else if (horizonSpeed < 0 || horizonSpeed > 255) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "horizonSpeed 为 1-255的数字"); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "horizonSpeed 为 0-255的数字"); } if (verticalSpeed == null) { verticalSpeed = 100; }else if (verticalSpeed < 0 || verticalSpeed > 255) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "verticalSpeed 为 1-255的数字"); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "verticalSpeed 为 0-255的数字"); } if (zoomSpeed == null) { zoomSpeed = 16; - }else if (zoomSpeed < 0 || zoomSpeed > 16) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "zoomSpeed 为 1-255的数字"); + }else if (zoomSpeed < 0 || zoomSpeed > 15) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "zoomSpeed 为 0-15的数字"); } int cmdCode = 0; @@ -163,6 +163,12 @@ public class PtzController { log.debug("设备光圈控制 API调用,deviceId:{} ,channelId:{} ,command:{} ,speed:{} ",deviceId, channelId, command, speed); } + if (speed == null) { + speed = 100; + }else if (speed < 0 || speed > 255) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "speed 为 0-255的数字"); + } + int cmdCode = 0x40; switch (command){ case "in": @@ -195,7 +201,7 @@ public class PtzController { if (speed == null) { speed = 100; }else if (speed < 0 || speed > 255) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "verticalSpeed 为 1-255的数字"); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "speed 为 0-255的数字"); } int cmdCode = 0x40;