Browse Source

执行工艺的时候,不能执行其他指令

master
白凤吉 2 months ago
parent
commit
0945e87a95
  1. 7
      src/main/java/com/iflytop/gd/app/command/control/FanStartCommand.java
  2. 7
      src/main/java/com/iflytop/gd/app/command/control/FanStopCommand.java
  3. 8
      src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java
  4. 7
      src/main/java/com/iflytop/gd/app/command/control/HeatStopCommand.java
  5. 5
      src/main/java/com/iflytop/gd/app/command/control/MoveToHeatAreaCommand.java
  6. 5
      src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java
  7. 5
      src/main/java/com/iflytop/gd/app/command/control/ShakeStartCommand.java
  8. 7
      src/main/java/com/iflytop/gd/app/command/control/ShakeStopCommand.java
  9. 5
      src/main/java/com/iflytop/gd/app/command/control/SolutionAddCommand.java
  10. 5
      src/main/java/com/iflytop/gd/app/command/control/TakePhotoCommand.java
  11. 6
      src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java
  12. 6
      src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java
  13. 7
      src/main/java/com/iflytop/gd/app/command/control/WarmUpStartCommand.java
  14. 5
      src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java

7
src/main/java/com/iflytop/gd/app/command/control/FanStartCommand.java

@ -1,11 +1,14 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.HeatModuleService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -27,6 +30,10 @@ public class FanStartCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode);
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true);

7
src/main/java/com/iflytop/gd/app/command/control/FanStopCommand.java

@ -1,11 +1,14 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.HeatModuleService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -27,6 +30,10 @@ public class FanStopCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode);
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(false);

8
src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java

@ -1,6 +1,7 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.api.DevicePositionService;
import com.iflytop.gd.app.service.device.DeviceStateService;
@ -9,6 +10,8 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.HeatingType;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -36,7 +39,10 @@ public class HeatStartCommand extends BaseCommandHandler {
Integer seconds = cmdDTO.getIntegerParam("seconds");
Double temperature = cmdDTO.getDoubleParam("temperature");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode);
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, temperature);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(time);

7
src/main/java/com/iflytop/gd/app/command/control/HeatStopCommand.java

@ -1,12 +1,15 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.HeatModuleService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.HeatingType;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -29,6 +32,10 @@ public class HeatStopCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode);
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
//关闭加热
heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode);

5
src/main/java/com/iflytop/gd/app/command/control/MoveToHeatAreaCommand.java

