diff --git a/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java b/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java index 34d7f39..844e0c6 100644 --- a/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java +++ b/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java @@ -79,7 +79,7 @@ public class SprayTaskExecutor { int sprayNum = 1; int currentIndex = 0; for (SprayTaskStep sprayTaskStep : sprayTask.getSprayTaskStepList()) {//循环进行多次喷涂 - if(!sprayTask.isFirstImmobility()){ + if (!sprayTask.isFirstImmobility()) { //先移动到玻片位置 DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskStep.getIndex()][0], 20.0); DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(75.5 - slideArr[sprayTaskStep.getIndex()][1], 20.0); @@ -92,13 +92,11 @@ public class SprayTaskExecutor { DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height, 15.0); CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetAboveSlideCommand); commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetAboveSlideCommandFuture); - }else{ - sprayTask.setFirstImmobility(false); - } - DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(sprayTask.getSprayParams().getVolume());//推动移动注射泵 - CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpForwardCommand); - commandWait(syringePumpForwardCommandFuture); + DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(sprayTask.getSprayParams().getVolume());//推动移动注射泵 + CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpForwardCommand); + commandWait(syringePumpForwardCommandFuture); + } Thread.sleep(100); sprayTask.setSuspendable(true);//可以暂停,单次喷涂范围内可以进行暂停 deviceStatus.setSuspendable(true); @@ -107,7 +105,7 @@ public class SprayTaskExecutor { DecimalFormat df = new DecimalFormat("#.##"); for (int i = 0; i < sprayTaskStep.getSpraySteps().size(); i++) {//单次喷涂 - if(currentIndex != sprayTaskStep.getIndex()) { + if (currentIndex != sprayTaskStep.getIndex()) { sprayNum = 0; currentIndex = sprayTaskStep.getIndex(); } @@ -115,6 +113,7 @@ public class SprayTaskExecutor { currentStep++; continue; } + sprayTask.setFirstImmobility(false); List sprayStepCommands = sprayTaskStep.getSpraySteps().get(i); DeviceCommand xSprayStepCommands = sprayStepCommands.get(0); xSprayStepCommands.getParam().put("speed", sprayTask.getSprayParams().getMovingSpeed());//防止修改了移动速度这里重新设置移动速度 diff --git a/src/main/java/com/qyft/ms/app/front/cmd/DemoCommand.java b/src/main/java/com/qyft/ms/app/front/cmd/DemoCommand.java index 8478166..937596b 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/DemoCommand.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/DemoCommand.java @@ -30,24 +30,29 @@ public class DemoCommand extends BaseCommandHandler { @Override public CompletableFuture handle(FrontCmdControlForm form) { return runAsync(() -> { - DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin();//x轴回原点 - DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorXOrigin();//y轴回原点 +// DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin();//x轴回原点 +// DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorXOrigin();//y轴回原点 +// +// CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXOriginCommand); +// CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYOriginCommand); +// +// commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture); +// +// +// DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet();//获得电机XYZ相对原点坐标 +// +// CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXyzPositionGetCommand); +// +// commandWait(motorXyzPositionGetCommandFuture); +// +// JSONObject responseResultJson = motorXyzPositionGetCommandFuture.getResponseResult(); +// +// webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.DEVICE_ERROR, "参数XXX必填")); + Double volume = form.getDoubleParam("volume"); + DeviceCommand syringePumpStartCommand = DeviceCommandGenerator.syringePumpVolumeSet(volume); // 生成移动注射泵指令 + CommandFuture syringePumpStartCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStartCommand); + commandWait(syringePumpStartCommandFuture); - CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXOriginCommand); - CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYOriginCommand); - - commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture); - - - DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet();//获得电机XYZ相对原点坐标 - - CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXyzPositionGetCommand); - - commandWait(motorXyzPositionGetCommandFuture); - - JSONObject responseResultJson = motorXyzPositionGetCommandFuture.getResponseResult(); - - webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.DEVICE_ERROR, "参数XXX必填")); }); } diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java index 76fbb18..35debab 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java @@ -36,6 +36,10 @@ public class MatrixSprayChangeParam extends BaseCommandHandler { @Override public CompletableFuture handle(FrontCmdControlForm form) { SprayTask sprayTask = SprayTask.getInstance(); + if (!sprayTask.isSpraying()) {//判断设备是否正在喷涂 + webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.DEVICE_ERROR, "未开始喷涂无法修改")); + throw new RuntimeException("未开始喷涂无法修改"); + } Double motorZHeight = form.getDoubleParam("motorZHeight"); Double gasPressure = form.getDoubleParam("gasPressure"); Double volume = form.getDoubleParam("volume"); @@ -51,6 +55,19 @@ public class MatrixSprayChangeParam extends BaseCommandHandler { sprayTask.setChangeSprayParam(motorZHeight, gasPressure, volume, highVoltage, highVoltageValue, movingSpeed); return runAsync(() -> { + if (!sprayTask.isPaused()) { + //4.是否打开高压 + if (highVoltage) {//打开高压 + DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(highVoltageValue);//开启高压 + CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageOpenCommand); + commandWait(highVoltageOpenCommandFuture); + } else {//关闭高压 + DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压 + CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageCloseCommand); + commandWait(highVoltageCloseCommandFuture); + } + } + //1.速度 DeviceCommand motorXSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorXSpeedSet(movingSpeed);//x轴电机速度设置 DeviceCommand motorYSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorYSpeedSet(movingSpeed);//y轴电机速度设置 @@ -64,25 +81,14 @@ public class MatrixSprayChangeParam extends BaseCommandHandler { CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpVolumeSetCommand); commandWait(syringePumpVolumeSetCommandFuture); - //3.z轴高度 + //3.z轴高度 SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "slide_height")); Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); Double height = slideHeight - motorZHeight; DeviceCommand smotorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(height, sprayTask.getSprayParams().getMovingSpeed());//移动z轴到指定位置 CommandFuture smotorZPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), smotorZPositionSetCommand); commandWait(smotorZPositionSetCommandFuture); - if (!sprayTask.isPaused()) { - //4.是否打开高压 - if (highVoltage) {//打开高压 - DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(highVoltageValue);//开启高压 - CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageOpenCommand); - commandWait(highVoltageOpenCommandFuture); - } else {//关闭高压 - DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压 - CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageCloseCommand); - commandWait(highVoltageCloseCommandFuture); - } - } + }); } diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java index e8a2440..14feaa5 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java @@ -42,6 +42,12 @@ public class MatrixSprayContinue extends BaseCommandHandler { deviceStatus.setPaused(false); return runAsync(() -> { + if (sprayTask.getSprayParams().getHighVoltage()) { + DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(sprayTask.getSprayParams().getHighVoltageValue()); //打开高压 + CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageOpenCommand); + commandWait(highVoltageOpenCommandFuture); + } + DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenSyringePipeline();//打开三通阀喷嘴管路 CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), threeWayValveOpenSyringePipelineCommand); commandWait(threeWayValveOpenSyringePipelineCommandFuture); @@ -54,11 +60,6 @@ public class MatrixSprayContinue extends BaseCommandHandler { CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpForwardCommand); commandWait(syringePumpForwardCommandFuture); - if (sprayTask.getSprayParams().getHighVoltage()) { - DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(sprayTask.getSprayParams().getHighVoltageValue()); //打开高压 - CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageOpenCommand); - commandWait(highVoltageOpenCommandFuture); - } sprayTask.setFirstImmobility(true); sprayTaskExecutor.startTask(); }); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java index 5660783..0afeb54 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java @@ -41,6 +41,7 @@ public class MatrixSprayPause extends BaseCommandHandler { deviceStatus.setPaused(true); sprayTask.setSuspendable(false);//不可暂停 deviceStatus.setSuspendable(false); + sprayTask.setFirstImmobility(true); return runAsync(() -> { sprayTaskExecutor.stopTask();//终止喷涂任务线程 diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java index 77c0366..67577ca 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java @@ -199,11 +199,11 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); if (j == pathList.size() - 1) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } else { deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } deviceCommandList.add(deviceCommands); } @@ -236,11 +236,11 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); if (j == pathList.size() - 1) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } else { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } deviceCommandList.add(deviceCommands); } @@ -272,11 +272,11 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); if (j == pathList.size() - 1) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } else { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } deviceCommandList.add(deviceCommands); } @@ -295,11 +295,11 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); if (j == pathList.size() - 1) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } else { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 } deviceCommandList.add(deviceCommands); } diff --git a/src/main/java/com/qyft/ms/system/common/device/command/DeviceCommandGenerator.java b/src/main/java/com/qyft/ms/system/common/device/command/DeviceCommandGenerator.java index 8941735..901d0b4 100644 --- a/src/main/java/com/qyft/ms/system/common/device/command/DeviceCommandGenerator.java +++ b/src/main/java/com/qyft/ms/system/common/device/command/DeviceCommandGenerator.java @@ -206,23 +206,11 @@ public class DeviceCommandGenerator { } /** - * 推动移动注射泵 - * - * @param speed 是指注射泵每分钟注射多少微升(volume 最低0.1) - */ - public static DeviceCommand syringePumpBackward(Double speed) { - Map params = new HashMap<>(); - params.put("direction", "backward"); - params.put("speed", speed); - return controlCmd("syringe_pump", "move", params, "推动移动注射泵"); - } - - /** * 注射泵流速设置 */ - public static DeviceCommand syringePumpVolumeSet(Double volume) { + public static DeviceCommand syringePumpVolumeSet(Double speed) { Map params = new HashMap<>(); - params.put("volume", volume); + params.put("speed", speed); return controlCmd("syringe_pump", "set", params, "注射泵流速设置"); } diff --git a/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java b/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java index 7dfa5c6..495463b 100644 --- a/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java +++ b/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java @@ -1,6 +1,7 @@ package com.qyft.ms.system.service.device; import cn.hutool.json.JSONObject; +import com.qyft.ms.app.device.status.DeviceStatus; import com.qyft.ms.system.common.constant.CommandStatus; import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CyclicNumberGenerator; @@ -12,7 +13,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -25,6 +25,7 @@ public class DeviceCommandService { private final DeviceTcpClient deviceTcpClient; private final WebSocketService webSocketService; + private final DeviceStatus deviceStatus; public CommandFuture executeCommand(DeviceCommand cmdToDevice) { @@ -47,31 +48,18 @@ public class DeviceCommandService { public CommandFuture sendCommandNoFront(DeviceCommand deviceCommand) { - CommandFuture commandFuture = executeCommand(deviceCommand); - commandFuture.getResponseFuture().thenApply(result -> { - Boolean success = result.getBool("success"); - if (!success) { //response失败 - String message = deviceCommand.getCmdName() + "指令,设备response错误"; - } - return result; - }); - - return commandFuture; + return executeCommand(deviceCommand); } - public CommandFuture sendCommand(String cmdId, String cmdCode, DeviceCommand deviceCommand) throws IOException { + public CommandFuture sendCommand(String cmdId, String cmdCode, DeviceCommand deviceCommand) throws Exception { + if (deviceStatus.isStopPressed()) { + throw new RuntimeException("设备急停中"); + } CommandFuture commandFuture = executeCommand(deviceCommand); + commandFuture.setCmdId(cmdId); + commandFuture.setCmdCode(cmdCode); + commandFuture.setDeviceCommand(deviceCommand); webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.DEVICE_SEND, deviceCommand.getCmdName() + "指令,已发给设备", deviceCommand)); - commandFuture.getResponseFuture().thenApply(result -> { - Boolean success = result.getBool("success"); - if (success == null || !success) { //response失败 - String message = deviceCommand.getCmdName() + "指令,设备response错误"; - webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.DEVICE_ERROR, message, result)); - } - webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.DEVICE_RESULT, deviceCommand.getCmdName() + "指令,设备response正常,耗时:" + (commandFuture.getEndSendTime() - commandFuture.getStartSendTime()), result)); - return result; - }); - return commandFuture; } @@ -83,8 +71,16 @@ public class DeviceCommandService { future.setEndSendTime(System.currentTimeMillis()); Boolean success = deviceResult.getBool("success"); //数据验证 if (success == null || !success) { //response失败 - future.completeResponseExceptionally(new RuntimeException("response失败")); + if(future.getCmdId() != null) { + webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(future.getCmdId(), future.getCmdCode(), CommandStatus.DEVICE_ERROR, + future.getDeviceCommand().getCmdName() + "指令,设备response错误,耗时:" + (future.getEndSendTime() - future.getStartSendTime()), deviceResult)); + } + future.completeResponseExceptionally(new RuntimeException("response失败:" + deviceResult)); } else { + if(future.getCmdId() != null) { + webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(future.getCmdId(), future.getCmdCode(), CommandStatus.DEVICE_RESULT, + future.getDeviceCommand().getCmdName() + "指令,设备response正常,耗时:" + (future.getEndSendTime() - future.getStartSendTime()), deviceResult)); + } future.completeResponse(deviceResult); } }