Browse Source

fix:每次喷涂等待时也可以暂停,恢复时继续等待完毕剩下的时间

master
白凤吉 2 weeks ago
parent
commit
c59d3fc5dc
  1. 44
      src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java
  2. 10
      src/main/java/com/qyft/ms/app/device/status/SprayTask.java

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

@ -85,9 +85,9 @@ public class SprayTaskExecutor {
for (SprayTimes sprayTimes : sprayTaskParam.getTimes()) {//每个拨片有多次喷涂循环每次喷涂
if (sprayNum < sprayTask.getSprayNum()) {
sprayNum++;
if("grid".equals(sprayTimes.getMatrixPathType())){//判断本次是否是田字格
if ("grid".equals(sprayTimes.getMatrixPathType())) {//判断本次是否是田字格
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 2);
}else{
} else {
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 1);
}
continue;
@ -174,11 +174,11 @@ public class SprayTaskExecutor {
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture);
sprayTask.setCurrentCountSprayNum(sprayTask.getCurrentCountSprayNum() + 1);
if (sprayTimes.getGridDelay() != null) {
delay(sprayTimes.getGridDelay() * 1000);
if ("grid".equals(sprayTimes.getMatrixPathType()) && sprayTimes.getGridDelay() != null) {
delay(2, sprayTimes.getGridDelay() * 1000);
}
}
delay(sprayTimes.getDelay() * 1000);
delay(1, sprayTimes.getDelay() * 1000);
sprayNum++;
sprayTask.setSprayNum(sprayNum);
sprayTask.setCurrentStep(0);
@ -306,6 +306,38 @@ public class SprayTaskExecutor {
}
private void delay(long millisecond) throws InterruptedException {
Thread.sleep(millisecond);
delay(null, millisecond);
}
/**
* @param type 1每次喷涂睡眠 2田字格睡眠
*/
private void delay(Integer type, long millisecond) throws InterruptedException {
SprayTask task = SprayTask.getInstance();
long remaining = millisecond;
if (type != null) {
if (type == 1 && task.getRemainingDelay() != null) {//每次喷涂睡眠
remaining = task.getRemainingDelay();
} else if (type == 2 && task.getRemainingGridDelay() != null) {//田字格睡眠
remaining = task.getRemainingGridDelay();
}
}
long chunk = 100;
while (remaining > 0) {
long sleepTime = Math.min(chunk, remaining);
try {
Thread.sleep(sleepTime);
remaining -= sleepTime;
} catch (InterruptedException e) {
if (type != null) { //中断时把还没睡完的时间存起来再向上抛
if (type == 1) {//每次喷涂睡眠
task.setRemainingDelay(remaining);
} else if (type == 2) {//田字格睡眠
task.setRemainingGridDelay(remaining);
}
}
throw e;
}
}
}
}

10
src/main/java/com/qyft/ms/app/device/status/SprayTask.java

@ -45,6 +45,14 @@ public class SprayTask {
*/
private Point3D currentPausedPoint = null;
/**
* 田字格等待剩余毫秒数
*/
private volatile Long remainingGridDelay = null;
/**
* 一次喷涂完毕等待剩余毫秒数
*/
private volatile Long remainingDelay = null;
/**
* 当前喷涂任务所有参数
*/
private List<SprayTaskParams> sprayTaskParams = null;
@ -94,6 +102,8 @@ public class SprayTask {
sprayNum = 0;
currentCountSprayNum = 1;
operationLogId = null;
remainingGridDelay = null;
remainingDelay = null;
sprayTaskSprayedList.clear();
}

Loading…
Cancel
Save