|
|
@ -22,14 +22,44 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@CommandMapping("debug_holding_jaw_close") |
|
|
|
public class HoldingJawCloseCommandHandler extends BaseCommandHandler { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
private boolean stop = false; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
this.stop = false; |
|
|
|
return runAsync(() -> { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(34.0); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
Double velocity = cmdDTO.getDoubleParam("velocity"); |
|
|
|
Double distance = cmdDTO.getDoubleParam("distance"); |
|
|
|
Integer times = cmdDTO.getIntegerParam("times"); |
|
|
|
if (velocity != null) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawSet(velocity); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (times != null) { |
|
|
|
for (int i = 0; i < times; i++) { |
|
|
|
if (stop) { |
|
|
|
return; |
|
|
|
} |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(-distance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
|
|
|
|
DeviceCommandBundle backDeviceCommand = DeviceCommandGenerator.clawMove(distance); |
|
|
|
CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), backDeviceCommand); |
|
|
|
commandWait(backDeviceCommandFuture); |
|
|
|
} |
|
|
|
} else { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(-distance); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
commandWait(deviceCommandFuture); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized void stop() { |
|
|
|
this.stop = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|