Browse Source

增加预充 排空功能

master
王梦远 2 months ago
parent
commit
24688ff9a2
  1. 82
      src/main/java/com/iflytop/sgs/app/cmd/control/DrainLiquidCommand.java
  2. 33
      src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java
  3. 8
      src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java
  4. 33
      src/main/resources/sql/init.sql

82
src/main/java/com/iflytop/sgs/app/cmd/control/DrainLiquidCommand.java

@ -0,0 +1,82 @@
package com.iflytop.sgs.app.cmd.control;
import cn.hutool.core.lang.Assert;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.Point3D;
import com.iflytop.sgs.app.model.bo.status.device.TrayState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceSensorService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
import com.iflytop.sgs.app.service.device.module.SolutionModuleService;
import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.DeviceSensorCode;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.enums.SolutionCode;
import com.iflytop.sgs.common.enums.SystemConfigCode;
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;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 管道排空
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("drain_liquid")//业务指令注解
public class DrainLiquidCommand extends BaseCommandHandler {
private final HeatModuleService heatModuleService;
private final TransferModuleService transferModuleService;
private final DevicePositionService devicePositionService;
private final DeviceStateService deviceStateService;
private final DeviceSensorService deviceSensorService;
private final SolutionModuleService solutionModuleService;
private final SystemConfigService systemConfigService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
if (deviceStateService.getCommandMutexState().get().isTransferCommandExecuting()) {
throw new AppException(ResultCode.CMD_BUSY);
}
boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取上料区托盘状态
Assert.isTrue(!liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//上料区不能存在托盘
deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(true);
return runAsync(() -> {
try {
boolean preFillFlag = systemConfigService.getSystemConfigBooleanByCode(SystemConfigCode.pre_fill_when_open_service);
Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D();//加热位1坐标
Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置
Double preFillDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pre_fill_distance_when_open_service);//预充距离
if (preFillFlag) {
solutionModuleService.solutionMotorMoveZero();//加液机械臂上升
transferModuleService.transferZMoveZero();//Z轴抬升至最高
transferModuleService.transferXMove(heatArea1TrayClawPoint.getX());//转运模块移动至加热位1
solutionModuleService.solutionMotorMove(liquidAreaPreFillPoint);//加液机械臂下降至至预充点位
solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(-preFillDistance);//排空
solutionModuleService.liquidValveSwitch(SolutionCode.thin);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(-preFillDistance);//排空
solutionModuleService.liquidValveSwitch(SolutionCode.thick);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(-preFillDistance);//排空
solutionModuleService.liquidValveSwitch(SolutionCode.water);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(-preFillDistance);//排空
solutionModuleService.solutionMotorMoveZero();//回原点
}
} finally {
deviceStateService.getCommandMutexState().get().setTransferCommandExecuting(false);
}
});
}
}

33
src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java

@ -4,7 +4,9 @@ import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.core.SelfMoveTestGenerator;
import com.iflytop.sgs.app.model.bo.Point3D;
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.DeviceSensorService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
@ -12,12 +14,12 @@ import com.iflytop.sgs.app.service.device.module.SolutionModuleService;
import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import com.iflytop.sgs.app.ws.server.WebSocketSender;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.DevicePartId;
import com.iflytop.sgs.common.enums.DeviceSensorCode;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.enums.*;
import com.iflytop.sgs.common.enums.cmd.CmdColor;
import com.iflytop.sgs.common.enums.data.DevicePositionCode;
import com.iflytop.sgs.common.exception.AppException;
import com.iflytop.sgs.common.result.ResultCode;
import com.iflytop.sgs.hardware.exception.HardwareException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -39,6 +41,7 @@ public class MoveTestCommand extends BaseCommandHandler {
private final DeviceStateService deviceStateService;
private final WebSocketSender webSocketService;
private final DeviceSensorService deviceSensorService;
private final SystemConfigService systemConfigService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
@ -74,6 +77,30 @@ public class MoveTestCommand extends BaseCommandHandler {
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点使托盘落入上料区
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "4、z轴电机检测完毕", 100, "success"));
CompletableFuture.runAsync(() -> {
try {
boolean preFillFlag = systemConfigService.getSystemConfigBooleanByCode(SystemConfigCode.pre_fill_when_open_service);
Point3D heatArea1TrayClawPoint = devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint).getPoint3D();//加热位1坐标
Double liquidAreaPreFillPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaPreFillPoint).getPositon(); //预充时加液臂下降位置
Double preFillDistance = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.pre_fill_distance_when_open_service);//预充距离
if (preFillFlag) {
transferModuleService.transferXMove(heatArea1TrayClawPoint.getX());//转运模块移动至加热位1
solutionModuleService.solutionMotorMove(liquidAreaPreFillPoint);//加液机械臂下降至至预充点位
solutionModuleService.liquidValveSwitch(SolutionCode.waste);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(-preFillDistance);//排空
solutionModuleService.liquidValveSwitch(SolutionCode.thin);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(preFillDistance);//预充
solutionModuleService.liquidValveSwitch(SolutionCode.thick);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(preFillDistance);//预充
solutionModuleService.liquidValveSwitch(SolutionCode.water);//电磁阀对应通道打开
solutionModuleService.liquidPumpMove(preFillDistance);//预充
solutionModuleService.solutionMotorMoveZero();//回原点
}
} catch (Exception e) {
log.error("设备开机预充失败");
}
});
} finally {
deviceStateService.getCommandMutexState().get().setMoveTest(false);
}

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

