Browse Source

fix:调整业务指令处理逻辑

tags/1.0
白凤吉 5 months ago
parent
commit
73e768ce67
  1. 13
      src/main/java/com/qyft/ms/app/front/cmd/DemoCommand.java
  2. 8
      src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStart.java
  3. 4
      src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStop.java
  4. 7
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java
  5. 18
      src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java
  6. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/DehumidifierValveClose.java
  7. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/DehumidifierValveOpen.java
  8. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/HighVoltageClose.java
  9. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/HighVoltageOpen.java
  10. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/LaserControlClose.java
  11. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/LaserControlOpen.java
  12. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/LightingPanelClose.java
  13. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/LightingPanelOpen.java
  14. 10
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXMove.java
  15. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXOrigin.java
  16. 4
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXStop.java
  17. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXYZPositionGet.java
  18. 10
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorYMove.java
  19. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorYOrigin.java
  20. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorYStop.java
  21. 12
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorZMove.java
  22. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorZOrigin.java
  23. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/MotorZStop.java
  24. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/NozzleValveClose.java
  25. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/NozzleValveOpen.java
  26. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/SyringePumpStart.java
  27. 8
      src/main/java/com/qyft/ms/app/front/cmd/debug/ThreeWayValveCloseAll.java
  28. 8
      src/main/java/com/qyft/ms/app/front/cmd/debug/ThreeWayValveOpenNuzzlePipeline.java
  29. 8
      src/main/java/com/qyft/ms/app/front/cmd/debug/ThreeWayValveOpenSyringePipeline.java
  30. 8
      src/main/java/com/qyft/ms/app/front/cmd/debug/WashValveClose.java
  31. 6
      src/main/java/com/qyft/ms/app/front/cmd/debug/WashValveOpen.java
  32. 18
      src/main/java/com/qyft/ms/system/common/device/command/CommandFuture.java
  33. 5
      src/main/java/com/qyft/ms/system/core/handler/BaseCommandHandler.java
  34. 2
      src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

13
src/main/java/com/qyft/ms/app/front/cmd/DemoCommand.java

@ -1,5 +1,6 @@
package com.qyft.ms.app.front.cmd; package com.qyft.ms.app.front.cmd;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -32,7 +33,17 @@ public class DemoCommand extends BaseCommandHandler {
CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(motorXOriginCommand, form, emitter); CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(motorXOriginCommand, form, emitter);
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(motorYOriginCommand, form, emitter); CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(motorYOriginCommand, form, emitter);
commandWaitAll(motorXOriginCommandFuture, motorYOriginCommandFuture);
commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture);
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet();//获得电机XYZ相对原点坐标
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter);
commandWait(motorXyzPositionGetCommandFuture);
JSONObject ackResultJson = motorXyzPositionGetCommandFuture.getAckResult();
JSONObject responseResultJson = motorXyzPositionGetCommandFuture.getResponseResult();
}); });

8
src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStart.java

