From 8b9bac5cb30da7834e22980f8841f504b006200b Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sat, 23 Dec 2023 00:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=91=84=E5=83=8F=E6=9C=BA?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmanager/gb28181/ptz/PtzController.java | 177 ++++++++++++++++++ 1 file changed, 177 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java index 6c3e2df3..513a5b8b 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java @@ -227,4 +227,181 @@ public class PtzController { throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); } } + + @Operation(summary = "巡航组控制") + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "command", description = "控制指令 允许值: add, remove, setSpeed, setStay, start, stop", required = true) + @Parameter(name = "cruiseId", description = "巡航组编号", required = true) + @Parameter(name = "presetId", description = "预置位编号", required = true) + @Parameter(name = "speed", description = "巡航速度(1~4095)", required = true) + @Parameter(name = "stay", description = "巡航停留时间(1~4095)", required = true) + @GetMapping("/cruise/control/{deviceId}/{channelId}") + public void cruiseControlApi(@PathVariable String deviceId, @PathVariable String channelId, + String command, Integer cruiseId, + @Parameter(required = false) Integer presetId, + @Parameter(required = false)Integer speed, + @Parameter(required = false)Integer stay) { + if (logger.isDebugEnabled()) { + logger.debug("设备巡航组控制API调用"); + } + Device device = storager.queryVideoDevice(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在"); + } + int cmdCode = 0; + int param1 = cruiseId; + int param2 = presetId != null? presetId: 0; + int param3 = 0; + switch (command){ + case "add": + cmdCode = 132; + break; + case "remove": + cmdCode = 133; + break; + case "setSpeed": + cmdCode = 134; + param3= speed; + break; + case "setStay": + cmdCode = 135; + param3= stay; + break; + case "start": + cmdCode = 136; + break; + case "stop": + param1 = 0; + param2 = 0; + break; + default: + break; + } + try { + cmder.frontEndCmd(device, channelId, cmdCode, param1, param2, param3); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 巡航组控制: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } + + @Operation(summary = "扫描组控制") + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "command", description = "控制指令 允许值: setLeft, setRight, start, stop", required = true) + @Parameter(name = "scanId", description = "扫描组编号", required = true) + @Parameter(name = "speed", description = "自动扫描速度(1~4095)", required = false) + @GetMapping("/scan/control/{deviceId}/{channelId}") + public void scanControlApi(@PathVariable String deviceId, @PathVariable String channelId, + String command, Integer scanId, @Parameter(required = false)Integer speed) { + if (logger.isDebugEnabled()) { + logger.debug("设备扫描组API调用"); + } + Device device = storager.queryVideoDevice(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在"); + } + int cmdCode = 0; + int param1 = scanId; + int param2 = 0; + int param3 = 0; + switch (command){ + case "setSpeed": + cmdCode = 138; + if (speed == null || speed == 0) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "speed值不正确"); + } + param3 = speed; + break; + case "setLeft": + cmdCode = 137; + break; + case "setRight": + cmdCode = 137; + break; + case "start": + cmdCode = 137; + break; + case "stop": + param1 = 0; + param2 = 0; + break; + default: + break; + } + try { + cmder.frontEndCmd(device, channelId, cmdCode, param1, param2, param3); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 扫描组控制: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } + + @Operation(summary = "雨刷开关") + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "command", description = "控制指令 允许值: on off", required = true) + @GetMapping("/wiper/control/{deviceId}/{channelId}") + public void wiperControlApi(@PathVariable String deviceId, @PathVariable String channelId, String command) { + if (logger.isDebugEnabled()) { + logger.debug("设备雨刷开关控制API调用"); + } + Device device = storager.queryVideoDevice(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在"); + } + int cmdCode = 0; + switch (command){ + case "on": + cmdCode = 140; + break; + case "off": + cmdCode = 141; + break; + default: + break; + } + try { + cmder.frontEndCmd(device, channelId, cmdCode, 1, 0, 0); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 雨刷开关控制: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } + + @Operation(summary = "辅助控制开关") + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "command", description = "控制指令 允许值: on off", required = true) + @Parameter(name = "auxiliaryId", description = "开关ID(2-255)", required = true) + @GetMapping("/auxiliary/control/{deviceId}/{channelId}") + public void auxiliaryControlApi(@PathVariable String deviceId, @PathVariable String channelId, String command, int auxiliaryId) { + if (logger.isDebugEnabled()) { + logger.debug("设备雨刷开关控制API调用"); + } + Device device = storager.queryVideoDevice(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在"); + } + int cmdCode = 0; + int param2 = 0; + int param3 = 0; + switch (command){ + case "on": + cmdCode = 140; + break; + case "off": + cmdCode = 141; + break; + default: + break; + } + try { + cmder.frontEndCmd(device, channelId, cmdCode, auxiliaryId, param2, param3); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 雨刷开关控制: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } }