Browse Source

fix:增加业务指令

master
王梦远 2 months ago
parent
commit
626675c1b6
  1. 9
      src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java
  2. 9
      src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java
  3. 11
      src/main/java/com/iflytop/sgs/app/cmd/control/DoorCloseCommand.java
  4. 7
      src/main/java/com/iflytop/sgs/app/cmd/control/DoorOpenCommand.java
  5. 7
      src/main/java/com/iflytop/sgs/app/cmd/control/DryStartCommand.java
  6. 12
      src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java
  7. 6
      src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java
  8. 6
      src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java
  9. 5
      src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java
  10. 8
      src/main/java/com/iflytop/sgs/app/cmd/control/HeatStopCommand.java
  11. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java
  12. 4
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java
  13. 28
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java
  14. 18
      src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java
  15. 10
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java
  16. 10
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java
  17. 1
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java
  18. 1
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStopCommand.java
  19. 4
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java
  20. 2
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/HeatModuleState.java
  21. 16
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/PumpState.java
  22. 19
      src/main/java/com/iflytop/sgs/app/model/bo/status/device/ValveState.java
  23. 14
      src/main/java/com/iflytop/sgs/app/service/device/module/DoorModuleService.java
  24. 18
      src/main/java/com/iflytop/sgs/common/enums/PumpStateCode.java
  25. 3
      src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java
  26. 28
      src/main/java/com/iflytop/sgs/common/enums/ValveStateCode.java

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

