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. 46
      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();

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

@ -141,7 +141,10 @@ public class MatrixSprayStart extends BaseCommandHandler {
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "电压不能大于6000V"));
throw new RuntimeException("电压不能大于6000V");
}
return runAsync(() -> {
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());
@ -196,8 +199,8 @@ public class MatrixSprayStart extends BaseCommandHandler {
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轴
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轴
@ -233,8 +236,8 @@ public class MatrixSprayStart extends BaseCommandHandler {
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轴
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轴
@ -269,8 +272,8 @@ public class MatrixSprayStart extends BaseCommandHandler {
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轴
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轴
@ -292,8 +295,8 @@ public class MatrixSprayStart extends BaseCommandHandler {
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轴
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轴
@ -306,9 +309,32 @@ public class MatrixSprayStart extends BaseCommandHandler {
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