Browse Source

fix:退火参数改为数组

master
王梦远 2 months ago
parent
commit
d7d2276e9d
  1. 44
      src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java
  2. 21
      src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java
  3. 36
      src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java
  4. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java
  5. 8
      src/main/java/com/iflytop/sgs/app/model/vo/SetTargetTemperatureVO.java
  6. 4
      src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java
  7. 2
      src/main/java/com/iflytop/sgs/common/result/ResultCode.java

44
src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java

@ -1,5 +1,7 @@
package com.iflytop.sgs.app.cmd.control;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONArray;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.Point3D;
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState;
@ -12,6 +14,8 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.enums.HeatingType;
import com.iflytop.sgs.common.enums.data.DevicePositionCode;
import com.iflytop.sgs.common.exception.AppException;
import com.iflytop.sgs.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -33,36 +37,26 @@ public class AnnealStartCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//TODO 判断退火加热模块传感器是否有托盘
String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode");
HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标加热模块
HeatModuleCode annealHeatModuleCode = HeatModuleCode.heat_module_04;//退火模块
if(!annealHeatModuleCode.equals(targetHeatModuleCode)) {//目标加热模块不是退火模块
//TODO 判断目标加热模块传感器是否有托盘如果没有托盘的话提示错误
JSONArray heatModuleCodeJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode");
if (heatModuleCodeJsonArray.size() > 1 && !heatModuleCodeJsonArray.getStr(0).equals(HeatModuleCode.heat_module_04.name())) {//参数校验 设备问题参数固定位[heat_module_04]
throw new AppException(ResultCode.PARAMETER_TYPE_MISMATCH);
}
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离
Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置
Point3D annealHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(annealHeatModuleCode);//获取退火加热模块托盘夹取点
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(annealHeatModuleCode);//获取设定的退火温度
double targetTemperature = heatModuleState.getAnnealTemperature();
heatModuleState.setTargetTemperature(targetTemperature);//将退火温度设定为目标温度
return runAsync(() -> {
if(!annealHeatModuleCode.equals(targetHeatModuleCode)) {//目标加热模块不是退火模块
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至夹取点 + 移动距离
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//将Z轴下降至托盘夹取点高度
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleTrayClawPoint3D.getX());//将X轴移动至托盘夹取点
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//Z轴下降至夹取点使托盘落入石墨加热盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高
for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) {
String targetHeatModuleCodeStr = heatModuleCodeJsonArray.getStr(i);
HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标退火模块
Assert.isTrue(targetHeatModuleCode != null, () -> new AppException(ResultCode.PARAMETER_TYPE_MISMATCH));//参数检验
HeatModuleState heatModuleState=deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode);//获取加热模块状态
Assert.isTrue(heatModuleState.isTrayStatus(), () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//检测是否有托盘
double targetTemperature = heatModuleState.getAnnealTemperature();//获取设定的退火温度
heatModuleState.setTargetTemperature(targetTemperature);//将退火温度设定为目标温度
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleCode, targetTemperature);//开启加热
deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setHeatingType(HeatingType.annealing);//状态修改为退火中
}
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleCode, targetTemperature);//开启加热
deviceStateService.getDeviceState().getHeatModuleByCode(annealHeatModuleCode).setHeatingType(HeatingType.annealing);//状态修改为退火中
});
}
}

21
src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java

@ -1,6 +1,7 @@
package com.iflytop.sgs.app.cmd.control;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONArray;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
@ -30,13 +31,23 @@ public class AnnealStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
HeatModuleCode annealHeatModuleCode = HeatModuleCode.heat_module_04;//退火模块
HeatModuleState heatModuleState=deviceStateService.getDeviceState().getHeatModuleByCode(annealHeatModuleCode);//获取退火区的状态
Assert.isTrue(heatModuleState.getHeatingType().equals(HeatingType.annealing),()->new AppException(ResultCode.CRAFT_RUNNING));//判断退火区状态
JSONArray heatModuleCodeJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode");
if (heatModuleCodeJsonArray.size() > 1 && !heatModuleCodeJsonArray.getStr(0).equals(HeatModuleCode.heat_module_04.name())) {//参数校验 设备问题参数固定位[heat_module_04]
throw new AppException(ResultCode.PARAMETER_TYPE_MISMATCH);
}
return runAsync(() -> {
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleCode);//关闭加热棒
deviceStateService.getDeviceState().getHeatModuleByCode(annealHeatModuleCode).setHeatingType(HeatingType.stop);//设置退火区退火状态
for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) {
String targetHeatModuleCodeStr = heatModuleCodeJsonArray.getStr(i);
HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标退火模块
Assert.isTrue(targetHeatModuleCode != null, () -> new AppException(ResultCode.PARAMETER_TYPE_MISMATCH));//参数检验
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode);//获取退火区的状态
Assert.isTrue(heatModuleState.getHeatingType().equals(HeatingType.annealing), () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NOT_ANNEAL));//判断退火区状态
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleCode);//关闭加热棒
deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setHeatingType(HeatingType.stop);//设置退火区退火状态
}
});
}
}

