diff --git a/src/main/java/com/iflytop/colortitration/app/command/selftest/ShakeMotorOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/ShakeMotorOriginCommand.java new file mode 100644 index 0000000..e68bc95 --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/app/command/selftest/ShakeMotorOriginCommand.java @@ -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 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); + }); + } +} + + diff --git a/src/main/java/com/iflytop/colortitration/app/command/selftest/StirMotorOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/StirMotorOriginCommand.java new file mode 100644 index 0000000..43df42d --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/app/command/selftest/StirMotorOriginCommand.java @@ -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("checkStirMotorOriginCommand") +@RequiredArgsConstructor +@CommandMapping("check_stir_motor_origin") +public class StirMotorOriginCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture 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); + }); + } +} + + diff --git a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/XYOriginCommand.java similarity index 91% rename from src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java rename to src/main/java/com/iflytop/colortitration/app/command/selftest/XYOriginCommand.java index 31c7ccf..16e891f 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/selftest/XYOriginCommand.java @@ -15,13 +15,13 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 龙门架机械臂z轴回原点 + * 机械臂回原点 */ @Slf4j @Component @RequiredArgsConstructor -@CommandMapping("check_gantry_xy_origin")//业务指令注解 -public class GantryXYOriginCommand extends BaseCommandHandler { +@CommandMapping("check_xy_origin")//业务指令注解 +public class XYOriginCommand extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; @Override diff --git a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java similarity index 89% rename from src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java rename to src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java index 638e598..c72b604 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java @@ -15,13 +15,13 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 龙门架机械臂z轴回原点 + * z轴回原点 */ @Slf4j @Component @RequiredArgsConstructor -@CommandMapping("check_gantry_z_origin")//业务指令注解 -public class GantryZOriginCommand extends BaseCommandHandler { +@CommandMapping("check_z_origin")//业务指令注解 +public class ZOriginCommand extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; @Override diff --git a/src/main/java/com/iflytop/colortitration/app/controller/SelfTestController.java b/src/main/java/com/iflytop/colortitration/app/controller/SelfTestController.java index 16e4708..c45dc5d 100644 --- a/src/main/java/com/iflytop/colortitration/app/controller/SelfTestController.java +++ b/src/main/java/com/iflytop/colortitration/app/controller/SelfTestController.java @@ -18,12 +18,6 @@ import org.springframework.web.bind.annotation.RestController; public class SelfTestController { private final DeviceState deviceState; -// @Operation(summary = "获取自检状态") -// @GetMapping("/status") -// public Result getSelfTestStatus() { -// return Result.success(selfTestService.getSelfTestState()); -// } - @Operation(summary = "自检完毕") @PostMapping("/finish") public Result selfTestFinish() throws Exception {