Browse Source

fix:修改喷涂逻辑

tags/1.0
白凤吉 5 months ago
parent
commit
d4a056de3e
  1. 98
      src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java
  2. 22
      src/main/java/com/qyft/ms/app/device/status/SprayTask.java
  3. 46
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java
  4. 98
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java
  5. 12
      src/main/java/com/qyft/ms/app/model/bo/Point2D.java
  6. 13
      src/main/java/com/qyft/ms/app/model/bo/Point3D.java
  7. 4
      src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

98
src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java

@ -1,8 +1,11 @@
package com.qyft.ms.app.device.spray;
import cn.hutool.json.JSONObject;
import com.qyft.ms.app.common.constant.WebSocketMessageType;
import com.qyft.ms.app.device.status.SprayTask;
import com.qyft.ms.app.model.bo.Point2D;
import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
import com.qyft.ms.system.model.bo.DeviceCommand;
import com.qyft.ms.system.service.WebSocketService;
import com.qyft.ms.system.service.device.DeviceCommandService;
@ -36,18 +39,93 @@ public class SprayTaskExecutor {
try {
webSocketService.pushMsg(WebSocketMessageType.SPRAY_TASK, "喷涂任务线程启动");
SprayTask sprayTask = SprayTask.getInstance();
int currentStep = sprayTask.getCurrentStep();
for (int i = currentStep; i < sprayTask.getSpraySteps().size(); i++) {
sprayTask.setCurrentStep(i);
List<DeviceCommand> sprayStepList = sprayTask.getSpraySteps().get(i);
List<CommandFuture> commandFutureList = new ArrayList<>();
for (DeviceCommand sprayStep : sprayStepList) {
CommandFuture commandFuture = deviceCommandService.sendCommand(sprayStep);
commandFutureList.add(commandFuture);
if (!sprayTask.isSprayPreStepsCompleted()) {
//XYZ回原点
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(0.0);
DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(0.0);
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(0.0);
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand);
CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(motorYPositionSetCommand);
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand);
commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetCommandFuture);
Double height = 101.2 - sprayTask.getSprayParams().getMotorZHeight();//TODO 101.2是玻片高度这个应该从数据库中获取
DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height);
CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommand(motorZPositionSetAboveSlideCommand);
commandWait(motorZPositionSetAboveSlideCommandFuture);
DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenSyringePipeline();//打开三通阀喷嘴管路
CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(threeWayValveOpenSyringePipelineCommand);
commandWait(threeWayValveOpenSyringePipelineCommandFuture);
if (sprayTask.getSprayParams().getHighVoltage()) {//加电
DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(sprayTask.getSprayParams().getHighVoltageValue());//开启高压
CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(highVoltageOpenCommand);
commandWait(highVoltageOpenCommandFuture);
}
CommandFuture[] commandFutureArray = commandFutureList.toArray(new CommandFuture[0]);
commandWait(commandFutureArray);
sprayTask.setSprayPreStepsCompleted(true);
}
int reCurrentStep = sprayTask.getCurrentStep();
int currentStep = 0;
for (List<List<DeviceCommand>> deviceCommandList : sprayTask.getSpraySteps()) {//循环进行多次喷涂
DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen();//开启喷嘴阀
DeviceCommand syringePumpForwardCommand = DeviceCommandGenerator.syringePumpForward(sprayTask.getSprayParams().getVolume());//推动移动注射泵
CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(nozzleValveOpenCommand);
CommandFuture syringePumpForwardCommandFuture = deviceCommandService.sendCommand(syringePumpForwardCommand);
commandWait(nozzleValveOpenCommandFuture, syringePumpForwardCommandFuture);
List<Point2D> sprayStepList = new ArrayList<>();
sprayTask.setSuspendable(true);//可以暂停单次喷涂范围内可以进行暂停
for (List<DeviceCommand> deviceCommandAgg : deviceCommandList) {//单次喷涂
if (reCurrentStep < currentStep) {
break;
}
List<CommandFuture> commandFutureList = new ArrayList<>();
for (DeviceCommand sprayStep : deviceCommandAgg) {
CommandFuture commandFuture = deviceCommandService.sendCommand(sprayStep);
commandFutureList.add(commandFuture);
}
CommandFuture[] commandFutureArray = commandFutureList.toArray(new CommandFuture[0]);
//TODO开启点位推送
commandWait(commandFutureArray);
//TODO关闭点位推送
currentStep++;
sprayTask.setCurrentStep(currentStep);//将当前的喷涂进度缓存
//将当前点位缓存
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); //生成电机XYZ相对原点坐标指令
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(motorXyzPositionGetCommand);
commandWait(motorXyzPositionGetCommandFuture);
JSONObject motorXyzPositionGetCommandResult = motorXyzPositionGetCommandFuture.getResponseResult();
Double xAxisPosition = motorXyzPositionGetCommandResult.getDouble("xAxisPosition");
Double yAxisPosition = motorXyzPositionGetCommandResult.getDouble("yAxisPosition");
sprayStepList.add(new Point2D(xAxisPosition, yAxisPosition));
}
sprayTask.setSuspendable(false);//不可暂停
sprayTask.getSprayedPoints().add(sprayStepList);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose();//关闭喷嘴阀
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop();//停止推动注射泵
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(nozzleValveCloseCommand);
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(syringePumpStopCommand);
commandWait(nozzleValveCloseCommandFuture, syringePumpStopCommandFuture);
}
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(highVoltageCloseCommand);
commandWait(highVoltageCloseCommandFuture);
//XYZ回原点
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(0.0);
DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(0.0);
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(0.0);
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand);
CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(motorYPositionSetCommand);
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand);
commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetCommandFuture);
} catch (InterruptedException e) {
webSocketService.pushMsg(WebSocketMessageType.SPRAY_TASK, "喷涂任务线程停止");
Thread.currentThread().interrupt();

22
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.Point2D;
import com.qyft.ms.system.model.bo.DeviceCommand;
import lombok.Data;
@ -20,14 +21,24 @@ public class SprayTask {
private volatile boolean paused = false;
/**
* 当前状态是否可以暂停
*/
private volatile boolean suspendable = false;
/**
* 设备是否正在进行的喷涂任务
*/
private volatile boolean spraying = false;
/**
* 喷涂前置步骤是否完成
*/
private volatile boolean sprayPreStepsCompleted = false;
/**
* 喷涂步骤列表
*/
private final List<List<DeviceCommand>> spraySteps = new CopyOnWriteArrayList<>();
private final List<List<List<DeviceCommand>>> spraySteps = new CopyOnWriteArrayList<>();
/**
* 当前正在执行的步骤序号
@ -35,6 +46,11 @@ public class SprayTask {
private volatile int currentStep = 0;
/**
* 已喷涂点位
*/
private volatile List<List<Point2D>> sprayedPoints = new CopyOnWriteArrayList<>();
/**
* 喷涂参数
*/
private final SprayParams sprayParams = new SprayParams();
@ -47,10 +63,6 @@ public class SprayTask {
return Holder.INSTANCE;
}
public void addStep(DeviceCommand... steps) {
spraySteps.add(Arrays.asList(steps));
}
public void setChangeSprayParam(Double motorZHeight,
Double gasPressure,
Double volume,

46
src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java

@ -2,15 +2,19 @@ package com.qyft.ms.app.front.cmd.business;
import com.qyft.ms.app.device.spray.SprayTaskExecutor;
import com.qyft.ms.app.device.status.SprayTask;
import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.constant.CommandStatus;
import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
import com.qyft.ms.system.common.device.command.FrontCommand;
import com.qyft.ms.system.core.handler.BaseCommandHandler;
import com.qyft.ms.system.model.bo.DeviceCommand;
import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
@ -31,25 +35,29 @@ public class MatrixSprayPause extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> {
sprayTaskExecutor.stopTask();//终止喷涂任务线程
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(syringePumpStopCommand, form, emitter);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(nozzleValveCloseCommand, form, emitter);
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); //关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(highVoltageCloseCommand, form, emitter);
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture);
DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); //x轴停止移动
DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); //y轴停止移动
DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); //z轴停止移动
CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(motorXStopCommand, form, emitter);
CommandFuture motorYStopCommandFuture = deviceCommandService.sendCommand(motorYStopCommand, form, emitter);
CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(motorZStopCommand, form, emitter);
commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture);
SprayTask sprayTask = SprayTask.getInstance();
if(sprayTask.isSuspendable()){
sprayTaskExecutor.stopTask();//终止喷涂任务线程
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(syringePumpStopCommand, form, emitter);
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(nozzleValveCloseCommand, form, emitter);
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); //关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(highVoltageCloseCommand, form, emitter);
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture);
DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); //x轴停止移动
DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); //y轴停止移动
DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); //z轴停止移动
CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(motorXStopCommand, form, emitter);
CommandFuture motorYStopCommandFuture = deviceCommandService.sendCommand(motorYStopCommand, form, emitter);
CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(motorZStopCommand, form, emitter);
commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture);
}else{
emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "当前喷涂任务不可暂停"), MediaType.APPLICATION_JSON);
}
});
}
}