@ -43,10 +43,10 @@ public class DehumidifierStart extends BaseCommandHandler {
// 获取设备当前湿度 // 获取设备当前湿度
DeviceCommand humidityGetCmd = DeviceCommandGenerator.humidityGet(); // 生成获取湿度指令 DeviceCommand humidityGetCmd = DeviceCommandGenerator.humidityGet(); // 生成获取湿度指令
CommandFuture humidityGetCmdFuture = deviceCommandService.sendCommand(humidityGetCmd, form, emitter); CommandFuture humidityGetCmdFuture = deviceCommandService.sendCommand(humidityGetCmd, form, emitter);
waitAll(humidityGetCmdFuture.getAckFuture());
commandWait(humidityGetCmdFuture);
JSONObject humidityGetCmdFutureResult = humidityGetCmdFuture.getEventFuture().get();
Double deviceHumidity = humidityGetCmdFutureResult.getJSONObject("result").getDouble("humidity");
JSONObject humidityGetCmdFutureResult = humidityGetCmdFuture.getResponseResult();
Double deviceHumidity = humidityGetCmdFutureResult.getDouble("humidity");
// 判断是否需要除湿若前端设定湿度大于当前湿度则无需开启除湿阀 // 判断是否需要除湿若前端设定湿度大于当前湿度则无需开启除湿阀
if (humidity > deviceHumidity) { if (humidity > deviceHumidity) {
@ -57,7 +57,7 @@ public class DehumidifierStart extends BaseCommandHandler {
// 开启除湿阀门 // 开启除湿阀门
DeviceCommand dehumidifierValveOpenCmd = DeviceCommandGenerator.dehumidifierValveOpen(); // 生成开启除湿阀指令 DeviceCommand dehumidifierValveOpenCmd = DeviceCommandGenerator.dehumidifierValveOpen(); // 生成开启除湿阀指令
CommandFuture dehumidifierValveOpenCmdFuture = deviceCommandService.sendCommand(dehumidifierValveOpenCmd, form, emitter); CommandFuture dehumidifierValveOpenCmdFuture = deviceCommandService.sendCommand(dehumidifierValveOpenCmd, form, emitter);
waitAll(dehumidifierValveOpenCmdFuture.getAckFuture());
commandWait(dehumidifierValveOpenCmdFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStop.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.business; package com.qyft.ms.app.front.cmd.business;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -32,7 +30,7 @@ public class DehumidifierStop extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand dehumidifierStopCommand = DeviceCommandGenerator.dehumidifierValveClose(); // 生成关闭除湿阀指令 DeviceCommand dehumidifierStopCommand = DeviceCommandGenerator.dehumidifierValveClose(); // 生成关闭除湿阀指令
CommandFuture dehumidifierStopCommandFuture = deviceCommandService.sendCommand(dehumidifierStopCommand, form, emitter); CommandFuture dehumidifierStopCommandFuture = deviceCommandService.sendCommand(dehumidifierStopCommand, form, emitter);
waitAll(dehumidifierStopCommandFuture.getAckFuture());
commandWait(dehumidifierStopCommandFuture);
}); });
} }
} }

7
src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java

@ -83,12 +83,7 @@ public class MatrixSprayStart extends BaseCommandHandler {
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand, form, emitter); CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand, form, emitter);
CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(motorYPositionSetCommand, form, emitter); CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(motorYPositionSetCommand, form, emitter);
deviceCommandService.waitForEvent(DeviceEventConstants.MOTOR_X_MOVE_FINISHED, motorZPositionSetCommandFuture);
deviceCommandService.waitForEvent(DeviceEventConstants.MOTOR_Y_MOVE_FINISHED, motorXPositionSetCommandFuture);
deviceCommandService.waitForEvent(DeviceEventConstants.MOTOR_Z_MOVE_FINISHED, motorYPositionSetCommandFuture);
waitAll(motorZPositionSetCommandFuture.getAckFuture(), motorXPositionSetCommandFuture.getAckFuture(),motorYPositionSetCommandFuture.getAckFuture());
waitAllEvent(motorZPositionSetCommandFuture.getEventFuture(), motorXPositionSetCommandFuture.getEventFuture(),motorYPositionSetCommandFuture.getEventFuture());
commandWait(motorZPositionSetCommandFuture, motorXPositionSetCommandFuture,motorYPositionSetCommandFuture);
}); });

18
src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java

