|
|
@ -0,0 +1,41 @@ |
|
|
|
package com.iflytop.colortitration.app.command.selftest; |
|
|
|
|
|
|
|
import com.iflytop.colortitration.app.common.annotation.CommandMapping; |
|
|
|
import com.iflytop.colortitration.app.common.utils.CommandUtil; |
|
|
|
import com.iflytop.colortitration.app.core.command.BaseCommandHandler; |
|
|
|
import com.iflytop.colortitration.app.core.command.CommandFuture; |
|
|
|
import com.iflytop.colortitration.app.core.command.DeviceCommand; |
|
|
|
import com.iflytop.colortitration.app.core.command.DeviceCommandGenerator; |
|
|
|
import com.iflytop.colortitration.app.model.dto.CommandDTO; |
|
|
|
import com.iflytop.colortitration.app.service.DeviceCommandService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
/** |
|
|
|
* 摇匀电机回原点 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Component("checkShakeMotorOriginCommand") |
|
|
|
@RequiredArgsConstructor |
|
|
|
@CommandMapping("check_shake_motor_origin") |
|
|
|
public class ShakeMotorOriginCommand extends BaseCommandHandler { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
|
|
return runAsync(() -> { |
|
|
|
DeviceCommand device1Command = DeviceCommandGenerator.titrationMotor1Origin(); |
|
|
|
CommandFuture command1Future = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), device1Command); |
|
|
|
CommandUtil.wait(command1Future); |
|
|
|
|
|
|
|
DeviceCommand device2Command = DeviceCommandGenerator.titrationMotor2Origin(); |
|
|
|
CommandFuture command2Future = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), device2Command); |
|
|
|
CommandUtil.wait(command2Future); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|