Browse Source

fix:喷涂路线中才记录位置

master
白凤吉 3 weeks ago
parent
commit
4804f805eb
  1. 28
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java

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

@ -38,8 +38,10 @@ public class MatrixSprayPause extends BaseCommandHandler {
@Override @Override
public CompletableFuture<Void> handle(FrontCmdControlForm form) { public CompletableFuture<Void> handle(FrontCmdControlForm form) {
SprayTask sprayTask = SprayTask.getInstance(); SprayTask sprayTask = SprayTask.getInstance();
if(sprayTask.isPaused()){
throw new RuntimeException("设备暂停中");
}
sprayTask.setPaused(true);//设置已暂停 sprayTask.setPaused(true);//设置已暂停
deviceStatus.setPaused(true);
try { try {
sprayTaskExecutor.stopTask();//终止喷涂任务线程 sprayTaskExecutor.stopTask();//终止喷涂任务线程
@ -59,16 +61,18 @@ public class MatrixSprayPause extends BaseCommandHandler {
CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand); CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand);
commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture); commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture);
//记录当前位置
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXyzPositionGetCommand);
commandWait(motorXyzPositionGetCommandFuture);
JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getResponseResult();
Double xAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("xAxisPosition");
Double yAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("yAxisPosition");
Double zAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("zAxisPosition");
Point3D point3D = new Point3D(xAxisPosition, yAxisPosition, zAxisPosition);
sprayTask.setCurrentPausedPoint(point3D);
if(sprayTask.getCurrentStep() > 0){
//记录当前位置
DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令
CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXyzPositionGetCommand);
commandWait(motorXyzPositionGetCommandFuture);
JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getResponseResult();
Double xAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("xAxisPosition");
Double yAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("yAxisPosition");
Double zAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("zAxisPosition");
Point3D point3D = new Point3D(xAxisPosition, yAxisPosition, zAxisPosition);
sprayTask.setCurrentPausedPoint(point3D);
}
OperationLog operationLog = operationLogService.getById(sprayTask.getOperationLogId()); OperationLog operationLog = operationLogService.getById(sprayTask.getOperationLogId());
operationLog.setStatus(2); operationLog.setStatus(2);
@ -84,6 +88,8 @@ public class MatrixSprayPause extends BaseCommandHandler {
commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture); commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}finally {
deviceStatus.setPaused(true);
} }
return runAsync(() -> { return runAsync(() -> {

Loading…
Cancel
Save