98
src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java

@ -5,19 +5,24 @@ import com.qyft.ms.app.device.spray.SprayTaskExecutor;
import com.qyft.ms.app.device.status.SprayTask;
import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.constant.CommandStatus;
import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
import com.qyft.ms.system.common.device.command.FrontCommand;
import com.qyft.ms.system.common.utils.CheckedRunnable;
import com.qyft.ms.system.common.utils.LambdaUtil;
import com.qyft.ms.system.core.handler.BaseCommandHandler;
import com.qyft.ms.system.model.bo.DeviceCommand;
import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -36,6 +41,7 @@ public class MatrixSprayStart extends BaseCommandHandler {
private static final ExecutorService singleExecutor = Executors.newSingleThreadExecutor();
private final SprayTaskExecutor sprayTaskExecutor;
private final DeviceCommandService deviceCommandService;
private static boolean nonNullCheck(ResponseBodyEmitter emitter, String cmdId, String cmdCode,
String matrixPathType,
@ -122,21 +128,9 @@ public class MatrixSprayStart extends BaseCommandHandler {
if (nonNullCheck(emitter, matrixPathType, form.getCmdId(), form.getCmdCode(), motorZHeight, gasPressure, volume, highVoltage, spacing, movingSpeed, times, positionList))
return;
// 2. xyz回原点
sprayTask.addStep(DeviceCommandGenerator.motorZPositionSet(0.0),//z轴回原点
DeviceCommandGenerator.motorXPositionSet(0.0),//x轴回原点
DeviceCommandGenerator.motorYPositionSet(0.0));//y轴回原点
// 3. 设定喷涂参数
sprayTask.setSprayParam(matrixPathType, motorZHeight, gasPressure, volume, highVoltage, highVoltageValue, spacing, movingSpeed, times, positionList);
// 4.开启三通阀到喷嘴管路
sprayTask.addStep(DeviceCommandGenerator.threeWayValveOpenSyringePipeline());//打开三通阀喷嘴管路
// 5.移动z轴到玻片上方
Double height = 101.2 - motorZHeight;//TODO 101.2是玻片高度这个应该从数据库中获取
sprayTask.addStep(DeviceCommandGenerator.motorZPositionSet(height));//移动z轴到指定高度
// 6.是否加电 设定电压
if (highVoltage) {//加电
sprayTask.addStep(DeviceCommandGenerator.highVoltageOpen(highVoltageValue));//开启高压
}
// 7.循环喷涂区域
Double[][] slideArr = { //TODO 每个玻片的位置应当从数据库获取
{18.08, 0.0},
@ -144,6 +138,7 @@ public class MatrixSprayStart extends BaseCommandHandler {
{72.08, 0.0},
{99.08, 0.0}
};
for (Map<String, Object> position : positionList) {
int index = (int) position.get("index"); //index 第几个玻片
Double[] upperLeft = {((Number) position.get("x1")).doubleValue(), ((Number) position.get("y1")).doubleValue()}; //范围左上角 x1y1
@ -156,8 +151,6 @@ public class MatrixSprayStart extends BaseCommandHandler {
double right = slideCompleteUCSX + lowerRight[0];
double top = slideCompleteUCSY + upperLeft[1];
double bottom = slideCompleteUCSY + lowerRight[1];
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(slide[0]),//移动x轴到玻片原点
DeviceCommandGenerator.motorYPositionSet(slide[1]));//移动y轴到玻片原点
if ("horizontal".equals(matrixPathType)) {//喷涂路径类型 horizontal 横向 | vertical 纵向 | grid 网格先横向后纵向
for (int i = 0; i < times; i++) {
double topReal = top;
@ -172,20 +165,14 @@ public class MatrixSprayStart extends BaseCommandHandler {
spacing,
PathGenerator.MoveMode.HORIZONTAL_ZIGZAG_TOP_DOWN
);
sprayTask.addStep(DeviceCommandGenerator.nozzleValveOpen(),//开启喷嘴阀
DeviceCommandGenerator.syringePumpForward(volume));//推动移动注射泵
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>();
for (PathGenerator.Points p : pathList) {//喷针移动目标位置
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(p.getX()),//移动x轴
DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
}
sprayTask.addStep(DeviceCommandGenerator.nozzleValveClose(),//关闭喷嘴阀
DeviceCommandGenerator.syringePumpStop());//停止推动注射泵
if (i + 1 != times) { //如果不是最后一次执行完毕后回到玻片原点
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(slide[0]),//移动x轴到玻片原点
DeviceCommandGenerator.motorYPositionSet(slide[1]));//移动y轴到玻片原点
List<DeviceCommand> deviceCommands = new ArrayList<>();
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
deviceCommandList.add(deviceCommands);
}
sprayTask.getSpraySteps().add(deviceCommandList);
}
} else if ("vertical".equals(matrixPathType)) {
for (int i = 0; i < times; i++) {
@ -201,20 +188,14 @@ public class MatrixSprayStart extends BaseCommandHandler {
spacing,
PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT
);
sprayTask.addStep(DeviceCommandGenerator.nozzleValveOpen(),//开启喷嘴阀
DeviceCommandGenerator.syringePumpForward(volume));//推动移动注射泵
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>();
for (PathGenerator.Points p : pathList) {//喷针移动目标位置
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(p.getX()),//移动x轴
DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
}
sprayTask.addStep(DeviceCommandGenerator.nozzleValveClose(),//关闭喷嘴阀
DeviceCommandGenerator.syringePumpStop());//停止推动注射泵
if (i + 1 != times) { //如果不是最后一次执行完毕后回到玻片原点
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(slide[0]),//移动x轴到玻片原点
DeviceCommandGenerator.motorYPositionSet(slide[1]));//移动y轴到玻片原点
List<DeviceCommand> deviceCommands = new ArrayList<>();
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
deviceCommandList.add(deviceCommands);
}
sprayTask.getSpraySteps().add(deviceCommandList);
}
} else if ("grid".equals(matrixPathType)) {
for (int i = 0; i < times; i++) {
@ -234,47 +215,36 @@ public class MatrixSprayStart extends BaseCommandHandler {
spacing,
PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT
);
sprayTask.addStep(DeviceCommandGenerator.nozzleValveOpen(),//开启喷嘴阀
DeviceCommandGenerator.syringePumpForward(volume));//推动移动注射泵
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>();
for (PathGenerator.Points p : pathList) {//喷针移动目标位置
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(p.getX()),//移动x轴
DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
List<DeviceCommand> deviceCommands = new ArrayList<>();
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
deviceCommandList.add(deviceCommands);
}
sprayTask.addStep(DeviceCommandGenerator.nozzleValveClose(),//关闭喷嘴阀
DeviceCommandGenerator.syringePumpStop());//停止推动注射泵
sprayTask.getSpraySteps().add(deviceCommandList);
pathList = PathGenerator.generatePathPoints(
leftReal, rightReal, topReal, bottomReal,
spacing,
PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT
);
sprayTask.addStep(DeviceCommandGenerator.nozzleValveOpen(),//开启喷嘴阀
DeviceCommandGenerator.syringePumpForward(volume));//推动移动注射泵
deviceCommandList = new ArrayList<>();
for (PathGenerator.Points p : pathList) {//喷针移动目标位置
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(p.getX()),//移动x轴
DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
}
sprayTask.addStep(DeviceCommandGenerator.nozzleValveClose(),//关闭喷嘴阀
DeviceCommandGenerator.syringePumpStop());//停止推动注射泵
if (i + 1 != times) { //如果不是最后一次执行完毕后回到玻片原点
sprayTask.addStep(DeviceCommandGenerator.motorXPositionSet(slide[0]),//移动x轴到玻片原点
DeviceCommandGenerator.motorYPositionSet(slide[1]));//移动y轴到玻片原点
List<DeviceCommand> deviceCommands = new ArrayList<>();
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX()));//移动x轴
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY()));//移动y轴
deviceCommandList.add(deviceCommands);
}
sprayTask.getSpraySteps().add(deviceCommandList);
}
}
}
// 8.关高压电
sprayTask.addStep(DeviceCommandGenerator.highVoltageClose());//关闭高压电
// 9. xyz回原点
sprayTask.addStep(DeviceCommandGenerator.motorZPositionSet(0.0),//z轴回原点
DeviceCommandGenerator.motorXPositionSet(0.0),//x轴回原点
DeviceCommandGenerator.motorYPositionSet(0.0));//y轴回原点
// 10. 启动喷涂线程开始喷涂
sprayTaskExecutor.startTask();
emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.SEND, "开始喷涂"), MediaType.APPLICATION_JSON);
emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.SEND, "开启喷涂线程"), MediaType.APPLICATION_JSON);
});
}

12
src/main/java/com/qyft/ms/app/model/bo/Point2D.java

@ -0,0 +1,12 @@
package com.qyft.ms.app.model.bo;
import lombok.Data;
@Data
public class Point2D {
private double x;
private double y;
public Point2D(double x, double y) {
}
}

13
src/main/java/com/qyft/ms/app/model/bo/Point3D.java

@ -0,0 +1,13 @@
package com.qyft.ms.app.model.bo;
import lombok.Data;
@Data
public class Point3D {
private double x;
private double y;
private double z;
public Point3D(double x, double y, double z) {
}
}

4
src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

@ -34,8 +34,8 @@ public class DeviceCommandService {
commandFutureMap.remove(cmdToDevice.getCommandId());
}
// cmdFuture.getResponseFuture().whenComplete((result, ex) ->
// commandFutureMap.remove(cmdToDevice.getCommandId()));
cmdFuture.getResponseFuture().whenComplete((result, ex) ->
commandFutureMap.remove(cmdToDevice.getCommandId()));
return cmdFuture;
}

Loading…
Cancel
Save