@ -3,7 +3,6 @@ package com.qyft.ms.app.front.cmd.business;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.constant.CommandStatus; import com.qyft.ms.system.common.constant.CommandStatus;
import com.qyft.ms.system.common.constant.DeviceEventConstants;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
import com.qyft.ms.system.common.device.command.FrontCommand; import com.qyft.ms.system.common.device.command.FrontCommand;
@ -43,7 +42,7 @@ public class NozzlePipelinePreFill extends BaseCommandHandler {
// 判断z轴是否在安全距离如果不在安全距离则抬升z轴 // 判断z轴是否在安全距离如果不在安全距离则抬升z轴
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获取xyz当前位置指令 DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获取xyz当前位置指令
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter); CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter);
waitAll(motorXyzPositionGetCommandFuture.getAckFuture());
commandWait(motorXyzPositionGetCommandFuture);
JSONObject motorXyzPositionGetCommandFutureResult = motorXyzPositionGetCommandFuture.getAckFuture().get(); JSONObject motorXyzPositionGetCommandFutureResult = motorXyzPositionGetCommandFuture.getAckFuture().get();
JSONObject resultObj = motorXyzPositionGetCommandFutureResult.getJSONObject("result"); JSONObject resultObj = motorXyzPositionGetCommandFutureResult.getJSONObject("result");
@ -58,9 +57,7 @@ public class NozzlePipelinePreFill extends BaseCommandHandler {
emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.SEND, "z轴超出安全距离,抬升z轴至安全距离"), MediaType.APPLICATION_JSON); emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.SEND, "z轴超出安全距离,抬升z轴至安全距离"), MediaType.APPLICATION_JSON);
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(80.0); DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(80.0);
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter);
deviceCommandService.waitForEvent(DeviceEventConstants.MOTOR_Z_MOVE_FINISHED,motorZPositionSetCommandFuture);
waitAll(motorZPositionSetCommandFuture.getAckFuture());
waitAllEvent(motorZPositionSetCommandFuture.getEventFuture());
commandWait(motorZPositionSetCommandFuture);
} }
// x轴移动到废液位置下降z轴高度防止飞溅 // x轴移动到废液位置下降z轴高度防止飞溅
@ -72,26 +69,21 @@ public class NozzlePipelinePreFill extends BaseCommandHandler {
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(70.0); DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(70.0);
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter);
deviceCommandService.waitForEvent(DeviceEventConstants.MOTOR_X_MOVE_FINISHED,motorXPositionSetCommandFuture);
deviceCommandService.waitForEvent(DeviceEventConstants.MOTOR_Z_MOVE_FINISHED,motorZPositionSetCommandFuture);
waitAll(motorXPositionSetCommandFuture.getAckFuture(),motorZPositionSetCommandFuture.getAckFuture());
waitAllEvent(motorXPositionSetCommandFuture.getEventFuture(),motorZPositionSetCommandFuture.getEventFuture());
commandWait(motorXPositionSetCommandFuture, motorZPositionSetCommandFuture);
// 打开三通阀注射器管路 // 打开三通阀注射器管路
DeviceCommand threeWayValveOpenNozzlePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline(); DeviceCommand threeWayValveOpenNozzlePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline();
CommandFuture threeWayValveOpenNozzlePipelineCommandFuture = deviceCommandService.sendCommand(threeWayValveOpenNozzlePipelineCommand, form, emitter); CommandFuture threeWayValveOpenNozzlePipelineCommandFuture = deviceCommandService.sendCommand(threeWayValveOpenNozzlePipelineCommand, form, emitter);
waitAll(threeWayValveOpenNozzlePipelineCommandFuture.getAckFuture());
// 打开喷嘴阀 // 打开喷嘴阀
DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen(); DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen();
CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(nozzleValveOpenCommand, form, emitter); CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(nozzleValveOpenCommand, form, emitter);
waitAll(nozzleValveOpenCommandFuture.getAckFuture());
// 设置注射泵速度推注射泵 // 设置注射泵速度推注射泵
DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(speed); DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(speed);
CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(syringePumpForwardCommand, form, emitter); CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(syringePumpForwardCommand, form, emitter);
waitAll(syringePumpForwardCommandFuture.getAckFuture());
commandWait(threeWayValveOpenNozzlePipelineCommandFuture, nozzleValveOpenCommandFuture, syringePumpForwardCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/DehumidifierValveClose.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class DehumidifierValveClose extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand dehumidifierValveCloseCommand = DeviceCommandGenerator.dehumidifierValveClose();//生成关闭除湿阀指令 DeviceCommand dehumidifierValveCloseCommand = DeviceCommandGenerator.dehumidifierValveClose();//生成关闭除湿阀指令
CommandFuture dehumidifierValveCloseCommandFuture = deviceCommandService.sendCommand(dehumidifierValveCloseCommand, form, emitter); CommandFuture dehumidifierValveCloseCommandFuture = deviceCommandService.sendCommand(dehumidifierValveCloseCommand, form, emitter);
waitAll(dehumidifierValveCloseCommandFuture.getAckFuture());
commandWait(dehumidifierValveCloseCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/DehumidifierValveOpen.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class DehumidifierValveOpen extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand dehumidifierValveOpenCommand = DeviceCommandGenerator.dehumidifierValveOpen(); // 生成开启除湿阀指令 DeviceCommand dehumidifierValveOpenCommand = DeviceCommandGenerator.dehumidifierValveOpen(); // 生成开启除湿阀指令
CommandFuture dehumidifierValveOpenCommandFuture = deviceCommandService.sendCommand(dehumidifierValveOpenCommand, form, emitter); CommandFuture dehumidifierValveOpenCommandFuture = deviceCommandService.sendCommand(dehumidifierValveOpenCommand, form, emitter);
waitAll(dehumidifierValveOpenCommandFuture.getAckFuture());
commandWait(dehumidifierValveOpenCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/HighVoltageClose.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class HighVoltageClose extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); // 生成关闭高压指令 DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); // 生成关闭高压指令
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(highVoltageCloseCommand, form, emitter); CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(highVoltageCloseCommand, form, emitter);
waitAll(highVoltageCloseCommandFuture.getAckFuture());
commandWait(highVoltageCloseCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/HighVoltageOpen.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -32,7 +30,7 @@ public class HighVoltageOpen extends BaseCommandHandler {
Double voltage = form.getDoubleParam("voltage"); Double voltage = form.getDoubleParam("voltage");
DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(voltage); // 生成打开高压指令 DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(voltage); // 生成打开高压指令
CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(highVoltageOpenCommand, form, emitter); CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(highVoltageOpenCommand, form, emitter);
waitAll(highVoltageOpenCommandFuture.getAckFuture());
commandWait(highVoltageOpenCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/LaserControlClose.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class LaserControlClose extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand laserControlCloseCommand = DeviceCommandGenerator.laserControlClose(); // 生成关闭激光指令 DeviceCommand laserControlCloseCommand = DeviceCommandGenerator.laserControlClose(); // 生成关闭激光指令
CommandFuture laserControlCloseCommandFuture = deviceCommandService.sendCommand(laserControlCloseCommand, form, emitter); CommandFuture laserControlCloseCommandFuture = deviceCommandService.sendCommand(laserControlCloseCommand, form, emitter);
waitAll(laserControlCloseCommandFuture.getAckFuture());
commandWait(laserControlCloseCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/LaserControlOpen.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -32,7 +30,7 @@ public class LaserControlOpen extends BaseCommandHandler {
Double power = form.getDoubleParam("power"); Double power = form.getDoubleParam("power");
DeviceCommand laserControlOpenCommand = DeviceCommandGenerator.laserControlOpen(power); // 生成打开激光指令 DeviceCommand laserControlOpenCommand = DeviceCommandGenerator.laserControlOpen(power); // 生成打开激光指令
CommandFuture laserControlOpenCommandFuture = deviceCommandService.sendCommand(laserControlOpenCommand, form, emitter); CommandFuture laserControlOpenCommandFuture = deviceCommandService.sendCommand(laserControlOpenCommand, form, emitter);
waitAll(laserControlOpenCommandFuture.getAckFuture());
commandWait(laserControlOpenCommandFuture);
}); });
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/LightingPanelClose.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class LightingPanelClose extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand lightingPanelCloseCommand = DeviceCommandGenerator.lightingPanelClose(); // 生成关闭照明灯指令 DeviceCommand lightingPanelCloseCommand = DeviceCommandGenerator.lightingPanelClose(); // 生成关闭照明灯指令
CommandFuture lightingPanelCloseCommandFuture = deviceCommandService.sendCommand(lightingPanelCloseCommand, form, emitter); CommandFuture lightingPanelCloseCommandFuture = deviceCommandService.sendCommand(lightingPanelCloseCommand, form, emitter);
waitAll(lightingPanelCloseCommandFuture.getAckFuture());
commandWait(lightingPanelCloseCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/LightingPanelOpen.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class LightingPanelOpen extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand lightingPanelOpenCommand = DeviceCommandGenerator.lightingPanelOpen(); // 生成打开照明灯板指令 DeviceCommand lightingPanelOpenCommand = DeviceCommandGenerator.lightingPanelOpen(); // 生成打开照明灯板指令
CommandFuture lightingPanelOpenCommandFuture = deviceCommandService.sendCommand(lightingPanelOpenCommand, form, emitter); CommandFuture lightingPanelOpenCommandFuture = deviceCommandService.sendCommand(lightingPanelOpenCommand, form, emitter);
waitAll(lightingPanelOpenCommandFuture.getAckFuture());
commandWait(lightingPanelOpenCommandFuture);
}); });
} }
} }

