Browse Source

feat:增加设备状态

master
白凤吉 3 months ago
parent
commit
d0e5ad56ff
  1. 4
      src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java
  2. 4
      src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java
  3. 4
      src/main/java/com/iflytop/gd/app/cmd/MoveToHeatAreaCommand.java
  4. 4
      src/main/java/com/iflytop/gd/app/cmd/MoveToSolutionAreaCommand.java
  5. 4
      src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java
  6. 4
      src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java
  7. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.java
  8. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.java
  9. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java
  10. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java
  11. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java
  12. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java
  13. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java
  14. 5
      src/main/java/com/iflytop/gd/app/core/device/DeviceState.java
  15. 8
      src/main/java/com/iflytop/gd/app/core/device/HeatAreaState.java
  16. 4
      src/main/java/com/iflytop/gd/app/core/device/SolutionAreaState.java
  17. 10
      src/main/java/com/iflytop/gd/app/core/device/SolutionContainerState.java
  18. 4
      src/main/java/com/iflytop/gd/app/core/device/TrayState.java
  19. 8
      src/main/java/com/iflytop/gd/app/service/CraftsStepService.java
  20. 12
      src/main/java/com/iflytop/gd/app/service/DeviceCommandUtilService.java
  21. 20
      src/main/java/com/iflytop/gd/app/service/DeviceStateInitializerService.java
  22. 91
      src/main/java/com/iflytop/gd/app/service/DeviceStateService.java
  23. 4
      src/main/java/com/iflytop/gd/common/enums/HeatModuleCode.java

4
src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java

@ -4,7 +4,7 @@ import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.DeviceCommandUtilService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -25,7 +25,7 @@ public class HeatStartCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
Double temperature = cmdDTO.getDoubleParam("temperature");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
return runAsync(() -> {
deviceCommandUtilService.heatRodOpen(heatModuleId, temperature);
});

4
src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java

@ -4,7 +4,7 @@ import com.iflytop.gd.app.core.BaseCommandHandler;
import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.DeviceCommandUtilService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -24,7 +24,7 @@ public class HeatStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
return runAsync(() -> {
deviceCommandUtilService.heatRodClose(heatModuleId);
});

4
src/main/java/com/iflytop/gd/app/cmd/MoveToHeatAreaCommand.java

