Browse Source

add:测试发现的一些问题

master
王梦远 2 months ago
parent
commit
f9b2ac88e3
  1. 4
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java
  2. 10
      src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java
  3. 2
      src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java

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

10
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(() -> {

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

Loading…
Cancel
Save