Browse Source

feat:实现喷涂过程中参数实时调整

tags/1.0
白凤吉 5 months ago
parent
commit
4f1df0be1d
  1. 14
      src/main/java/com/qyft/ms/app/device/status/SprayTask.java
  2. 72
      src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java

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

@ -20,11 +20,6 @@ public class SprayTask {
private volatile boolean paused = false;
/**
* 当前状态是否可以暂停
*/
private volatile boolean suspendable = false;
/**
* 设备是否正在进行的喷涂任务
*/
private volatile boolean spraying = false;
@ -56,6 +51,15 @@ public class SprayTask {
spraySteps.add(Arrays.asList(steps));
}
public void setChangeSprayParam(Double motorZHeight,
Double gasPressure,
Double volume,
Boolean highVoltage,
Double highVoltageValue,
Double movingSpeed){
}
public void setSprayParam(String matrixPathType,
Double motorZHeight,
Double gasPressure,

72
src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java

@ -0,0 +1,72 @@
package com.qyft.ms.app.front.cmd.business;
import com.qyft.ms.app.device.status.SprayTask;
import com.qyft.ms.system.common.annotation.CommandMapping;
import com.qyft.ms.system.common.device.command.CommandFuture;
import com.qyft.ms.system.common.device.command.DeviceCommandGenerator;
import com.qyft.ms.system.core.handler.BaseCommandHandler;
import com.qyft.ms.system.model.bo.DeviceCommand;
import com.qyft.ms.system.model.form.FrontCmdControlForm;
import com.qyft.ms.system.service.device.DeviceCommandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
import java.util.concurrent.CompletableFuture;
/**
* 喷涂_喷涂过程中参数实时调整
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("matrix_spray_change_param")//业务指令注解
public class MatrixSprayChangeParam extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) {
return runAsync(() -> {
SprayTask sprayTask = SprayTask.getInstance();
Double motorZHeight = form.getDoubleParam("motorZHeight");
Double gasPressure = form.getDoubleParam("gasPressure");
Double volume = form.getDoubleParam("volume");
Boolean highVoltage = form.getBooleanParam("highVoltage");
Double highVoltageValue = form.getDoubleParam("highVoltageValue");
Double movingSpeed = form.getDoubleParam("movingSpeed");
sprayTask.setChangeSprayParam(motorZHeight, gasPressure, volume, highVoltage, highVoltageValue, movingSpeed);
if (!sprayTask.isPaused()) {
//1.速度
DeviceCommand motorXSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorXSpeedSet(movingSpeed);//x轴电机速度设置
DeviceCommand motorYSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorYSpeedSet(movingSpeed);//y轴电机速度设置
DeviceCommand motorZSpeedSetCmdToDeviceCommand = DeviceCommandGenerator.motorZSpeedSet(movingSpeed);//z轴电机速度设置
CommandFuture motorXSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(motorXSpeedSetCmdToDeviceCommand, form, emitter);
CommandFuture motorYSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(motorYSpeedSetCmdToDeviceCommand, form, emitter);
CommandFuture motorZSpeedSetCmdToDeviceCommandFuture = deviceCommandService.sendCommand(motorZSpeedSetCmdToDeviceCommand, form, emitter);
commandWait(motorXSpeedSetCmdToDeviceCommandFuture, motorYSpeedSetCmdToDeviceCommandFuture, motorZSpeedSetCmdToDeviceCommandFuture);
//2.流速
DeviceCommand syringePumpVolumeSetCommand = DeviceCommandGenerator.syringePumpVolumeSet(volume);//注射泵流速设置
CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(syringePumpVolumeSetCommand, form, emitter);
commandWait(syringePumpVolumeSetCommandFuture);
//3.z轴高度
Double height = 101.2 - motorZHeight;//TODO 101.2是玻片高度这个应该从数据库中获取
DeviceCommand smotorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(height);//移动z轴到指定位置
CommandFuture smotorZPositionSetCommandFuture = deviceCommandService.sendCommand(smotorZPositionSetCommand, form, emitter);
commandWait(smotorZPositionSetCommandFuture);
//4.是否打开高压
if (highVoltage) {//打开高压
DeviceCommand highVoltageOpenCommand = DeviceCommandGenerator.highVoltageOpen(highVoltageValue);//开启高压
CommandFuture highVoltageOpenCommandFuture = deviceCommandService.sendCommand(highVoltageOpenCommand, form, emitter);
commandWait(highVoltageOpenCommandFuture);
} else {//关闭高压
DeviceCommand highVoltageCloseCommand = DeviceCommandGenerator.highVoltageClose();//关闭高压
CommandFuture highVoltageCloseCommandFuture = deviceCommandService.sendCommand(highVoltageCloseCommand, form, emitter);
commandWait(highVoltageCloseCommandFuture);
}
}
});
}
}
Loading…
Cancel
Save