|
|
@ -2,17 +2,13 @@ package com.iflytop.gd.app.cmd.debug; |
|
|
|
|
|
|
|
import com.iflytop.gd.app.core.BaseCommandHandler; |
|
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
|
import com.iflytop.gd.app.service.DeviceCommandService; |
|
|
|
import com.iflytop.gd.common.annotation.CommandMapping; |
|
|
|
import com.iflytop.gd.common.cmd.CommandFuture; |
|
|
|
import com.iflytop.gd.common.cmd.DeviceCommandBundle; |
|
|
|
import com.iflytop.gd.common.cmd.DeviceCommandGenerator; |
|
|
|
import com.iflytop.gd.hardware.type.LiquidDistributionArmDriver; |
|
|
|
import com.iflytop.gd.hardware.type.Servo.LiquidArmMId; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
/** |
|
|
@ -23,24 +19,13 @@ import java.util.concurrent.CompletableFuture; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@CommandMapping("debug_liquid_arm_reset") |
|
|
|
public class LiquidArmResetCommandHandler extends BaseCommandHandler { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
private final LiquidDistributionArmDriver liquidDistributionArmDriver; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
return runAsync(() -> { |
|
|
|
List<String> target = (List<String>) cmdDTO.getParams().get("target"); |
|
|
|
List<CommandFuture> futuresList = new ArrayList<>(); |
|
|
|
if (target != null && target.contains("largeArm")) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Origin(); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
if (target != null && target.contains("smallArm")) { |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Origin(); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
futuresList.add(deviceCommandFuture); |
|
|
|
} |
|
|
|
commandWait(futuresList.toArray(new CommandFuture[0])); |
|
|
|
liquidDistributionArmDriver.liquidDistributionArmEnable(LiquidArmMId.LiquidDistributionArm, 1); |
|
|
|
liquidDistributionArmDriver.liquidDistributionArmMoveToBlock(LiquidArmMId.LiquidDistributionArm, 0); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|