修复WVP作为下级平台接受deviceControl指令的问题-修复指令响应

pull/741/head
gaofw189 2023-02-06 10:35:32 +08:00
parent 40ece192fe
commit 25fca14e62
5 changed files with 82 additions and 73 deletions

View File

@ -47,6 +47,7 @@ public class SIPSender {
}
public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException {
try {
ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME);
String transport = "UDP";
if (viaHeader == null) {
@ -103,6 +104,9 @@ public class SIPSender {
sipProvider.sendResponse((Response)message);
}
}
} finally {
logger.info("[SEND]:SUCCESS:{}", message);
}
}
public CallIdHeader getNewCallIdHeader(String ip, String transport){

View File

@ -183,7 +183,7 @@ public interface ISIPCommander {
* @param channelId
* @param recordCmdStr Record / StopRecord
*/
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/**
*
@ -197,7 +197,7 @@ public interface ISIPCommander {
*
* @param device
*/
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/**
*
@ -206,7 +206,7 @@ public interface ISIPCommander {
* @param alarmMethod
* @param alarmType
*/
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/**
* ,IDR

View File

@ -664,7 +664,7 @@ public class SIPCommander implements ISIPCommander {
* @param recordCmdStr Record / StopRecord
*/
@Override
public void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
public void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset();
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
@ -682,7 +682,7 @@ public class SIPCommander implements ISIPCommander {
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent);
}
/**
@ -716,7 +716,7 @@ public class SIPCommander implements ISIPCommander {
* @param guardCmdStr "SetGuard"/"ResetGuard"
*/
@Override
public void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
public void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset();
@ -729,7 +729,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("</Control>\r\n");
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent);
}
/**
@ -738,7 +738,7 @@ public class SIPCommander implements ISIPCommander {
* @param device
*/
@Override
public void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
public void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset();
@ -765,7 +765,7 @@ public class SIPCommander implements ISIPCommander {
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent);
}
/**

View File

@ -131,16 +131,16 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
handleRecordCmd(deviceForPlatform,channelId,rootElement,request,DeviceControlType.RECORD);
break;
case I_FRAME:
handleIFameCmd(deviceForPlatform,channelId);
handleIFameCmd(deviceForPlatform,request,channelId);
break;
case TELE_BOOT:
handleTeleBootCmd(deviceForPlatform);
handleTeleBootCmd(deviceForPlatform,request);
break;
case DRAG_ZOOM_IN:
handleDragZoom(deviceForPlatform,channelId,rootElement,DeviceControlType.DRAG_ZOOM_IN);
handleDragZoom(deviceForPlatform,channelId,rootElement,request,DeviceControlType.DRAG_ZOOM_IN);
break;
case DRAG_ZOOM_OUT:
handleDragZoom(deviceForPlatform,channelId,rootElement,DeviceControlType.DRAG_ZOOM_OUT);
handleDragZoom(deviceForPlatform,channelId,rootElement,request,DeviceControlType.DRAG_ZOOM_OUT);
break;
case HOME_POSITION:
handleHomePositionCmd(deviceForPlatform,channelId,rootElement,request,DeviceControlType.HOME_POSITION);
@ -167,7 +167,6 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 云台/前端: {}", e.getMessage());
}
}
/**
@ -175,9 +174,10 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
* @param device
* @param channelId id
*/
private void handleIFameCmd(Device device,String channelId){
private void handleIFameCmd(Device device,SIPRequest request,String channelId){
try {
cmder.iFrameCmd(device,channelId);
responseAck(request, Response.OK);
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage());
}
@ -187,9 +187,10 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
*
* @param device
*/
private void handleTeleBootCmd(Device device){
private void handleTeleBootCmd(Device device,SIPRequest request){
try {
cmder.teleBootCmd(device);
responseAck(request, Response.OK);
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 重启: {}", e.getMessage());
}
@ -203,7 +204,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
* @param rootElement
* @param type
*/
private void handleDragZoom(Device device,String channelId,Element rootElement,DeviceControlType type){
private void handleDragZoom(Device device,String channelId,Element rootElement,SIPRequest request,DeviceControlType type){
String cmdString = getText(rootElement,type.getVal());
StringBuffer cmdXml = new StringBuffer(200);
cmdXml.append("<" + type.getVal() + ">\r\n");
@ -211,6 +212,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
cmdXml.append("</" + type.getVal() + ">\r\n");
try {
cmder.dragZoomCmd(device,channelId,cmdXml.toString());
responseAck(request, Response.OK);
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 拉框控制: {}", e.getMessage());
}
@ -255,7 +257,8 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}
try {
cmder.alarmCmd(device, alarmMethod,alarmType,
errorResult -> onError(request,errorResult));
errorResult -> onError(request,errorResult),
okResult -> onOk(request,okResult));
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 告警消息: {}", e.getMessage());
}
@ -274,7 +277,8 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
String cmdString = getText(rootElement,type.getVal());
try {
cmder.recordCmd(device, channelId,cmdString,
errorResult -> onError(request,errorResult));
errorResult -> onError(request,errorResult),
okResult -> onOk(request,okResult));
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 录像控制: {}", e.getMessage());
}
@ -292,7 +296,8 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
String cmdString = getText(rootElement,type.getVal());
try {
cmder.guardCmd(device, cmdString,
errorResult -> onError(request,errorResult));
errorResult -> onError(request,errorResult),
okResult -> onOk(request,okResult));
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage());
}

View File

@ -110,7 +110,7 @@ public class DeviceControl {
msg.setKey(key);
msg.setData(String.format("开始/停止录像操作失败,错误码: %s, %s", event.statusCode, event.msg));
resultHolder.invokeAllResult(msg);
});
},null);
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 开始/停止录像: {}", e.getMessage());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
@ -143,7 +143,7 @@ public class DeviceControl {
msg.setKey(key);
msg.setData(String.format("布防/撤防操作失败,错误码: %s, %s", event.statusCode, event.msg));
resultHolder.invokeResult(msg);
});
},null);
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
@ -192,7 +192,7 @@ public class DeviceControl {
msg.setKey(key);
msg.setData(String.format("报警复位操作失败,错误码: %s, %s", event.statusCode, event.msg));
resultHolder.invokeResult(msg);
});
},null);
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 报警复位: {}", e.getMessage());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());