From f9b2ac88e3169c4f29f576e8fda4d87408790b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Wed, 28 May 2025 16:10:53 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=B5=8B=E8=AF=95=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java | 4 ++-- .../iflytop/sgs/app/service/device/DeviceCommandService.java | 10 ++++++---- .../com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java index 13dfd93..71050cf 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java @@ -33,8 +33,8 @@ public class DebugBeeOpenCommand extends BaseCommandHandler { Assert.notNull(mode, ()->new AppException(ResultCode.INVALID_PARAMETER)); return runAsync(() -> { DeviceCommandBundle beeOpenDeviceCommand = DeviceCommandGenerator.beepOpen(mode); - CommandFuture doorMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), beeOpenDeviceCommand); - CommandUtil.wait(doorMoveDeviceCommandFuture); + CommandFuture beeOpenDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), beeOpenDeviceCommand); + CommandUtil.wait(beeOpenDeviceCommandFuture); }); } diff --git a/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java b/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java index 5a9008e..7be95a0 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java @@ -8,6 +8,7 @@ import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.CyclicNumberGenerator; import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.constant.CommandStatus; +import com.iflytop.sgs.hardware.HardwareService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -21,6 +22,7 @@ import java.util.concurrent.ConcurrentMap; public class DeviceCommandService { private final WebSocketSender webSocketService; private final DeviceStateService deviceStateService; + private final HardwareService hardwareService; /** * 需要等待加液区空闲的转运机械臂指令 */ @@ -54,10 +56,10 @@ public class DeviceCommandService { sendCommandFutureMap.put(cmdId, commandFuture); commandFuture.setStartSendTime(System.currentTimeMillis()); if (!deviceStateService.getDeviceState().isVirtual()) { -// if (!hardwareService.sendCommand(commandFuture.getDeviceCommandBundle().getDeviceCommand())) { -// sendCommandFutureMap.remove(commandFuture.getDeviceCommandBundle().getDeviceCommand().getCmdId()); -// throw new RuntimeException("向设备发送指令失败"); -// } + if (!hardwareService.sendCommand(commandFuture.getDeviceCommandBundle().getDeviceCommand())) { + sendCommandFutureMap.remove(commandFuture.getDeviceCommandBundle().getDeviceCommand().getCmdId()); + throw new RuntimeException("向设备发送指令失败"); + } } else { //虚拟模式 new Thread(() -> { diff --git a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java index ccd9266..24b4de0 100644 --- a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java @@ -557,7 +557,7 @@ public class DeviceCommandGenerator { public static DeviceCommandBundle beepOpen(String mode) { DeviceCommandParams params = new DeviceCommandParams(); params.setBeepMode(CmdBeepMode.valueOf(mode)); - return controlCmd(CmdDevice.beep, CmdAction.open, null, "蜂鸣器 开启"); + return controlCmd(CmdDevice.beep, CmdAction.open, params, "蜂鸣器 开启"); } /**