From 3ef1c33f5634c24229992960e224779b472f313f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Fri, 21 Mar 2025 07:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E4=B9=9F=E4=B8=8D=E7=9F=A5=E9=81=93?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E4=BB=80=E4=B9=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/app/device/spray/SprayTaskExecutor.java | 16 +++++++++++-- .../app/front/cmd/business/MatrixSprayStart.java | 28 ++++++++++------------ 2 files changed, 26 insertions(+), 18 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 d5a52b3..9088c1b 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 @@ -146,15 +146,27 @@ public class SprayTaskExecutor { sprayTask.setSuspendable(true);//可以暂停,单次喷涂范围内可以进行暂停 deviceStatus.setSuspendable(true); + double cacheXPoint = -1; + double cacheYPoint = -1; for (int i = 0; i < sprayTaskStep.getSpraySteps().size(); i++) {//单次喷涂 if (currentStep < reCurrentStep) { continue; } List sprayStepCommands = sprayTaskStep.getSpraySteps().get(i); List commandFutureList = new ArrayList<>(); + double aXPoint = (double) sprayStepCommands.get(0).getParam().get("position"); + double aYPoint = (double) sprayStepCommands.get(1).getParam().get("position"); for (DeviceCommand sprayStep : sprayStepCommands) { - CommandFuture commandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), sprayStep); - commandFutureList.add(commandFuture); + if(cacheXPoint != aXPoint){ + CommandFuture commandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), sprayStep); + commandFutureList.add(commandFuture); + cacheXPoint = aXPoint; + } + if(cacheYPoint != aYPoint){ + CommandFuture commandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), sprayStep); + commandFutureList.add(commandFuture); + cacheYPoint = aYPoint; + } } CommandFuture[] commandFutureArray = commandFutureList.toArray(new CommandFuture[0]); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java index b21861f..9a6073d 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java @@ -208,13 +208,12 @@ public class MatrixSprayStart extends BaseCommandHandler { for (int j = 0; j < pathList.size(); j++) { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - if (j == 0) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 - } if (j == pathList.size() - 1) { deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), 20.0));//移动x轴 deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), 20.0));//移动y轴 + }else{ + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 } deviceCommandList.add(deviceCommands); } @@ -246,13 +245,12 @@ public class MatrixSprayStart extends BaseCommandHandler { for (int j = 0; j < pathList.size(); j++) { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - if (j == 0) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 - } if (j == pathList.size() - 1) { deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), 20.0));//移动x轴 deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), 20.0));//移动y轴 + }else{ + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 } deviceCommandList.add(deviceCommands); } @@ -283,13 +281,12 @@ public class MatrixSprayStart extends BaseCommandHandler { for (int j = 0; j < pathList.size(); j++) { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - if (j == 0) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 - } if (j == pathList.size() - 1) { deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), 20.0));//移动x轴 deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), 20.0));//移动y轴 + }else{ + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 } deviceCommandList.add(deviceCommands); } @@ -307,13 +304,12 @@ public class MatrixSprayStart extends BaseCommandHandler { for (int j = 0; j < pathList.size(); j++) { PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - if (j == 0) { - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 - } if (j == pathList.size() - 1) { deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), 20.0));//移动x轴 deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), 20.0));//移动y轴 + }else{ + deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 + deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 } deviceCommandList.add(deviceCommands); }