From ce8cd1c2380dbbe519f615128e8d93d5b161e1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Mon, 19 May 2025 17:14:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E4=BB=A3=E7=A0=81=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iflytop/gd/app/cmd/ShakeOriginCommand.java | 33 ++++++++++++++++++++ .../gd/app/cmd/debug/DebugShakerResetCommand.java | 35 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/main/java/com/iflytop/gd/app/cmd/ShakeOriginCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugShakerResetCommand.java 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); + }); + } +} +