From fc663e131d206f992c2176cd522bafe8e24b44e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 15 Jul 2025 11:52:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=96=B7=E6=B6=82=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E6=9A=82=E5=81=9C=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/app/device/spray/SprayTaskExecutor.java | 84 +++++++++++++--------- .../qyft/ms/app/device/status/DeviceStatus.java | 6 -- .../com/qyft/ms/app/device/status/SprayTask.java | 14 +++- .../front/cmd/business/MatrixSprayContinue.java | 8 +-- .../app/front/cmd/business/MatrixSprayPause.java | 29 ++++++-- .../app/front/cmd/business/MatrixSprayStart.java | 2 - .../ms/app/front/cmd/business/MatrixSprayStop.java | 1 - .../java/com/qyft/ms/app/model/bo/Point3D.java | 9 ++- .../model/bo/SprayTaskPointCollectorPushBO.java | 9 +-- .../java/com/qyft/ms/app/model/bo/SprayTimes.java | 4 +- .../qyft/ms/app/service/VirtualDeviceService.java | 7 ++ .../listener/DeviceTcpMessageEventListener.java | 1 - .../service/device/DeviceCommandService.java | 7 -- 13 files changed, 106 insertions(+), 75 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 eff4f68..2562560 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 @@ -67,41 +67,24 @@ public class SprayTaskExecutor { webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.DEVICE_ERROR, "设备正在喷涂,请先停止喷涂")); return; } - Position slidePosition1 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position1")); - Position slidePosition2 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position2")); - Position slidePosition3 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position3")); - Position slidePosition4 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position4")); - Double[][] slideArr = { - {slidePosition1.getX(), slidePosition1.getY()}, - {slidePosition2.getX(), slidePosition2.getY()}, - {slidePosition3.getX(), slidePosition3.getY()}, - {slidePosition4.getX(), slidePosition4.getY()} - }; taskThread = new Thread(() -> { try { webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.START, "喷涂任务开始执行")); List sprayTaskParams = sprayTask.getSprayTaskParams(); - - DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenNozzlePipeline();//打开三通阀注射器管路 - CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), threeWayValveOpenSyringePipelineCommand); - commandWait(threeWayValveOpenSyringePipelineCommandFuture); - - DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen();//开启喷嘴阀 - CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveOpenCommand); - commandWait(nozzleValveOpenCommandFuture); - - int currentStep = 0; //当前喷涂步骤 - int sprayCount = 0; - int sprayNum = 1; - int currentIndex = 0; + int currentStep = 0; //不管是暂停还是新的线程,记录当前线程喷涂步骤序号 + int sprayNum = 1; //当前玻片是第几次喷涂 for (SprayTaskParams sprayTaskParam : sprayTaskParams) {//循环玻片 + if (sprayTask.getCurrentIndex() != null && sprayTaskParam.getIndex() > sprayTask.getCurrentIndex()) { + continue; + } + sprayTask.setCurrentIndex(sprayTaskParam.getIndex()); for (SprayTimes sprayTimes : sprayTaskParam.getTimes()) {//每个拨片有多次喷涂,循环每次喷涂 sprayTask.setSprayTimes(sprayTimes); Double[] slide = slideArr[sprayTaskParam.getIndex()];//获取玻片的坐标 List sprayTaskStepList = getSprayPath(sprayTaskParam.getIndex(), sprayTimes);//计算本次喷涂的路线 - //先移动到玻片位置 + //先移动到玻片左上角位置 DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskParam.getIndex()][0], 20.0); DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(75.5 - slideArr[sprayTaskParam.getIndex()][1], 20.0); CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXPositionSetCommand); @@ -113,10 +96,31 @@ public class SprayTaskExecutor { DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height, 15.0); CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZPositionSetAboveSlideCommand); commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetAboveSlideCommandFuture); - Thread.sleep(100); + + 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); + } + + //因为走的是折现,所以单词指令只需要移动x或y,缓存上一个点位用来判断本次是走x还是y double cacheXPoint = -1; double cacheYPoint = -1; - sprayNum++; for (SprayTaskStep sprayTaskStep : sprayTaskStepList) {//因为田字格喷涂其实是两次 if (sprayTimes.getHighVoltage()) {//加电 DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(sprayTimes.getHighVoltageValue());//开启高压 @@ -128,6 +132,10 @@ public class SprayTaskExecutor { CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpForwardCommand); commandWait(syringePumpForwardCommandFuture); for (int i = 0; i < sprayTaskStep.getSprayPathPointList().size(); i++) {//循环路线 + if (currentStep < sprayTask.getCurrentStep()) { + currentStep++; + continue; + } Point2D currentPoint = sprayTaskStep.getSprayPathPointList().get(i); List commandFutureList = new ArrayList<>(); if (cacheXPoint != currentPoint.x) { @@ -142,19 +150,19 @@ public class SprayTaskExecutor { commandFutureList.add(commandFuture); cacheYPoint = currentPoint.y; } - SprayTaskPointCollectorPushBO sprayTaskPointCollectorPushBO = new SprayTaskPointCollectorPushBO(sprayTask.getCmdId(), sprayTask.getCmdCode(), sprayTaskParam.getIndex(), sprayNum, sprayCount, currentPoint); + SprayTaskPointCollectorPushBO sprayTaskPointCollectorPushBO = new SprayTaskPointCollectorPushBO(sprayTask.getCmdId(), sprayTask.getCmdCode(), sprayTaskParam.getIndex(), sprayNum, currentPoint); webSocketService.pushMsg(WebSocketMessageType.SPRAY_POINT, sprayTaskPointCollectorPushBO);//向前端推送当前路径 CommandFuture[] commandFutureArray = commandFutureList.toArray(new CommandFuture[0]); commandWait(commandFutureArray); - currentStep++;//当前喷涂步数自增 + currentStep++;//当前喷涂步数。因为暂停可能本次路线还没走完,所以这里只有在走完一次路线后才会自增 + sprayTask.setCurrentStep(currentStep); } //一次喷涂完毕后停止推注射泵 DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop();//停止推动注射泵 CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), syringePumpStopCommand); commandWait(syringePumpStopCommandFuture); } - sprayCount++; sprayNum++; } } @@ -176,6 +184,10 @@ public class SprayTaskExecutor { CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZOriginCommand); commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture); + SprayTask.getInstance().clear(); + deviceStatus.setSpraying(false);//是否正在进行喷涂 + deviceStatus.setPaused(false);//是否暂停 + webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.SUCCESS, "喷涂任务执行成功")); webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.SPRAY_TASK_FINISH, "喷涂任务结束")); } catch (InterruptedException e) { @@ -184,13 +196,10 @@ public class SprayTaskExecutor { log.info("喷涂任务失败", e); webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.FAIL, "喷涂任务执行失败")); webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.SPRAY_TASK_FINISH, "喷涂任务结束")); - SprayTask.getInstance().clear(); + deviceStatus.setSpraying(false);//是否正在进行喷涂 + deviceStatus.setPaused(false);//是否暂停 } finally { - SprayTask.getInstance().clear(); - deviceStatus.setSpraying(false); - deviceStatus.setPaused(false); - deviceStatus.setSuspendable(false); webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.SEND, "喷涂任务线程退出")); // 在线程结束后将 taskThread 设置为 null,保证状态一致和资源释放 synchronized (this) { @@ -272,4 +281,11 @@ public class SprayTaskExecutor { return sprayTaskStepList; } + private void delay(long millisecond) { + try { + Thread.sleep(millisecond); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/src/main/java/com/qyft/ms/app/device/status/DeviceStatus.java b/src/main/java/com/qyft/ms/app/device/status/DeviceStatus.java index 5f0cf85..1396932 100644 --- a/src/main/java/com/qyft/ms/app/device/status/DeviceStatus.java +++ b/src/main/java/com/qyft/ms/app/device/status/DeviceStatus.java @@ -23,11 +23,6 @@ public class DeviceStatus { private volatile boolean paused = false; /** - * 当前状态是否可以暂停 - */ - private volatile boolean suspendable = false; - - /** * 是否正在清洗注射器管路 */ private volatile boolean cleaningSyringePipeline = false; @@ -76,7 +71,6 @@ public class DeviceStatus { JSONObject json = new JSONObject(); json.putOnce("spraying", spraying); json.putOnce("paused", paused); - json.putOnce("suspendable", suspendable); json.putOnce("cleaningSyringePipeline", cleaningSyringePipeline); json.putOnce("cleaningNozzlePipeline", cleaningNozzlePipeline); json.putOnce("prefilling", prefilling); 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 9ca38e3..2864b25 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 @@ -1,5 +1,6 @@ package com.qyft.ms.app.device.status; +import com.qyft.ms.app.model.bo.Point3D; import com.qyft.ms.app.model.bo.SprayTaskParams; import com.qyft.ms.app.model.bo.SprayTimes; import lombok.Data; @@ -22,6 +23,14 @@ public class SprayTask { */ private volatile int currentStep = 0; /** + * 当前喷涂的玻片序号 + */ + private Integer currentIndex = null; + /** + * 当前暂停点位 + */ + private Point3D currentPausedPoint = null; + /** * 当前喷涂任务所有参数 */ private List sprayTaskParams = null; @@ -33,6 +42,7 @@ public class SprayTask { * 标志喷涂任务暂停 */ private volatile boolean paused = false; + /** * 标志喷涂任务结束 */ @@ -42,7 +52,7 @@ public class SprayTask { */ private volatile boolean spraying = false; - private final Object pauseLock = new Object(); + private final Object closeLock = new Object(); private SprayTask() { @@ -60,6 +70,8 @@ public class SprayTask { currentStep = 0; sprayTaskParams = null; sprayTimes = null; + currentPausedPoint = null; + currentIndex = null; } private static class Holder { diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java index 32287a2..d641cbb 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayContinue.java @@ -36,9 +36,7 @@ public class MatrixSprayContinue extends BaseCommandHandler { if (!sprayTask.isSpraying()) { throw new RuntimeException("设备没有正在喷涂"); } - sprayTask.setSpraying(true); - sprayTask.setPaused(false); - deviceStatus.setSpraying(true); + sprayTask.setPaused(false);//解除暂停 deviceStatus.setPaused(false); SprayTimes sprayTimes = sprayTask.getSprayTimes(); return runAsync(() -> { @@ -60,9 +58,7 @@ public class MatrixSprayContinue extends BaseCommandHandler { CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpForwardCommand); commandWait(syringePumpForwardCommandFuture); - synchronized(sprayTask.getPauseLock()) { - sprayTask.getPauseLock().notify(); - } + sprayTaskExecutor.startTask(); }); } diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java index 12e3211..49c70cf 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java @@ -1,9 +1,11 @@ package com.qyft.ms.app.front.cmd.business; +import cn.hutool.json.JSONObject; import com.qyft.ms.app.device.spray.SprayTaskExecutor; import com.qyft.ms.app.device.status.DeviceStatus; import com.qyft.ms.app.device.status.SprayTask; +import com.qyft.ms.app.model.bo.Point3D; import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; @@ -33,10 +35,11 @@ public class MatrixSprayPause extends BaseCommandHandler { @Override public CompletableFuture handle(FrontCmdControlForm form) { SprayTask sprayTask = SprayTask.getInstance(); - sprayTask.setPaused(true);//已暂停 + sprayTask.setPaused(true);//设置已暂停 deviceStatus.setPaused(true); - deviceStatus.setSuspendable(false); try { + sprayTaskExecutor.stopTask();//终止喷涂任务线程 + DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵 CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStopCommand); DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀 @@ -53,9 +56,25 @@ public class MatrixSprayPause extends BaseCommandHandler { CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand); commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture); - while (!sprayTaskExecutor.taskThreadIsWaiting()) { - Thread.sleep(5); - } + //记录当前位置 + DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令 + CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXyzPositionGetCommand); + commandWait(motorXyzPositionGetCommandFuture); + JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getResponseResult(); + Double xAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("xAxisPosition"); + Double yAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("yAxisPosition"); + Double zAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("zAxisPosition"); + Point3D point3D = new Point3D(xAxisPosition, yAxisPosition, zAxisPosition); + sprayTask.setCurrentPausedPoint(point3D); + + //XYZ回原点 + DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin(); + DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin(); + DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin(); + CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXOriginCommand); + CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYOriginCommand); + CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZOriginCommand); + commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture); } catch (Exception e) { throw new RuntimeException(e); } 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 6ad9d2d..023c014 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 @@ -71,10 +71,8 @@ public class MatrixSprayStart extends BaseCommandHandler { } sprayTask.setCmdId(form.getCmdId()); sprayTask.setCmdCode(form.getCmdCode()); - sprayTask.setClose(false); sprayTask.setSpraying(true);//正在进行喷涂 deviceStatus.setSpraying(true); - return runAsync(() -> { //喷涂开始前先回原点 DeviceCommand overallDeviceStatusGetCommand = DeviceCommandGenerator.overallDeviceStatusGet(); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java index 4b56874..d770a64 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java @@ -77,7 +77,6 @@ public class MatrixSprayStop extends BaseCommandHandler { SprayTask.getInstance().clear(); deviceStatus.setSpraying(false); deviceStatus.setPaused(false); - deviceStatus.setSuspendable(false); }); } } diff --git a/src/main/java/com/qyft/ms/app/model/bo/Point3D.java b/src/main/java/com/qyft/ms/app/model/bo/Point3D.java index 6b9d1ee..ed64dc3 100644 --- a/src/main/java/com/qyft/ms/app/model/bo/Point3D.java +++ b/src/main/java/com/qyft/ms/app/model/bo/Point3D.java @@ -4,10 +4,13 @@ import lombok.Data; @Data public class Point3D { - private double x; - private double y; - private double z; + public double x; + public double y; + public double z; public Point3D(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; } } diff --git a/src/main/java/com/qyft/ms/app/model/bo/SprayTaskPointCollectorPushBO.java b/src/main/java/com/qyft/ms/app/model/bo/SprayTaskPointCollectorPushBO.java index 6021115..a6b858d 100644 --- a/src/main/java/com/qyft/ms/app/model/bo/SprayTaskPointCollectorPushBO.java +++ b/src/main/java/com/qyft/ms/app/model/bo/SprayTaskPointCollectorPushBO.java @@ -13,7 +13,7 @@ public class SprayTaskPointCollectorPushBO { */ String cmdCode; /** - * 当前是第几个玻片 从0开始 + * 当前喷涂的是第几个玻片 从0开始 */ Integer index; /** @@ -21,21 +21,16 @@ public class SprayTaskPointCollectorPushBO { */ Integer number; /** - * 总喷涂计数 - */ - Integer sprayCount; - /** * 当前点位坐标 */ Point2D currentPoint; - public SprayTaskPointCollectorPushBO(String cmdId, String cmdCode, Integer index, Integer number, Integer sprayCount, Point2D currentPoint) { + public SprayTaskPointCollectorPushBO(String cmdId, String cmdCode, Integer index, Integer number, Point2D currentPoint) { this.cmdId = cmdId; this.cmdCode = cmdCode; this.index = index; this.number = number; - this.sprayCount = sprayCount; this.currentPoint = currentPoint; } } diff --git a/src/main/java/com/qyft/ms/app/model/bo/SprayTimes.java b/src/main/java/com/qyft/ms/app/model/bo/SprayTimes.java index c6a3472..3d4a853 100644 --- a/src/main/java/com/qyft/ms/app/model/bo/SprayTimes.java +++ b/src/main/java/com/qyft/ms/app/model/bo/SprayTimes.java @@ -32,10 +32,10 @@ public class SprayTimes { private Double movingSpeed; @Schema(description = "田字格喷涂中间延时数,非田字格不传递该参数") - private Double gridDelay; + private Long gridDelay; @Schema(description = "本次喷涂结束后延时数") - private Double delay; + private Long delay; @Schema(description = "喷涂左上角x") private Double x1; diff --git a/src/main/java/com/qyft/ms/app/service/VirtualDeviceService.java b/src/main/java/com/qyft/ms/app/service/VirtualDeviceService.java index 7f1eaef..8fca416 100644 --- a/src/main/java/com/qyft/ms/app/service/VirtualDeviceService.java +++ b/src/main/java/com/qyft/ms/app/service/VirtualDeviceService.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; public class VirtualDeviceService { private final DeviceCommandService deviceCommandService; + public void completeCommandResponse(DeviceCommand cmdToDevice) { new Thread(() -> { try { @@ -55,6 +56,12 @@ public class VirtualDeviceService { data.putOnce("temperature", 60); jsonObject.putOnce("data", data); } + }else if (device.contains("xyz")) { + JSONObject data = new JSONObject(); + data.putOnce("xAxisPosition", 20); + data.putOnce("yAxisPosition", 20); + data.putOnce("zAxisPosition", 15); + jsonObject.putOnce("data", data); } } diff --git a/src/main/java/com/qyft/ms/system/core/listener/DeviceTcpMessageEventListener.java b/src/main/java/com/qyft/ms/system/core/listener/DeviceTcpMessageEventListener.java index 0c47bd3..8b62e55 100644 --- a/src/main/java/com/qyft/ms/system/core/listener/DeviceTcpMessageEventListener.java +++ b/src/main/java/com/qyft/ms/system/core/listener/DeviceTcpMessageEventListener.java @@ -38,7 +38,6 @@ public class DeviceTcpMessageEventListener { SprayTask.getInstance().clear(); deviceStatus.setSpraying(false); deviceStatus.setPaused(false); - deviceStatus.setSuspendable(false); deviceStatus.setStopPressed(true); deviceStatus.setSelfTestCompleted(false); deviceCommandService.releaseAllCommandFutures(); diff --git a/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java b/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java index 2c9af3d..77cd038 100644 --- a/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java +++ b/src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java @@ -75,13 +75,6 @@ public class DeviceCommandService { public CommandFuture sendCommandSprayTask(String cmdId, String cmdCode, DeviceCommand deviceCommand) throws Exception { SprayTask sprayTask = SprayTask.getInstance(); - synchronized (sprayTask.getPauseLock()) { - while (sprayTask.isPaused()) { - log.info("喷涂暂停"); - sprayTask.getPauseLock().wait(); - log.info("喷涂继续"); - } - } synchronized (sprayTask.getCloseLock()) { if (sprayTask.isClose() || Thread.currentThread().isInterrupted()) { throw new InterruptedException();