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, "蜂鸣器 开启"); } /**