10
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXMove.java

@ -36,12 +36,10 @@ public class MotorXMove extends BaseCommandHandler {
// 获取当前x轴位置 // 获取当前x轴位置
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成电机XYZ相对原点坐标指令 DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成电机XYZ相对原点坐标指令
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter); CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter);
waitAll(motorXyzPositionGetCommandFuture.getAckFuture());
commandWait(motorXyzPositionGetCommandFuture);
JSONObject motorXyzPositionGetCommandResult = motorXyzPositionGetCommandFuture.getAckFuture().get();
JSONObject motorXyzPositionGetCommandResultObj = motorXyzPositionGetCommandResult.getJSONObject("result");
Double xAxisPosition = motorXyzPositionGetCommandResultObj.getDouble("xAxisPosition");
JSONObject motorXyzPositionGetCommandResult = motorXyzPositionGetCommandFuture.getResponseResult();
Double xAxisPosition = motorXyzPositionGetCommandResult.getDouble("xAxisPosition");
// 计算目标位置 // 计算目标位置
double finalPosition = 0.0; double finalPosition = 0.0;
@ -57,7 +55,7 @@ public class MotorXMove extends BaseCommandHandler {
// 生成移动x轴到指定位置指令并发送 // 生成移动x轴到指定位置指令并发送
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(finalPosition, speed); DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(finalPosition, speed);
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand, form, emitter); CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand, form, emitter);
waitAll(motorXPositionSetCommandFuture.getAckFuture());
commandWait(motorXPositionSetCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXOrigin.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class MotorXOrigin extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin(); // x轴回原点 DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin(); // x轴回原点
CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(motorXOriginCommand, form, emitter); CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(motorXOriginCommand, form, emitter);
waitAll(motorXOriginCommandFuture.getAckFuture());
commandWait(motorXOriginCommandFuture);
}); });
} }
} }

