From d0e5ad56ff3c3a52be31626d306e7f83da199861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Sun, 11 May 2025 19:37:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iflytop/gd/app/cmd/HeatStartCommand.java | 4 +- .../com/iflytop/gd/app/cmd/HeatStopCommand.java | 4 +- .../iflytop/gd/app/cmd/MoveToHeatAreaCommand.java | 4 +- .../gd/app/cmd/MoveToSolutionAreaCommand.java | 4 +- .../com/iflytop/gd/app/cmd/TrayDownCommand.java | 4 +- .../java/com/iflytop/gd/app/cmd/TrayUpCommand.java | 4 +- .../gd/app/cmd/debug/FanStartCommandHandler.java | 4 +- .../gd/app/cmd/debug/FanStopCommandHandler.java | 4 +- .../app/cmd/debug/HeaterStartCommandHandler.java | 4 +- .../gd/app/cmd/debug/HeaterStopCommandHandler.java | 4 +- .../PalletElevatorLiftDownCommandHandler.java | 4 +- .../debug/PalletElevatorLiftUpCommandHandler.java | 4 +- .../debug/PalletElevatorStopCommandHandler.java | 4 +- .../iflytop/gd/app/core/device/DeviceState.java | 5 +- .../iflytop/gd/app/core/device/HeatAreaState.java | 8 ++ .../gd/app/core/device/SolutionAreaState.java | 4 +- .../gd/app/core/device/SolutionContainerState.java | 10 ++- .../com/iflytop/gd/app/core/device/TrayState.java | 4 +- .../iflytop/gd/app/service/CraftsStepService.java | 8 +- .../gd/app/service/DeviceCommandUtilService.java | 12 +-- .../app/service/DeviceStateInitializerService.java | 20 ++--- .../iflytop/gd/app/service/DeviceStateService.java | 91 ++++++++++++++++------ .../iflytop/gd/common/enums/HeatModuleCode.java | 17 ++++ .../iflytop/gd/common/enums/HeatModuleIdCode.java | 17 ---- 24 files changed, 151 insertions(+), 97 deletions(-) create mode 100644 src/main/java/com/iflytop/gd/common/enums/HeatModuleCode.java delete mode 100644 src/main/java/com/iflytop/gd/common/enums/HeatModuleIdCode.java diff --git a/src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java index 4d5e130..c9bcce2 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java +++ b/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 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); }); diff --git a/src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java index 6b0d079..3af6f17 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java +++ b/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 handle(CmdDTO cmdDTO) { String heatId = cmdDTO.getStringParam("heatId"); - HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); return runAsync(() -> { deviceCommandUtilService.heatRodClose(heatModuleId); }); diff --git a/src/main/java/com/iflytop/gd/app/cmd/MoveToHeatAreaCommand.java b/src/main/java/com/iflytop/gd/app/cmd/MoveToHeatAreaCommand.java index 91be111..6ecff43 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/MoveToHeatAreaCommand.java +++ b/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 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); //将机械臂移动至加液区托盘上方 diff --git a/src/main/java/com/iflytop/gd/app/cmd/MoveToSolutionAreaCommand.java b/src/main/java/com/iflytop/gd/app/cmd/MoveToSolutionAreaCommand.java index a363b97..fda7c1a 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/MoveToSolutionAreaCommand.java +++ b/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 handle(CmdDTO cmdDTO) { String heatId = cmdDTO.getStringParam("heatId"); - HeatModuleIdCode heatModuleId = HeatModuleIdCode.valueOf(heatId); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); return runAsync(() -> { gantryArmService.waitLiquidIdle();//等待加液区空闲 diff --git a/src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java b/src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java index a45c4f2..3632572 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java +++ b/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 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);//下降加热位托盘 diff --git a/src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java b/src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java index 016b9c4..7e53c26 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java +++ b/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 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);//抬升加热位托盘 diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.java index b0151c1..ec44e2c 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStartCommandHandler.java +++ b/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 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(); diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.java index ac997e8..210ddd7 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/FanStopCommandHandler.java +++ b/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 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(); diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java index 3258480..92797b1 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStartCommandHandler.java +++ b/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); diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java index e580b16..f292b5e 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/HeaterStopCommandHandler.java +++ b/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 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(); diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java index 2b29f21..dda4be0 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java +++ b/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); diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java index 7391245..7fd4cb1 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java +++ b/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); diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java index 4630711..4377d1d 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java +++ b/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(); diff --git a/src/main/java/com/iflytop/gd/app/core/device/DeviceState.java b/src/main/java/com/iflytop/gd/app/core/device/DeviceState.java index 4cdbd44..88b3d0a 100644 --- a/src/main/java/com/iflytop/gd/app/core/device/DeviceState.java +++ b/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 heatArea = new HashMap<>(); + private final List heatArea = new ArrayList<>(); @Schema(description = "托盘") private final List tray = new ArrayList<>(); diff --git a/src/main/java/com/iflytop/gd/app/core/device/HeatAreaState.java b/src/main/java/com/iflytop/gd/app/core/device/HeatAreaState.java index f8c350c..6a1091b 100644 --- a/src/main/java/com/iflytop/gd/app/core/device/HeatAreaState.java +++ b/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; + } } diff --git a/src/main/java/com/iflytop/gd/app/core/device/SolutionAreaState.java b/src/main/java/com/iflytop/gd/app/core/device/SolutionAreaState.java index 2f07b2b..8f6b3b5 100644 --- a/src/main/java/com/iflytop/gd/app/core/device/SolutionAreaState.java +++ b/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 solutionContainer = new HashMap<>(); + private List solutionContainer = new ArrayList<>(); @Schema(description = "是否正在加液,true正在加液,false未运行") private boolean pumping = false; diff --git a/src/main/java/com/iflytop/gd/app/core/device/SolutionContainerState.java b/src/main/java/com/iflytop/gd/app/core/device/SolutionContainerState.java index 8f53f7d..5f4ba7e 100644 --- a/src/main/java/com/iflytop/gd/app/core/device/SolutionContainerState.java +++ b/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; } } diff --git a/src/main/java/com/iflytop/gd/app/core/device/TrayState.java b/src/main/java/com/iflytop/gd/app/core/device/TrayState.java index 7032d01..edafebb 100644 --- a/src/main/java/com/iflytop/gd/app/core/device/TrayState.java +++ b/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; diff --git a/src/main/java/com/iflytop/gd/app/service/CraftsStepService.java b/src/main/java/com/iflytop/gd/app/service/CraftsStepService.java index a851894..e12f28c 100644 --- a/src/main/java/com/iflytop/gd/app/service/CraftsStepService.java +++ b/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();//等待加液区空闲 diff --git a/src/main/java/com/iflytop/gd/app/service/DeviceCommandUtilService.java b/src/main/java/com/iflytop/gd/app/service/DeviceCommandUtilService.java index 205db8d..8fc6430 100644 --- a/src/main/java/com/iflytop/gd/app/service/DeviceCommandUtilService.java +++ b/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); diff --git a/src/main/java/com/iflytop/gd/app/service/DeviceStateInitializerService.java b/src/main/java/com/iflytop/gd/app/service/DeviceStateInitializerService.java index 8c07917..1f7ea66 100644 --- a/src/main/java/com/iflytop/gd/app/service/DeviceStateInitializerService.java +++ b/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 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 heatArea = deviceState.getHeatArea(); + for (HeatModuleCode code : HeatModuleCode.values()) { + heatArea.add(new HeatAreaState(code)); + } List containerList = containerService.getList(); - Map solutionBucket = deviceState.getSolutionArea().getSolutionContainer(); + List 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)); } } diff --git a/src/main/java/com/iflytop/gd/app/service/DeviceStateService.java b/src/main/java/com/iflytop/gd/app/service/DeviceStateService.java index bfad5f6..3ecf5f3 100644 --- a/src/main/java/com/iflytop/gd/app/service/DeviceStateService.java +++ b/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); } diff --git a/src/main/java/com/iflytop/gd/common/enums/HeatModuleCode.java b/src/main/java/com/iflytop/gd/common/enums/HeatModuleCode.java new file mode 100644 index 0000000..acc204e --- /dev/null +++ b/src/main/java/com/iflytop/gd/common/enums/HeatModuleCode.java @@ -0,0 +1,17 @@ +package com.iflytop.gd.common.enums; + +import lombok.Getter; + +/** + * 加热模块code枚举 + * 格式为 "heat_module_01" ~ "heat_module_06" + */ +@Getter +public enum HeatModuleCode { + heat_module_01, + heat_module_02, + heat_module_03, + heat_module_04, + heat_module_05, + heat_module_06; +} diff --git a/src/main/java/com/iflytop/gd/common/enums/HeatModuleIdCode.java b/src/main/java/com/iflytop/gd/common/enums/HeatModuleIdCode.java deleted file mode 100644 index c460179..0000000 --- a/src/main/java/com/iflytop/gd/common/enums/HeatModuleIdCode.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.iflytop.gd.common.enums; - -import lombok.Getter; - -/** - * 加热模块id枚举 - * 格式为 "heat_module_01" ~ "heat_module_06" - */ -@Getter -public enum HeatModuleIdCode { - heat_module_01, - heat_module_02, - heat_module_03, - heat_module_04, - heat_module_05, - heat_module_06; -}