@ -7,7 +7,7 @@ import com.iflytop.gd.app.service.DeviceCommandUtilService;
import com.iflytop.gd.app.service.DevicePositionService;
import com.iflytop.gd.app.service.GantryArmService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -30,7 +30,7 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
return runAsync(() -> {
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹爪点
deviceCommandUtilService.gantryMove(liquidAreaTrayPoint3D); //将机械臂移动至加液区托盘上方

4
src/main/java/com/iflytop/gd/app/cmd/MoveToSolutionAreaCommand.java

@ -7,7 +7,7 @@ import com.iflytop.gd.app.service.DeviceCommandUtilService;
import com.iflytop.gd.app.service.DevicePositionService;
import com.iflytop.gd.app.service.GantryArmService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -30,7 +30,7 @@ public class MoveToSolutionAreaCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
return runAsync(() -> {
gantryArmService.waitLiquidIdle();//等待加液区空闲

4
src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java

@ -5,7 +5,7 @@ import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.DeviceCommandUtilService;
import com.iflytop.gd.app.service.DevicePositionService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -27,7 +27,7 @@ public class TrayDownCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
return runAsync(() -> {
double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); //获取加热位下降托盘位置
deviceCommandUtilService.heaterMotorMove(heatModuleId, trayLower);//下降加热位托盘

4
src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java

@ -5,7 +5,7 @@ import com.iflytop.gd.app.model.dto.CmdDTO;
import com.iflytop.gd.app.service.DeviceCommandUtilService;
import com.iflytop.gd.app.service.DevicePositionService;
import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -27,7 +27,7 @@ public class TrayUpCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
String heatId = cmdDTO.getStringParam("heatId");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
return runAsync(() -> {
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); //获取加热位抬升托盘位置
deviceCommandUtilService.heaterMotorMove(heatModuleId, trayLift);//抬升加热位托盘

4
src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +28,7 @@ public class FanStartCommandHandler extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(index);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index);
DeviceCommandBundle deviceCommand;
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Open();

4
src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +28,7 @@ public class FanStopCommandHandler extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(index);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index);
DeviceCommandBundle deviceCommand;
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Close();

4
src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -29,7 +29,7 @@ public class HeaterStartCommandHandler extends BaseCommandHandler {
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
Double temperature = cmdDTO.getDoubleParam("temperature");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(index);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index);
DeviceCommandBundle deviceCommand;
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Open(temperature);

4
src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +28,7 @@ public class HeaterStopCommandHandler extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(index);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index);
DeviceCommandBundle deviceCommand;
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heatRod1Close();

4
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -35,7 +35,7 @@ public class PalletElevatorLiftDownCommandHandler extends BaseCommandHandler {
Double velocity = cmdDTO.getDoubleParam("velocity");
Integer times = cmdDTO.getIntegerParam("times");
DeviceCommandBundle deviceCommand;
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(index);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index);
if (velocity != null) {
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Set(velocity);

4
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -34,7 +34,7 @@ public class PalletElevatorLiftUpCommandHandler extends BaseCommandHandler {
Double velocity = cmdDTO.getDoubleParam("velocity");
Integer times = cmdDTO.getIntegerParam("times");
DeviceCommandBundle deviceCommand;
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(index);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index);
if (velocity != null) {
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Set(velocity);

4
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.annotation.CommandMapping;
import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -33,7 +33,7 @@ public class PalletElevatorStopCommandHandler extends BaseCommandHandler {
palletElevatorLiftDownCommandHandler.stop();
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(index);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(index);
DeviceCommandBundle deviceCommand;
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Stop();

5
src/main/java/com/iflytop/gd/app/core/device/DeviceState.java

@ -1,13 +1,10 @@
package com.iflytop.gd.app.core.device;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Schema(description = "当前设备")
@Data
@ -31,7 +28,7 @@ public class DeviceState {
private final SolutionAreaState solutionArea = new SolutionAreaState();
@Schema(description = "加热操作区属性")
private final Map<HeatModuleIdCode, HeatAreaState> heatArea = new HashMap<>();
private final List<HeatAreaState> heatArea = new ArrayList<>();
@Schema(description = "托盘")
private final List<TrayState> tray = new ArrayList<>();

8
src/main/java/com/iflytop/gd/app/core/device/HeatAreaState.java

@ -1,11 +1,15 @@
package com.iflytop.gd.app.core.device;
import com.iflytop.gd.common.enums.HeatModuleCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "加热模块")
@Data
public class HeatAreaState {
@Schema(description = "加热模块code")
private HeatModuleCode moduleCode;
@Schema(description = "托盘状态,0为无托盘,1为有托盘,2为托盘抬起")
private int trayStatus = 0;
@ -20,4 +24,8 @@ public class HeatAreaState {
@Schema(description = "加热器当前温度")
private double temperature = 0.0;
public HeatAreaState(HeatModuleCode moduleCode) {
this.moduleCode = moduleCode;
}
}

4
src/main/java/com/iflytop/gd/app/core/device/SolutionAreaState.java

@ -4,7 +4,9 @@ import com.iflytop.gd.common.enums.ContainerCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Schema(description = "加液模块")
@ -20,7 +22,7 @@ public class SolutionAreaState {
private int trayStatus = 0;
@Schema(description = "溶液容器状态")
private Map<ContainerCode, SolutionContainerState> solutionContainer = new HashMap<>();
private List<SolutionContainerState> solutionContainer = new ArrayList<>();
@Schema(description = "是否正在加液,true正在加液,false未运行")
private boolean pumping = false;

10
src/main/java/com/iflytop/gd/app/core/device/SolutionContainerState.java

@ -1,5 +1,6 @@
package com.iflytop.gd.app.core.device;
import com.iflytop.gd.common.enums.ContainerCode;
import com.iflytop.gd.common.enums.ContainerType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -7,10 +8,12 @@ import lombok.Data;
@Schema(description = "溶液容器")
@Data
public class SolutionContainerState {
@Schema(description = "容器id")
@Schema(description = "容器数据id")
private Long id;
@Schema(description = "容器code")
private ContainerCode containerCode;
@Schema(description = "容器类型 solution溶液容器 neutralization中和容器")
private ContainerType type;
@ -20,8 +23,9 @@ public class SolutionContainerState {
@Schema(description = "容器是否为满,true为满,false不满")
private boolean full = false;
public SolutionContainerState(Long id, ContainerType type) {
public SolutionContainerState(Long id, ContainerCode containerCode, ContainerType type) {
this.id = id;
this.containerCode = containerCode;
this.type = type;
}
}

4
src/main/java/com/iflytop/gd/app/core/device/TrayState.java

@ -1,6 +1,6 @@
package com.iflytop.gd.app.core.device;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -13,7 +13,7 @@ public class TrayState {
private String uuid = UUID.randomUUID().toString();
@Schema(description = "所属加热模块id")
private HeatModuleIdCode heatModuleId;
private HeatModuleCode heatModuleId;
@Schema(description = "是否在加液区")
private boolean inSolutionArea = false;

8
src/main/java/com/iflytop/gd/app/service/CraftsStepService.java

@ -7,7 +7,7 @@ import com.iflytop.gd.app.model.bo.CraftsStep;
import com.iflytop.gd.app.model.bo.Point2D;
import com.iflytop.gd.app.model.bo.Point3D;
import com.iflytop.gd.common.enums.AcidPumpDeviceCode;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import com.iflytop.gd.common.exception.AppException;
import com.iflytop.gd.common.result.ResultCode;
@ -50,7 +50,7 @@ public class CraftsStepService {
* 将托盘从加热区移动至加液区并且添加溶液
*/
private boolean addLiquid(String heatId, JSONObject params) throws Exception {
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "等待加液区空闲", null));
gantryArmService.waitLiquidIdle();//等待加液区空闲
@ -154,7 +154,7 @@ public class CraftsStepService {
* 将托盘从加液区移动至加热区并开启加热
*/
private boolean heating(String heatId, JSONObject params) throws Exception {
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
//if 判断加液区是否有托盘
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液区托盘夹爪点
@ -231,7 +231,7 @@ public class CraftsStepService {
* 拍照操作·
*/
private boolean takePhoto(String heatId) throws Exception {
HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId);
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId);
webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "等待加液区空闲", null));
gantryArmService.waitLiquidIdle();//等待加液区空闲

12
src/main/java/com/iflytop/gd/app/service/DeviceCommandUtilService.java

@ -7,7 +7,7 @@ import com.iflytop.gd.common.cmd.CommandFuture;
import com.iflytop.gd.common.cmd.DeviceCommandBundle;
import com.iflytop.gd.common.cmd.DeviceCommandGenerator;
import com.iflytop.gd.common.enums.AcidPumpDeviceCode;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import com.iflytop.gd.common.enums.data.DevicePositionCode;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@ -122,7 +122,7 @@ public class DeviceCommandUtilService {
/**
* 加热模块升降电机移动到指定位置
*/
public void heaterMotorMove(HeatModuleIdCode heatModuleId, double position) throws Exception {
public void heaterMotorMove(HeatModuleCode heatModuleId, double position) throws Exception {
DeviceCommandBundle deviceCommand = switch (heatModuleId) {
case heat_module_01 -> DeviceCommandGenerator.heaterMotor1Move(position);
case heat_module_02 -> DeviceCommandGenerator.heaterMotor2Move(position);
@ -195,7 +195,7 @@ public class DeviceCommandUtilService {
/**
* 指定加热模块开始加热
*/
public void heatRodOpen(HeatModuleIdCode heatModuleId, double temperature) throws Exception {
public void heatRodOpen(HeatModuleCode heatModuleId, double temperature) throws Exception {
DeviceCommandBundle deviceCommand = switch (heatModuleId) {
case heat_module_01 -> DeviceCommandGenerator.heatRod1Open(temperature);
case heat_module_02 -> DeviceCommandGenerator.heatRod2Open(temperature);
@ -211,7 +211,7 @@ public class DeviceCommandUtilService {
/**
* 指定加热模块停止加热
*/
public void heatRodClose(HeatModuleIdCode heatModuleId) throws Exception {
public void heatRodClose(HeatModuleCode heatModuleId) throws Exception {
DeviceCommandBundle deviceCommand = switch (heatModuleId) {
case heat_module_01 -> DeviceCommandGenerator.heatRod1Close();
case heat_module_02 -> DeviceCommandGenerator.heatRod2Close();
@ -265,7 +265,7 @@ public class DeviceCommandUtilService {
/**
* 获取指定加热区托盘夹爪点位
*/
public Point3D getHeatAreaTrayClawPoint3D(HeatModuleIdCode heatModuleId) {
public Point3D getHeatAreaTrayClawPoint3D(HeatModuleCode heatModuleId) {
DevicePosition devicePosition = switch (heatModuleId) {
case heat_module_01 -> devicePositionService.getPosition(DevicePositionCode.heatArea1TrayClawPoint);
case heat_module_02 -> devicePositionService.getPosition(DevicePositionCode.heatArea2TrayClawPoint);
@ -281,7 +281,7 @@ public class DeviceCommandUtilService {
/**
* 获取指定加热区拍子夹爪点位
*/
public Point3D getHeatAreaCapClawPointPoint3D(HeatModuleIdCode heatModuleId) {
public Point3D getHeatAreaCapClawPointPoint3D(HeatModuleCode heatModuleId) {
DevicePosition devicePosition = switch (heatModuleId) {
case heat_module_01 -> devicePositionService.getPosition(DevicePositionCode.heatArea1CapClawPoint);
case heat_module_02 -> devicePositionService.getPosition(DevicePositionCode.heatArea2CapClawPoint);

20
src/main/java/com/iflytop/gd/app/service/DeviceStateInitializerService.java

@ -6,13 +6,12 @@ import com.iflytop.gd.app.core.device.SolutionContainerState;
import com.iflytop.gd.app.model.entity.Container;
import com.iflytop.gd.common.enums.ContainerCode;
import com.iflytop.gd.common.enums.ContainerType;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
@RequiredArgsConstructor
@ -23,21 +22,18 @@ public class DeviceStateInitializerService {
@PostConstruct
public void initializeDeviceState() {
DeviceState deviceState = deviceStateService.getDeviceState();
Map<HeatModuleIdCode, HeatAreaState> heatArea = deviceState.getHeatArea();
heatArea.put(HeatModuleIdCode.heat_module_01, new HeatAreaState());
heatArea.put(HeatModuleIdCode.heat_module_02, new HeatAreaState());
heatArea.put(HeatModuleIdCode.heat_module_03, new HeatAreaState());
heatArea.put(HeatModuleIdCode.heat_module_04, new HeatAreaState());
heatArea.put(HeatModuleIdCode.heat_module_05, new HeatAreaState());
heatArea.put(HeatModuleIdCode.heat_module_06, new HeatAreaState());
List<HeatAreaState> heatArea = deviceState.getHeatArea();
for (HeatModuleCode code : HeatModuleCode.values()) {
heatArea.add(new HeatAreaState(code));
}
List<Container> containerList = containerService.getList();
Map<ContainerCode, SolutionContainerState> solutionBucket = deviceState.getSolutionArea().getSolutionContainer();
List<SolutionContainerState> solutionBucket = deviceState.getSolutionArea().getSolutionContainer();
for (Container container : containerList) {
if (container.getType() == 0) {
solutionBucket.put(ContainerCode.valueOf(container.getCode()), new SolutionContainerState(container.getId(), ContainerType.solution));
solutionBucket.add(new SolutionContainerState(container.getId(), ContainerCode.valueOf(container.getCode()), ContainerType.solution));
} else {
solutionBucket.put(ContainerCode.valueOf(container.getCode()), new SolutionContainerState(container.getId(), ContainerType.neutralization));
solutionBucket.add(new SolutionContainerState(container.getId(), ContainerCode.valueOf(container.getCode()), ContainerType.neutralization));
}
}

91
src/main/java/com/iflytop/gd/app/service/DeviceStateService.java

@ -1,15 +1,11 @@
package com.iflytop.gd.app.service;
import com.iflytop.gd.app.core.device.DeviceState;
import com.iflytop.gd.app.core.device.HeatAreaState;
import com.iflytop.gd.app.core.device.TrayState;
import com.iflytop.gd.app.core.device.TubeState;
import com.iflytop.gd.app.core.device.*;
import com.iflytop.gd.app.core.listener.DeviceStateListener;
import com.iflytop.gd.common.enums.ContainerCode;
import com.iflytop.gd.common.enums.HeatModuleIdCode;
import com.iflytop.gd.common.enums.HeatModuleCode;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.beans.PropertyChangeSupport;
@ -64,36 +60,71 @@ public class DeviceStateService {
support.firePropertyChange("setGantryArmStateIdle", oldValue, idle);
}
public synchronized void setHeatAreaStateTrayStatus(HeatModuleIdCode heatModuleId, int trayStatus) {
HeatAreaState heatAreaState = deviceState.getHeatArea().get(heatModuleId);
public synchronized void setHeatAreaStateTrayStatus(HeatModuleCode heatModuleId, int trayStatus) {
HeatAreaState heatAreaState = null;
for (HeatAreaState t : deviceState.getHeatArea()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatAreaState = t;
break;
}
}
assert heatAreaState != null;
int oldValue = heatAreaState.getTrayStatus();
heatAreaState.setTrayStatus(trayStatus);
support.firePropertyChange("setHeatAreaStateTrayStatus", oldValue, trayStatus);
}
public synchronized void setHeatAreaStateHeating(HeatModuleIdCode heatModuleId, boolean heating) {
HeatAreaState heatAreaState = deviceState.getHeatArea().get(heatModuleId);
public synchronized void setHeatAreaStateHeating(HeatModuleCode heatModuleId, boolean heating) {
HeatAreaState heatAreaState = null;
for (HeatAreaState t : deviceState.getHeatArea()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatAreaState = t;
break;
}
}
assert heatAreaState != null;
boolean oldValue = heatAreaState.isHeating();
heatAreaState.setHeating(heating);
support.firePropertyChange("setHeatAreaStateHeating", oldValue, heating);
}
public synchronized void setHeatAreaStateCapExist(HeatModuleIdCode heatModuleId, boolean capStatus) {
HeatAreaState heatAreaState = deviceState.getHeatArea().get(heatModuleId);
public synchronized void setHeatAreaStateCapExist(HeatModuleCode heatModuleId, boolean capStatus) {
HeatAreaState heatAreaState = null;
for (HeatAreaState t : deviceState.getHeatArea()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatAreaState = t;
break;
}
}
assert heatAreaState != null;
boolean oldValue = heatAreaState.isCapExist();
heatAreaState.setCapExist(capStatus);
support.firePropertyChange("setHeatAreaStateCapExist", oldValue, capStatus);
}
public synchronized void setHeatAreaStateTargetTemperature(HeatModuleIdCode heatModuleId, double targetTemperature) {
HeatAreaState heatAreaState = deviceState.getHeatArea().get(heatModuleId);
public synchronized void setHeatAreaStateTargetTemperature(HeatModuleCode heatModuleId, double targetTemperature) {
HeatAreaState heatAreaState = null;
for (HeatAreaState t : deviceState.getHeatArea()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatAreaState = t;
break;
}
}
assert heatAreaState != null;
double oldValue = heatAreaState.getTargetTemperature();
heatAreaState.setTemperature(targetTemperature);
support.firePropertyChange("setHeatAreaStateTargetTemperature", oldValue, targetTemperature);
}
public synchronized void setHeatAreaStateTemperature(HeatModuleIdCode heatModuleId, double temperature) {
HeatAreaState heatAreaState = deviceState.getHeatArea().get(heatModuleId);
public synchronized void setHeatAreaStateTemperature(HeatModuleCode heatModuleId, double temperature) {
HeatAreaState heatAreaState = null;
for (HeatAreaState t : deviceState.getHeatArea()) {
if (heatModuleId.equals(t.getModuleCode())) {
heatAreaState = t;
break;
}
}
assert heatAreaState != null;
double oldValue = heatAreaState.getTemperature();
heatAreaState.setTemperature(temperature);
support.firePropertyChange("setHeatAreaStateTemperature", oldValue, temperature);
@ -124,18 +155,34 @@ public class DeviceStateService {
}
public synchronized void setSolutionContainerStateEmpty(ContainerCode containerCode, boolean empty) {
boolean oldValue = deviceState.getSolutionArea().getSolutionContainer().get(containerCode).isEmpty();
deviceState.getSolutionArea().getSolutionContainer().get(containerCode).setEmpty(empty);
SolutionContainerState solutionContainerState = null;
for (SolutionContainerState t : deviceState.getSolutionArea().getSolutionContainer()) {
if (containerCode.equals(t.getContainerCode())) {
solutionContainerState = t;
break;
}
}
assert solutionContainerState != null;
boolean oldValue = solutionContainerState.isEmpty();
solutionContainerState.setEmpty(empty);
support.firePropertyChange("setSolutionContainerStateEmpty", oldValue, empty);
}
public synchronized void setSolutionContainerStateFull(ContainerCode containerCode, boolean full) {
boolean oldValue = deviceState.getSolutionArea().getSolutionContainer().get(containerCode).isFull();
deviceState.getSolutionArea().getSolutionContainer().get(containerCode).setFull(full);
SolutionContainerState solutionContainerState = null;
for (SolutionContainerState t : deviceState.getSolutionArea().getSolutionContainer()) {
if (containerCode.equals(t.getContainerCode())) {
solutionContainerState = t;
break;
}
}
assert solutionContainerState != null;
boolean oldValue = solutionContainerState.isFull();
solutionContainerState.setFull(full);
support.firePropertyChange("setSolutionContainerStateFull", oldValue, full);
}
public synchronized void setTrayStateHeatModuleId(String trayUUID, HeatModuleIdCode heatModuleId) {
public synchronized void setTrayStateHeatModuleId(String trayUUID, HeatModuleCode heatModuleId) {
TrayState foundTrayState = null;
for (TrayState t : deviceState.getTray()) {
if (trayUUID.equals(t.getUuid())) {
@ -144,7 +191,7 @@ public class DeviceStateService {
}
}
assert foundTrayState != null;
HeatModuleIdCode oldValue = foundTrayState.getHeatModuleId();
HeatModuleCode oldValue = foundTrayState.getHeatModuleId();
foundTrayState.setHeatModuleId(heatModuleId);
support.firePropertyChange("setTrayStateHeatModuleId", oldValue, heatModuleId);
}

4
src/main/java/com/iflytop/gd/common/enums/HeatModuleIdCode.java → src/main/java/com/iflytop/gd/common/enums/HeatModuleCode.java

@ -3,11 +3,11 @@ package com.iflytop.gd.common.enums;
import lombok.Getter;
/**
* 加热模块id枚举
* 加热模块code枚举
* 格式为 "heat_module_01" ~ "heat_module_06"
*/
@Getter
public enum HeatModuleIdCode {
public enum HeatModuleCode {
heat_module_01,
heat_module_02,
heat_module_03,
Loading…
Cancel
Save