@ -11,14 +11,16 @@ public enum SystemConfigCode {
thick("浓硝酸加液系数"),
thin("稀硝酸加液系数"),
back_flow_distance("稀硝酸加液系数"),
pre_fill_distance("预充距离"),
drain_distance("排空距离"),
pre_fill_distance("加液预充距离"),
drain_distance("加液排空距离"),
reduce_distance("过量抽液距离"),
cycle_clean_max("允许的最大清洁次数"),
liquid_max_speed("蠕动泵最大转速限制"),
door_origin_is_ignore("忽略门自检"),
crafts_end_beep_times("工艺结束蜂鸣器响次数"),
fan_stop_temperature("风扇关闭的温度设置")
fan_stop_temperature("风扇关闭的温度设置"),
pre_fill_when_open_service("开机是否预充"),
pre_fill_distance_when_open_service("开机预充距离"),
;
private final String description;

33
src/main/resources/sql/init.sql

@ -58,6 +58,8 @@ INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time
INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (10, '忽略门自检', 'door_origin_is_ignore', 'true', '2025-05-29T14:23:48', '2025-05-29T14:23:48');
INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (11, '工艺结束蜂鸣器次数', 'crafts_end_beep_times', '3', '2025-06-04 19:06:55.000', '2025-06-04 19:06:56.000');
INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (12, '风扇关闭的温度设置', 'fan_stop_temperature', '110.0', '2025-06-04 19:06:55.000', '2025-06-04 19:06:56.000');
INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (13, '开机是否预充', 'pre_fill_when_open_service', 'true', '2025-06-04 19:06:55.000', '2025-06-04 19:06:56.000');
INSERT OR IGNORE INTO system_config ("id", "name", "code", "value", "create_time", "update_time") VALUES (14, '开机预充距离', 'pre_fill_distance_when_open_service', '40.0', '2025-06-04 19:06:55.000', '2025-06-04 19:06:56.000');
@ -82,37 +84,6 @@ CREATE TABLE IF NOT EXISTS device_param_config
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- crafts_going正在执行的工艺 根据工艺id重新生成工艺 然后根据记录的step_id恢复到断电前的步骤,
-- 加液 需要记录已经加液的列
-- 抽液 需要记录已经抽取的列
-- 清洗 需要记录清洗的次数和已经清洗的列
-- 加热需要记录已经加热的分钟
-- 烘干需要记录烘干的分钟
-- 退火需要记录退火的分钟
-- 断电恢复后,重新上电,首先保证机械臂能够正常到安全位置
-- 1、加液机械臂回原点
-- 2、自检位置需要加 x z的左 右 上 下移动 定死移动距离
-- 3、z回原点 x回原点
-- 4、检测到机械臂有托盘,检测上料区是否有托盘,如果无移动至上料区,如果有前台进行提示
-- 5、机械臂无托盘开始进行自检,自检需要增加停止和恢复按钮
-- 6、自检完成,检测到存在未完成的工艺
-- 7、前台弹窗显示未完成的工艺,工艺名称 工艺步骤 正在执行的步骤 当前步骤的参数
-- 8、对正在执行的步骤,支持手动进行参数的更改 参数内容
-- 9、按照doing表里的数据,启动工艺,传入当前执行的步骤id,从正在执行的步骤开始执行
-- 加液前断电
-- 加液中断电
-- 加液后断电
-- 抽液前断电
-- 抽液中断电
-- 抽液后断电
-- 清洗前断电
-- 清洗中断电
--
--退
--退
--退
-- crafts 工艺 表
CREATE TABLE IF NOT EXISTS crafts
(

Loading…
Cancel
Save