4
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXStop.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,7 +29,7 @@ public class MotorXStop extends BaseCommandHandler {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); // 生成x轴停止移动指令 DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); // 生成x轴停止移动指令
CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(motorXStopCommand, form, emitter); CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(motorXStopCommand, form, emitter);
waitAll(motorXStopCommandFuture.getAckFuture());
commandWait(motorXStopCommandFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorXYZPositionGet.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -30,8 +28,8 @@ public class MotorXYZPositionGet extends BaseCommandHandler {
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令 DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令
CommandFuture future = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter);
commandWait(motorXyzPositionGetCommandFuture);
}); });
} }
} }

10
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorYMove.java

@ -10,7 +10,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -36,10 +35,9 @@ public class MotorYMove extends BaseCommandHandler {
// 获取当前Y轴位置 // 获取当前Y轴位置
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令 DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter); CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter);
waitAll(motorXyzPositionGetCommandFuture.getAckFuture());
JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getAckFuture().get();
JSONObject motorXyzPositionGetCommandResultObj = motorXyzPositionGetCommandDeviceResult.getJSONObject("result");
Double yAxisPosition = motorXyzPositionGetCommandResultObj.getDouble("yAxisPosition");
commandWait(motorXyzPositionGetCommandFuture);
JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getResponseResult();
Double yAxisPosition = motorXyzPositionGetCommandDeviceResult.getDouble("yAxisPosition");
// 计算目标位置 // 计算目标位置
double finalPosition = 0.0; double finalPosition = 0.0;
@ -55,7 +53,7 @@ public class MotorYMove extends BaseCommandHandler {
// 生成移动Y轴到指定位置指令并发送 // 生成移动Y轴到指定位置指令并发送
DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(finalPosition, speed); DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(finalPosition, speed);
CommandFuture moveFuture = deviceCommandService.sendCommand(motorYPositionSetCommand, form, emitter); CommandFuture moveFuture = deviceCommandService.sendCommand(motorYPositionSetCommand, form, emitter);
waitAll(moveFuture.getAckFuture());
commandWait(moveFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorYOrigin.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -30,8 +28,8 @@ public class MotorYOrigin extends BaseCommandHandler {
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin(); // 生成Y回原点指令 DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin(); // 生成Y回原点指令
CommandFuture future = deviceCommandService.sendCommand(motorYOriginCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(motorYOriginCommand, form, emitter);
commandWait(motorYOriginCommandFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorYStop.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -30,8 +28,8 @@ public class MotorYStop extends BaseCommandHandler {
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); // 生成Y停止指令 DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); // 生成Y停止指令
CommandFuture future = deviceCommandService.sendCommand(motorYStopCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture motorYStopCommandFuture = deviceCommandService.sendCommand(motorYStopCommand, form, emitter);
commandWait(motorYStopCommandFuture);
}); });
} }
} }