@ -52,6 +52,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
}
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
//校验目标加热位是否有托盘
try {
@ -68,6 +69,9 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
if(solutionModuleState.getTrayStatus() == 0){
throw new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY);
}
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
} catch (Exception e) {
deviceStateService.getCommandMutexState().get().setMoveToHeatAreaCommandExecuting(false);
throw e;
@ -92,7 +96,6 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
return runAsync(() -> {
try {
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
trayState.setHeatModuleId(heatModuleCode);
capModuleService.capUpBalanceNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand());//提升拍子存放区至拍子夹取的高度
gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D); //将机械臂移动至加液模块上方

5
src/main/java/com/iflytop/gd/app/command/control/MoveToSolutionAreaCommand.java

@ -55,6 +55,7 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
}
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode);
//校验目标加热位是否有托盘
try {
@ -71,6 +72,9 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
if(solutionModuleState.getTrayStatus() == 1){
throw new AppException(ResultCode.SOLUTION_MODULE_OCCUPIED);
}
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
} catch (Exception e) {
deviceStateService.getCommandMutexState().get().setMoveToSolutionAreaCommandExecuting(false);
throw e;
@ -95,7 +99,6 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
return runAsync(() -> {
try {
TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode);
solutionModuleService.requestSolutionModule();//申请使用加液区并等待
capModuleService.capUpBalanceNoWait(cmdDTO.getCommandId(), cmdDTO.getCommand()); //提升拍子存放区至拍子夹取的高度
gantryModuleService.gantryMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatAreaCapClawPointPoint3D);//将机械臂移动至加热模块拍子上方

5
src/main/java/com/iflytop/gd/app/command/control/ShakeStartCommand.java

@ -1,6 +1,7 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.SolutionModuleService;
@ -35,6 +36,10 @@ public class ShakeStartCommand extends BaseCommandHandler {
if (deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() != 1) {
throw new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY);
}
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
deviceStateService.getCommandMutexState().get().setShakeStartCommandExecuting(true);
solutionModuleService.shakeStart(cmdDTO.getCommandId(), cmdDTO.getCommand());//开始摇匀

7
src/main/java/com/iflytop/gd/app/command/control/ShakeStopCommand.java

@ -1,10 +1,13 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.SolutionModuleService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -24,6 +27,10 @@ public class ShakeStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
solutionModuleService.shakeStop(cmdDTO.getCommandId(), cmdDTO.getCommand());//停止摇匀
solutionModuleService.shakeOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand());//摇匀回原点

5
src/main/java/com/iflytop/gd/app/command/control/SolutionAddCommand.java

@ -4,6 +4,7 @@ import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.model.entity.Container;
import com.iflytop.gd.app.service.api.ContainerService;
@ -50,6 +51,10 @@ public class SolutionAddCommand extends BaseCommandHandler {
if (deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() != 1) {
throw new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY);
}
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
deviceStateService.getCommandMutexState().get().setSolutionAddCommandExecuting(true);
deviceStateService.getDeviceState().getSolutionModule().setPumping(true);
return runAsync(() -> {

5
src/main/java/com/iflytop/gd/app/command/control/TakePhotoCommand.java

@ -1,6 +1,7 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.SolutionModuleService;
@ -29,6 +30,10 @@ public class TakePhotoCommand extends BaseCommandHandler {
if(deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() != 1){
throw new AppException(ResultCode.SOLUTION_MODULE_NO_TRAY);
}
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
solutionModuleService.fillLightOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), 100.0);
solutionModuleService.takePhoto(cmdDTO.getCommandId(), cmdDTO.getCommand());//拍照

6
src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java

@ -1,6 +1,7 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.api.DevicePositionService;
import com.iflytop.gd.app.service.device.DeviceStateService;
@ -38,6 +39,11 @@ public class TrayDownCommand extends BaseCommandHandler {
}
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
//从数据库获取加热位下降托盘位置
double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance();
return runAsync(() -> {

6
src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java

@ -1,6 +1,7 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.api.DevicePositionService;
import com.iflytop.gd.app.service.device.DeviceStateService;
@ -36,6 +37,11 @@ public class TrayUpCommand extends BaseCommandHandler {
}
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule();
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
//获取加热位抬升托盘位置
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance();
return runAsync(() -> {

7
src/main/java/com/iflytop/gd/app/command/control/WarmUpStartCommand.java

@ -1,12 +1,15 @@
package com.iflytop.gd.app.command.control;
import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.bo.status.device.TrayState;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.device.DeviceStateService;
import com.iflytop.gd.app.service.device.module.HeatModuleService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.HeatingType;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -29,6 +32,10 @@ public class WarmUpStartCommand extends BaseCommandHandler {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId);
Double temperature = cmdDTO.getDoubleParam("temperature");
TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode);
if (trayState != null && trayState.getCrafts() != null) {
throw new AppException(ResultCode.CRAFT_RUNNING);
}
return runAsync(() -> {
heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, temperature);
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setWarmUpTemperature(temperature);

5
src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java

@ -98,7 +98,10 @@ public class CraftsStepService {
* 工艺执行完毕
*/
public void finish(CraftsContext craftsContext) throws Exception {
HeatModuleCode heatModuleCode = craftsContext.getHeatModuleCode();
moveToSolutionModule(craftsContext.getHeatModuleCode());
heatModuleService.heatRodClose(heatModuleCode);//停止加热
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.finish);
//蜂鸣器提示
// otherModuleService.craftsFinishBeepRemind();
}
@ -200,8 +203,6 @@ public class CraftsStepService {
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0);//加热模块托盘升降状态
delay(second);
log.info("工艺{},加热完成", heatModuleCode);
heatModuleService.heatRodClose(heatModuleCode);//停止加热
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.finish);
log.info("工艺{},抬升加热位托盘", heatModuleCode);
heatModuleService.heaterMotorMove(heatModuleCode, trayLift);//抬升加热位托盘
return true;

Loading…
Cancel
Save