|
@ -141,174 +141,200 @@ public class MatrixSprayStart extends BaseCommandHandler { |
|
|
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "电压不能大于6000V")); |
|
|
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "电压不能大于6000V")); |
|
|
throw new RuntimeException("电压不能大于6000V"); |
|
|
throw new RuntimeException("电压不能大于6000V"); |
|
|
} |
|
|
} |
|
|
return runAsync(() -> { |
|
|
|
|
|
// 3. 设定喷涂参数 |
|
|
|
|
|
sprayTask.setSprayParam(matrixPathType, motorZHeight, gasPressure, volume, highVoltage, highVoltageValue, spacing, movingSpeed, times, positionList); |
|
|
|
|
|
sprayTask.setCacheParams(form.getParams()); |
|
|
|
|
|
|
|
|
if (positionList.isEmpty()) { |
|
|
|
|
|
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "喷涂区域不能为空")); |
|
|
|
|
|
throw new RuntimeException("喷涂区域不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
// 3. 设定喷涂参数 |
|
|
|
|
|
sprayTask.setSprayParam(matrixPathType, motorZHeight, gasPressure, volume, highVoltage, highVoltageValue, spacing, movingSpeed, times, positionList); |
|
|
|
|
|
sprayTask.setCacheParams(form.getParams()); |
|
|
|
|
|
|
|
|
OperationLog operationLog = new OperationLog(); |
|
|
|
|
|
operationLog.setMatrixInfo(JSONUtil.toJsonStr(sprayTask.getCacheParams())); |
|
|
|
|
|
operationLogService.add(operationLog); |
|
|
|
|
|
|
|
|
OperationLog operationLog = new OperationLog(); |
|
|
|
|
|
operationLog.setMatrixInfo(JSONUtil.toJsonStr(sprayTask.getCacheParams())); |
|
|
|
|
|
operationLogService.add(operationLog); |
|
|
|
|
|
|
|
|
// 7.循环喷涂区域 |
|
|
|
|
|
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()} |
|
|
|
|
|
}; |
|
|
|
|
|
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()}; //范围左上角 x1,y1 |
|
|
|
|
|
Double[] lowerRight = {((Number) position.get("x2")).doubleValue(), ((Number) position.get("y2")).doubleValue()}; //范围右下角 x2,y2 |
|
|
|
|
|
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])); |
|
|
|
|
|
if ("horizontal".equals(matrixPathType)) {//喷涂路径类型 horizontal 横向 | vertical 纵向 | grid 网格先横向后纵向 |
|
|
|
|
|
for (int i = 1; i <= times; i++) { |
|
|
|
|
|
double topReal = top; |
|
|
|
|
|
double bottomReal = bottom; |
|
|
|
|
|
double leftReal = left; |
|
|
|
|
|
double rightReal = right; |
|
|
|
|
|
if (i % 2 == 0) {//双数喷涂,插空移动边界 |
|
|
|
|
|
double halfSpacing = spacing / 2; |
|
|
|
|
|
topReal = top + halfSpacing; |
|
|
|
|
|
bottomReal = bottomReal - halfSpacing; |
|
|
|
|
|
leftReal = left + halfSpacing; |
|
|
|
|
|
rightReal = right - halfSpacing; |
|
|
|
|
|
} |
|
|
|
|
|
List<PathGenerator.Points> pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.HORIZONTAL_ZIGZAG_TOP_DOWN |
|
|
|
|
|
); |
|
|
|
|
|
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
// 7.循环喷涂区域 |
|
|
|
|
|
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()} |
|
|
|
|
|
}; |
|
|
|
|
|
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()}; //范围左上角 x1,y1 |
|
|
|
|
|
Double[] lowerRight = {((Number) position.get("x2")).doubleValue(), ((Number) position.get("y2")).doubleValue()}; //范围右下角 x2,y2 |
|
|
|
|
|
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])); |
|
|
|
|
|
if ("horizontal".equals(matrixPathType)) {//喷涂路径类型 horizontal 横向 | vertical 纵向 | grid 网格先横向后纵向 |
|
|
|
|
|
for (int i = 1; i <= times; i++) { |
|
|
|
|
|
double topReal = top; |
|
|
|
|
|
double bottomReal = bottom; |
|
|
|
|
|
double leftReal = left; |
|
|
|
|
|
double rightReal = right; |
|
|
|
|
|
if (i % 2 == 0) {//双数喷涂,插空移动边界 |
|
|
|
|
|
double halfSpacing = spacing / 2; |
|
|
|
|
|
topReal = top + halfSpacing; |
|
|
|
|
|
bottomReal = bottomReal - halfSpacing; |
|
|
|
|
|
leftReal = left + halfSpacing; |
|
|
|
|
|
rightReal = right - halfSpacing; |
|
|
|
|
|
} |
|
|
|
|
|
List<PathGenerator.Points> pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.HORIZONTAL_ZIGZAG_TOP_DOWN |
|
|
|
|
|
); |
|
|
|
|
|
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
if (j == pathList.size() - 1) { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
|
|
|
} else { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
} |
|
|
} |
|
|
|
|
|
deviceCommandList.add(deviceCommands); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
SprayTaskStep sprayTaskStep = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep.setIndex(index); |
|
|
|
|
|
sprayTaskStep.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep); |
|
|
|
|
|
|
|
|
SprayTaskStep sprayTaskStep = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep.setIndex(index); |
|
|
|
|
|
sprayTaskStep.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep); |
|
|
|
|
|
} |
|
|
|
|
|
} else if ("vertical".equals(matrixPathType)) { |
|
|
|
|
|
for (int i = 1; i <= times; i++) { |
|
|
|
|
|
double topReal = top; |
|
|
|
|
|
double bottomReal = bottom; |
|
|
|
|
|
double leftReal = left; |
|
|
|
|
|
double rightReal = right; |
|
|
|
|
|
if (i % 2 == 0) {//双数喷涂,插空移动边界 |
|
|
|
|
|
double halfSpacing = spacing / 2; |
|
|
|
|
|
topReal = top + halfSpacing; |
|
|
|
|
|
bottomReal = bottomReal - halfSpacing; |
|
|
|
|
|
leftReal = left + halfSpacing; |
|
|
|
|
|
rightReal = right - halfSpacing; |
|
|
} |
|
|
} |
|
|
} else if ("vertical".equals(matrixPathType)) { |
|
|
|
|
|
for (int i = 1; i <= times; i++) { |
|
|
|
|
|
double topReal = top; |
|
|
|
|
|
double bottomReal = bottom; |
|
|
|
|
|
double leftReal = left; |
|
|
|
|
|
double rightReal = right; |
|
|
|
|
|
if (i % 2 == 0) {//双数喷涂,插空移动边界 |
|
|
|
|
|
double halfSpacing = spacing / 2; |
|
|
|
|
|
topReal = top + halfSpacing; |
|
|
|
|
|
bottomReal = bottomReal - halfSpacing; |
|
|
|
|
|
leftReal = left + halfSpacing; |
|
|
|
|
|
rightReal = right - halfSpacing; |
|
|
|
|
|
} |
|
|
|
|
|
List<PathGenerator.Points> pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT |
|
|
|
|
|
); |
|
|
|
|
|
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
List<PathGenerator.Points> pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT |
|
|
|
|
|
); |
|
|
|
|
|
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
if (j == pathList.size() - 1) { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
|
|
|
} else { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
} |
|
|
} |
|
|
SprayTaskStep sprayTaskStep = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep.setIndex(index); |
|
|
|
|
|
sprayTaskStep.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep); |
|
|
|
|
|
|
|
|
deviceCommandList.add(deviceCommands); |
|
|
} |
|
|
} |
|
|
} else if ("grid".equals(matrixPathType)) { |
|
|
|
|
|
for (int i = 1; i <= times; i++) { |
|
|
|
|
|
double topReal = top; |
|
|
|
|
|
double bottomReal = bottom; |
|
|
|
|
|
double leftReal = left; |
|
|
|
|
|
double rightReal = right; |
|
|
|
|
|
double halfSpacing = spacing / 2; |
|
|
|
|
|
if (i % 2 == 0) {//双数喷涂,插空移动边界 |
|
|
|
|
|
topReal = top + halfSpacing; |
|
|
|
|
|
bottomReal = bottomReal - halfSpacing; |
|
|
|
|
|
leftReal = left + halfSpacing; |
|
|
|
|
|
rightReal = right - halfSpacing; |
|
|
|
|
|
} |
|
|
|
|
|
List<PathGenerator.Points> pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.HORIZONTAL_ZIGZAG_TOP_DOWN |
|
|
|
|
|
); |
|
|
|
|
|
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
SprayTaskStep sprayTaskStep = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep.setIndex(index); |
|
|
|
|
|
sprayTaskStep.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep); |
|
|
|
|
|
} |
|
|
|
|
|
} else if ("grid".equals(matrixPathType)) { |
|
|
|
|
|
for (int i = 1; i <= times; i++) { |
|
|
|
|
|
double topReal = top; |
|
|
|
|
|
double bottomReal = bottom; |
|
|
|
|
|
double leftReal = left; |
|
|
|
|
|
double rightReal = right; |
|
|
|
|
|
double halfSpacing = spacing / 2; |
|
|
|
|
|
if (i % 2 == 0) {//双数喷涂,插空移动边界 |
|
|
|
|
|
topReal = top + halfSpacing; |
|
|
|
|
|
bottomReal = bottomReal - halfSpacing; |
|
|
|
|
|
leftReal = left + halfSpacing; |
|
|
|
|
|
rightReal = right - halfSpacing; |
|
|
|
|
|
} |
|
|
|
|
|
List<PathGenerator.Points> pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.HORIZONTAL_ZIGZAG_TOP_DOWN |
|
|
|
|
|
); |
|
|
|
|
|
List<List<DeviceCommand>> deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
if (j == pathList.size() - 1) { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
|
|
|
} else { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
} |
|
|
} |
|
|
SprayTaskStep sprayTaskStep = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep.setIndex(index); |
|
|
|
|
|
sprayTaskStep.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep); |
|
|
|
|
|
|
|
|
deviceCommandList.add(deviceCommands); |
|
|
|
|
|
} |
|
|
|
|
|
SprayTaskStep sprayTaskStep = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep.setIndex(index); |
|
|
|
|
|
sprayTaskStep.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep); |
|
|
|
|
|
|
|
|
pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT |
|
|
|
|
|
); |
|
|
|
|
|
deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
pathList = PathGenerator.generatePathPoints( |
|
|
|
|
|
leftReal, rightReal, topReal, bottomReal, |
|
|
|
|
|
spacing, |
|
|
|
|
|
PathGenerator.MoveMode.VERTICAL_ZIGZAG_LEFT_RIGHT |
|
|
|
|
|
); |
|
|
|
|
|
deviceCommandList = new ArrayList<>(); |
|
|
|
|
|
for (int j = 0; j < pathList.size(); j++) { |
|
|
|
|
|
PathGenerator.Points p = pathList.get(j); |
|
|
|
|
|
List<DeviceCommand> deviceCommands = new ArrayList<>(); |
|
|
|
|
|
if (j == pathList.size() - 1) { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
|
|
|
} else { |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorXPositionSet(p.getX(), movingSpeed));//移动x轴 |
|
|
|
|
|
deviceCommands.add(DeviceCommandGenerator.motorYPositionSet(75.5 - p.getY(), movingSpeed));//移动y轴 |
|
|
} |
|
|
} |
|
|
SprayTaskStep sprayTaskStep2 = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep2.setIndex(index); |
|
|
|
|
|
sprayTaskStep2.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep2); |
|
|
|
|
|
|
|
|
deviceCommandList.add(deviceCommands); |
|
|
} |
|
|
} |
|
|
|
|
|
SprayTaskStep sprayTaskStep2 = new SprayTaskStep(); |
|
|
|
|
|
sprayTaskStep2.setIndex(index); |
|
|
|
|
|
sprayTaskStep2.setSpraySteps(deviceCommandList); |
|
|
|
|
|
sprayTask.getSprayTaskStepList().add(sprayTaskStep2); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return runAsync(() -> { |
|
|
|
|
|
//XYZ回原点 |
|
|
|
|
|
DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin(); |
|
|
|
|
|
DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin(); |
|
|
|
|
|
DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin(); |
|
|
|
|
|
CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXOriginCommand); |
|
|
|
|
|
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYOriginCommand); |
|
|
|
|
|
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZOriginCommand); |
|
|
|
|
|
commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture); |
|
|
|
|
|
|
|
|
|
|
|
DeviceCommand threeWayValveOpenSyringePipelineCommand = DeviceCommandGenerator.threeWayValveOpenSyringePipeline();//打开三通阀喷嘴管路 |
|
|
|
|
|
CommandFuture threeWayValveOpenSyringePipelineCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), threeWayValveOpenSyringePipelineCommand); |
|
|
|
|
|
commandWait(threeWayValveOpenSyringePipelineCommandFuture); |
|
|
|
|
|
|
|
|
|
|
|
if (sprayTask.getSprayParams().getHighVoltage()) {//加电 |
|
|
|
|
|
DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(highVoltageValue);//开启高压 |
|
|
|
|
|
CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageOpenCommand); |
|
|
|
|
|
commandWait(highVoltageOpenCommandFuture); |
|
|
} |
|
|
} |
|
|
// log.info(JSONUtil.toJsonStr(sprayTask.getSprayTaskStepList())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DeviceCommand nozzleValveOpenCommand = DeviceCommandGenerator.nozzleValveOpen();//开启喷嘴阀 |
|
|
|
|
|
CommandFuture nozzleValveOpenCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), nozzleValveOpenCommand); |
|
|
|
|
|
commandWait(nozzleValveOpenCommandFuture); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 10. 启动喷涂线程,开始喷涂 |
|
|
// 10. 启动喷涂线程,开始喷涂 |
|
|
sprayTaskExecutor.startTask(); |
|
|
sprayTaskExecutor.startTask(); |
|
|
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.SEND, "已开启喷涂线程")); |
|
|
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.SEND, "已开启喷涂线程")); |
|
|