Browse Source

fix:测试问题修改

master
王梦远 2 months ago
parent
commit
eb7ab719ff
  1. 37
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidMotorOriginCommand.java
  2. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java
  3. 1
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStopCommand.java
  4. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java
  5. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToAnnealAreaCommand.java
  6. 1
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java
  7. 6
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java
  8. 8
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java
  9. 36
      src/main/java/com/iflytop/sgs/app/cmd/control/XOriginCommand.java
  10. 36
      src/main/java/com/iflytop/sgs/app/cmd/control/ZOriginCommand.java
  11. 11
      src/main/java/com/iflytop/sgs/app/cmd/selftest/MoveTestCommand.java
  12. 16
      src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java

37
src/main/java/com/iflytop/sgs/app/cmd/control/LiquidMotorOriginCommand.java

@ -0,0 +1,37 @@
package com.iflytop.sgs.app.cmd.control;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 加液位电机回原点
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("liquid_motor_origin")
public class LiquidMotorOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

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

@ -48,7 +48,7 @@ public class LiquidPreFillStartCommand extends BaseCommandHandler {
deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用
deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应的酸液通道打开
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatArea1TrayClawPoint.getX());//转运移动至加热位1
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatArea1TrayClawPoint.getX());//转运模块移动至加热位1
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),liquidAreaPreFillPoint);//加液机械臂下降至至预充点位
solutionModuleService.liquidPumpRotateForward(cmdDTO.getCommandId(), cmdDTO.getCommand());//预充开始 todo 测试后改动 需要测试一下
});

1
src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStopCommand.java

@ -34,6 +34,7 @@ public class LiquidPreFillStopCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
solutionModuleService.liquidPumpStop(cmdDTO.getCommandId(), cmdDTO.getCommand());//停止预充
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂归0
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用解除
deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束
});

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

@ -50,7 +50,7 @@ public class LiquidReduceCommand extends BaseCommandHandler {
double reduceNumber= systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.number_reduce);//抽液volume配置
return runAsync(() -> {
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//将X轴移动至加液时托盘位置点
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点
boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取夹爪是否有托盘
Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY));//判断转态
deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用
@ -66,7 +66,7 @@ public class LiquidReduceCommand extends BaseCommandHandler {
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升
}
}
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高移出试管
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升至最高移出试管
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至托盘至加液位置点
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用解除
deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束

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

@ -49,7 +49,6 @@ public class MoveToAnnealAreaCommand extends BaseCommandHandler {
} else {
heatModuleCode = null;
}
Point3D heatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleCode);//获取加热模块托盘夹取点
Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离
Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方点位
@ -69,6 +68,7 @@ public class MoveToAnnealAreaCommand extends BaseCommandHandler {
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽
}
}else{
Point3D heatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(heatModuleCode);//获取加热模块托盘夹取点
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至加热区托盘夹取点 + 进出卡槽移动距离
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleTrayClawPoint3D.getZ());//Z轴下降至夹取点使托盘落入石墨加热盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽

1
src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java

@ -77,6 +77,7 @@ public class MoveToFeedAreaCommand extends BaseCommandHandler {
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点使托盘落入上料区
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleXPickTrayMoveDistance);//X轴移出卡槽
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高
deviceStateService.getDeviceState().getTransferModule().setTrayStatus(false);//设定托盘夹爪为FALSE
}
deviceStateService.getDeviceState().getSolutionModule().setFeedAreaTrayStatus(true);//设定上料区托盘状态
});

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

