From ff106bc2ecca359dbd7556267ee804f14ae4c021 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 06:58:26 +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/controller/SprayTaskController.java | 2 + .../qyft/ms/app/device/spray/SensorCollector.java | 2 +- .../ms/app/device/spray/SprayTaskExecutor.java | 70 +++++++++++++++--- .../app/front/cmd/business/DehumidifierStart.java | 2 +- .../ms/app/front/cmd/business/DeviceSelfTest.java | 2 +- .../front/cmd/business/MatrixSprayChangeParam.java | 6 +- .../app/front/cmd/business/MatrixSprayStart.java | 82 +++++++++++++++------- .../front/cmd/business/NozzlePipelinePreFill.java | 10 +++ .../cmd/business/NozzlePipelinePreFillStop.java | 5 ++ .../app/front/cmd/business/NozzlePipelineWash.java | 5 ++ .../front/cmd/business/SyringePipelineWash.java | 19 ++++- .../cmd/business/SyringePipelineWashStop.java | 10 +++ .../qyft/ms/app/model/vo/SprayTaskStatusVO.java | 9 ++- 13 files changed, 179 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/qyft/ms/app/controller/SprayTaskController.java b/src/main/java/com/qyft/ms/app/controller/SprayTaskController.java index b90ad06..67e9650 100644 --- a/src/main/java/com/qyft/ms/app/controller/SprayTaskController.java +++ b/src/main/java/com/qyft/ms/app/controller/SprayTaskController.java @@ -23,6 +23,8 @@ public class SprayTaskController { public Result getStatus() { SprayTask sprayTask = SprayTask.getInstance(); SprayTaskStatusVO sprayTaskStatusVO = new SprayTaskStatusVO(); + sprayTaskStatusVO.setCmdId(sprayTask.getCmdId()); + sprayTaskStatusVO.setCmdCode(sprayTask.getCmdCode()); sprayTaskStatusVO.setSprayTaskSprayedList(sprayTask.getSprayTaskSprayedList()); sprayTaskStatusVO.setSprayParams(sprayTask.getCacheParams()); return Result.success(sprayTaskStatusVO); diff --git a/src/main/java/com/qyft/ms/app/device/spray/SensorCollector.java b/src/main/java/com/qyft/ms/app/device/spray/SensorCollector.java index f13ca9e..46f815c 100644 --- a/src/main/java/com/qyft/ms/app/device/spray/SensorCollector.java +++ b/src/main/java/com/qyft/ms/app/device/spray/SensorCollector.java @@ -33,7 +33,7 @@ public class SensorCollector { CommandFuture humidityGetCmdFuture = deviceCommandService.sendCommandNoFront(humidityGetCmd); commandWait(humidityGetCmdFuture); JSONObject humidityGetCmdFutureResult = humidityGetCmdFuture.getResponseResult(); - Double deviceHumidity = humidityGetCmdFutureResult.getDouble("humidity"); + Double deviceHumidity = humidityGetCmdFutureResult.getJSONObject("data").getDouble("humidity"); Map map = new HashMap<>(); map.put("humidity", deviceHumidity); webSocketService.pushMsgNoLog(WebSocketMessageType.SENSOR, map); 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 009d327..d5a52b3 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 @@ -81,13 +81,13 @@ public class SprayTaskExecutor { CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYPositionSetCommand); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetCommand); commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetCommandFuture); - - SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "slide_height")); - Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); - Double height = slideHeight - sprayTask.getSprayParams().getMotorZHeight(); - DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height); - CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetAboveSlideCommand); - commandWait(motorZPositionSetAboveSlideCommandFuture); +// +// SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "slide_height")); +// Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); +// Double height = slideHeight - sprayTask.getSprayParams().getMotorZHeight();//下降z轴高度 +// DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height); +// CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetAboveSlideCommand); +// commandWait(motorZPositionSetAboveSlideCommandFuture); DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenSyringePipeline();//打开三通阀喷嘴管路 CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), threeWayValveOpenSyringePipelineCommand); @@ -100,15 +100,45 @@ public class SprayTaskExecutor { } sprayTask.setSprayPreStepsCompleted(true); } - DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen();//开启喷嘴阀 CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveOpenCommand); commandWait(nozzleValveOpenCommandFuture); + int reCurrentStep = sprayTask.getCurrentStep(); int currentStep = 0; //当前喷涂步骤 int sprayNum = 1; for (SprayTaskStep sprayTaskStep : sprayTask.getSprayTaskStepList()) {//循环进行多次喷涂 + //加快速度 +// DeviceCommand motorXSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorXSpeedSet(20.0);//x轴电机速度设置 +// DeviceCommand motorYSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorYSpeedSet(20.0);//y轴电机速度设置 +// DeviceCommand motorZSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorZSpeedSet(20.0);//z轴电机速度设置 +// CommandFuture motorXSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXSpeedSetCmdToDeviceCommand); +// CommandFuture motorYSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYSpeedSetCmdToDeviceCommand); +// CommandFuture motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZSpeedSetCmdToDeviceCommand); +// commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture); + //先移动到玻片位置 + DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskStep.getIndex()][0],20.0); + DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(slideArr[sprayTaskStep.getIndex()][1],20.0); + CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXPositionSetCommand); + CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYPositionSetCommand); + + SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "slide_height")); + Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); + Double height = slideHeight - sprayTask.getSprayParams().getMotorZHeight();//下降z轴高度 + DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height,15.0); + CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetAboveSlideCommand); + commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetAboveSlideCommandFuture); + + //还原速度 +// motorXSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorXSpeedSet(sprayTask.getSprayParams().getMovingSpeed());//x轴电机速度设置 +// motorYSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorYSpeedSet(sprayTask.getSprayParams().getMovingSpeed());//y轴电机速度设置 +// motorZSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorZSpeedSet(sprayTask.getSprayParams().getMovingSpeed());//y轴电机速度设置 +// motorXSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXSpeedSetCmdToDeviceCommand); +// motorYSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYSpeedSetCmdToDeviceCommand); +// motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZSpeedSetCmdToDeviceCommand); +// commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture); + DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(sprayTask.getSprayParams().getVolume());//推动移动注射泵 CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpForwardCommand); commandWait(syringePumpForwardCommandFuture); @@ -170,15 +200,33 @@ public class SprayTaskExecutor { CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveCloseCommand); commandWait(nozzleValveCloseCommandFuture); + //加快速度 +// DeviceCommand motorXSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorXSpeedSet(20.0);//x轴电机速度设置 +// DeviceCommand motorYSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorYSpeedSet(20.0);//y轴电机速度设置 +// DeviceCommand motorZSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorZSpeedSet(20.0);//y轴电机速度设置 +// CommandFuture motorXSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXSpeedSetCmdToDeviceCommand); +// CommandFuture motorYSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYSpeedSetCmdToDeviceCommand); +// CommandFuture motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZSpeedSetCmdToDeviceCommand); +// commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture); + //XYZ回原点 - DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(0.0); - DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(0.0); - DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(0.0); + DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(0.0,20.0); + DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(0.0,20.0); + DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(0.0,15.0); CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXPositionSetCommand); CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYPositionSetCommand); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetCommand); commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetCommandFuture); + //还原速度 +// motorXSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorXSpeedSet(sprayTask.getSprayParams().getMovingSpeed());//x轴电机速度设置 +// motorYSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorYSpeedSet(sprayTask.getSprayParams().getMovingSpeed());//y轴电机速度设置 +// motorZSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorZSpeedSet(sprayTask.getSprayParams().getMovingSpeed());//y轴电机速度设置 +// motorXSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXSpeedSetCmdToDeviceCommand); +// motorYSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYSpeedSetCmdToDeviceCommand); +// motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZSpeedSetCmdToDeviceCommand); +// commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture); + SprayTask.getInstance().clear(); deviceStatus.setSpraying(false); deviceStatus.setSuspendable(false); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStart.java b/src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStart.java index 5981b6e..b567c53 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStart.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/DehumidifierStart.java @@ -49,7 +49,7 @@ public class DehumidifierStart extends BaseCommandHandler { commandWait(humidityGetCmdFuture); JSONObject humidityGetCmdFutureResult = humidityGetCmdFuture.getResponseResult(); - Double deviceHumidity = humidityGetCmdFutureResult.getDouble("humidity"); + Double deviceHumidity = humidityGetCmdFutureResult.getJSONObject("data").getDouble("humidity"); // 判断是否需要除湿:若前端设定湿度大于当前湿度,则无需开启除湿阀 if (humidity > deviceHumidity) { diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java b/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java index 1817441..99bf02b 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java @@ -41,7 +41,7 @@ public class DeviceSelfTest extends BaseCommandHandler { commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture); try { if (motorXOriginCommandFuture.getResponseResult().getBool("status")) { - selfTestService.getSelfTestStatus().setXAxisAtOrigin(false); + selfTestService.getSelfTestStatus().setXAxisAtOrigin(true); } if (motorYOriginCommandFuture.getResponseResult().getBool("status")) { selfTestService.getSelfTestStatus().setYAxisAtOrigin(true); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java index 0184134..8f74425 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java @@ -57,9 +57,9 @@ public class MatrixSprayChangeParam extends BaseCommandHandler { CommandFuture motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZSpeedSetCmdToDeviceCommand); commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture); //2.流速 - DeviceCommand syringePumpVolumeSetCommand = DeviceCommandGenerator.syringePumpVolumeSet(volume);//注射泵流速设置 - CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpVolumeSetCommand); - commandWait(syringePumpVolumeSetCommandFuture); +// DeviceCommand syringePumpVolumeSetCommand = DeviceCommandGenerator.syringePumpVolumeSet(volume);//注射泵流速设置 +// CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpVolumeSetCommand); +// commandWait(syringePumpVolumeSetCommandFuture); //3.z轴高度 SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "slide_height")); Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); 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 7cc5117..b21861f 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 @@ -54,15 +54,15 @@ public class MatrixSprayStart extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; private void nonNullCheck(String cmdId, String cmdCode, - String matrixPathType, - Double motorZHeight, - Double gasPressure, - Double volume, - Boolean highVoltage, - Double spacing, - Double movingSpeed, - Double times, - Object position) { + String matrixPathType, + Double motorZHeight, + Double gasPressure, + Double volume, + Boolean highVoltage, + Double spacing, + Double movingSpeed, + Double times, + Object position) { Map paramMap = new LinkedHashMap<>(); paramMap.put("matrix_path_type", matrixPathType); @@ -159,9 +159,9 @@ public class MatrixSprayStart extends BaseCommandHandler { CommandFuture motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZSpeedSetCmdToDeviceCommand); commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture); //2.流速 - DeviceCommand syringePumpVolumeSetCommand = DeviceCommandGenerator.syringePumpVolumeSet(sprayTask.getSprayParams().getVolume());//注射泵流速设置 - CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpVolumeSetCommand); - commandWait(syringePumpVolumeSetCommandFuture); +// DeviceCommand syringePumpVolumeSetCommand = DeviceCommandGenerator.syringePumpVolumeSet(sprayTask.getSprayParams().getVolume());//注射泵流速设置 +// CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpVolumeSetCommand); +// commandWait(syringePumpVolumeSetCommandFuture); // 7.循环喷涂区域 Position slidePosition1 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position1")); @@ -181,8 +181,8 @@ public class MatrixSprayStart extends BaseCommandHandler { Double[] slide = slideArr[index];//获取玻片的坐标 //规划路线坐标 DecimalFormat df = new DecimalFormat("#.##"); - double left = Double.parseDouble(df.format( slide[0] + upperLeft[0])); - double right = Double.parseDouble(df.format( slide[0] + lowerRight[0])); + double left = Double.parseDouble(df.format(slide[0] + upperLeft[0])); + double right = Double.parseDouble(df.format(slide[0] + lowerRight[0])); double top = Double.parseDouble(df.format(slide[1] + upperLeft[1])); double bottom = Double.parseDouble(df.format(slide[1] + lowerRight[1])); if ("horizontal".equals(matrixPathType)) {//喷涂路径类型 horizontal 横向 | vertical 纵向 | grid 网格先横向后纵向 @@ -204,12 +204,21 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.MoveMode.HORIZONTAL_ZIGZAG_TOP_DOWN ); List> deviceCommandList = new ArrayList<>(); - for (PathGenerator.Points p : pathList) {//喷针移动目标位置 + + for (int j = 0; j < pathList.size(); j++) { + PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 + 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轴 + } deviceCommandList.add(deviceCommands); } + SprayTaskStep sprayTaskStep = new SprayTaskStep(); sprayTaskStep.setIndex(index); sprayTaskStep.setSpraySteps(deviceCommandList); @@ -234,10 +243,17 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT ); List> deviceCommandList = new ArrayList<>(); - for (PathGenerator.Points p : pathList) {//喷针移动目标位置 + for (int j = 0; j < pathList.size(); j++) { + PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 + 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轴 + } deviceCommandList.add(deviceCommands); } SprayTaskStep sprayTaskStep = new SprayTaskStep(); @@ -264,10 +280,17 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.MoveMode.HORIZONTAL_ZIGZAG_TOP_DOWN ); List> deviceCommandList = new ArrayList<>(); - for (PathGenerator.Points p : pathList) {//喷针移动目标位置 + for (int j = 0; j < pathList.size(); j++) { + PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 + 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轴 + } deviceCommandList.add(deviceCommands); } SprayTaskStep sprayTaskStep = new SprayTaskStep(); @@ -281,10 +304,17 @@ public class MatrixSprayStart extends BaseCommandHandler { PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT ); deviceCommandList = new ArrayList<>(); - for (PathGenerator.Points p : pathList) {//喷针移动目标位置 + for (int j = 0; j < pathList.size(); j++) { + PathGenerator.Points p = pathList.get(j); List deviceCommands = new ArrayList<>(); - deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴 - deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴 + 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轴 + } deviceCommandList.add(deviceCommands); } SprayTaskStep sprayTaskStep2 = new SprayTaskStep(); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java index aaca822..2fa9481 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java @@ -48,6 +48,10 @@ public class NozzlePipelinePreFill extends BaseCommandHandler { webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "参数 speed 必填")); throw new RuntimeException("参数 speed 必填"); } + if (speed > 100) { + webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "预充速度不能大于100")); + throw new RuntimeException("预充速度不能大于100"); + } deviceStatus.setPrefilling(true); return runAsync(() -> { //2.判断z轴是否在安全距离,如果不在安全距离可以不抬升z轴 @@ -76,6 +80,12 @@ public class NozzlePipelinePreFill extends BaseCommandHandler { DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(wasteLiquor.getZ(), speed); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionSetCommand); commandWait(motorZPositionSetCommandFuture); + + //7.开启喷嘴阀 + DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen(); // 开启喷嘴阀 + CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveOpenCommand); + commandWait(nozzleValveOpenCommandFuture); + //5.打开三通阀注射器管路 DeviceCommand threeWayValveOpenNozzlePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline(); CommandFuture threeWayValveOpenNozzlePipelineCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), threeWayValveOpenNozzlePipelineCommand); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java index eb7953c..4fe6837 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java @@ -38,6 +38,11 @@ public class NozzlePipelinePreFillStop extends BaseCommandHandler { CommandFuture threeWayValveCloseAllCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), threeWayValveCloseAllCommand); commandWait(syringePumpStopCommandFuture, threeWayValveCloseAllCommandFuture); + //7.关闭喷嘴阀 + DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); // 关闭喷嘴阀 + CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveCloseCommand); + commandWait(nozzleValveCloseCommandFuture); + deviceStatus.setPrefilling(false); }); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java index c2a07ae..0c6c21a 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java @@ -77,6 +77,11 @@ public class NozzlePipelineWash extends BaseCommandHandler { CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), threeWayValveOpenSyringePipelineCommand); commandWait(threeWayValveOpenSyringePipelineCommandFuture); + //6.打开清洗阀 + DeviceCommand washValveOpenCommand = DeviceCommandGenerator.washValveOpen(); // 生成打开清洗阀指令 + CommandFuture washValveOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), washValveOpenCommand); + commandWait(washValveOpenCommandFuture); + } catch (Exception e) { deviceStatus.setCleaningNozzlePipeline(false); throw new RuntimeException(e); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java index b062994..7f1d8f1 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java @@ -48,6 +48,10 @@ public class SyringePipelineWash extends BaseCommandHandler { webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "参数 speed 必填")); throw new RuntimeException("参数 speed 必填"); } + if (speed > 100) { + webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "清洗速度不能大于100")); + throw new RuntimeException("预充速度不能大于100"); + } deviceStatus.setCleaningSyringePipeline(true); return runAsync(() -> { try { @@ -77,11 +81,24 @@ public class SyringePipelineWash extends BaseCommandHandler { DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(wasteLiquor.getZ(), speed); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionSetCommand); commandWait(motorZPositionSetCommandFuture); + //5.打开三通阀注射器管路 DeviceCommand threeWayValveOpenNozzlePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline(); CommandFuture threeWayValveOpenNozzlePipelineCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), threeWayValveOpenNozzlePipelineCommand); commandWait(threeWayValveOpenNozzlePipelineCommandFuture); - //6.设置注射泵速度,推注射泵 + + //6.打开清洗阀 + DeviceCommand washValveOpenCommand = DeviceCommandGenerator.washValveOpen(); // 生成打开清洗阀指令 + CommandFuture washValveOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), washValveOpenCommand); + commandWait(washValveOpenCommandFuture); + + //7.开启喷嘴阀 + DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen(); // 开启喷嘴阀 + CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveOpenCommand); + commandWait(nozzleValveOpenCommandFuture); + + + //7.设置注射泵速度,推注射泵 DeviceCommand syringePumpStartCommand = DeviceCommandGenerator.syringePumpForward(speed); // 生成移动注射泵指令 CommandFuture syringePumpStartCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStartCommand); commandWait(syringePumpStartCommandFuture); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java index 6216570..f3030ed 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java @@ -37,6 +37,16 @@ public class SyringePipelineWashStop extends BaseCommandHandler { CommandFuture threeWayValveCloseAllCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), threeWayValveCloseAllCommand); commandWait(syringePumpStopCommandFuture, threeWayValveCloseAllCommandFuture); + //6.关闭清洗阀 + DeviceCommand washValveCloseCommand = DeviceCommandGenerator.washValveClose(); // 关闭清洗阀 + CommandFuture washValveCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), washValveCloseCommand); + commandWait(washValveCloseCommandFuture); + + //7.关闭喷嘴阀 + DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); // 关闭喷嘴阀 + CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveCloseCommand); + commandWait(nozzleValveCloseCommandFuture); + deviceStatus.setCleaningSyringePipeline(false); deviceStatus.setCleaningNozzlePipeline(false); }); diff --git a/src/main/java/com/qyft/ms/app/model/vo/SprayTaskStatusVO.java b/src/main/java/com/qyft/ms/app/model/vo/SprayTaskStatusVO.java index 5c07e79..f44b8ce 100644 --- a/src/main/java/com/qyft/ms/app/model/vo/SprayTaskStatusVO.java +++ b/src/main/java/com/qyft/ms/app/model/vo/SprayTaskStatusVO.java @@ -13,7 +13,14 @@ import java.util.Map; */ @Data public class SprayTaskStatusVO { - + /** + * 前端指令id + */ + private String cmdId; + /** + * 前端指令code + */ + private String cmdCode; /** * 已喷涂点位 */