36
src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java

@ -6,6 +6,7 @@ import com.iflytop.sgs.app.model.bo.Point3D;
import com.iflytop.sgs.app.model.bo.status.device.TrayState;
import com.iflytop.sgs.app.model.bo.status.device.TubeState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.model.entity.SystemConfig;
import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
@ -41,38 +42,39 @@ public class CleanStartCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//TODO 需要先更新一下传感器状态
//TODO 需要先更新一下托盘状态 状态码新增转运模块是否有托盘
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(),()->new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));
double cleanWaterVolume= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.volume_clean));//清洁时加水的量
double waterScale= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));//水转换系数
double pumpPosition= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));//抽液时蠕动泵移动
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(), () -> new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//判断转运模块托盘状态
double cleanWaterVolume = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.volume_clean));//清洁时加水的量
double waterScale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));//水转换系数
double pumpPosition = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));//抽液时蠕动泵移动
Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置
Integer cycle = cmdDTO.getIntegerParam("cycle");//清洗次数
Integer maxCycles = Integer.valueOf(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.cycle_clean_max));//获取最大清洁次数配置
Assert.isTrue(cycle > 0 && cycle < maxCycles, () -> new AppException(ResultCode.INVALID_PARAMETER));//cycle参数校验
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距
List<TrayState> trayStates=deviceStateService.getDeviceState().getTrays();//所有的托盘
TrayState trayState=trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘
List<TrayState> trayStates = deviceStateService.getDeviceState().getTrays();//所有的托盘
TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘
return runAsync(() -> {
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//电磁阀对应通道打开
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), pumpPosition);
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0.0);//加液模块上升
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.0);//加液模块上升
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.water);//电磁阀对应通道打开
for (int i = 0; i < cycle; i++) {
for(TubeState tubeState : trayState.getTubes()){
if(tubeState.isAddSolution() && tubeState.isExists()){
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), cleanWaterVolume*waterScale);
//todo 线程sleep指定时间
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -cleanWaterVolume*waterScale);
double distance=(tubeState.getColumnNum()-1)*trayTubeHorizontalSpacingDistance;
for (TubeState tubeState : trayState.getTubes()) {
if (tubeState.isAddSolution() && tubeState.isExists()) {
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), cleanWaterVolume * waterScale * 8);//八通道蠕动泵
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -cleanWaterVolume * waterScale * 8);//八通道蠕动泵
double distance = (tubeState.getColumnNum() - 1) * trayTubeHorizontalSpacingDistance;//x轴移动距离
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//X轴依次按照试管间距移动
}
}
}
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);//加液模块上升至最高移出试管
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高移出试管
});
}
}

2
src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java

@ -59,7 +59,7 @@ public class LiquidAddCommand extends BaseCommandHandler {
Solutions solutions = solutionsService.getById(solutionId);//获取溶液
ValveStateCode valveStateCode = ValveStateCode.valueOf(solutions.getName());//根据溶液获取电磁阀code
double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比
double position = volume * scale;//加液泵的转数
double position = volume * scale * 8;//加液泵的转数
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置

8
src/main/java/com/iflytop/sgs/app/model/vo/SetTargetTemperatureVO.java

@ -13,14 +13,14 @@ public class SetTargetTemperatureVO {
@Schema(description = "加热模块code")
private HeatModuleCode moduleCode;
@Max(value = 150, message = "加热温度不能超过150度")
@Min(value = 0, message = "加热温度不能低于0度")
@Max(value = 120, message = "加热温度不能超过120度")
@Min(value = 50, message = "加热温度不能低于50度")
@Schema(description = "加热温度")
private Double heatTemperature;
@Max(value = 200, message = "烘干温度不能超过200度")
@Min(value = 100, message = "烘干温度不能低于100度")
@Max(value = 135, message = "烘干温度不能超过135度")
@Min(value = 50, message = "烘干温度不能低于50度")
@Schema(description = "烘干温度")
private Double dryTemperature;

4
src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java

@ -15,7 +15,9 @@ public enum SystemConfigCode {
scale_waste("废水转换系数"),
scale_vacant("空气转换系数"),
volume_clean("清洁时加水的量"),
number_reduce("抽液时机蠕动泵的转数");
number_reduce("抽液时机蠕动泵的转数"),
cycle_clean_max
("清洁最大次数");
private String description;

2
src/main/java/com/iflytop/sgs/common/result/ResultCode.java

@ -55,6 +55,8 @@ public enum ResultCode implements IResultCode, Serializable {
TARGET_HEAT_MODULE_NO_TRAY("6022", "目标加热模块无托盘"),
CAP_LIFT_ERROR("6023", "拍子升降错误"),
CMD_BUSY("6024", "设备忙,请稍后"),
TARGET_HEAT_MODULE_NOT_ANNEAL("6025", "目标加热区不是退火状态"),
TRANSFER_MODULE_NO_TRAY("6026", "转运模块无托盘"),
;
/** 状态码 */
private final String code;

Loading…
Cancel
Save