Browse Source

调试指令修改

master
王梦远 2 weeks ago
parent
commit
b9290689c6
  1. 22
      src/main/java/com/iflytop/colortitration/app/command/debug/BrushlessPumpMoveCommand.java
  2. 6
      src/main/java/com/iflytop/colortitration/app/command/debug/CeramicPumpMoveCommand.java
  3. 8
      src/main/java/com/iflytop/colortitration/app/command/debug/ClawOpenCommand.java
  4. 4
      src/main/java/com/iflytop/colortitration/app/command/debug/ClawStopCommand.java
  5. 33
      src/main/java/com/iflytop/colortitration/app/command/debug/MagnetCloseCommand.java
  6. 33
      src/main/java/com/iflytop/colortitration/app/command/debug/MagnetOpenCommand.java
  7. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorDisableCommand.java
  8. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorEnableCommand.java
  9. 12
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveByCommand.java
  10. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveToCommand.java
  11. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorOriginCommand.java
  12. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorStopCommand.java
  13. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorDisableCommand.java
  14. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorEnableCommand.java
  15. 12
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveByCommand.java
  16. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveToCommand.java
  17. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorOriginCommand.java
  18. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorStopCommand.java
  19. 8
      src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpMoveCommand.java
  20. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorDisableCommand.java
  21. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorEnableCommand.java
  22. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveByCommand.java
  23. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveToCommand.java
  24. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorOriginCommand.java
  25. 2
      src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorStopCommand.java
  26. 15
      src/main/java/com/iflytop/colortitration/app/core/command/DeviceCommandGenerator.java
  27. 1
      src/main/java/com/iflytop/colortitration/common/enums/Device.java

22
src/main/java/com/iflytop/colortitration/app/command/debug/BrushlessPumpMoveCommand.java

