From 9b031c17e5b741157024a2ed3427cd55c09c4a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Sat, 26 Jul 2025 17:35:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E6=A3=80=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/selftest/GantryXYOriginCommand.java | 38 -------------------- .../app/command/selftest/GantryZOriginCommand.java | 36 ------------------- .../command/selftest/ShakeMotorOriginCommand.java | 41 ++++++++++++++++++++++ .../command/selftest/StirMotorOriginCommand.java | 41 ++++++++++++++++++++++ .../app/command/selftest/XYOriginCommand.java | 38 ++++++++++++++++++++ .../app/command/selftest/ZOriginCommand.java | 36 +++++++++++++++++++ .../app/controller/SelfTestController.java | 6 ---- 7 files changed, 156 insertions(+), 80 deletions(-) delete mode 100644 src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java delete mode 100644 src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java create mode 100644 src/main/java/com/iflytop/colortitration/app/command/selftest/ShakeMotorOriginCommand.java create mode 100644 src/main/java/com/iflytop/colortitration/app/command/selftest/StirMotorOriginCommand.java create mode 100644 src/main/java/com/iflytop/colortitration/app/command/selftest/XYOriginCommand.java create mode 100644 src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java diff --git a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java deleted file mode 100644 index 31c7ccf..0000000 --- a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -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; - -/** - * 龙门架机械臂z轴回原点 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("check_gantry_xy_origin")//业务指令注解 -public class GantryXYOriginCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CommandDTO commandDTO) { - return runAsync(() -> { - DeviceCommand roboticArmBigMotorCommand = DeviceCommandGenerator.roboticArmBigMotorOrigin(); - CommandFuture roboticArmBigMotorFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), roboticArmBigMotorCommand); - DeviceCommand roboticArmSmallMotorCommand = DeviceCommandGenerator.roboticArmSmallMotorOrigin(); - CommandFuture roboticArmSmallMotorFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), roboticArmSmallMotorCommand); - CommandUtil.wait(roboticArmBigMotorFuture, roboticArmSmallMotorFuture); - }); - } -} - diff --git a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java deleted file mode 100644 index 638e598..0000000 --- a/src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -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; - -/** - * 龙门架机械臂z轴回原点 - */ -@Slf4j -@Component -@RequiredArgsConstructor -@CommandMapping("check_gantry_z_origin")//业务指令注解 -public class GantryZOriginCommand extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; - - @Override - public CompletableFuture handle(CommandDTO commandDTO) { - return runAsync(() -> { - DeviceCommand deviceCommand = DeviceCommandGenerator.zOrigin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); - CommandUtil.wait(deviceCommandFuture); - }); - } -} - 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/XYOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/XYOriginCommand.java new file mode 100644 index 0000000..16e891f --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/app/command/selftest/XYOriginCommand.java @@ -0,0 +1,38 @@ +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 +@RequiredArgsConstructor +@CommandMapping("check_xy_origin")//业务指令注解 +public class XYOriginCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CommandDTO commandDTO) { + return runAsync(() -> { + DeviceCommand roboticArmBigMotorCommand = DeviceCommandGenerator.roboticArmBigMotorOrigin(); + CommandFuture roboticArmBigMotorFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), roboticArmBigMotorCommand); + DeviceCommand roboticArmSmallMotorCommand = DeviceCommandGenerator.roboticArmSmallMotorOrigin(); + CommandFuture roboticArmSmallMotorFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), roboticArmSmallMotorCommand); + CommandUtil.wait(roboticArmBigMotorFuture, roboticArmSmallMotorFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java new file mode 100644 index 0000000..c72b604 --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java @@ -0,0 +1,36 @@ +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; + +/** + * z轴回原点 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("check_z_origin")//业务指令注解 +public class ZOriginCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CommandDTO commandDTO) { + return runAsync(() -> { + DeviceCommand deviceCommand = DeviceCommandGenerator.zOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); + CommandUtil.wait(deviceCommandFuture); + }); + } +} + 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 {