@ -1,5 +1,6 @@
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;
@ -20,20 +21,24 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("heat_start")//业务指令注解
@CommandMapping("anneal_start")//业务指令注解
public class AnnealStartCommand extends BaseCommandHandler {
private final HeatModuleService heatModuleService;
private final DeviceStateService deviceStateService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId");
JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode");
return runAsync(() -> {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
//获取当前加热区
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断是否可以进行退火
Assert.isTrue(heatModuleState.getTrayStatus() == 1, heatModuleId + "加热区无托盘");
//设置加热区目标温度
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTargetTemperature(heatModuleState.getAnnealTemperature());
//从系统状态中获取指定加热区设定的退火温度数值

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

@ -1,7 +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.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
@ -19,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("heat_start")//业务指令注解
@CommandMapping("anneal_stop")//业务指令注解
public class AnnealStopCommand extends BaseCommandHandler {
private final HeatModuleService heatModuleService;
private final DeviceStateService deviceStateService;
@ -29,8 +31,13 @@ public class AnnealStopCommand extends BaseCommandHandler {
JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId");
return runAsync(() -> {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
//获取当前加热区
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断当前加热区是否处于退火状态
Assert.isTrue(heatModuleState.isAnnealing(), heatModuleId + "加热区目前不在退火状态");
//关闭加热
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId);
//设置加热区状态 退火结束

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

@ -1,6 +1,8 @@
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.status.device.DoorModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.DoorModuleService;
@ -24,9 +26,14 @@ public class DoorCloseCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//获取当前的门状态
DoorModuleState doorModuleState=deviceStateService.getDeviceState().getDoorModule();
//判断当前门的状态
Assert.isTrue(doorModuleState.isOpen(),"门已处于关闭状态");
return runAsync(() -> {
//门电机回原点
doorModuleService.doorOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand());
//门电机回0
doorModuleService.doorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);
//将门状态设置为false
deviceStateService.getDeviceState().getDoorModule().setOpen(false);
});

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

@ -1,6 +1,8 @@
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.status.device.DoorModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
@ -27,6 +29,11 @@ public class DoorOpenCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
//获取当前的门状态
DoorModuleState doorModuleState=deviceStateService.getDeviceState().getDoorModule();
//判断当前门的状态
Assert.isTrue(!doorModuleState.isOpen(),"门已处于打开状态");
return runAsync(() -> {
//从数据库获取开门距离
Double doorOpenDistance = devicePositionService.getPosition(DevicePositionCode.doorOpen).getDistance();

7
src/main/java/com/iflytop/sgs/app/cmd/control/DryStartCommand.java

@ -1,5 +1,6 @@
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;
@ -20,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("heat_start")//业务指令注解
@CommandMapping("dry_start")//业务指令注解
public class DryStartCommand extends BaseCommandHandler {
private final HeatModuleService deviceCommandUtilService;
private final DeviceStateService deviceStateService;
@ -34,11 +35,13 @@ public class DryStartCommand extends BaseCommandHandler {
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断有无托盘
Assert.isTrue(heatModuleState.getTrayStatus() == 1, heatModuleId + "加热区无托盘");
//设置加热区目标温度
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTargetTemperature(heatModuleState.getDryTemperature());
//从系统状态中获取指定加热区设定的烘干温度数值
double temperature = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).getDryTemperature();
//开启退火
//开启烘干
deviceCommandUtilService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature);
//设置加热区状态 正在烘干
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setDrying(true);

12
src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java

@ -1,7 +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.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
@ -19,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("heat_start")//业务指令注解
@CommandMapping("dry_stop")//业务指令注解
public class DryStopCommand extends BaseCommandHandler {
private final HeatModuleService heatModuleService;
private final DeviceStateService deviceStateService;
@ -31,9 +33,13 @@ public class DryStopCommand extends BaseCommandHandler {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//关闭加热
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断当前加热区是否处于烘干状态
Assert.isTrue(heatModuleState.isDrying(), heatModuleId + "加热区目前不在烘干状态");
//关闭烘干
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId);
//设置加热区状态 退火结束
//设置加热区状态 烘干结束
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setDrying(false);
}

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

@ -1,7 +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.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
@ -31,6 +33,10 @@ public class FanStartCommand extends BaseCommandHandler {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断风扇状态
Assert.isTrue(heatModuleState.isFanOpen(),heatModuleId+"加热区 风扇已打开");
heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setFanOpen(true);
}

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

@ -1,7 +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.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
@ -31,6 +33,10 @@ public class FanStopCommand extends BaseCommandHandler {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断风扇状态
Assert.isTrue(!heatModuleState.isFanOpen(),heatModuleId+"加热区 风扇已关闭");
heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setFanOpen(false);
}

5
src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java

@ -1,5 +1,6 @@
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;
@ -20,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("heat_start")//业务指令注解
@CommandMapping("heater_start")//业务指令注解
public class HeatStartCommand extends BaseCommandHandler {
private final HeatModuleService heatModuleService;
private final DeviceStateService deviceStateService;
@ -34,6 +35,8 @@ public class HeatStartCommand extends BaseCommandHandler {
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断是否可以进行退火
Assert.isTrue(heatModuleState.getTrayStatus() == 1, heatModuleId + "加热区无托盘");
//设置加热区目标温度
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTargetTemperature(heatModuleState.getHeatTemperature());
//从系统状态中获取指定加热区设定的烘干温度数值

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

@ -1,7 +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.status.device.HeatModuleState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.module.HeatModuleService;
@ -19,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("heat_stop")//业务指令注解
@CommandMapping("heater_stop")//业务指令注解
public class HeatStopCommand extends BaseCommandHandler {
private final HeatModuleService heatModuleService;
private final DeviceStateService deviceStateService;
@ -31,6 +33,10 @@ public class HeatStopCommand extends BaseCommandHandler {
for (int i = 0; i < heatIdJsonArray.size(); i++) {
String heatId = heatIdJsonArray.getStr(i);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//获取当前加热区状态
HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
//判断当前加热区是否处于退火状态
Assert.isTrue(heatModuleState.isHeating(), heatModuleId + "加热区目前不在加热状态");
//关闭加热
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setHeating(false);

4
src/main/java/com/iflytop/sgs/app/cmd/control/SolutionAddCommand.java → src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java

@ -17,8 +17,8 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("solution_add")//业务指令注解
public class SolutionAddCommand extends BaseCommandHandler {
@CommandMapping("liquid_add")//业务指令注解
public class LiquidAddCommand extends BaseCommandHandler {
private final SolutionModuleService solutionModuleService;
private final DeviceStateService deviceStateService;

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

@ -17,8 +17,8 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("solution_add")//业务指令注解
public class SolutionReduceCommand extends BaseCommandHandler {
@CommandMapping("liquid_reduce")//业务指令注解
public class LiquidReduceCommand extends BaseCommandHandler {
private final SolutionModuleService solutionModuleService;
private final DeviceStateService deviceStateService;

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

@ -1,7 +1,10 @@
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.HeatModuleState;
import com.iflytop.sgs.app.model.bo.status.device.PumpState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.DevicePositionService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
@ -10,6 +13,7 @@ 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.PumpStateCode;
import com.iflytop.sgs.common.enums.data.DevicePositionCode;
import com.iflytop.sgs.common.exception.AppException;
import com.iflytop.sgs.common.result.ResultCode;
@ -50,6 +54,12 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
}
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
HeatModuleState heatModuleState=deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId);
PumpState pumpState=deviceStateService.getDeviceState().getPumpState();
//判断是否有托盘
Assert.isTrue(heatModuleState.getTrayStatus()==0,heatModuleId+"此加热位已存在托盘");
//判断泵现在处于关闭状态
Assert.isTrue(pumpState.equals(PumpStateCode.close),"蠕动泵正在运行,无法转移");
//加液电机升起的安全高度
double liquidMotorSafeDistance = devicePositionService.getPosition(DevicePositionCode.clawTrayGrip).getDistance();
//获取机械臂夹取托盘的横向距离
@ -58,18 +68,28 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
double clawTrayHeight = devicePositionService.getPosition(DevicePositionCode.clawTrayHeight).getDistance();
//获取指定加热模块上方点位
Point3D heatAreaTrayClawPoint3D = heatModuleService.getHeatAreaTrayClawPoint3D(heatModuleId);
//获取加液模块的上方点位
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();
return runAsync(() -> {
try {
//升高加液电机高度
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorSafeDistance);
//移动到加液区点位
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);
//下降z轴
transferModuleService.transferZMove(clawTrayHeight);
//向左夹紧托盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayGrip);
//移动机械臂到加热区上方 此时机械臂夹着托盘
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawPoint3D); //将机械臂移动至加热模块上方
//下降z轴,夹爪脱离机械臂
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayClawPoint3D);
//下降z轴
transferModuleService.transferZMove(clawTrayHeight);
//移动x轴向右脱离托盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -clawTrayGrip);
//z轴返回原点
solutionModuleService.motorLiquidMove(0);
//z轴返回0点
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(),0);
//设置加热区有托盘
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTrayStatus(1);
} finally {
deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(false);
}

18
src/main/java/com/iflytop/sgs/app/cmd/control/MoveToSolutionAreaCommand.java → src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java

@ -25,8 +25,8 @@ import java.util.concurrent.CompletableFuture;
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("move_to_solution_area")//业务指令注解
public class MoveToSolutionAreaCommand extends BaseCommandHandler {
@CommandMapping("move_to_liquid_area")//业务指令注解
public class MoveToLiquidAreaCommand extends BaseCommandHandler {
private final HeatModuleService heatModuleService;
private final SolutionModuleService solutionModuleService;
private final TransferModuleService transferModuleService;
@ -66,16 +66,24 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
try {
//升高加液电机高度
solutionModuleService.motorLiquidMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorSafeDistance);
//机械臂移动到加热位上方或者上料位上方
//机械臂移动到加热位上方
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaTrayPoint3D);
//下降z轴
transferModuleService.transferZMove(clawTrayHeight);
//移动x轴向左夹紧托盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), clawTrayGrip);
//z轴上升到0点
transferModuleService.transferZMove(0);
//z轴上升到0点 todo 安全距离即可 需要测试
transferModuleService.transferZMove(100);
//机械臂移动到加液区
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);
//下降z轴
transferModuleService.transferZMove(clawTrayHeight);
//移动x轴向右放开托盘
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -clawTrayGrip);
//z轴上升到0点 todo 安全距离即可 需要测试
transferModuleService.transferZMove(100);
//todo x轴回原点
transferModuleService.transferXMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand());
} finally {
deviceStateService.getCommandMutexState().get().setMoveToSolutionAreaCommandExecuting(false);
}

10
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java

@ -1,14 +1,15 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.status.device.ValveState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
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.enums.SystemConfigCode;
import com.iflytop.sgs.common.enums.cmd.CmdDirection;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
@ -27,18 +28,17 @@ import java.util.concurrent.CompletableFuture;
public class DebugLiquidPumpAddCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final SystemConfigService systemConfigService;
private final DeviceStateService deviceStateService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double volume = cmdDTO.getDoubleParam("volume");
//todo 监测阀门开启状态 将加液量转换成电机转数
Double scale = Double.valueOf(systemConfigService.getSystemConfig(SystemConfigCode.scale_thin));
ValveState valveState = deviceStateService.getDeviceState().getValveState();
Double scale = Double.valueOf(systemConfigService.getSystemConfig(valveState.getState().getSystemConfigCode()));
Double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
CmdDirection cmdDirection = CmdDirection.forward;
DeviceCommandBundle deviceCommand;
if (speed != null) {
deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(position);

10
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java

@ -1,8 +1,11 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.bo.status.device.ValveState;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.api.SystemConfigService;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.common.annotation.CommandMapping;
import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
@ -24,12 +27,15 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("liquid_pump_reduce")
public class DebugLiquidPumpReduceCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final DeviceStateService deviceStateService;
private SystemConfigService systemConfigService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double volume = cmdDTO.getDoubleParam("volume");
//todo 量转换成转数
Double position = Double.valueOf(1000);
ValveState valveState = deviceStateService.getDeviceState().getValveState();
Double scale = Double.valueOf(systemConfigService.getSystemConfig(valveState.getState().getSystemConfigCode()));
Double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {

1
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java

@ -29,7 +29,6 @@ public class DebugLiquidPumpStartCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double speed = cmdDTO.getDoubleParam("speed");
String direction = cmdDTO.getStringParam("direction");//front back 正转倒转
Integer channel = 1;
CmdDirection cmdDirection = CmdDirection.valueOf(direction);
return runAsync(() -> {
DeviceCommandBundle deviceCommand;

1
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStopCommand.java

@ -26,7 +26,6 @@ public class DebugLiquidPumpStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Integer channel = 1;
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);

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

@ -34,6 +34,10 @@ public class DeviceState {
private User currentUser;
@Schema(description = "当前实验")
private Tasks currentTasks;
@Schema(description = "电磁阀状态")
private ValveState valveState;
@Schema(description = "蠕动泵状态")
private PumpState pumpState;
/**
* 获取指定加热模块状态
*/

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

@ -10,8 +10,6 @@ public class HeatModuleState {
@Schema(description = "加热模块code")
private HeatModuleCode moduleCode;
@Schema(description = "托盘升降状态,0为降下,1为抬起")
private int trayUp = 0;
@Schema(description = "托盘状态,0为无托盘,1为有托盘")
private int trayStatus = 0;

16
src/main/java/com/iflytop/sgs/app/model/bo/status/device/PumpState.java

@ -0,0 +1,16 @@
package com.iflytop.sgs.app.model.bo.status.device;
import com.iflytop.sgs.common.enums.PumpStateCode;
import com.iflytop.sgs.common.enums.ValveStateCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "电磁转换阀")
@Data
public class PumpState {
@Schema(description = "开关")
private PumpStateCode state;
}

19
src/main/java/com/iflytop/sgs/app/model/bo/status/device/ValveState.java

@ -1,5 +1,6 @@
package com.iflytop.sgs.app.model.bo.status.device;
import com.iflytop.sgs.common.enums.ValveStateCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -7,22 +8,8 @@ import lombok.Data;
@Data
public class ValveState {
@Schema(description = "稀硝酸开关 true开")
private boolean thin = false;
@Schema(description = "浓硝酸开关 true开")
private boolean thick = false;
@Schema(description = "废水开关 true开")
private boolean waste = false;
@Schema(description = "蒸馏水开关 true开")
private boolean water = false;
@Schema(description = "开关")
private ValveStateCode state;
}

14
src/main/java/com/iflytop/sgs/app/service/device/module/DoorModuleService.java

@ -22,13 +22,6 @@ public class DoorModuleService {
/**
* 门电机回原点
*/
public void doorOrigin() throws Exception {
doorOrigin(null, null);
}
/**
* 门电机回原点
*/
public void doorOrigin(String cmdId, String cmdCode) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand);
@ -38,13 +31,6 @@ public class DoorModuleService {
/**
* 门电机移动
*/
public void doorMove(double position) throws Exception {
doorMove(null, null, position);
}
/**
* 门电机移动
*/
public void doorMove(String cmdId, String cmdCode, double position) throws Exception {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand);

18
src/main/java/com/iflytop/sgs/common/enums/PumpStateCode.java

@ -0,0 +1,18 @@
package com.iflytop.sgs.common.enums;
import lombok.Getter;
/**
* 电磁转换阀状态枚举类 index为对应的物理通道
*
*/
@Getter
public enum PumpStateCode {
//加液时 液量的转换系数
open(),
close();
}

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

@ -12,7 +12,8 @@ public enum SystemConfigCode {
scale_thin("稀硝酸转换系数"),
scale_thick("浓硝酸转换系数"),
scale_water("水转换系数"),
scale_waste("废水转换系数");
scale_waste("废水转换系数"),
scale_vacant("空气转换系数");
private String description;

28
src/main/java/com/iflytop/sgs/common/enums/ValveStateCode.java

@ -0,0 +1,28 @@
package com.iflytop.sgs.common.enums;
import lombok.Getter;
/**
* 电磁转换阀状态枚举类 index为对应的物理通道
*
*/
@Getter
public enum ValveStateCode {
//加液时 液量的转换系数
thin_way(1, "稀硝酸通道",SystemConfigCode.scale_thin),
thick_way(2, "浓硝酸通道",SystemConfigCode.scale_thick),
water(3, "蒸馏水通道",SystemConfigCode.scale_water),
waste(4, "废水通道",SystemConfigCode.scale_waste),
vacant(5, "空气通道",SystemConfigCode.scale_vacant);
private final Integer index;
private final String description;
private SystemConfigCode systemConfigCode;
ValveStateCode(Integer index, String description, SystemConfigCode systemConfigCode) {
this.index = index;
this.description = description;
this.systemConfigCode = systemConfigCode;
}
}
Loading…
Cancel
Save