12
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorZMove.java

@ -10,7 +10,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -37,10 +36,9 @@ public class MotorZMove extends BaseCommandHandler {
// 生成获得电机XYZ相对原点坐标指令 // 生成获得电机XYZ相对原点坐标指令
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet();
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter); CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand, form, emitter);
waitAll(motorXyzPositionGetCommandFuture.getAckFuture());
JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getAckFuture().get();
JSONObject motorXyzPositionGetCommandResultObj = motorXyzPositionGetCommandDeviceResult.getJSONObject("result");
Double zAxisPosition = motorXyzPositionGetCommandResultObj.getDouble("zAxisPosition");
commandWait(motorXyzPositionGetCommandFuture);
JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getResponseResult();
Double zAxisPosition = motorXyzPositionGetCommandDeviceResult.getDouble("zAxisPosition");
// 根据方向计算最终位置 // 根据方向计算最终位置
double finalPosition = 0.0; double finalPosition = 0.0;
@ -55,8 +53,8 @@ public class MotorZMove extends BaseCommandHandler {
// 生成移动Z轴到指定位置指令 // 生成移动Z轴到指定位置指令
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(finalPosition, speed); DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(finalPosition, speed);
CommandFuture moveFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter);
waitAll(moveFuture.getAckFuture());
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter);
commandWait(motorZPositionSetCommandFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorZOrigin.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -30,8 +28,8 @@ public class MotorZOrigin extends BaseCommandHandler {
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin(); // 生成Z回原点指令 DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin(); // 生成Z回原点指令
CommandFuture future = deviceCommandService.sendCommand(motorZOriginCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(motorZOriginCommand, form, emitter);
commandWait(motorZOriginCommandFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/MotorZStop.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -30,8 +28,8 @@ public class MotorZStop extends BaseCommandHandler {
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); // 生成Z停止指令 DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); // 生成Z停止指令
CommandFuture future = deviceCommandService.sendCommand(motorZStopCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(motorZStopCommand, form, emitter);
commandWait(motorZStopCommandFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/NozzleValveClose.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -30,8 +28,8 @@ public class NozzleValveClose extends BaseCommandHandler {
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); // 生成关闭喷嘴阀指令 DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); // 生成关闭喷嘴阀指令
CommandFuture future = deviceCommandService.sendCommand(nozzleValveCloseCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture nozzleValveCloseCommandfuture = deviceCommandService.sendCommand(nozzleValveCloseCommand, form, emitter);
commandWait(nozzleValveCloseCommandfuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/NozzleValveOpen.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -30,8 +28,8 @@ public class NozzleValveOpen extends BaseCommandHandler {
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen(); // 生成开启喷嘴阀指令 DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen(); // 生成开启喷嘴阀指令
CommandFuture future = deviceCommandService.sendCommand(nozzleValveOpenCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(nozzleValveOpenCommand, form, emitter);
commandWait(nozzleValveOpenCommandFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/SyringePumpStart.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -32,8 +30,8 @@ public class SyringePumpStart extends BaseCommandHandler {
Double speed = form.getDoubleParam("speed"); Double speed = form.getDoubleParam("speed");
String direction = form.getStringParam("direction"); String direction = form.getStringParam("direction");
DeviceCommand syringePumpStartCommand = DeviceCommandGenerator.syringePumpStart(direction, speed); // 生成移动注射泵指令 DeviceCommand syringePumpStartCommand = DeviceCommandGenerator.syringePumpStart(direction, speed); // 生成移动注射泵指令
CommandFuture future = deviceCommandService.sendCommand(syringePumpStartCommand, form, emitter);
waitAll(future.getAckFuture());
CommandFuture syringePumpStartCommandFuture = deviceCommandService.sendCommand(syringePumpStartCommand, form, emitter);
commandWait(syringePumpStartCommandFuture);
}); });
} }
} }

8
src/main/java/com/qyft/ms/app/front/cmd/debug/ThreeWayValveCloseAll.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -29,9 +27,9 @@ public class ThreeWayValveCloseAll extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand command = DeviceCommandGenerator.threeWayValveCloseAll(); // 生成全部关闭三通阀指令
CommandFuture future = deviceCommandService.sendCommand(command, form, emitter);
waitAll(future.getAckFuture());
DeviceCommand threeWayValveCloseAllCommand = DeviceCommandGenerator.threeWayValveCloseAll(); // 生成全部关闭三通阀指令
CommandFuture threeWayValveCloseAllCommandFuture = deviceCommandService.sendCommand(threeWayValveCloseAllCommand, form, emitter);
commandWait(threeWayValveCloseAllCommandFuture);
}); });
} }
} }

