|
|
@ -17,6 +17,8 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
/** |
|
|
@ -40,38 +42,49 @@ public class MatrixSprayStop extends BaseCommandHandler { |
|
|
|
if (!sprayTask.isSpraying()) { |
|
|
|
throw new RuntimeException("设备没有正在喷涂"); |
|
|
|
} |
|
|
|
if(sprayTask.isClosing()){ |
|
|
|
throw new RuntimeException("正在结束喷涂,请稍后"); |
|
|
|
} |
|
|
|
webSocketService.pushCMDResponseMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.SPRAY_TASK_FINISH, "喷涂任务结束")); |
|
|
|
SprayTask.getInstance().clear(); |
|
|
|
deviceStatus.setSpraying(false); |
|
|
|
deviceStatus.setPaused(false); |
|
|
|
deviceStatus.setSuspendable(false); |
|
|
|
|
|
|
|
return runAsync(() -> { |
|
|
|
sprayTaskExecutor.stopTask();//终止喷涂任务线程 |
|
|
|
sprayTask.setClosing(true); |
|
|
|
try{ |
|
|
|
sprayTaskExecutor.stopTask();//终止喷涂任务线程 |
|
|
|
|
|
|
|
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵 |
|
|
|
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStopCommand); |
|
|
|
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀 |
|
|
|
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveCloseCommand); |
|
|
|
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); //关闭高压 |
|
|
|
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageCloseCommand); |
|
|
|
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture); |
|
|
|
|
|
|
|
DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); //x轴停止移动 |
|
|
|
DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); //y轴停止移动 |
|
|
|
DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); //z轴停止移动 |
|
|
|
CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXStopCommand); |
|
|
|
CommandFuture motorYStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYStopCommand); |
|
|
|
CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand); |
|
|
|
commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture); |
|
|
|
|
|
|
|
DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵 |
|
|
|
CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStopCommand); |
|
|
|
DeviceCommand nozzleValveCloseCommand = DeviceCommandGenerator.nozzleValveClose(); //关闭喷嘴阀 |
|
|
|
CommandFuture nozzleValveCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), nozzleValveCloseCommand); |
|
|
|
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose(); //关闭高压 |
|
|
|
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), highVoltageCloseCommand); |
|
|
|
commandWait(syringePumpStopCommandFuture, nozzleValveCloseCommandFuture, highVoltageCloseCommandFuture); |
|
|
|
//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 motorXStopCommand = DeviceCommandGenerator.motorXStop(); //x轴停止移动 |
|
|
|
DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); //y轴停止移动 |
|
|
|
DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); //z轴停止移动 |
|
|
|
CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXStopCommand); |
|
|
|
CommandFuture motorYStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYStopCommand); |
|
|
|
CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand); |
|
|
|
commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture); |
|
|
|
SprayTask.getInstance().clear(); |
|
|
|
deviceStatus.setSpraying(false); |
|
|
|
deviceStatus.setPaused(false); |
|
|
|
deviceStatus.setSuspendable(false); |
|
|
|
}finally { |
|
|
|
sprayTask.setClosing(false); |
|
|
|
} |
|
|
|
|
|
|
|
//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); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |