|
@ -68,6 +68,16 @@ public class SprayTaskExecutor { |
|
|
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.DEVICE_ERROR, "设备正在喷涂,请先停止喷涂")); |
|
|
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.DEVICE_ERROR, "设备正在喷涂,请先停止喷涂")); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
Position slidePosition1 = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "slide_position1")); |
|
|
|
|
|
Position slidePosition2 = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "slide_position2")); |
|
|
|
|
|
Position slidePosition3 = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "slide_position3")); |
|
|
|
|
|
Position slidePosition4 = positionService.getOne(new LambdaQueryWrapper<Position>().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(() -> { |
|
|
taskThread = new Thread(() -> { |
|
|
try { |
|
|
try { |
|
@ -88,6 +98,8 @@ public class SprayTaskExecutor { |
|
|
int currentIndex = 0; |
|
|
int currentIndex = 0; |
|
|
for (SprayTaskParams sprayTaskParam : sprayTaskParams) {//循环玻片 |
|
|
for (SprayTaskParams sprayTaskParam : sprayTaskParams) {//循环玻片 |
|
|
for (SprayTimes sprayTimes : sprayTaskParam.getTimes()) {//每个拨片有多次喷涂,循环每次喷涂 |
|
|
for (SprayTimes sprayTimes : sprayTaskParam.getTimes()) {//每个拨片有多次喷涂,循环每次喷涂 |
|
|
|
|
|
Double[] slide = slideArr[sprayTaskParam.getIndex()];//获取玻片的坐标 |
|
|
|
|
|
|
|
|
List<SprayTaskStep> sprayTaskStepList = getSprayPath(sprayTaskParam.getIndex(), sprayTimes);//计算本次喷涂的路线 |
|
|
List<SprayTaskStep> sprayTaskStepList = getSprayPath(sprayTaskParam.getIndex(), sprayTimes);//计算本次喷涂的路线 |
|
|
//先移动到玻片位置 |
|
|
//先移动到玻片位置 |
|
|
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskParam.getIndex()][0], 20.0); |
|
|
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskParam.getIndex()][0], 20.0); |
|
@ -119,13 +131,13 @@ public class SprayTaskExecutor { |
|
|
Point2D currentPoint = sprayTaskStep.getSprayPathPointList().get(i); |
|
|
Point2D currentPoint = sprayTaskStep.getSprayPathPointList().get(i); |
|
|
List<CommandFuture> commandFutureList = new ArrayList<>(); |
|
|
List<CommandFuture> commandFutureList = new ArrayList<>(); |
|
|
if (cacheXPoint != currentPoint.x) { |
|
|
if (cacheXPoint != currentPoint.x) { |
|
|
DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(currentPoint.x, sprayTimes.getMovingSpeed()); |
|
|
|
|
|
|
|
|
DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(slide[0] + currentPoint.x, sprayTimes.getMovingSpeed()); |
|
|
CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), deviceCommand); |
|
|
CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), deviceCommand); |
|
|
commandFutureList.add(commandFuture); |
|
|
commandFutureList.add(commandFuture); |
|
|
cacheXPoint = currentPoint.x; |
|
|
cacheXPoint = currentPoint.x; |
|
|
} |
|
|
} |
|
|
if (cacheYPoint != currentPoint.y) { |
|
|
if (cacheYPoint != currentPoint.y) { |
|
|
DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(currentPoint.y, sprayTimes.getMovingSpeed()); |
|
|
|
|
|
|
|
|
DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(slide[1] +currentPoint.y, sprayTimes.getMovingSpeed()); |
|
|
CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), deviceCommand); |
|
|
CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), deviceCommand); |
|
|
commandFutureList.add(commandFuture); |
|
|
commandFutureList.add(commandFuture); |
|
|
cacheYPoint = currentPoint.y; |
|
|
cacheYPoint = currentPoint.y; |
|
@ -211,24 +223,10 @@ public class SprayTaskExecutor { |
|
|
|
|
|
|
|
|
private List<SprayTaskStep> getSprayPath(Integer index, SprayTimes sprayTimes) { |
|
|
private List<SprayTaskStep> getSprayPath(Integer index, SprayTimes sprayTimes) { |
|
|
String matrixPathType = sprayTimes.getMatrixPathType(); |
|
|
String matrixPathType = sprayTimes.getMatrixPathType(); |
|
|
Position slidePosition1 = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "slide_position1")); |
|
|
|
|
|
Position slidePosition2 = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "slide_position2")); |
|
|
|
|
|
Position slidePosition3 = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "slide_position3")); |
|
|
|
|
|
Position slidePosition4 = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "slide_position4")); |
|
|
|
|
|
Double[][] slideArr = { |
|
|
|
|
|
{slidePosition1.getX(), slidePosition1.getY()}, |
|
|
|
|
|
{slidePosition2.getX(), slidePosition2.getY()}, |
|
|
|
|
|
{slidePosition3.getX(), slidePosition3.getY()}, |
|
|
|
|
|
{slidePosition4.getX(), slidePosition4.getY()} |
|
|
|
|
|
}; |
|
|
|
|
|
Double[] upperLeft = {sprayTimes.getX1(), sprayTimes.getY1()}; //范围左上角 x1,y1 |
|
|
|
|
|
Double[] lowerRight = {sprayTimes.getX2(), sprayTimes.getY2()}; //范围左上角 x1,y1 |
|
|
|
|
|
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 top = Double.parseDouble(df.format(slide[1] + upperLeft[1])); |
|
|
|
|
|
double bottom = Double.parseDouble(df.format(slide[1] + lowerRight[1])); |
|
|
|
|
|
|
|
|
double left = sprayTimes.getX1(); |
|
|
|
|
|
double right = sprayTimes.getX2(); |
|
|
|
|
|
double top = sprayTimes.getY1(); |
|
|
|
|
|
double bottom = sprayTimes.getY2(); |
|
|
Double spacing = sprayTimes.getSpacing(); |
|
|
Double spacing = sprayTimes.getSpacing(); |
|
|
List<SprayTaskStep> sprayTaskStepList = new CopyOnWriteArrayList<>(); |
|
|
List<SprayTaskStep> sprayTaskStepList = new CopyOnWriteArrayList<>(); |
|
|
if ("horizontal".equals(matrixPathType)) {//喷涂路径类型 horizontal 横向 | vertical 纵向 | grid 网格先横向后纵向 |
|
|
if ("horizontal".equals(matrixPathType)) {//喷涂路径类型 horizontal 横向 | vertical 纵向 | grid 网格先横向后纵向 |
|
|