8
src/main/java/com/qyft/ms/app/front/cmd/debug/ThreeWayValveOpenNuzzlePipeline.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -29,9 +27,9 @@ public class ThreeWayValveOpenNuzzlePipeline extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand command = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline(); // 生成打开喷嘴管路指令
CommandFuture future = deviceCommandService.sendCommand(command, form, emitter);
waitAll(future.getAckFuture());
DeviceCommand threeWayValveOpenNozzlePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline(); // 生成打开喷嘴管路指令
CommandFuture threeWayValveOpenNozzlePipelineCommandFuture = deviceCommandService.sendCommand(threeWayValveOpenNozzlePipelineCommand, form, emitter);
commandWait(threeWayValveOpenNozzlePipelineCommandFuture);
}); });
} }
} }

8
src/main/java/com/qyft/ms/app/front/cmd/debug/ThreeWayValveOpenSyringePipeline.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -29,9 +27,9 @@ public class ThreeWayValveOpenSyringePipeline extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand command = DeviceCommandGenerator.threeWayValveOpenSyringePipeline(); // 生成打开注射器管路指令
CommandFuture future = deviceCommandService.sendCommand(command, form, emitter);
waitAll(future.getAckFuture());
DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenSyringePipeline(); // 生成打开注射器管路指令
CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(threeWayValveOpenSyringePipelineCommand, form, emitter);
commandWait(threeWayValveOpenSyringePipelineCommandFuture);
}); });
} }
} }

8
src/main/java/com/qyft/ms/app/front/cmd/debug/WashValveClose.java

