Browse Source

调整业务指令开始清洗、开门、关门

master
白凤吉 2 months ago
parent
commit
3204650b2b
  1. 83
      src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java
  2. 42
      src/main/java/com/iflytop/sgs/app/cmd/control/CleanStopCommand.java
  3. 9
      src/main/java/com/iflytop/sgs/app/cmd/control/DoorCloseCommand.java
  4. 14
      src/main/java/com/iflytop/sgs/app/cmd/control/DoorOpenCommand.java
  5. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java
  6. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java
  7. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java
  8. 12
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java
  9. 2
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/TubeState.java
  10. 4
      src/main/java/com/iflytop/sgs/app/service/api/TrayService.java
  11. 8
      src/main/java/com/iflytop/sgs/app/service/device/module/SolutionModuleService.java
  12. 2
      src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java
  13. 4
      src/main/java/com/iflytop/sgs/common/enums/data/DevicePositionCode.java

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

@ -1,11 +1,9 @@
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;
import com.iflytop.sgs.app.model.bo.status.device.SolutionModuleState;
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.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
@ -15,8 +13,6 @@ import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.enums.HeatModuleCode;
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;
@ -34,60 +30,47 @@ public class CleanStartCommand extends BaseCommandHandler {
private final SolutionModuleService solutionModuleService;
private final DevicePositionService devicePositionService;
private final TransferModuleService transferModuleService;
private final DeviceStateService deviceStateService;
private final HeatModuleService heatModuleService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//清洗次数
Integer cycle = cmdDTO.getIntegerParam("cycle");
String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode");
HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标加热模块
//TODO 判断目标加热模块传感器是否有托盘如果没有托盘的话提示错误
JSONArray jsonArray=cmdDTO.getJSONArrayParam("index");
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
HeatModuleState heatModuleState=deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
SolutionModuleState solutionModuleState=deviceStateService.getDeviceState().getSolutionModule();
//转运模块Z轴拿取托盘时起下降的高度位置
Point3D transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPoint3D();
//转运模块Z轴移动托盘时起托盘的高度位置
Point3D transferModuleZTrayUpMovePositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZTrayUpMovePositon).getPoint3D();
//转运模块X轴拿取托盘进出卡槽移动距离
double transferModuleXPickTrayMoveDistance=devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();
//获取指定加热模块上方点位
Point3D heatAreaTrayPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleId);
//获取加液区上方点位
Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();
//判断加热区有无托盘
Assert.isTrue(heatModuleState.getTrayStatus(),new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY,ResultCode.TARGET_HEAT_MODULE_NO_TRAY.getMsg()));
return runAsync(() -> {
//机械臂移动到加液区位置
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);
//加液臂z下降
transferModuleService.transferZMoveBy(clawTrayHeight);
//加液臂x左移 夹紧托盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayGrip);
//加液臂z上移动
transferModuleService.transferZMoveBy(-clawTrayHeight);
for (int i=0;i<jsonArray.size();i++) {
//x z 移动到index1位置 todo 坐标位置
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), new Point3D());
//加液臂下降 至加液位置 todo 坐标位置
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 100);
//抽液
//加水 todo
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离
Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距
Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon();//加液模块电机下降进入试管加液位置
//抽液
//加液臂抬升至安全距离 todo 坐标位置
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 100);
TrayState trayState = deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode);
return runAsync(() -> {
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(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点
for (int i = 0; i < cycle; i++) {
for(TubeState tubeState : trayState.getTubes()){ //TODO 切换阀门加液取等操作没完成以后再考虑应该是先对所有列进行加液然后从头再依次抽取
if(tubeState.isAddSolution() && tubeState.isExists()){
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),solutionModuleMotorDownInTubeAddPositon);//加液模块下降进入试管
//TODO
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -trayTubeHorizontalSpacingDistance);//X轴依次按照试管间距移动
}
}
}
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);//加液模块上升至最高移出试管
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), targetHeatModuleTrayClawPoint3D.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轴抬升至最高
});
}
}

