Browse Source

fix:移动电机必须给速度

tags/1.0
白凤吉 4 months ago
parent
commit
2e5ba19ca5
  1. 48
      src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java
  2. 5
      src/main/java/com/qyft/ms/app/device/status/SprayTask.java
  3. 332
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java
  4. 16
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java
  5. 6
      src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java
  6. 21
      src/main/java/com/qyft/ms/system/common/device/command/DeviceCommandGenerator.java

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

@ -71,39 +71,6 @@ public class SprayTaskExecutor {
taskThread = new Thread(() -> {
try {
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.START, "喷涂任务开始执行"));
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(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);
//
// SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper<SysSettings>().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);
commandWait(threeWayValveOpenSyringePipelineCommandFuture);
if (sprayTask.getSprayParams().getHighVoltage()) {//加电
DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(sprayTask.getSprayParams().getHighVoltageValue());//开启高压
CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageOpenCommand);
commandWait(highVoltageOpenCommandFuture);
}
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;
@ -185,6 +152,7 @@ public class SprayTaskExecutor {
commandWait(syringePumpStopCommandFuture);
sprayNum++;
}
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), highVoltageCloseCommand);
commandWait(highVoltageCloseCommandFuture);
@ -194,13 +162,13 @@ public class SprayTaskExecutor {
commandWait(nozzleValveCloseCommandFuture);
//XYZ回原点
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);
DeviceCommand motorXOriginCommand = DeviceCommandGenerator.motorXOrigin();
DeviceCommand motorYOriginCommand = DeviceCommandGenerator.motorYOrigin();
DeviceCommand motorZOriginCommand = DeviceCommandGenerator.motorZOrigin();
CommandFuture motorXOriginCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorXOriginCommand);
CommandFuture motorYOriginCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorYOriginCommand);
CommandFuture motorZOriginCommandFuture = deviceCommandService.sendCommand(sprayTask.getCmdId(), sprayTask.getCmdCode(), motorZOriginCommand);
commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture);
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.SUCCESS, "喷涂任务执行成功"));

5
src/main/java/com/qyft/ms/app/device/status/SprayTask.java

@ -41,10 +41,6 @@ public class SprayTask {
*/
private volatile boolean spraying = false;
/**
* 喷涂前置步骤是否完成
*/
private volatile boolean sprayPreStepsCompleted = false;
/**
* 当前正在执行的步骤序号
*/
private volatile int currentStep = 0;
@ -120,7 +116,6 @@ public class SprayTask {
paused = false;
suspendable = false;
spraying = false;
sprayPreStepsCompleted = false;
sprayTaskStepList.clear();
currentStep = 0;
sprayTaskSprayedList.clear();

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

@ -141,174 +141,200 @@ public class MatrixSprayStart extends BaseCommandHandler {
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "电压不能大于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()}; //范围左上角 x1y1
Double[] lowerRight = {((Number) position.get("x2")).doubleValue(), ((Number) position.get("y2")).doubleValue()}; //范围右下角 x2y2
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()}; //范围左上角 x1y1
Double[] lowerRight = {((Number) position.get("x2")).doubleValue(), ((Number) position.get("y2")).doubleValue()}; //范围右下角 x2y2
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. 启动喷涂线程开始喷涂
sprayTaskExecutor.startTask();
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.SEND, "已开启喷涂线程"));

16
src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStop.java

@ -51,14 +51,14 @@ public class MatrixSprayStop extends BaseCommandHandler {
CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand);
commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture);
//4.回到原点
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(0.0);
DeviceCommand motorYPositionSetCommand = DeviceCommandGenerator.motorYPositionSet(0.0);
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(0.0);
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXPositionSetCommand);
CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYPositionSetCommand);
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionSetCommand);
commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetCommandFuture);
//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);
SprayTask.getInstance().clear();
deviceStatus.setSpraying(false);

6
src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java

@ -59,17 +59,17 @@ public class NozzlePipelineWash extends BaseCommandHandler {
SysSettings safeZHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper<SysSettings>().eq(SysSettings::getCode, "safe_z_height"));
double safeZHeight = Double.parseDouble(safeZHeightSysSettings.getValue());
if (zAxisPosition > safeZHeight) { //z轴超出安全距离抬升z轴
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(safeZHeight);
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(safeZHeight, 15.0);
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionSetCommand);
commandWait(motorZPositionSetCommandFuture);
}
Position wasteLiquor = positionService.getOne(new LambdaQueryWrapper<Position>().eq(Position::getPointCode, "waste_liquor"));
//2.轴移动到废液位置
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(wasteLiquor.getX());
DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(wasteLiquor.getX(), 20.0);
CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXPositionSetCommand);
commandWait(motorXPositionSetCommandFuture);
//3.下降z轴高度防止飞溅
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(wasteLiquor.getZ());
DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(wasteLiquor.getZ(), 15.0);
CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZPositionSetCommand);
commandWait(motorZPositionSetCommandFuture);
//4.开启三通阀到喷嘴管路

21
src/main/java/com/qyft/ms/system/common/device/command/DeviceCommandGenerator.java

@ -316,27 +316,6 @@ public class DeviceCommandGenerator {
/**
* 移动x轴到指定位置
*/
public static DeviceCommand motorXPositionSet(Double position) {
return motorXPositionSet(position, null, "移动x轴到指定位置");
}
/**
* 移动y轴到指定位置
*/
public static DeviceCommand motorYPositionSet(Double position) {
return motorYPositionSet(position, null, "移动y轴到指定位置");
}
/**
* 移动z轴到指定位置
*/
public static DeviceCommand motorZPositionSet(Double position) {
return motorZPositionSet(position, null, "移动z轴到指定位置");
}
/**
* 移动x轴到指定位置
*/
public static DeviceCommand motorXPositionSet(Double position, Double speed) {
return motorXPositionSet(position, speed, "移动x轴到指定位置");
}

Loading…
Cancel
Save