diff --git a/src/main/java/com/iflytop/gd/app/cmd/ShakeOriginCommand.java b/src/main/java/com/iflytop/gd/app/cmd/ShakeOriginCommand.java new file mode 100644 index 0000000..294956b --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/ShakeOriginCommand.java @@ -0,0 +1,33 @@ +package com.iflytop.gd.app.cmd; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandUtilService; +import com.iflytop.gd.app.service.DeviceStateService; +import com.iflytop.gd.common.annotation.CommandMapping; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 摇匀回原点 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("shake_origin")//业务指令注解 +public class ShakeOriginCommand extends BaseCommandHandler { + private final DeviceCommandUtilService deviceCommandUtilService; + private final DeviceStateService deviceStateService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + deviceCommandUtilService.shakeOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand());//摇匀回原点 + deviceStateService.setSolutionModuleStateShaking(true); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerResetCommand.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerResetCommand.java new file mode 100644 index 0000000..c2fd73e --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerResetCommand.java @@ -0,0 +1,35 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommandBundle; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 处理摇匀回原点 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_shaker_reset") +public class DebugShakerResetCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.shakeMotorOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + }); + } +} +