临时提交

结构优化
648540858 2023-12-27 14:28:58 +08:00
parent aa11d02dbf
commit 66f32d799d
4 changed files with 116 additions and 81 deletions

View File

@ -180,9 +180,9 @@ public interface ISIPCommander {
* *
* @param device * @param device
* @param channelId * @param channelId
* @param recordCmdStr Record / StopRecord * @param record
*/ */
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; void recordCmd(Device device, String channelId, boolean record, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/** /**
* *
@ -196,7 +196,7 @@ public interface ISIPCommander {
* *
* @param device * @param device
*/ */
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; void guardCmd(Device device, boolean guard, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/** /**
* *
@ -205,7 +205,7 @@ public interface ISIPCommander {
* @param alarmMethod * @param alarmMethod
* @param alarmType * @param alarmType
*/ */
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; void alarmCmd(Device device, Integer alarmMethod, Integer alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/** /**
* ,IDR * ,IDR
@ -224,7 +224,7 @@ public interface ISIPCommander {
* @param resetTime 使:(s) * @param resetTime 使:(s)
* @param presetIndex 使0~255 * @param presetIndex 使0~255
*/ */
void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/** /**
* *

View File

@ -694,7 +694,7 @@ public class SIPCommander implements ISIPCommander {
* @param recordCmdStr Record / StopRecord * @param recordCmdStr Record / StopRecord
*/ */
@Override @Override
public void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { public void recordCmd(Device device, String channelId, boolean record, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200); StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset(); String charset = device.getCharset();
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n"); cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
@ -706,7 +706,12 @@ public class SIPCommander implements ISIPCommander {
} else { } else {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
} }
cmdXml.append("<RecordCmd>" + recordCmdStr + "</RecordCmd>\r\n"); if (record) {
cmdXml.append("<RecordCmd>Record</RecordCmd>\r\n");
}else {
cmdXml.append("<RecordCmd>StopRecord</RecordCmd>\r\n");
}
cmdXml.append("</Control>\r\n"); cmdXml.append("</Control>\r\n");
@ -746,7 +751,7 @@ public class SIPCommander implements ISIPCommander {
* @param guardCmdStr "SetGuard"/"ResetGuard" * @param guardCmdStr "SetGuard"/"ResetGuard"
*/ */
@Override @Override
public void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { public void guardCmd(Device device, boolean setGuard, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200); StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset(); String charset = device.getCharset();
@ -755,7 +760,11 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n"); cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
cmdXml.append("<SN>" + SipUtils.getNewSn() + "</SN>\r\n"); cmdXml.append("<SN>" + SipUtils.getNewSn() + "</SN>\r\n");
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
cmdXml.append("<GuardCmd>" + guardCmdStr + "</GuardCmd>\r\n"); if (setGuard) {
cmdXml.append("<GuardCmd>SetGuard</GuardCmd>\r\n");
}else {
cmdXml.append("<GuardCmd>ResetGuard</GuardCmd>\r\n");
}
cmdXml.append("</Control>\r\n"); cmdXml.append("</Control>\r\n");
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
@ -768,7 +777,7 @@ public class SIPCommander implements ISIPCommander {
* @param device * @param device
*/ */
@Override @Override
public void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { public void alarmCmd(Device device, Integer alarmMethod, Integer alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200); StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset(); String charset = device.getCharset();

View File

@ -281,14 +281,20 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
*/ */
private void handleAlarmCmd(Device device, Element rootElement, SIPRequest request) { private void handleAlarmCmd(Device device, Element rootElement, SIPRequest request) {
//告警方法 //告警方法
String alarmMethod = ""; Integer alarmMethod = null;
//告警类型 //告警类型
String alarmType = ""; Integer alarmType = null;
List<Element> info = rootElement.elements("Info"); List<Element> info = rootElement.elements("Info");
if (info != null) { if (info != null) {
for (Element element : info) { for (Element element : info) {
alarmMethod = getText(element, "AlarmMethod"); String alarmMethodStr = getText(element, "AlarmMethod");
alarmType = getText(element, "AlarmType"); if (alarmMethodStr != null) {
alarmMethod = Integer.parseInt(alarmMethodStr);
}
String alarmTypeStr = getText(element, "AlarmType");
if (alarmTypeStr != null) {
alarmType = Integer.parseInt(alarmTypeStr);
}
} }
} }
try { try {
@ -312,8 +318,16 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
private void handleRecordCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) { private void handleRecordCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) {
//获取整个消息主体,我们只需要修改请求头即可 //获取整个消息主体,我们只需要修改请求头即可
String cmdString = getText(rootElement, type.getVal()); String cmdString = getText(rootElement, type.getVal());
Boolean isRecord = null;
if (cmdString.equalsIgnoreCase("Record")) {
isRecord = true;
}else if (cmdString.equalsIgnoreCase("StopRecord")) {
isRecord = false;
}else {
return;
}
try { try {
cmder.recordCmd(device, channelId, cmdString, cmder.recordCmd(device, channelId, isRecord,
errorResult -> onError(request, errorResult), errorResult -> onError(request, errorResult),
okResult -> onOk(request, okResult)); okResult -> onOk(request, okResult));
} catch (InvalidArgumentException | SipException | ParseException e) { } catch (InvalidArgumentException | SipException | ParseException e) {
@ -332,8 +346,16 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
private void handleGuardCmd(Device device, Element rootElement, SIPRequest request, DeviceControlType type) { private void handleGuardCmd(Device device, Element rootElement, SIPRequest request, DeviceControlType type) {
//获取整个消息主体,我们只需要修改请求头即可 //获取整个消息主体,我们只需要修改请求头即可
String cmdString = getText(rootElement, type.getVal()); String cmdString = getText(rootElement, type.getVal());
boolean setGuard;
if (cmdString.equalsIgnoreCase("Record")) {
setGuard = true;
}else if (cmdString.equalsIgnoreCase("StopRecord")) {
setGuard = false;
}else {
return;
}
try { try {
cmder.guardCmd(device, cmdString, cmder.guardCmd(device, setGuard,
errorResult -> onError(request, errorResult), errorResult -> onError(request, errorResult),
okResult -> onOk(request, okResult)); okResult -> onOk(request, okResult));
} catch (InvalidArgumentException | SipException | ParseException e) { } catch (InvalidArgumentException | SipException | ParseException e) {

View File

@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
@ -45,16 +46,11 @@ public class DeviceControl {
private IVideoManagerStorage storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private SIPCommander cmder; private ISIPCommander cmder;
@Autowired @Autowired
private DeferredResultHolder resultHolder; private DeferredResultHolder resultHolder;
/**
* API
*
* @param deviceId ID
*/
@Operation(summary = "远程启动控制命令", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "远程启动控制命令", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/teleboot/{deviceId}") @GetMapping("/teleboot/{deviceId}")
@ -71,24 +67,20 @@ public class DeviceControl {
} }
} }
/**
* API
*
* @param deviceId ID
* @param recordCmdStr RecordStopRecord
* @param channelId
*/
@Operation(summary = "录像控制", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "录像控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@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 = "recordCmdStr", description = "命令, 可选值Record手动录像StopRecord(停止手动录像)", required = true) @Parameter(name = "command", description = "控制命令可选值start手动录像stop停止手动录像", required = true)
@GetMapping("/record/{deviceId}/{recordCmdStr}") @GetMapping("/record/{deviceId}/{channelId}/{command}")
public DeferredResult<ResponseEntity<String>> recordApi(@PathVariable String deviceId, public DeferredResult<ResponseEntity<String>> recordApi(@PathVariable String deviceId, @PathVariable String channelId,
@PathVariable String recordCmdStr, String channelId) { @PathVariable String command) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("开始/停止录像API调用"); logger.debug("开始/停止录像API调用");
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId;
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L); DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L);
@ -105,8 +97,16 @@ public class DeviceControl {
return result; return result;
} }
resultHolder.put(key, uuid, result); resultHolder.put(key, uuid, result);
boolean isRecord;
if (command.equalsIgnoreCase("start")) {
isRecord = true;
}else if (command.equalsIgnoreCase("stop")) {
isRecord = false;
}else {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "command参数不是规定值");
}
try { try {
cmder.recordCmd(device, channelId, recordCmdStr, event -> { cmder.recordCmd(device, channelId, isRecord, event -> {
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setId(uuid); msg.setId(uuid);
msg.setKey(key); msg.setKey(key);
@ -121,25 +121,31 @@ public class DeviceControl {
return result; return result;
} }
/**
* /API
*
* @param deviceId ID
* @param guardCmdStr SetGuardResetGuard
*/
@Operation(summary = "布防/撤防命令", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "布防/撤防命令", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "guardCmdStr", description = "命令, 可选值SetGuard布防ResetGuard撤防", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@GetMapping("/guard/{deviceId}/{guardCmdStr}") @Parameter(name = "command", description = "控制命令可选值start布防stop撤防", required = true)
public DeferredResult<String> guardApi(@PathVariable String deviceId, @PathVariable String guardCmdStr) { @GetMapping("/guard/{deviceId}/{command}")
public DeferredResult<String> guardApi(@PathVariable String deviceId, @PathVariable String command) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("布防/撤防API调用"); logger.debug("布防/撤防API调用");
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId;
String uuid =UUID.randomUUID().toString(); String uuid =UUID.randomUUID().toString();
boolean setGuard;
if (command.equalsIgnoreCase("start")) {
setGuard = true;
}else if (command.equalsIgnoreCase("stop")) {
setGuard = false;
}else {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "command参数不是规定值");
}
try { try {
cmder.guardCmd(device, guardCmdStr, event -> { cmder.guardCmd(device, setGuard, event -> {
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setId(uuid); msg.setId(uuid);
msg.setKey(key); msg.setKey(key);
@ -165,28 +171,30 @@ public class DeviceControl {
return result; return result;
} }
/**
* API
*
* @param deviceId ID
* @param alarmMethod
* @param alarmType
*/
@Operation(summary = "报警复位", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "报警复位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "alarmMethod", description = "报警方式, 取值0为全部," +
@Parameter(name = "alarmMethod", description = "报警方式") "1为电话报警,2为设备报警,3为短信报警,4为GPS报警,5为视频报警,6为设备故障报警," +
@Parameter(name = "alarmType", description = "报警类型") "7其他报警;" +
"可以为直接组合如12为电话报警或设备报警", required = false)
@Parameter(name = "alarmType", description = "报警类型, " +
"alarmMethod为2时取值为1-视频丢失报警;2-设备防拆报警;3-存储设备磁盘满报警;4-设备高温报警;5-设备低温报警。" +
"alarmMethod为5时, 取值为:1-人工视频报警;2-运动目标检测报警;3-遗留物检测报警;4-物体移除检测报警;5-绊线检测报警;" +
" 6-入侵检测报警;7-逆行检测报警;8-徘徊检测报警;9-流量统计报警;10-密度检测报警;11-视频异常检测报警;12-快速移动报警。" +
"alarmMethod为6时, 取值为:1-存储设备磁盘故障报警;2-存储设备风扇故障报警 ", required = false)
@GetMapping("/reset_alarm/{deviceId}") @GetMapping("/reset_alarm/{deviceId}")
public DeferredResult<ResponseEntity<String>> resetAlarmApi(@PathVariable String deviceId, String channelId, public DeferredResult<ResponseEntity<String>> resetAlarmApi(@PathVariable String deviceId,
@RequestParam(required = false) String alarmMethod, @RequestParam(required = false) Integer alarmMethod,
@RequestParam(required = false) String alarmType) { @RequestParam(required = false) Integer alarmType) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("报警复位API调用"); logger.debug("报警复位API调用");
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId ;
try { try {
cmder.alarmCmd(device, alarmMethod, alarmType, event -> { cmder.alarmCmd(device, alarmMethod, alarmType, event -> {
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
@ -213,22 +221,18 @@ public class DeviceControl {
return result; return result;
} }
/**
* API
*
* @param deviceId ID
* @param channelId ID
*/
@Operation(summary = "强制关键帧", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "强制关键帧", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号") @Parameter(name = "channelId", description = "通道国标编号")
@GetMapping("/i_frame/{deviceId}") @GetMapping("/i_frame/{deviceId}/{channelId}")
public JSONObject iFrame(@PathVariable String deviceId, public JSONObject iFrame(@PathVariable String deviceId, @PathVariable String channelId) {
@RequestParam(required = false) String channelId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("强制关键帧API调用"); logger.debug("强制关键帧API调用");
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
try { try {
cmder.iFrameCmd(device, channelId); cmder.iFrameCmd(device, channelId);
} catch (InvalidArgumentException | SipException | ParseException e) { } catch (InvalidArgumentException | SipException | ParseException e) {
@ -242,24 +246,15 @@ public class DeviceControl {
return json; return json;
} }
/**
* API
*
* @param deviceId ID
* @param enabled 使1:,0:
* @param resetTime
* @param presetIndex
* @param channelId
*/
@Operation(summary = "看守位控制", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "看守位控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@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 = "enabled", description = "是否开启看守位 1:开启,0:关闭", required = true) @Parameter(name = "command", description = "控制命令: start-开启看守位 stop-关闭看守位", required = true)
@Parameter(name = "presetIndex", description = "调用预置位编号") @Parameter(name = "presetIndex", description = "调用预置位编号, 取值范围为-255")
@Parameter(name = "resetTime", description = "自动归位时间间隔") @Parameter(name = "resetTime", description = "自动归位时间间隔,单位:秒(s)")
@GetMapping("/home_position/{deviceId}/{enabled}") @GetMapping("/home_position/{deviceId}/{command}")
public DeferredResult<String> homePositionApi(@PathVariable String deviceId, public DeferredResult<String> homePositionApi(@PathVariable String deviceId,
@PathVariable String enabled, @PathVariable String command,
@RequestParam(required = false) String resetTime, @RequestParam(required = false) String resetTime,
@RequestParam(required = false) String presetIndex, @RequestParam(required = false) String presetIndex,
String channelId) { String channelId) {
@ -269,6 +264,9 @@ public class DeviceControl {
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
try { try {
cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> { cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> {
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
@ -332,6 +330,9 @@ public class DeviceControl {
logger.debug(String.format("设备拉框放大 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); logger.debug(String.format("设备拉框放大 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
StringBuffer cmdXml = new StringBuffer(200); StringBuffer cmdXml = new StringBuffer(200);
cmdXml.append("<DragZoomIn>\r\n"); cmdXml.append("<DragZoomIn>\r\n");
cmdXml.append("<Length>" + length+ "</Length>\r\n"); cmdXml.append("<Length>" + length+ "</Length>\r\n");
@ -384,6 +385,9 @@ public class DeviceControl {
logger.debug(String.format("设备拉框缩小 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); logger.debug(String.format("设备拉框缩小 API调用deviceId%s channelId%s length%d width%d midpointx%d midpointy%d lengthx%d lengthy%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
StringBuffer cmdXml = new StringBuffer(200); StringBuffer cmdXml = new StringBuffer(200);
cmdXml.append("<DragZoomOut>\r\n"); cmdXml.append("<DragZoomOut>\r\n");
cmdXml.append("<Length>" + length+ "</Length>\r\n"); cmdXml.append("<Length>" + length+ "</Length>\r\n");