From a7d78f6e90f9d0cf78b6f777152d4b7f16667db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Thu, 17 Jul 2025 17:30:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E6=97=B6=E9=98=80=E9=97=A8=E7=8A=B6=E6=80=81=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/app/device/spray/SprayTaskExecutor.java | 62 ++++++++++++---------- 1 file changed, 34 insertions(+), 28 deletions(-) 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); } }