|
|
@ -24,9 +24,11 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@CommandMapping("debug_transportation_arm_move") |
|
|
|
public class TransportationArmMoveCommandHandler extends BaseCommandHandler { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
private boolean stop = false; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
this.stop = false; |
|
|
|
return runAsync(() -> { |
|
|
|
Double xDimDistance = cmdDTO.getDoubleParam("xDimDistance"); |
|
|
|
Double yDimDistance = cmdDTO.getDoubleParam("yDimDistance"); |
|
|
@ -35,18 +37,20 @@ public class TransportationArmMoveCommandHandler extends BaseCommandHandler { |
|
|
|
Double xDimVelocity = cmdDTO.getDoubleParam("xDimVelocity"); |
|
|
|
Double yDimVelocity = cmdDTO.getDoubleParam("yDimVelocity"); |
|
|
|
Double zDimVelocity = cmdDTO.getDoubleParam("zDimVelocity"); |
|
|
|
Integer times = cmdDTO.getIntegerParam("times"); |
|
|
|
|
|
|
|
List<CommandFuture> futuresList = new ArrayList<>(); |
|
|
|
if(xDimVelocity != null){ |
|
|
|
if (xDimVelocity != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXSet(xDimVelocity); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if(yDimVelocity != null){ |
|
|
|
if (yDimVelocity != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYSet(yDimVelocity); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if(zDimVelocity != null){ |
|
|
|
if (zDimVelocity != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(zDimVelocity); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
@ -54,24 +58,70 @@ public class TransportationArmMoveCommandHandler extends BaseCommandHandler { |
|
|
|
commandWait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
|
|
|
|
futuresList.clear(); |
|
|
|
if (xDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (yDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (zDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
if (times != null) { |
|
|
|
for (int i = 0; i < times; i++) { |
|
|
|
if (stop) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (xDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (yDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (zDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
commandWait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
if (xDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(-xDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (yDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(-yDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (zDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(-zDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
commandWait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (xDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (yDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (zDimDistance != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
commandWait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
} |
|
|
|
|
|
|
|
commandWait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized void stop() { |
|
|
|
this.stop = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|