42
src/main/java/com/iflytop/sgs/app/cmd/control/CleanStopCommand.java

@ -1,42 +0,0 @@
package com.iflytop.sgs.app.cmd.control;
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.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.DevicePositionService;
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.HeatModuleCode;
import com.iflytop.sgs.common.enums.data.DevicePositionCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 结束清洗 todo wmy 需要改
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("heat_start")//业务指令注解
public class CleanStopCommand extends BaseCommandHandler {
private final SolutionModuleService solutionModuleService;
private final DevicePositionService devicePositionService;
private final TransferModuleService transferModuleService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
});
}
}

9
src/main/java/com/iflytop/sgs/app/cmd/control/DoorCloseCommand.java

@ -26,16 +26,9 @@ public class DoorCloseCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//获取当前的门状态
DoorModuleState doorModuleState=deviceStateService.getDeviceState().getDoorModule();
//判断当前门的状态
Assert.isTrue(doorModuleState.isOpen(),"门已处于关闭状态");
return runAsync(() -> {
//门电机回0点
deviceStateService.getDeviceState().getDoorModule().setOpen(false); //将门状态设置为false
doorModuleService.doorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);
//将门状态设置为false
deviceStateService.getDeviceState().getDoorModule().setOpen(false);
});
}
}

14
src/main/java/com/iflytop/sgs/app/cmd/control/DoorOpenCommand.java

@ -29,18 +29,12 @@ public class DoorOpenCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//获取当前的门状态
DoorModuleState doorModuleState=deviceStateService.getDeviceState().getDoorModule();
//判断当前门的状态
Assert.isTrue(!doorModuleState.isOpen(),"门已处于打开状态");
Double doorOpenPosition = devicePositionService.getPosition(DevicePositionCode.doorOpenPosition).getDistance();//获取开门位置
return runAsync(() -> {
//从数据库获取开门距离
Double doorOpenDistance = devicePositionService.getPosition(DevicePositionCode.doorOpen).getDistance();
//电机移动开门距离
doorModuleService.doorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorOpenDistance);
//将门状态设置为true
deviceStateService.getDeviceState().getDoorModule().setOpen(true);
deviceStateService.getDeviceState().getDoorModule().setOpen(true);//将门状态设置为true
doorModuleService.doorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorOpenPosition);
});
}
}

4
src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java

@ -68,7 +68,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
return runAsync(() -> {
try {
//升高加液电机高度 回0点
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);
//移动机械臂到加热区上方 此时机械臂夹着托盘
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayPoint3D);
//下降z轴
@ -76,7 +76,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
//移动x轴向右脱离托盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);
//z轴返回0点
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);
//设置加热区有托盘
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTrayStatus(true);
} finally {

4
src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java

@ -61,7 +61,7 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler {
return runAsync(() -> {
try {
//升高加液电机高度 回0点
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);
//移动机械臂到加热区上方 此时机械臂夹着托盘
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayPoint3D);
//下降z轴
@ -69,7 +69,7 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler {
//移动x轴向左托起托盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);
//z轴返回0点
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);
//移动到建邺区
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);
//设置加液区有托盘 todo

2
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java

@ -33,7 +33,7 @@ public class DebugLiquidMotorMoveToCommand extends BaseCommandHandler {
CommandFuture liquidMotorSetDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorSetDeviceCommandBundle);
CommandUtil.wait(liquidMotorSetDeviceCommandFuture);
DeviceCommandBundle liquidMotorMoveDeviceCommandBundle = DeviceCommandGenerator.liquidMotorMove(position);
DeviceCommandBundle liquidMotorMoveDeviceCommandBundle = DeviceCommandGenerator.solutionMotorMove(position);
CommandFuture liquidMotorMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorMoveDeviceCommandBundle);
CommandUtil.wait(liquidMotorMoveDeviceCommandFuture);
});

12
src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java

