2 changed files with 81 additions and 5 deletions
-
14src/main/java/com/qyft/ms/app/device/status/SprayTask.java
-
72src/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); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue