Browse Source

修改自检功能

master
王梦远 1 week ago
parent
commit
9b031c17e5
  1. 41
      src/main/java/com/iflytop/colortitration/app/command/selftest/ShakeMotorOriginCommand.java
  2. 41
      src/main/java/com/iflytop/colortitration/app/command/selftest/StirMotorOriginCommand.java
  3. 6
      src/main/java/com/iflytop/colortitration/app/command/selftest/XYOriginCommand.java
  4. 6
      src/main/java/com/iflytop/colortitration/app/command/selftest/ZOriginCommand.java
  5. 6
      src/main/java/com/iflytop/colortitration/app/controller/SelfTestController.java

41
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<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);
});
}
}

41
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<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);
});
}
}

6
src/main/java/com/iflytop/colortitration/app/command/selftest/GantryXYOriginCommand.java → 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; import java.util.concurrent.CompletableFuture;
/** /**
* 龙门架机械臂z轴回原点
* 机械臂回原点
*/ */
@Slf4j @Slf4j
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
@CommandMapping("check_gantry_xy_origin")//业务指令注解
public class GantryXYOriginCommand extends BaseCommandHandler {
@CommandMapping("check_xy_origin")//业务指令注解
public class XYOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService; private final DeviceCommandService deviceCommandService;
@Override @Override

6
src/main/java/com/iflytop/colortitration/app/command/selftest/GantryZOriginCommand.java → 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; import java.util.concurrent.CompletableFuture;
/** /**
* 龙门架机械臂z轴回原点
* z轴回原点
*/ */
@Slf4j @Slf4j
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
@CommandMapping("check_gantry_z_origin")//业务指令注解
public class GantryZOriginCommand extends BaseCommandHandler {
@CommandMapping("check_z_origin")//业务指令注解
public class ZOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService; private final DeviceCommandService deviceCommandService;
@Override @Override

6
src/main/java/com/iflytop/colortitration/app/controller/SelfTestController.java

@ -18,12 +18,6 @@ import org.springframework.web.bind.annotation.RestController;
public class SelfTestController { public class SelfTestController {
private final DeviceState deviceState; private final DeviceState deviceState;
// @Operation(summary = "获取自检状态")
// @GetMapping("/status")
// public Result<SelfTestState> getSelfTestStatus() {
// return Result.success(selfTestService.getSelfTestState());
// }
@Operation(summary = "自检完毕") @Operation(summary = "自检完毕")
@PostMapping("/finish") @PostMapping("/finish")
public Result<?> selfTestFinish() throws Exception { public Result<?> selfTestFinish() throws Exception {

Loading…
Cancel
Save