@ -21,7 +21,7 @@ public class DeviceState {
@Schema(description = "加热模块属性")
private final List<HeatModuleState> heatModule = new ArrayList<>();
@Schema(description = "托盘")
private final List<TrayState> tray = new ArrayList<>();
private final List<TrayState> trays = new ArrayList<>();
@Schema(description = "虚拟模式,true为虚拟")
private boolean virtual = false;
@Schema(description = "初始化状态,true初始化完毕")
@ -47,12 +47,16 @@ public class DeviceState {
return null;
}
public synchronized TrayState getTrayState(String trayUUID) {
for (TrayState t : tray) {
if (t.getUuid().equals(trayUUID)) {
/**
* 根据指定加热模块获取所属托盘
*/
public synchronized TrayState getTrayByHeatModuleCode(HeatModuleCode heatModuleCode) {
for (TrayState t : trays) {
if (heatModuleCode.equals(t.getHeatModuleCode())) {
return t;
}
}
return null;
}
}

2
src/main/java/com/iflytop/sgs/app/model/bo/status/device/TubeState.java

@ -9,7 +9,7 @@ public class TubeState {
@Schema(description = "列编号")
private int columnNum;
@Schema(description = "是否添加溶液 true添加")
@Schema(description = "是否添加溶液 true添加")
private boolean addSolution = false;
@Schema(description = "是否存在试管 true存在")

4
src/main/java/com/iflytop/sgs/app/service/api/TrayService.java

@ -22,7 +22,7 @@ public class TrayService {
public synchronized TrayState trayIn() {
TrayState trayState = new TrayState();
trayState.setInFeed(true);
deviceStateService.getDeviceState().getTray().add(trayState);
deviceStateService.getDeviceState().getTrays().add(trayState);
deviceStateService.setSolutionModuleStateTrayStatus(1);
return trayState;
}
@ -31,7 +31,7 @@ public class TrayService {
* 拿走了托盘
*/
public synchronized void trayOut() {
List<TrayState> trayList = deviceStateService.getDeviceState().getTray();
List<TrayState> trayList = deviceStateService.getDeviceState().getTrays();
trayList.removeIf(TrayState::isInSolutionModule);
deviceStateService.setSolutionModuleStateTrayStatus(0);
}

8
src/main/java/com/iflytop/sgs/app/service/device/module/SolutionModuleService.java

@ -89,15 +89,15 @@ public class SolutionModuleService {
/**
* 加液机械臂移动到指定点
*/
public void motorLiquidMove(double position) throws Exception {
motorLiquidMove(null, null, position);
public void solutionMotorMove(double position) throws Exception {
solutionMotorMove(null, null, position);
}
/**
* 加液机械臂移动到指定点
*/
public void motorLiquidMove(String cmdId, String cmdCode, double position) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidMotorMove(position);
public void solutionMotorMove(String cmdId, String cmdCode, double position) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.solutionMotorMove(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}

2
src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java

@ -187,7 +187,7 @@ public class DeviceCommandGenerator {
*
* @param position 位置 单位 mm
*/
public static DeviceCommandBundle liquidMotorMove(Double position) {
public static DeviceCommandBundle solutionMotorMove(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.liquid_motor, CmdAction.move, params, "加液升降电机移动");

4
src/main/java/com/iflytop/sgs/common/enums/data/DevicePositionCode.java

@ -32,10 +32,6 @@ public enum DevicePositionCode {
*/
solutionModuleMotorDownInTubeExtPositon(DevicePositionType.POSITION, "加液模块电机下降进入试管抽取位置"),
/**
* 转运模块Z轴电机上升进入试管位置
*/
transferModuleZMotorUpInTubePositon(DevicePositionType.POSITION, "转运模块Z轴电机上升进入试管位置"),
/**
* 转运模块Z轴拿取托盘时下降的高度位置
*/
transferModuleZPickTrayDownPositon(DevicePositionType.POSITION, "转运模块Z轴拿取托盘时起下降的高度位置"),

Loading…
Cancel
Save