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