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 6d828c3..3b5bf5e 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,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); @@ -92,7 +97,7 @@ public class SprayTaskExecutor { List sprayTaskStepList = getSprayPath(sprayTimes);//计算本次喷涂的路线 - if(sprayTask.getCurrentStep() == 0){ + if (sprayTask.getCurrentStep() == 0) { //先移动到玻片左上角位置 DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskParam.getIndex()][0], 20.0); DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(slideArr[sprayTaskParam.getIndex()][1], 20.0); @@ -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); @@ -171,13 +176,18 @@ public class SprayTaskExecutor { sprayTask.setCurrentStep(currentStep); } //一次喷涂完毕后停止推注射泵 - DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop();//停止推动注射泵 - CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpStopCommand); - commandWait(syringePumpStopCommandFuture); + DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵 + 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 { - Thread.sleep(millisecond); - } catch (Exception e) { - throw new RuntimeException(e); - } + private void delay(long millisecond) throws InterruptedException { + Thread.sleep(millisecond); } }