From 74e86febdf6ec0899de8c2bc1148ed6a3ee7e62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Thu, 24 Jul 2025 15:40:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B0=83=E8=AF=95=E6=8C=87?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/debug/HeatRodGetCommand.java | 4 ++-- .../app/command/debug/LightOpenCommand.java | 6 ++--- .../debug/RoboticArmBigMotorMoveByCommand.java | 7 ------ .../debug/RoboticArmSmallMotorMoveByCommand.java | 7 ------ .../app/command/debug/StepPumpCloseCommand.java | 4 ++-- .../app/command/debug/StepPumpMoveCommand.java | 12 +++++----- .../app/command/debug/StepPumpOpenCommand.java | 18 +++++++------- .../app/command/debug/StirMotorMoveByCommand.java | 4 ++-- .../app/command/debug/StirMotorOriginCommand.java | 4 ++-- .../debug/TitrationMotorDisableCommand.java | 4 ++-- .../command/debug/TitrationMotorEnableCommand.java | 4 ++-- .../command/debug/TitrationMotorMoveByCommand.java | 12 +++++----- .../command/debug/TitrationMotorMoveToCommand.java | 8 +++---- .../command/debug/TitrationMotorOriginCommand.java | 4 ++-- .../command/debug/TitrationMotorStopCommand.java | 4 ++-- .../app/command/debug/ZMotorMoveByCommand.java | 7 ------ .../app/core/command/DeviceCommandGenerator.java | 28 +++++++++++----------- 17 files changed, 58 insertions(+), 79 deletions(-) diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/HeatRodGetCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/HeatRodGetCommand.java index c269b5f..d4e3b01 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/HeatRodGetCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/HeatRodGetCommand.java @@ -31,8 +31,8 @@ public class HeatRodGetCommand extends BaseCommandHandler { } return runAsync(() -> { DeviceCommand deviceCommand = switch (heatModuleCodeStr) { - case "heat_module_01" -> DeviceCommandGenerator.heatRod1Get(); - case "heat_module_02" -> DeviceCommandGenerator.heatRod2Get(); + case "heat_module_1" -> DeviceCommandGenerator.heatRod1Get(); + case "heat_module_2" -> DeviceCommandGenerator.heatRod2Get(); default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效 }; deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/LightOpenCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/LightOpenCommand.java index 8c86c6d..1f7f525 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/LightOpenCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/LightOpenCommand.java @@ -6,7 +6,6 @@ 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 com.iflytop.colortitration.common.base.IBaseEnum; import com.iflytop.colortitration.common.enums.TricolorLightColor; import com.iflytop.colortitration.common.exception.AppException; import com.iflytop.colortitration.common.result.ResultCode; @@ -33,9 +32,10 @@ public class LightOpenCommand extends BaseCommandHandler { if (StringUtils.isEmpty(colorStr)) { throw new AppException(ResultCode.INVALID_PARAMETER);//参数缺失 } - if (!IBaseEnum.contains(TricolorLightColor.class, colorStr)) { + // todo 颜色 需要确认下 + /*if (!IBaseEnum.contains(TricolorLightColor.class, colorStr)) { throw new AppException(ResultCode.PARAMETER_TYPE_MISMATCH);//参数类型不匹配 - } + }*/ TricolorLightColor color = TricolorLightColor.valueOf(colorStr); return runAsync(() -> { DeviceCommand deviceCommand = DeviceCommandGenerator.tricolorLightOpen(color); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveByCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveByCommand.java index e57ce46..7f1b55f 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveByCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveByCommand.java @@ -8,11 +8,8 @@ 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 com.iflytop.colortitration.common.exception.AppException; -import com.iflytop.colortitration.common.result.ResultCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; @@ -30,13 +27,9 @@ public class RoboticArmBigMotorMoveByCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CommandDTO commandDTO) { - String motorCode = commandDTO.getStringParam("motorCode"); Double speed = commandDTO.getDoubleParam("speed"); Integer times = commandDTO.getIntegerParam("times"); Double angle = commandDTO.getDoubleParam("angle"); - if (StringUtils.isEmpty(motorCode) || angle == null) { - throw new AppException(ResultCode.INVALID_PARAMETER); - } return runAsync(() -> { if (speed != null) { DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmBigMotorSetSpeed(speed); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveByCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveByCommand.java index 59131da..d138431 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveByCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveByCommand.java @@ -8,11 +8,8 @@ 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 com.iflytop.colortitration.common.exception.AppException; -import com.iflytop.colortitration.common.result.ResultCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; @@ -30,13 +27,9 @@ public class RoboticArmSmallMotorMoveByCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CommandDTO commandDTO) { - String motorCode = commandDTO.getStringParam("motorCode"); Double speed = commandDTO.getDoubleParam("speed"); Integer times = commandDTO.getIntegerParam("times"); Double angle = commandDTO.getDoubleParam("angle"); - if (StringUtils.isEmpty(motorCode) || angle == null) { - throw new AppException(ResultCode.INVALID_PARAMETER); - } return runAsync(() -> { if (speed != null) { DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmSmallMotorSetSpeed(speed); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpCloseCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpCloseCommand.java index 0aa9d9a..ddd8b9d 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpCloseCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpCloseCommand.java @@ -30,8 +30,8 @@ public class StepPumpCloseCommand extends BaseCommandHandler { return runAsync(() -> { DeviceCommand deviceCommand = switch (pumpCode) { case "set_pump_1" -> DeviceCommandGenerator.stepPump1Stop(); - case "set_pump_02" -> DeviceCommandGenerator.stepPump2Stop(); - case "set_pump_03" -> DeviceCommandGenerator.stepPump3Stop(); + case "set_pump_2" -> DeviceCommandGenerator.stepPump2Stop(); + case "set_pump_3" -> DeviceCommandGenerator.stepPump3Stop(); default -> throw new IllegalStateException("Unexpected value: " + pumpCode); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpMoveCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpMoveCommand.java index 58439fc..5eca3a0 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpMoveCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpMoveCommand.java @@ -34,9 +34,9 @@ public class StepPumpMoveCommand extends BaseCommandHandler { return runAsync(() -> { if (speed != null) { DeviceCommand deviceSetCommand = switch (pumpCode) { - case "set_pump_01" -> DeviceCommandGenerator.stepPump1SetSpeed(speed); - case "set_pump_02" -> DeviceCommandGenerator.stepPump2SetSpeed(speed); - case "set_pump_03" -> DeviceCommandGenerator.stepPump3SetSpeed(speed); + case "set_pump_1" -> DeviceCommandGenerator.stepPump1SetSpeed(speed); + case "set_pump_2" -> DeviceCommandGenerator.stepPump2SetSpeed(speed); + case "set_pump_3" -> DeviceCommandGenerator.stepPump3SetSpeed(speed); default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效 }; CommandFuture sentCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceSetCommand); @@ -44,9 +44,9 @@ public class StepPumpMoveCommand extends BaseCommandHandler { } DeviceCommand deviceMoveCommand = switch (pumpCode) { - case "set_pump_01" -> DeviceCommandGenerator.stepPump1MoveBy(distance); - case "set_pump_02" -> DeviceCommandGenerator.stepPump2MoveBy(distance); - case "set_pump_03" -> DeviceCommandGenerator.stepPump3MoveBy(distance); + case "set_pump_1" -> DeviceCommandGenerator.stepPump1MoveBy(distance); + case "set_pump_2" -> DeviceCommandGenerator.stepPump2MoveBy(distance); + case "set_pump_3" -> DeviceCommandGenerator.stepPump3MoveBy(distance); default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效 }; CommandFuture moveCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpOpenCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpOpenCommand.java index 6661266..f5b747b 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpOpenCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpOpenCommand.java @@ -34,9 +34,9 @@ public class StepPumpOpenCommand extends BaseCommandHandler { return runAsync(() -> { if (speed != null) { DeviceCommand deviceSetCommand = switch (pumpCode) { - case "set_pump_1" -> DeviceCommandGenerator.stepPump1SetSpeed(speed); - case "set_pump_2" -> DeviceCommandGenerator.stepPump2SetSpeed(speed); - case "set_pump_3" -> DeviceCommandGenerator.stepPump3SetSpeed(speed); + case "set_motor_1" -> DeviceCommandGenerator.stepPump1SetSpeed(speed); + case "set_motor_2" -> DeviceCommandGenerator.stepPump2SetSpeed(speed); + case "set_motor_3" -> DeviceCommandGenerator.stepPump3SetSpeed(speed); default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效 }; CommandFuture sentCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceSetCommand); @@ -45,15 +45,15 @@ public class StepPumpOpenCommand extends BaseCommandHandler { DeviceCommand deviceRoteCommand = switch (direction) { case "forward" -> switch (pumpCode) { - case "set_pump_1" -> DeviceCommandGenerator.stepPump1ForwardRotate(); - case "set_pump_2" -> DeviceCommandGenerator.stepPump2ForwardRotate(); - case "set_pump_3" -> DeviceCommandGenerator.stepPump3ForwardRotate(); + case "set_motor_1" -> DeviceCommandGenerator.stepPump1ForwardRotate(); + case "set_motor_2" -> DeviceCommandGenerator.stepPump2ForwardRotate(); + case "set_motor_3" -> DeviceCommandGenerator.stepPump3ForwardRotate(); default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效 }; case "backward" -> switch (pumpCode) { - case "set_pump_1" -> DeviceCommandGenerator.stepPump1BackwardRotate(); - case "set_pump_2" -> DeviceCommandGenerator.stepPump2BackwardRotate(); - case "set_pump_3" -> DeviceCommandGenerator.stepPump3BackwardRotate(); + case "set_motor_1" -> DeviceCommandGenerator.stepPump1BackwardRotate(); + case "set_motor_2" -> DeviceCommandGenerator.stepPump2BackwardRotate(); + case "set_motor_3" -> DeviceCommandGenerator.stepPump3BackwardRotate(); default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效 }; default -> throw new IllegalStateException("Unexpected value: " + direction); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorMoveByCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorMoveByCommand.java index 0b7bd08..749a4bb 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorMoveByCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorMoveByCommand.java @@ -78,8 +78,8 @@ public class StirMotorMoveByCommand extends BaseCommandHandler { } else { DeviceCommand deviceMoveCommand = switch (motorCode) { - case "titration_motor_01" -> DeviceCommandGenerator.stirMotor1MoveBy(distance); - case "titration_motor_02" -> DeviceCommandGenerator.stirMotor2MoveBy(distance); + case "titration_motor_1" -> DeviceCommandGenerator.stirMotor1MoveBy(distance); + case "titration_motor_2" -> DeviceCommandGenerator.stirMotor2MoveBy(distance); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorOriginCommand.java index 4c7fead..3896427 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorOriginCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/StirMotorOriginCommand.java @@ -35,8 +35,8 @@ public class StirMotorOriginCommand extends BaseCommandHandler { } return runAsync(() -> { DeviceCommand deviceCommand = switch (motorCode) { - case "magnet_stir_motor_01" -> DeviceCommandGenerator.stirMotor1Origin(); - case "magnet_stir_motor_02" -> DeviceCommandGenerator.stirMotor2Origin(); + case "stir_motor_1" -> DeviceCommandGenerator.stirMotor1Origin(); + case "stir_motor_2" -> DeviceCommandGenerator.stirMotor2Origin(); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorDisableCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorDisableCommand.java index 8a55b2c..997432c 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorDisableCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorDisableCommand.java @@ -35,8 +35,8 @@ public class TitrationMotorDisableCommand extends BaseCommandHandler { } return runAsync(() -> { DeviceCommand deviceCommand = switch (motorCode) { - case "titration_motor_01" -> DeviceCommandGenerator.titrationMotor1Disable(); - case "titration_motor_02" -> DeviceCommandGenerator.titrationMotor2Disable(); + case "titration_motor_1" -> DeviceCommandGenerator.titrationMotor1Disable(); + case "titration_motor_2" -> DeviceCommandGenerator.titrationMotor2Disable(); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorEnableCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorEnableCommand.java index bd87601..ebe00e1 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorEnableCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorEnableCommand.java @@ -35,8 +35,8 @@ public class TitrationMotorEnableCommand extends BaseCommandHandler { } return runAsync(() -> { DeviceCommand deviceCommand = switch (motorCode) { - case "titration_motor_01" -> DeviceCommandGenerator.titrationMotor1Enable(); - case "titration_motor_02" -> DeviceCommandGenerator.titrationMotor2Enable(); + case "titration_motor_1" -> DeviceCommandGenerator.titrationMotor1Enable(); + case "titration_motor_2" -> DeviceCommandGenerator.titrationMotor2Enable(); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveByCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveByCommand.java index 735b0dc..fa27ded 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveByCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveByCommand.java @@ -40,12 +40,12 @@ public class TitrationMotorMoveByCommand extends BaseCommandHandler { return runAsync(() -> { if (speed != null) { switch (motorCode) { - case "titration_motor_01" -> { + case "titration_motor_1" -> { DeviceCommand deviceCommand = DeviceCommandGenerator.titrationMotor1SetSpeed(speed); CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); CommandUtil.wait(commandFuture); } - case "titration_motor_02" -> { + case "titration_motor_2" -> { DeviceCommand deviceCommand = DeviceCommandGenerator.titrationMotor2SetSpeed(speed); CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); CommandUtil.wait(commandFuture); @@ -55,7 +55,7 @@ public class TitrationMotorMoveByCommand extends BaseCommandHandler { if (times != null) { for (int i = 0; i < times; i++) { switch (motorCode) { - case "titration_motor_01" -> { + case "titration_motor_1" -> { DeviceCommand deviceCommand = DeviceCommandGenerator.titrationMotor1MoveBy(distance); CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); CommandUtil.wait(commandFuture); @@ -64,7 +64,7 @@ public class TitrationMotorMoveByCommand extends BaseCommandHandler { CommandFuture backCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceBackCommand); CommandUtil.wait(backCommandFuture); } - case "titration_motor_02" -> { + case "titration_motor_2" -> { DeviceCommand deviceCommand = DeviceCommandGenerator.titrationMotor2MoveBy(distance); CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); CommandUtil.wait(commandFuture); @@ -78,8 +78,8 @@ public class TitrationMotorMoveByCommand extends BaseCommandHandler { } else { DeviceCommand deviceMoveCommand = switch (motorCode) { - case "titration_motor_01" -> DeviceCommandGenerator.titrationMotor1MoveBy(distance); - case "titration_motor_02" -> DeviceCommandGenerator.titrationMotor2MoveBy(distance); + case "titration_motor_1" -> DeviceCommandGenerator.titrationMotor1MoveBy(distance); + case "titration_motor_2" -> DeviceCommandGenerator.titrationMotor2MoveBy(distance); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveToCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveToCommand.java index 45f8da4..6ca1af6 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveToCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorMoveToCommand.java @@ -38,12 +38,12 @@ public class TitrationMotorMoveToCommand extends BaseCommandHandler { return runAsync(() -> { if (speed != null) { switch (motorCode) { - case "titration_motor_01" -> { + case "titration_motor_1" -> { DeviceCommand deviceCommand = DeviceCommandGenerator.titrationMotor1SetSpeed(speed); CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); CommandUtil.wait(commandFuture); } - case "titration_motor_02" -> { + case "titration_motor_2" -> { DeviceCommand deviceCommand = DeviceCommandGenerator.titrationMotor2SetSpeed(speed); CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); CommandUtil.wait(commandFuture); @@ -52,8 +52,8 @@ public class TitrationMotorMoveToCommand extends BaseCommandHandler { } DeviceCommand deviceMoveCommand = switch (motorCode) { - case "titration_motor_01" -> DeviceCommandGenerator.titrationMotor1MoveTo(position); - case "titration_motor_02" -> DeviceCommandGenerator.titrationMotor2MoveTo(position); + case "titration_motor_1" -> DeviceCommandGenerator.titrationMotor1MoveTo(position); + case "titration_motor_2" -> DeviceCommandGenerator.titrationMotor2MoveTo(position); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorOriginCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorOriginCommand.java index 7d3c1ca..13c0db4 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorOriginCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorOriginCommand.java @@ -35,8 +35,8 @@ public class TitrationMotorOriginCommand extends BaseCommandHandler { } return runAsync(() -> { DeviceCommand deviceCommand = switch (motorCode) { - case "titration_motor_01" -> DeviceCommandGenerator.titrationMotor1Origin(); - case "titration_motor_02" -> DeviceCommandGenerator.titrationMotor2Origin(); + case "titration_motor_1" -> DeviceCommandGenerator.titrationMotor1Origin(); + case "titration_motor_2" -> DeviceCommandGenerator.titrationMotor2Origin(); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorStopCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorStopCommand.java index a07c91e..22cc04f 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorStopCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/TitrationMotorStopCommand.java @@ -35,8 +35,8 @@ public class TitrationMotorStopCommand extends BaseCommandHandler { } return runAsync(() -> { DeviceCommand deviceCommand = switch (motorCode) { - case "titration_motor_01" -> DeviceCommandGenerator.titrationMotor1Stop(); - case "titration_motor_02" -> DeviceCommandGenerator.titrationMotor2Stop(); + case "titration_motor_1" -> DeviceCommandGenerator.titrationMotor1Stop(); + case "titration_motor_2" -> DeviceCommandGenerator.titrationMotor2Stop(); default -> throw new AppException(ResultCode.INVALID_PARAMETER); }; CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand); diff --git a/src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveByCommand.java b/src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveByCommand.java index 83eb503..26a3adb 100644 --- a/src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveByCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveByCommand.java @@ -8,11 +8,8 @@ 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 com.iflytop.colortitration.common.exception.AppException; -import com.iflytop.colortitration.common.result.ResultCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; @@ -30,13 +27,9 @@ public class ZMotorMoveByCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CommandDTO commandDTO) { - String motorCode = commandDTO.getStringParam("motorCode"); Double speed = commandDTO.getDoubleParam("speed"); Integer times = commandDTO.getIntegerParam("times"); Double distance = commandDTO.getDoubleParam("distance"); - if (StringUtils.isEmpty(motorCode) || distance == null) { - throw new AppException(ResultCode.INVALID_PARAMETER); - } return runAsync(() -> { if (speed != null) { DeviceCommand deviceCommand = DeviceCommandGenerator.zSet(speed); diff --git a/src/main/java/com/iflytop/colortitration/app/core/command/DeviceCommandGenerator.java b/src/main/java/com/iflytop/colortitration/app/core/command/DeviceCommandGenerator.java index d2477cb..de87724 100644 --- a/src/main/java/com/iflytop/colortitration/app/core/command/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/colortitration/app/core/command/DeviceCommandGenerator.java @@ -786,7 +786,7 @@ public class DeviceCommandGenerator { // =========================================== 滴定移动电机 ==================================================== /** - * titration_motor_01 回原点 + * titration_motor_1 回原点 */ public static DeviceCommand titrationMotor1Origin() { @@ -794,7 +794,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_01 停止 + * titration_motor_1 停止 */ public static DeviceCommand titrationMotor1Stop() { @@ -802,7 +802,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_01 使能 + * titration_motor_1 使能 */ public static DeviceCommand titrationMotor1Enable() { @@ -810,7 +810,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_01 失能 + * titration_motor_1 失能 */ public static DeviceCommand titrationMotor1Disable() { @@ -818,7 +818,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_01 设置速度 + * titration_motor_1 设置速度 */ public static DeviceCommand titrationMotor1SetSpeed(double speed) { DeviceCommandParams params = new DeviceCommandParams(); @@ -827,7 +827,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_01 绝对移动 + * titration_motor_1 绝对移动 */ public static DeviceCommand titrationMotor1MoveTo(double position) { DeviceCommandParams params = new DeviceCommandParams(); @@ -836,7 +836,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_01 相对移动 + * titration_motor_1 相对移动 */ public static DeviceCommand titrationMotor1MoveBy(double distance) { DeviceCommandParams params = new DeviceCommandParams(); @@ -845,7 +845,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_02 回原点 + * titration_motor_2 回原点 */ public static DeviceCommand titrationMotor2Origin() { @@ -853,7 +853,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_02 停止 + * titration_motor_2 停止 */ public static DeviceCommand titrationMotor2Stop() { @@ -861,7 +861,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_02 使能 + * titration_motor_2 使能 */ public static DeviceCommand titrationMotor2Enable() { @@ -869,7 +869,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_02 失能 + * titration_motor_2 失能 */ public static DeviceCommand titrationMotor2Disable() { @@ -877,7 +877,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_02 设置速度 + * titration_motor_2 设置速度 */ public static DeviceCommand titrationMotor2SetSpeed(double speed) { DeviceCommandParams params = new DeviceCommandParams(); @@ -887,7 +887,7 @@ public class DeviceCommandGenerator { /** - * titration_motor_02 绝对移动 + * titration_motor_2 绝对移动 */ public static DeviceCommand titrationMotor2MoveTo(double position) { DeviceCommandParams params = new DeviceCommandParams(); @@ -896,7 +896,7 @@ public class DeviceCommandGenerator { } /** - * titration_motor_02 相对移动 + * titration_motor_2 相对移动 */ public static DeviceCommand titrationMotor2MoveBy(double distance) { DeviceCommandParams params = new DeviceCommandParams();