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 5e421a9..3d87241 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 @@ -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; + } + } } } diff --git a/src/main/java/com/qyft/ms/app/device/status/SprayTask.java b/src/main/java/com/qyft/ms/app/device/status/SprayTask.java index 0c45d64..977d0b6 100644 --- a/src/main/java/com/qyft/ms/app/device/status/SprayTask.java +++ b/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 = null; @@ -94,6 +102,8 @@ public class SprayTask { sprayNum = 0; currentCountSprayNum = 1; operationLogId = null; + remainingGridDelay = null; + remainingDelay = null; sprayTaskSprayedList.clear(); }