@ -11,6 +11,8 @@ 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.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.enums.DeviceSensorCode;
import com.iflytop.sgs.common.enums.HeatModuleCode;
import com.iflytop.sgs.common.enums.data.DevicePositionCode;
@ -46,7 +48,9 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离
Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹爪位置点
//目标加热模块有无托盘
boolean heatModuleTrayExist=deviceSensorService.getTrayStateByHeatModuleCode(targetHeatModuleCode);//目标加热模块有无托盘
Assert.isTrue(!heatModuleTrayExist, ()->new AppException(ResultCode.TARGET_HEAT_MODULE_OCCUPIED));//提示被占用
return runAsync(() -> {
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置

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

@ -48,7 +48,7 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler {
targetHeatModuleCode = null;
}
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离
Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离
Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点
@ -56,10 +56,10 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler {
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液位置
boolean clawTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);//获取传感器状态
if(!clawTrayExist){//夹爪无托盘
if (!clawTrayExist) {//夹爪无托盘
if (targetHeatModuleCode == null) {//无加热模块参数
boolean feedTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态
Assert.isTrue(feedTrayExist, ()->new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须存在托盘
Assert.isTrue(feedTrayExist, () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区必须存在托盘
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离
transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getZ());//Z轴下降至夹取点使托盘落入石墨加热盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -transferModuleXPickTrayMoveDistance);//X轴进入卡槽
@ -75,8 +75,8 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler {
deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).setTrayStatus(false);//设定目标加热模块托盘状态
//deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInHeatModule(false);//设定托盘不在加热模块中 todo 报错
}
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点
}
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//x轴移动至加液时托盘位置点
//deviceStateService.getDeviceState().getTrayByHeatModuleCode(targetHeatModuleCode).setInSolutionPositon(true);//设定托盘在加液位中 todo 报错
});

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

@ -0,0 +1,36 @@
package com.iflytop.sgs.app.cmd.control;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* 处理复位x轴电机复位
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("x_origin")
public class XOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

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

@ -0,0 +1,36 @@
package com.iflytop.sgs.app.cmd.control;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* z轴电机复位
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("z_origin")
public class ZOriginCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

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

@ -5,12 +5,14 @@ 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.service.api.DevicePositionService;
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.app.ws.server.WebSocketSender;
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.data.DevicePositionCode;
import com.iflytop.sgs.common.exception.AppException;
@ -35,6 +37,7 @@ public class MoveTestCommand extends BaseCommandHandler {
private final DevicePositionService devicePositionService;
private final DeviceStateService deviceStateService;
private final WebSocketSender webSocketService;
private final DeviceSensorService deviceSensorService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
@ -50,9 +53,12 @@ public class MoveTestCommand extends BaseCommandHandler {
deviceStateService.getCommandMutexState().get().setMoveTest(true);
return runAsync(() -> {
try {
deviceSensorService.collectSensorState();//收集传感器转态
webSocketService.pushSelfMoveTest(SelfMoveTestGenerator.generateJson(cmdDTO.getCommandId(), cmdDTO.getCommand(), "1、各项传感器正常", 25));
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂抬升至最高
transferModuleService.transferZMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//Z轴抬升至最高
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),liquidAreaTrayPoint3D);//转移至加液区托盘点位
boolean clawTrayExist=deviceSensorService.getSensorStatus(DeviceSensorCode.CLAW_TRAY_EXIST);
transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), annealHeatModuleTrayClawPoint3D.getX());//将X轴移动至托盘夹取点
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管抽取位置
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液机械臂抬升至最高
@ -63,6 +69,11 @@ 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));
if(clawTrayExist){
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),feedAreaTrayPoint3D);//转移至加液区托盘点位
}
} finally {
deviceStateService.getCommandMutexState().get().setMoveTest(false);
}

16
src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java

@ -23,6 +23,19 @@ public class DeviceSensorService {
/*
* 获取传感器状态
* */
public boolean getTrayStateByHeatModuleCode(HeatModuleCode heatModuleCode) throws HardwareException {
DeviceSensorCode deviceSensorCode = switch (heatModuleCode) {
case heat_module_01 -> DeviceSensorCode.HEATER_TRAY_1_EXIST;
case heat_module_02 -> DeviceSensorCode.HEATER_TRAY_2_EXIST;
case heat_module_03 -> DeviceSensorCode.HEATER_TRAY_3_EXIST;
case heat_module_04 -> DeviceSensorCode.HEATER_TRAY_4_EXIST;
};
return deviceStatusService.getInputState(deviceSensorCode.name());
}
/*
* 获取传感器状态
* */
public boolean getSensorStatus(DeviceSensorCode sensorCode) throws HardwareException {
return deviceStatusService.getInputState(sensorCode.name());
}
@ -49,10 +62,9 @@ public class DeviceSensorService {
}
/**
* 采集所有传感器状态
* */
*/
public void collectSensorState() throws HardwareException {
HeatModuleState heat_module_01 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_01);
heat_module_01.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_1_EXIST));

Loading…
Cancel
Save