@ -30,7 +30,7 @@ public class BrushlessPumpMoveCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CommandDTO commandDTO) {
String pumpCode = commandDTO.getStringParam("pumpCode");
Double speed = commandDTO.getDoubleParam("speed");
Double position = commandDTO.getDoubleParam("position");
Double distance = commandDTO.getDoubleParam("distance");
return runAsync(() -> {
if (speed != null) {
DeviceCommand deviceSetCommand = switch (pumpCode) {
@ -51,16 +51,16 @@ public class BrushlessPumpMoveCommand extends BaseCommandHandler {
}
DeviceCommand deviceMoveCommand = switch (pumpCode) {
case "brushless_pump_1" -> DeviceCommandGenerator.brushlessPump1MoveBy(position);
case "brushless_pump_2" -> DeviceCommandGenerator.brushlessPump2MoveBy(position);
case "brushless_pump_3" -> DeviceCommandGenerator.brushlessPump3MoveBy(position);
case "brushless_pump_4" -> DeviceCommandGenerator.brushlessPump4MoveBy(position);
case "brushless_pump_5" -> DeviceCommandGenerator.brushlessPump5MoveBy(position);
case "brushless_pump_6" -> DeviceCommandGenerator.brushlessPump6MoveBy(position);
case "brushless_pump_7" -> DeviceCommandGenerator.brushlessPump7MoveBy(position);
case "brushless_pump_8" -> DeviceCommandGenerator.brushlessPump8MoveBy(position);
case "brushless_pump_9" -> DeviceCommandGenerator.brushlessPump9MoveBy(position);
case "brushless_pump_10" -> DeviceCommandGenerator.brushlessPump10MoveBy(position);
case "brushless_pump_1" -> DeviceCommandGenerator.brushlessPump1MoveBy(distance);
case "brushless_pump_2" -> DeviceCommandGenerator.brushlessPump2MoveBy(distance);
case "brushless_pump_3" -> DeviceCommandGenerator.brushlessPump3MoveBy(distance);
case "brushless_pump_4" -> DeviceCommandGenerator.brushlessPump4MoveBy(distance);
case "brushless_pump_5" -> DeviceCommandGenerator.brushlessPump5MoveBy(distance);
case "brushless_pump_6" -> DeviceCommandGenerator.brushlessPump6MoveBy(distance);
case "brushless_pump_7" -> DeviceCommandGenerator.brushlessPump7MoveBy(distance);
case "brushless_pump_8" -> DeviceCommandGenerator.brushlessPump8MoveBy(distance);
case "brushless_pump_9" -> DeviceCommandGenerator.brushlessPump9MoveBy(distance);
case "brushless_pump_10" -> DeviceCommandGenerator.brushlessPump10MoveBy(distance);
default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效
};
CommandFuture moveCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand);

6
src/main/java/com/iflytop/colortitration/app/command/debug/CeramicPumpMoveCommand.java

@ -30,7 +30,7 @@ public class CeramicPumpMoveCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CommandDTO commandDTO) {
String pumpCode = commandDTO.getStringParam("pumpCode");
Double speed = commandDTO.getDoubleParam("speed");
Double position = commandDTO.getDoubleParam("position");
Double distance = commandDTO.getDoubleParam("distance");
return runAsync(() -> {
if (speed != null) {
DeviceCommand deviceSetCommand = switch (pumpCode) {
@ -43,8 +43,8 @@ public class CeramicPumpMoveCommand extends BaseCommandHandler {
}
DeviceCommand deviceMoveCommand = switch (pumpCode) {
case "ceramic_pump_1" -> DeviceCommandGenerator.ceramicPump1MoveBy(position);
case "ceramic_pump_2" -> DeviceCommandGenerator.ceramicPump2MoveBy(position);
case "ceramic_pump_1" -> DeviceCommandGenerator.ceramicPump1MoveBy(distance);
case "ceramic_pump_2" -> DeviceCommandGenerator.ceramicPump2MoveBy(distance);
default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效
};
CommandFuture moveCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand);

8
src/main/java/com/iflytop/colortitration/app/command/debug/ClawOpenCommand.java

@ -1,5 +1,6 @@
package com.iflytop.colortitration.app.command.debug;
import com.iflytop.colortitration.app.common.annotation.CommandDebugMapping;
import com.iflytop.colortitration.app.common.utils.CommandUtil;
import com.iflytop.colortitration.app.core.command.BaseCommandHandler;
import com.iflytop.colortitration.app.core.command.CommandFuture;
@ -20,6 +21,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("claw_open")
public class ClawOpenCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@ -27,7 +29,7 @@ public class ClawOpenCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CommandDTO commandDTO) {
Double speed = commandDTO.getDoubleParam("speed");
Double times = commandDTO.getDoubleParam("times");
Double position = commandDTO.getDoubleParam("position");
Double distance = commandDTO.getDoubleParam("distance");
return runAsync(() -> {
if (speed != null) {
DeviceCommand deviceSetCommand = DeviceCommandGenerator.clawSet(speed);
@ -36,7 +38,7 @@ public class ClawOpenCommand extends BaseCommandHandler {
}
if (times != null) {
for (int i = 0; i < times; i++) {
DeviceCommand deviceMoveCommand = DeviceCommandGenerator.clawMove(position);
DeviceCommand deviceMoveCommand = DeviceCommandGenerator.clawMove(distance);
CommandFuture moveCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand);
CommandUtil.wait(moveCommandFuture);
TimeUnit.MILLISECONDS.sleep(500);
@ -46,7 +48,7 @@ public class ClawOpenCommand extends BaseCommandHandler {
}
} else {
DeviceCommand deviceMoveCommand = DeviceCommandGenerator.clawMove(position);
DeviceCommand deviceMoveCommand = DeviceCommandGenerator.clawMove(distance);
CommandFuture moveCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand);
CommandUtil.wait(moveCommandFuture);
}

4
src/main/java/com/iflytop/colortitration/app/command/debug/ClawCloseCommand.java → src/main/java/com/iflytop/colortitration/app/command/debug/ClawStopCommand.java

@ -1,5 +1,6 @@
package com.iflytop.colortitration.app.command.debug;
import com.iflytop.colortitration.app.common.annotation.CommandDebugMapping;
import com.iflytop.colortitration.app.common.utils.CommandUtil;
import com.iflytop.colortitration.app.core.command.BaseCommandHandler;
import com.iflytop.colortitration.app.core.command.CommandFuture;
@ -19,7 +20,8 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
public class ClawCloseCommand extends BaseCommandHandler {
@CommandDebugMapping("claw_stop")
public class ClawStopCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override

33
src/main/java/com/iflytop/colortitration/app/command/debug/MagnetCloseCommand.java

@ -0,0 +1,33 @@
package com.iflytop.colortitration.app.command.debug;
import com.iflytop.colortitration.app.common.annotation.CommandDebugMapping;
import com.iflytop.colortitration.app.core.command.BaseCommandHandler;
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
@CommandDebugMapping("magnet_close")
public class MagnetCloseCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CommandDTO commandDTO) {
return runAsync(() -> {
DeviceCommand deviceCommand = DeviceCommandGenerator.magnetClose();
deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand);
});
}
}

33
src/main/java/com/iflytop/colortitration/app/command/debug/MagnetOpenCommand.java

@ -0,0 +1,33 @@
package com.iflytop.colortitration.app.command.debug;
import com.iflytop.colortitration.app.common.annotation.CommandDebugMapping;
import com.iflytop.colortitration.app.core.command.BaseCommandHandler;
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
@CommandDebugMapping("magnet_open")
public class MagnetOpenCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CommandDTO commandDTO) {
return runAsync(() -> {
DeviceCommand deviceCommand = DeviceCommandGenerator.magnetOpen();
deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand);
});
}
}

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigDisableCommand.java → src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorDisableCommand.java

@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_big_disable")
public class RoboticArmBigDisableCommand extends BaseCommandHandler {
public class RoboticArmBigMotorDisableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigEnableCommand.java → src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorEnableCommand.java

@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_big_enable")
public class RoboticArmBigEnableCommand extends BaseCommandHandler {
public class RoboticArmBigMotorEnableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override

12
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveByCommand.java

@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_big_motor_move_by")
@CommandDebugMapping("robotic_arm_big_move_by")
public class RoboticArmBigMotorMoveByCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@ -33,8 +33,8 @@ public class RoboticArmBigMotorMoveByCommand extends BaseCommandHandler {
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) {
Double angle = commandDTO.getDoubleParam("angle");
if (StringUtils.isEmpty(motorCode) || angle == null) {
throw new AppException(ResultCode.INVALID_PARAMETER);
}
return runAsync(() -> {
@ -45,17 +45,17 @@ public class RoboticArmBigMotorMoveByCommand extends BaseCommandHandler {
}
if (times != null) {
for (int i = 0; i < times; i++) {
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmBigMotorMoveBy(distance);
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmBigMotorMoveBy(angle);
CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand);
CommandUtil.wait(commandFuture);
TimeUnit.MILLISECONDS.sleep(500);
DeviceCommand deviceBackCommand = DeviceCommandGenerator.roboticArmBigMotorMoveBy(-distance);
DeviceCommand deviceBackCommand = DeviceCommandGenerator.roboticArmBigMotorMoveBy(-angle);
CommandFuture backCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceBackCommand);
CommandUtil.wait(backCommandFuture);
}
} else {
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmBigMotorMoveBy(distance);
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmBigMotorMoveBy(angle);
CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand);
CommandUtil.wait(commandFuture);
}

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorMoveToCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_big_motor_move_to")
@CommandDebugMapping("robotic_arm_big_move_to")
public class RoboticArmBigMotorMoveToCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorOriginCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_big_motor_origin")
@CommandDebugMapping("robotic_arm_big_origin")
public class RoboticArmBigMotorOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmBigMotorStopCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_big_motor_stop")
@CommandDebugMapping("robotic_arm_big_stop")
public class RoboticArmBigMotorStopCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallDisableCommand.java → src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorDisableCommand.java

@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_small_disable")
public class RoboticArmSmallDisableCommand extends BaseCommandHandler {
public class RoboticArmSmallMotorDisableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallEnableCommand.java → src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorEnableCommand.java

@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_small_enable")
public class RoboticArmSmallEnableCommand extends BaseCommandHandler {
public class RoboticArmSmallMotorEnableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override

12
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveByCommand.java

@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_small_motor_move_by")
@CommandDebugMapping("robotic_arm_small_move_by")
public class RoboticArmSmallMotorMoveByCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@ -33,8 +33,8 @@ public class RoboticArmSmallMotorMoveByCommand extends BaseCommandHandler {
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) {
Double angle = commandDTO.getDoubleParam("angle");
if (StringUtils.isEmpty(motorCode) || angle == null) {
throw new AppException(ResultCode.INVALID_PARAMETER);
}
return runAsync(() -> {
@ -45,17 +45,17 @@ public class RoboticArmSmallMotorMoveByCommand extends BaseCommandHandler {
}
if (times != null) {
for (int i = 0; i < times; i++) {
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmSmallMotorMoveBy(distance);
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmSmallMotorMoveBy(angle);
CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand);
CommandUtil.wait(commandFuture);
TimeUnit.MILLISECONDS.sleep(500);
DeviceCommand deviceBackCommand = DeviceCommandGenerator.roboticArmSmallMotorMoveBy(-distance);
DeviceCommand deviceBackCommand = DeviceCommandGenerator.roboticArmSmallMotorMoveBy(-angle);
CommandFuture backCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceBackCommand);
CommandUtil.wait(backCommandFuture);
}
} else {
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmSmallMotorMoveBy(distance);
DeviceCommand deviceCommand = DeviceCommandGenerator.roboticArmSmallMotorMoveBy(angle);
CommandFuture commandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceCommand);
CommandUtil.wait(commandFuture);
}

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorMoveToCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_small_motor_move_to")
@CommandDebugMapping("robotic_arm_small_move_to")
public class RoboticArmSmallMotorMoveToCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorOriginCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_small_motor_origin")
@CommandDebugMapping("robotic_arm_small_origin")
public class RoboticArmSmallMotorOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/RoboticArmSmallMotorStopCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("robotic_arm_small_motor_stop")
@CommandDebugMapping("robotic_arm_small_stop")
public class RoboticArmSmallMotorStopCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

8
src/main/java/com/iflytop/colortitration/app/command/debug/StepPumpMoveCommand.java

@ -30,7 +30,7 @@ public class StepPumpMoveCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CommandDTO commandDTO) {
String pumpCode = commandDTO.getStringParam("pumpCode");
Double speed = commandDTO.getDoubleParam("speed");
Double position = commandDTO.getDoubleParam("position");
Double distance = commandDTO.getDoubleParam("distance");
return runAsync(() -> {
if (speed != null) {
DeviceCommand deviceSetCommand = switch (pumpCode) {
@ -44,9 +44,9 @@ public class StepPumpMoveCommand extends BaseCommandHandler {
}
DeviceCommand deviceMoveCommand = switch (pumpCode) {
case "set_pump_01" -> DeviceCommandGenerator.stepPump1MoveBy(position);
case "set_pump_02" -> DeviceCommandGenerator.stepPump2MoveBy(position);
case "set_pump_03" -> DeviceCommandGenerator.stepPump3MoveBy(position);
case "set_pump_01" -> DeviceCommandGenerator.stepPump1MoveBy(distance);
case "set_pump_02" -> DeviceCommandGenerator.stepPump2MoveBy(distance);
case "set_pump_03" -> DeviceCommandGenerator.stepPump3MoveBy(distance);
default -> throw new AppException(ResultCode.INVALID_PARAMETER);//参数无效
};
CommandFuture moveCommandFuture = deviceCommandService.sendCommand(commandDTO.getCommandId(), commandDTO.getCommand(), deviceMoveCommand);

2
src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorDisableCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("z_motor_disable")
@CommandDebugMapping("z_disable")
public class ZMotorDisableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorEnableCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("z_motor_enable")
@CommandDebugMapping("z_enable")
public class ZMotorEnableCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveByCommand.java

@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("z_motor_move_by")
@CommandDebugMapping("z_move_by")
public class ZMotorMoveByCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorMoveToCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("z_motor_move_to")
@CommandDebugMapping("z_move_to")
public class ZMotorMoveToCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorOriginCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("z_motor_origin")
@CommandDebugMapping("z_origin")
public class ZMotorOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

2
src/main/java/com/iflytop/colortitration/app/command/debug/ZMotorStopCommand.java

@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandDebugMapping("z_motor_stop")
@CommandDebugMapping("z_stop")
public class ZMotorStopCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;

15
src/main/java/com/iflytop/colortitration/app/core/command/DeviceCommandGenerator.java

@ -43,6 +43,21 @@ public class DeviceCommandGenerator {
* 蜂鸣器关闭
*/
public static DeviceCommand beepClose() {
return controlCmd(Device.MAGNET, Action.CLOSE, null);
}
// =========================================== 磁子开关 ====================================================
/**
* 电磁开启
*/
public static DeviceCommand magnetOpen() {
return controlCmd(Device.MAGNET, Action.OPEN, null);
}
/**
* 电磁关闭
*/
public static DeviceCommand magnetClose() {
return controlCmd(Device.BEEP, Action.CLOSE, null);
}
// =========================================== 加热棒 ====================================================

1
src/main/java/com/iflytop/colortitration/common/enums/Device.java

@ -30,6 +30,7 @@ public enum Device {
HEAT_ROD_2(HardwareType.IO_DEVICE, "加热棒 2"),
TRICOLOR_LIGHT(HardwareType.IO_DEVICE, "三色灯"),
BEEP(HardwareType.IO_DEVICE, "蜂鸣器"),
MAGNET(HardwareType.IO_DEVICE, "电磁开关"),
CONTAINER_LOW_LEVEL_1(HardwareType.IO_DEVICE, "容器低液位检测 1"),
CONTAINER_LOW_LEVEL_2(HardwareType.IO_DEVICE, "容器低液位检测 2"),
CONTAINER_LOW_LEVEL_3(HardwareType.IO_DEVICE, "容器低液位检测 3"),

Loading…
Cancel
Save