临时提交

结构优化
648540858 2024-01-29 18:57:12 +08:00
parent b17eea547a
commit 70f3f3b431
1 changed files with 41 additions and 27 deletions

View File

@ -98,11 +98,11 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
switch (deviceControlType) { switch (deviceControlType) {
case PTZ: case PTZ:
handlePtzCmd(commonGbChannel, rootElement, request, DeviceControlType.PTZ); handlePtzCmd(commonGbChannel, rootElement, request);
break;
case ALARM:
handleAlarmCmd(commonGbChannel, rootElement, request);
break; break;
// case ALARM:
// handleAlarmCmd(deviceForPlatform, rootElement, request);
// break;
// case GUARD: // case GUARD:
// handleGuardCmd(deviceForPlatform, rootElement, request, DeviceControlType.GUARD); // handleGuardCmd(deviceForPlatform, rootElement, request, DeviceControlType.GUARD);
// break; // break;
@ -133,7 +133,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
/** /**
* *
*/ */
private void handlePtzCmd(CommonGbChannel commonGbChannel, Element rootElement, SIPRequest request, DeviceControlType type) { private void handlePtzCmd(CommonGbChannel commonGbChannel, Element rootElement, SIPRequest request) {
IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType()); IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType());
if (resourceService == null) { if (resourceService == null) {
try { try {
@ -144,7 +144,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
return; return;
} }
String cmdString = getText(rootElement, type.getVal()); String cmdString = getText(rootElement, DeviceControlType.PTZ.getVal());
// 解析云台控制参数 // 解析云台控制参数
ICommandInfo commandInfo = ControlCommand.analysisCommand(cmdString); ICommandInfo commandInfo = ControlCommand.analysisCommand(cmdString);
if (commandInfo == null || !commandInfo.getType().equals(CommandType.PTZ)) { if (commandInfo == null || !commandInfo.getType().equals(CommandType.PTZ)) {
@ -166,22 +166,6 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
ptzCommand.getxSpeed(), ptzCommand.getySpeed(), ptzCommand.getzSpeed()); ptzCommand.getxSpeed(), ptzCommand.getySpeed(), ptzCommand.getzSpeed());
resourceService.ptzControl(commonGbChannel, ptzCommand); resourceService.ptzControl(commonGbChannel, ptzCommand);
// System.out.println();
// byte[] bytes = cmdString.getBytes();
// System.out.println(cmdString);
// for (byte aByte : bytes) {
// System.out.print(aByte);
// System.out.print(" ");
// }
// System.out.println(" ");
// try {
// cmder.fronEndCmd(device, channelId, cmdString,
// errorResult -> onError(request, errorResult),
// okResult -> onOk(request, okResult));
// } catch (InvalidArgumentException | SipException | ParseException e) {
// logger.error("[命令发送失败] 云台/前端: {}", e.getMessage());
// }
} }
/** /**
@ -275,12 +259,42 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
/** /**
* *** * ***
*
* @param device
* @param rootElement
* @param request
*/ */
private void handleAlarmCmd(Device device, Element rootElement, SIPRequest request) { private void handleAlarmCmd(CommonGbChannel commonGbChannel, Element rootElement, SIPRequest request) {
IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType());
if (resourceService == null) {
try {
responseAck(request, Response.FORBIDDEN);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 错误信息: {}", e.getMessage());
}
return;
}
//告警方法
Integer alarmMethod = null;
//告警类型
Integer alarmType = null;
List<Element> info = rootElement.elements("Info");
if (info != null) {
for (Element element : info) {
String alarmMethodStr = getText(element, "AlarmMethod");
if (alarmMethodStr != null) {
alarmMethod = Integer.parseInt(alarmMethodStr);
}
String alarmTypeStr = getText(element, "AlarmType");
if (alarmTypeStr != null) {
alarmType = Integer.parseInt(alarmTypeStr);
}
}
}
logger.info("\r\n[报警]: alarmMethod {} alarmType {}", alarmMethod, alarmType);
resourceService.ptzControl(commonGbChannel, ptzCommand);
//告警方法 //告警方法
Integer alarmMethod = null; Integer alarmMethod = null;
//告警类型 //告警类型