Browse Source

fix:修复暂停时阀门状态不正确的问题

master
白凤吉 3 weeks ago
parent
commit
a7d78f6e90
  1. 56
      src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java

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

@ -85,6 +85,11 @@ public class SprayTaskExecutor {
for (SprayTimes sprayTimes : sprayTaskParam.getTimes()) {//每个拨片有多次喷涂循环每次喷涂
if (sprayNum < sprayTask.getSprayNum()) {
sprayNum++;
if("grid".equals(sprayTimes.getMatrixPathType())){//判断本次是否是田字格
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 2);
}else{
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 1);
}
continue;
}
sprayTask.setSprayTimes(sprayTimes);
@ -107,28 +112,24 @@ public class SprayTaskExecutor {
commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetAboveSlideCommandFuture);
}
DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline();//打开三通阀注射器管路
DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline();//三通阀切换到注射器管路
CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), threeWayValveOpenSyringePipelineCommand);
DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen();//开启喷嘴阀
CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveOpenCommand);
commandWait(threeWayValveOpenSyringePipelineCommandFuture, nozzleValveOpenCommandFuture);
delay(500);
//判断是否有暂停的点位如果有则还原暂停时的点位
Point3D currentPausedPoint = sprayTask.getCurrentPausedPoint();
if (currentPausedPoint != null) {
DeviceCommand motorXRestoreCommand = DeviceCommandGenerator.motorXPositionSet(currentPausedPoint.x, 20.0);
DeviceCommand motorYRestoreCommand = DeviceCommandGenerator.motorYPositionSet(currentPausedPoint.y, 20.0);
DeviceCommand motorZRestoreCommand = DeviceCommandGenerator.motorZPositionSet(currentPausedPoint.z, 20.0);
CommandFuture motorXRestoreCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXRestoreCommand);
CommandFuture motorYRestoreCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYRestoreCommand);
CommandFuture motorZRestoreCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZRestoreCommand);
commandWait(motorXRestoreCommandFuture, motorYRestoreCommandFuture, motorZRestoreCommandFuture);
sprayTask.setCurrentPausedPoint(null);
}
// Point3D currentPausedPoint = sprayTask.getCurrentPausedPoint();
// if (currentPausedPoint != null) {
// DeviceCommand motorXRestoreCommand = DeviceCommandGenerator.motorXPositionSet(currentPausedPoint.x, 20.0);
// DeviceCommand motorYRestoreCommand = DeviceCommandGenerator.motorYPositionSet(currentPausedPoint.y, 20.0);
// DeviceCommand motorZRestoreCommand = DeviceCommandGenerator.motorZPositionSet(currentPausedPoint.z, 20.0);
// CommandFuture motorXRestoreCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXRestoreCommand);
// CommandFuture motorYRestoreCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYRestoreCommand);
// CommandFuture motorZRestoreCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZRestoreCommand);
// commandWait(motorXRestoreCommandFuture, motorYRestoreCommandFuture, motorZRestoreCommandFuture);
// sprayTask.setCurrentPausedPoint(null);
// }
//因为走的是折所以单词指令只需要移动x或y缓存上一个点位用来判断本次是走x还是y
//因为走的是折线所以单次指令只需要移动x或y缓存上一个点位用来判断本次是走x还是y
double cacheXPoint = -1;
double cacheYPoint = -1;
int currentStep = 0; //记录当前线程喷涂步骤序号
@ -139,6 +140,10 @@ public class SprayTaskExecutor {
commandWait(highVoltageOpenCommandFuture);
}
DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen();//开启喷嘴阀
CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveOpenCommand);
commandWait(threeWayValveOpenSyringePipelineCommandFuture, nozzleValveOpenCommandFuture);
DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(sprayTimes.getVolume());//推动移动注射泵
CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpForwardCommand);
commandWait(syringePumpForwardCommandFuture);
@ -172,12 +177,17 @@ public class SprayTaskExecutor {
}
//一次喷涂完毕后停止推注射泵
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpStopCommand);
commandWait(syringePumpStopCommandFuture);
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpStopCommand);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveCloseCommand);
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); //关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageCloseCommand);
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture);
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 1);
if (sprayTimes.getGridDelay() != null) {
delay(sprayTimes.getGridDelay() * 1000);
}
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 1);
}
sprayNum++;
sprayTask.setSprayNum(sprayNum);
@ -306,11 +316,7 @@ public class SprayTaskExecutor {
return sprayTaskStepList;
}
private void delay(long millisecond) {
try {
private void delay(long millisecond) throws InterruptedException {
Thread.sleep(millisecond);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Loading…
Cancel
Save