@ -1,6 +1,5 @@
package com.qyft.ms.app.front.cmd.debug; package com.qyft.ms.app.front.cmd.debug;
import cn.hutool.json.JSONObject;
import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
@ -10,7 +9,6 @@ import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService; import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -29,9 +27,9 @@ public class WashValveClose extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand command = DeviceCommandGenerator.washValveClose(); // 生成关闭清洗阀指令
CommandFuture future = deviceCommandService.sendCommand(command, form, emitter);
waitAll(future.getAckFuture());
DeviceCommand washValveCloseCommand = DeviceCommandGenerator.washValveClose(); // 生成关闭清洗阀指令
CommandFuture washValveCloseCommandFuture = deviceCommandService.sendCommand(washValveCloseCommand, form, emitter);
commandWait(washValveCloseCommandFuture);
}); });
} }
} }

6
src/main/java/com/qyft/ms/app/front/cmd/debug/WashValveOpen.java

@ -29,9 +29,9 @@ public class WashValveOpen extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> { return runAsync(() -> {
DeviceCommand command = DeviceCommandGenerator.washValveOpen(); // 生成打开清洗阀指令
CommandFuture future = deviceCommandService.sendCommand(command, form, emitter);
waitAll(future.getAckFuture());
DeviceCommand washValveOpenCommand = DeviceCommandGenerator.washValveOpen(); // 生成打开清洗阀指令
CommandFuture washValveOpenCommandFuture = deviceCommandService.sendCommand(washValveOpenCommand, form, emitter);
commandWait(washValveOpenCommandFuture);
}); });
} }
} }

18
src/main/java/com/qyft/ms/system/common/device/command/CommandFuture.java

@ -4,6 +4,7 @@ import cn.hutool.json.JSONObject;
import lombok.Getter; import lombok.Getter;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@Getter @Getter
@ -25,17 +26,26 @@ public class CommandFuture {
} }
/** /**
* 完成event反馈
* 完成response反馈
*/ */
public void completeResponse(JSONObject result) { public void completeResponse(JSONObject result) {
responseFuture.complete(result); responseFuture.complete(result);
} }
/**
* 获取ack反馈的json
*/
public JSONObject getAckResult() throws ExecutionException, InterruptedException {
return ackFuture.get();
}
/** /**
* 等待指令反馈
* 获取response反馈的json
*/ */
public void commandWait() {
responseFuture.orTimeout(5, TimeUnit.SECONDS).join();
public JSONObject getResponseResult() throws ExecutionException, InterruptedException {
return responseFuture.get();
} }
} }

5
src/main/java/com/qyft/ms/system/core/handler/BaseCommandHandler.java

@ -16,12 +16,13 @@ public abstract class BaseCommandHandler implements CommandHandler {
return CompletableFuture.runAsync(LambdaUtil.unchecked(task)); return CompletableFuture.runAsync(LambdaUtil.unchecked(task));
} }
protected void commandWaitAll(CommandFuture... futures) {
protected void commandWait(CommandFuture... futures) {
CompletableFuture<?>[] responseFutures = Arrays.stream(futures) CompletableFuture<?>[] responseFutures = Arrays.stream(futures)
.map(CommandFuture::getResponseFuture) .map(CommandFuture::getResponseFuture)
.toArray(CompletableFuture[]::new); .toArray(CompletableFuture[]::new);
CompletableFuture.allOf(responseFutures) CompletableFuture.allOf(responseFutures)
.orTimeout(5, TimeUnit.SECONDS)
.orTimeout(120, TimeUnit.SECONDS)
.join(); .join();
} }

2
src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

@ -66,7 +66,7 @@ public class DeviceCommandService {
throw new RuntimeException(message); throw new RuntimeException(message);
} }
frontCommandService.sendToFront(emitter, form, CommandStatus.RESULT, deviceCommand.getCommandName() + "指令,设备response正常", result); frontCommandService.sendToFront(emitter, form, CommandStatus.RESULT, deviceCommand.getCommandName() + "指令,设备response正常", result);
return result;
return result.get("data");
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

Loading…
Cancel
Save