Browse Source

fix:开启关闭喷嘴阀需要延迟10秒

master
白凤吉 4 days ago
parent
commit
2ce9a6d2b6
  1. 21
      src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java
  2. 21
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java

21
src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java

@ -173,10 +173,7 @@ public class SprayTaskExecutor {
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageCloseCommand);
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpStopCommand);
delay(10 * 1000L);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveCloseCommand);
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture);
commandWait(syringePumpStopCommandFuture, highVoltageCloseCommandFuture);
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 1);
if ("grid".equals(sprayTimes.getMatrixPathType()) && sprayTimes.getGridDelay() != null) {
@ -196,10 +193,16 @@ public class SprayTaskExecutor {
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageCloseCommand);
commandWait(highVoltageCloseCommandFuture);
Thread.sleep(500);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose();//关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveCloseCommand);
commandWait(nozzleValveCloseCommandFuture);
CompletableFuture<Void> nozzleCloseFuture = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(10 * 1000L);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveCloseCommand);
commandWait(nozzleValveCloseCommandFuture);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
sprayTask.setCannotPause(true);//喷涂完毕后就是回原点了期间不可暂停
//XYZ回原点
@ -210,7 +213,7 @@ public class SprayTaskExecutor {
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYOriginCommand);
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZOriginCommand);
commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture);
nozzleCloseFuture.get();
OperationLog operationLog = operationLogService.getById(sprayTask.getOperationLogId());
operationLog.setStatus(1);
operationLogService.updateById(operationLog);

21
src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java

@ -49,17 +49,27 @@ public class MatrixSprayStop extends BaseCommandHandler {
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.SPRAY_TASK_FINISH, "喷涂任务结束"));
return runAsync(() -> {
try{
try {
sprayTask.setClose(true);
sprayTaskExecutor.stopTask();//终止喷涂任务线程
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStopCommand);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveCloseCommand);
CompletableFuture<Void> nozzleCloseFuture = CompletableFuture.runAsync(() -> {
try {
Thread.sleep(10 * 1000L);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveCloseCommand);
commandWait(nozzleValveCloseCommandFuture);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); //关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageCloseCommand);
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture);
commandWait(syringePumpStopCommandFuture, highVoltageCloseCommandFuture);
DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); //x轴停止移动
DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); //y轴停止移动
@ -81,7 +91,8 @@ public class MatrixSprayStop extends BaseCommandHandler {
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYOriginCommand);
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZOriginCommand);
commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture);
}finally {
nozzleCloseFuture.get();
} finally {
sprayTask.clear();
deviceStatus.setSpraying(false);
deviceStatus.setPaused(false);

Loading…
Cancel
Save