Commit 01e592a1 authored by wanghao's avatar wanghao

1 指令追踪调整

parent 7cf31b96
...@@ -128,8 +128,9 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -128,8 +128,9 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
/** /**
* 仅处理已完成的指令 * 仅处理已完成的指令
*/ */
public void onlyCompleted(String commandId) { public void onlyCompleted() {
CommandExecution execution = currentCommands.get(commandId); // 每次只能有一个指令正在执行
CommandExecution execution = currentCommands.get("127.0.0.1");
// 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务 // 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务
if(execution == null) { if(execution == null) {
List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands(); List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands();
...@@ -142,7 +143,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -142,7 +143,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
if (execution != null) { if (execution != null) {
robotArmCommandService.completeCommand(execution.commandId); robotArmCommandService.completeCommand(execution.commandId);
currentCommands.remove(commandId); currentCommands.remove("127.0.0.1");
log.info("指令完成: {}", execution.commandId); log.info("指令完成: {}", execution.commandId);
} }
} }
...@@ -164,9 +165,9 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -164,9 +165,9 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
status.getCode(), status.getText(), status.getCode(), status.getText(),
status.getX(), status.getY(), status.getZ(), status.getR()); status.getX(), status.getY(), status.getZ(), status.getR());
CommandExecution execution = null; CommandExecution execution = currentCommands.get("127.0.0.1");
// 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务 // 如果指令追踪为空,则可能是 刚启动,再去 查一下有没有正在执行的任务
if(currentCommands.size() == 0) { if(execution == null) {
List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands(); List<RobotArmCommand> robotArmCommands = robotArmCommandService.selectTopRunningRobotArmCommands();
if(robotArmCommands != null && !robotArmCommands.isEmpty()) { if(robotArmCommands != null && !robotArmCommands.isEmpty()) {
// 注册指令跟踪 // 注册指令跟踪
...@@ -177,7 +178,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -177,7 +178,7 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
if (execution != null) { if (execution != null) {
robotArmCommandService.completeCommand(execution.commandId); robotArmCommandService.completeCommand(execution.commandId);
currentCommands.remove(execution.commandId + ""); currentCommands.remove("127.0.0.1");
log.info("指令完成: {}", execution.commandId); log.info("指令完成: {}", execution.commandId);
} }
} else { } else {
...@@ -192,7 +193,8 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -192,7 +193,8 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
CommandExecution execution = new CommandExecution(); CommandExecution execution = new CommandExecution();
execution.commandId = commandId; execution.commandId = commandId;
execution.startTime = System.currentTimeMillis(); execution.startTime = System.currentTimeMillis();
currentCommands.put(commandId + "", execution); // 每次只能有一个正在执行中的,所以先暂时用使用了127.0.0.1
currentCommands.put("127.0.0.1", execution);
log.info("注册指令跟踪: {}", commandId); log.info("注册指令跟踪: {}", commandId);
} }
......
...@@ -400,7 +400,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -400,7 +400,7 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
return AjaxResult.error("只有待执行状态的指令才能确认完成"); return AjaxResult.error("只有待执行状态的指令才能确认完成");
} }
try { try {
nettyUdpServerHandler.onlyCompleted(commandId +""); nettyUdpServerHandler.onlyCompleted();
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("执行确认完成指令时发生异常: " + e.getMessage()); return AjaxResult.error("执行确认完成指令时发生异常: " + e.getMessage());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment