diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java index 3a0f2ef..de3a1c8 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/HeatStartCommand.java @@ -4,8 +4,8 @@ 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.DeviceCommandUtilService; import com.iflytop.sgs.app.service.device.DeviceStateService; +import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.enums.HeatModuleCode; import lombok.RequiredArgsConstructor; @@ -22,7 +22,7 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("heat_start")//业务指令注解 public class HeatStartCommand extends BaseCommandHandler { - private final DeviceCommandUtilService deviceCommandUtilService; + private final HeatModuleService heatModuleService; private final DeviceStateService deviceStateService; @Override @@ -35,13 +35,13 @@ public class HeatStartCommand extends BaseCommandHandler { HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); HeatModuleState heatModuleState = deviceStateService.getHeatModuleState(heatModuleId); //设置加热区目标温度 - deviceStateService.setHeatModuleStateTargetTemperature(heatModuleId,heatModuleState.getHeatTemperature()); + deviceStateService.setHeatModuleStateTargetTemperature(heatModuleId, heatModuleState.getHeatTemperature()); //从系统状态中获取指定加热区设定的烘干温度数值 double temperature = deviceStateService.getHeatModuleState(heatModuleId).getHeatTemperature(); //开启加热 - deviceCommandUtilService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature); + heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature); //设置加热区状态 正在加热 - deviceStateService.setHeatModuleStateHeating(heatModuleId,true); + deviceStateService.setHeatModuleStateHeating(heatModuleId, true); } }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/TransferXOriginCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/TransferXOriginCommand.java index abb0954..bced4f2 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/TransferXOriginCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/TransferXOriginCommand.java @@ -26,7 +26,7 @@ public class TransferXOriginCommand extends BaseCommandHandler { public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { transferModuleService.transferXMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); - selfTestService.getSelfTestState().setGantryXOrigin(true);//设置是否在原点状态 + selfTestService.getSelfTestState().setTransferXOrigin(true);//设置是否在原点状态 }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/TransferZOriginCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/TransferZOriginCommand.java index d4b0e3e..a32bb29 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/TransferZOriginCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/TransferZOriginCommand.java @@ -26,7 +26,7 @@ public class TransferZOriginCommand extends BaseCommandHandler { public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { transferModuleService.transferZMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); - selfTestService.getSelfTestState().setGantryZOrigin(true);//设置是否在原点状态 + selfTestService.getSelfTestState().setTransferZOrigin(true);//设置是否在原点状态 }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java index ffd263c..20a4559 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java @@ -37,7 +37,7 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler { Integer times = cmdDTO.getIntegerParam("times"); if (speed != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXSet(speed); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXSet(speed); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } @@ -47,13 +47,13 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler { return; } if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(-distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(-distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } @@ -61,7 +61,7 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler { } } else { if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java index 395df33..93bbf7e 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java @@ -28,7 +28,7 @@ public class DebugMotorXMoveToCommand extends BaseCommandHandler { public CompletableFuture handle(CmdDTO cmdDTO) { double position = cmdDTO.getDoubleParam("position"); return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMove(position); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMove(position); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java index e9e23af..63aa4f8 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java @@ -27,7 +27,7 @@ public class DebugMotorXOriginCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXOrigin(); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXOrigin(); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java index 676066a..e3d90b7 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java @@ -27,7 +27,7 @@ public class DebugMotorXStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXStop(); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXStop(); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java index 443b55e..488fa64 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java @@ -36,7 +36,7 @@ public class DebugMotorZMoveByCommand extends BaseCommandHandler { if (speed != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(speed); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZSet(speed); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } @@ -46,19 +46,19 @@ public class DebugMotorZMoveByCommand extends BaseCommandHandler { return; } if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(-distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(-distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } } } else { if (distance != null) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(distance); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(distance); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java index 31357e4..46308e8 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java @@ -29,7 +29,7 @@ public class DebugMotorZMoveToCommand extends BaseCommandHandler { public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { double position = cmdDTO.getDoubleParam("position"); return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMove(position); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMove(position); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java index 9a5e1a7..414aef0 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java @@ -27,7 +27,7 @@ public class DebugMotorZOriginCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZOrigin(); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZOrigin(); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java index f5d3c4b..cae3c42 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java @@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture; @Slf4j @Component @RequiredArgsConstructor -@CommandMapping("gantry_z_set") +@CommandMapping("z_set") public class DebugMotorZSetCommand extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; @@ -28,7 +28,7 @@ public class DebugMotorZSetCommand extends BaseCommandHandler { public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { double speed = cmdDTO.getDoubleParam("speed"); - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(speed); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZSet(speed); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java index b2870fe..a17af08 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java @@ -27,7 +27,7 @@ public class DebugMotorZStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZStop(); + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZStop(); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); }); diff --git a/src/main/java/com/iflytop/sgs/app/controller/SelfTestController.java b/src/main/java/com/iflytop/sgs/app/controller/SelfTestController.java index d5d23a6..db44e8d 100644 --- a/src/main/java/com/iflytop/sgs/app/controller/SelfTestController.java +++ b/src/main/java/com/iflytop/sgs/app/controller/SelfTestController.java @@ -1,7 +1,6 @@ package com.iflytop.sgs.app.controller; import com.iflytop.sgs.app.model.bo.status.SelfTestState; -import com.iflytop.sgs.app.service.device.DeviceCommandUtilService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.SelfTestService; import com.iflytop.sgs.common.result.Result; @@ -22,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController; public class SelfTestController { private final SelfTestService selfTestService; private final DeviceStateService deviceStateService; - private final DeviceCommandUtilService deviceCommandUtilService; @Operation(summary = "获取自检状态") @GetMapping("/status") diff --git a/src/main/java/com/iflytop/sgs/app/model/bo/status/SelfTestState.java b/src/main/java/com/iflytop/sgs/app/model/bo/status/SelfTestState.java index c428bf3..f8e0a39 100644 --- a/src/main/java/com/iflytop/sgs/app/model/bo/status/SelfTestState.java +++ b/src/main/java/com/iflytop/sgs/app/model/bo/status/SelfTestState.java @@ -12,14 +12,14 @@ public class SelfTestState { @Schema(description = "摇匀是否在原点") private boolean shakeOrigin = false; - @Schema(description = "龙门架机械臂x轴是否在原点") - private boolean gantryXOrigin = false; + @Schema(description = "转运机械臂x轴是否在原点") + private boolean transferXOrigin = false; - @Schema(description = "龙门架机械臂y轴是否在原点") - private boolean gantryYOrigin = false; + @Schema(description = "转运机械臂y轴是否在原点") + private boolean transferYOrigin = false; - @Schema(description = "龙门架机械臂z轴是否在原点") - private boolean gantryZOrigin = false; + @Schema(description = "转运机械臂z轴是否在原点") + private boolean transferZOrigin = false; @Schema(description = "加液机械臂是否在原点") private boolean dualRobotOrigin = false; diff --git a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java index 4202eee..a55d536 100644 --- a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java +++ b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DeviceState.java @@ -12,9 +12,9 @@ import java.util.List; @Data public class DeviceState { @Schema(description = "门状态") - private final DoorState door = new DoorState(); - @Schema(description = "龙门架机械臂状态") - private final GantryArmState gantryArm = new GantryArmState(); + private final DoorModuleState doorModule = new DoorModuleState(); + @Schema(description = "转运机械臂状态") + private final TransferModuleState transferModule = new TransferModuleState(); @Schema(description = "加液模块属性") private final SolutionModuleState solutionModule = new SolutionModuleState(); @Schema(description = "加热模块属性") diff --git a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorState.java b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java similarity index 90% rename from src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorState.java rename to src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java index 557a4c6..d16e215 100644 --- a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorState.java +++ b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/DoorModuleState.java @@ -5,7 +5,7 @@ import lombok.Data; @Schema(description = "门") @Data -public class DoorState { +public class DoorModuleState { @Schema(description = "是否开门,true为开启状态,false为关闭状态") private boolean open = false; } diff --git a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/GantryArmState.java b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/TransferModuleState.java similarity index 76% rename from src/main/java/com/iflytop/sgs/app/model/bo/status/device/GantryArmState.java rename to src/main/java/com/iflytop/sgs/app/model/bo/status/device/TransferModuleState.java index b503cbd..cb3c726 100644 --- a/src/main/java/com/iflytop/sgs/app/model/bo/status/device/GantryArmState.java +++ b/src/main/java/com/iflytop/sgs/app/model/bo/status/device/TransferModuleState.java @@ -3,9 +3,9 @@ package com.iflytop.sgs.app.model.bo.status.device; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -@Schema(description = "龙门架机械臂") +@Schema(description = "转运机模块") @Data -public class GantryArmState { +public class TransferModuleState { @Schema(description = "是否空闲,true为空闲,false为占用") private boolean idle = true; } diff --git a/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java b/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java index e22b108..47236c1 100644 --- a/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java +++ b/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java @@ -1,12 +1,9 @@ package com.iflytop.sgs.app.service.crafts; import cn.hutool.json.JSONObject; -import com.iflytop.sgs.app.core.CraftsDebugGenerator; import com.iflytop.sgs.app.model.bo.CraftsStep; import com.iflytop.sgs.app.service.api.DevicePositionService; -import com.iflytop.sgs.app.service.device.DeviceCommandUtilService; import com.iflytop.sgs.app.service.device.DeviceStateService; -import com.iflytop.sgs.app.service.device.GantryArmService; import com.iflytop.sgs.app.ws.server.WebSocketSender; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -17,10 +14,8 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class CraftsStepService { - private final DeviceCommandUtilService deviceCommandUtilService; private final DevicePositionService devicePositionService; private final WebSocketSender webSocketService; - private final GantryArmService gantryArmService; private final DeviceStateService deviceStateService; @@ -35,37 +30,10 @@ public class CraftsStepService { String method = step.getMethod(); JSONObject params = step.getParams(); return switch (method) { - case "addLiquid" -> addLiquid(heatId, params); - case "shaking" -> shaking(heatId, params); - case "startHeating" -> heating(heatId, params); default -> true; }; } - /** - * 将托盘从加热区移动至加液区并且添加溶液 - */ - private boolean addLiquid(String heatId, JSONObject params) throws Exception { - return true; - } - - /** - * 摇匀操作 - */ - private boolean shaking(String heatId, JSONObject params) throws Exception { - Integer second = params.getInt("second"); - webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "开始摇匀", params)); - delay(second); - webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatId, "停止摇匀", null)); - return true; - } - - /** - * 将托盘从加液区移动至加热区并开启加热 - */ - private boolean heating(String heatId, JSONObject params) throws Exception { - return true; - } /** * 延时等待 diff --git a/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java b/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java index e807ecb..2b67812 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/DeviceCommandService.java @@ -27,50 +27,9 @@ public class DeviceCommandService { private final WebSocketSender webSocketService; private final DeviceStateService deviceStateService; /** - * 需要等待加液区空闲的龙门架机械臂指令 + * 需要等待加液区空闲的转运机械臂指令 */ private final ConcurrentMap sendCommandFutureMap = new ConcurrentHashMap<>(); - private final BlockingQueue gantryCommandQueue = new LinkedBlockingQueue<>(); - - @PostConstruct - private void initExecutorThread() { - new Thread(this::executeCommands).start(); - } - - private void executeCommands() { - while (true) { - try { - deviceStateService.setGantryArmStateIdle(true); - CommandFuture[] commandFutureArray = gantryCommandQueue.take(); - for (CommandFuture commandFuture : commandFutureArray) { - executeCommand(commandFuture); - } - } catch (Exception e) { - Thread.currentThread().interrupt(); - } finally { - deviceStateService.setGantryArmStateIdle(false); - } - } - } - - public synchronized CommandFuture[] sendCommandGantryQueue(DeviceCommandBundle... deviceCommandBundles) { - return sendCommandGantryQueue(null, null, deviceCommandBundles); - } - - public synchronized CommandFuture[] sendCommandGantryQueue(String cmdId, String cmdCode, DeviceCommandBundle... deviceCommandBundles) { - List commandFutureList = new ArrayList<>(); - for (DeviceCommandBundle deviceCommandBundle : deviceCommandBundles) { - commandFutureList.add(createDeviceCommandFuture(cmdId, cmdCode, deviceCommandBundle)); - } - CommandFuture[] commandFutureArray = commandFutureList.toArray(new CommandFuture[0]); - try { - gantryCommandQueue.put(commandFutureArray); - } catch (Exception e) { - log.error("设备指令入队列失败", e); - throw new RuntimeException(e); - } - return commandFutureArray; - } /** * 根据 DeviceCommand 创建 CommandFuture diff --git a/src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java b/src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java index 45ea3f8..58705ff 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/DeviceStateService.java @@ -95,14 +95,14 @@ public class DeviceStateService { } public synchronized void setDoorStatus(boolean status) { - boolean oldValue = deviceState.getDoor().isOpen(); - deviceState.getDoor().setOpen(status); + boolean oldValue = deviceState.getDoorModule().isOpen(); + deviceState.getDoorModule().setOpen(status); support.firePropertyChange("setDoorStatus", oldValue, status); } public synchronized void setGantryArmStateIdle(boolean idle) { - boolean oldValue = deviceState.getGantryArm().isIdle(); - deviceState.getGantryArm().setIdle(idle); + boolean oldValue = deviceState.getTransferModule().isIdle(); + deviceState.getTransferModule().setIdle(idle); support.firePropertyChange("setGantryArmStateIdle", oldValue, idle); } diff --git a/src/main/java/com/iflytop/sgs/app/service/device/GantryArmService.java b/src/main/java/com/iflytop/sgs/app/service/device/GantryArmService.java deleted file mode 100644 index 4bc3e64..0000000 --- a/src/main/java/com/iflytop/sgs/app/service/device/GantryArmService.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.iflytop.sgs.app.service.device; - - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -@Slf4j -@Service -@RequiredArgsConstructor -public class GantryArmService { - private final Lock liquidLock = new ReentrantLock(); - private final Condition liquidIdleCondition = liquidLock.newCondition(); - private final DeviceStateService deviceStateService; - - /** - * 等待加液区空闲 - */ - public void waitLiquidIdle() { - liquidLock.lock(); - try { - while (!deviceStateService.getDeviceState().getSolutionModule().isIdle()) { - liquidIdleCondition.await(); - } - } catch (InterruptedException e) { - throw new RuntimeException("等待加液区空闲错误", e); - } finally { - liquidLock.unlock(); - } - } - - /** - * 锁定加液区 - */ - public void setLiquidIdleFalse() { - liquidLock.lock(); - try { - deviceStateService.setSolutionModuleStateIdle(false); - liquidIdleCondition.signalAll(); // 唤醒所有等待的线程 - } finally { - liquidLock.unlock(); - } - } - - /** - * 释放加液区 - */ - public void setLiquidIdleTrue() { - liquidLock.lock(); - try { - deviceStateService.setSolutionModuleStateIdle(true); - liquidIdleCondition.signalAll(); // 唤醒所有等待的线程 - } finally { - liquidLock.unlock(); - } - } - -} diff --git a/src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java b/src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java index 23a820d..0474696 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java @@ -1,6 +1,7 @@ package com.iflytop.sgs.app.service.device; import com.iflytop.sgs.app.model.bo.Point3D; +import com.iflytop.sgs.app.service.device.module.TransferModuleService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -10,9 +11,9 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class StepCommandService { - private final DeviceCommandUtilService deviceCommandUtilService; + private final TransferModuleService transferModuleService; public void gantryToPoint3D(Point3D point3D) throws Exception { - deviceCommandUtilService.gantryMove(point3D); + transferModuleService.transferMove(point3D); } } diff --git a/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java b/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java index 1e5c840..661e3c5 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java @@ -19,8 +19,7 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor public class TransferModuleService { private final DeviceCommandService deviceCommandService; - private final DevicePositionService devicePositionService; - + /** * 转运机械臂移动到0点 @@ -44,24 +43,7 @@ public class TransferModuleService { CommandFuture transferXMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, transferXMoveDeviceCommand); DeviceCommandBundle transferZMoveDeviceCommand = DeviceCommandGenerator.transferZMove(point.getZ()); CommandFuture transferZMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, transferZMoveDeviceCommand); - CommandUtil.wait(transferXMoveDeviceCommandFuture,transferZMoveDeviceCommandFuture); - } - - /** - * 转运机械臂移动到指定点 - */ - public void transferMoveQueue(Point3D point) throws Exception { - transferMoveQueue(null, null, point); - } - - /** - * 转运机械臂移动到指定点 - */ - public void transferMoveQueue(String cmdId, String cmdCode, Point3D point) throws Exception { - DeviceCommandBundle transferXMoveDeviceCommand = DeviceCommandGenerator.transferXMove(point.getX()); - DeviceCommandBundle transferZMoveDeviceCommand = DeviceCommandGenerator.transferZMove(point.getZ()); - CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, transferXMoveDeviceCommand, transferZMoveDeviceCommand); - CommandUtil.wait(deviceCommandFutureArr); + CommandUtil.wait(transferXMoveDeviceCommandFuture, transferZMoveDeviceCommandFuture); } @@ -82,23 +64,6 @@ public class TransferModuleService { } /** - * 转运机械臂X轴回原点 - */ - public void transferXMoveOriginQueue() throws Exception { - transferXMoveOriginQueue(null, null); - } - - /** - * 转运机械臂X轴回原点 - */ - public void transferXMoveOriginQueue(String cmdId, String cmdCode) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXOrigin(); - CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFutureArr); - } - - - /** * 转运机械臂Z轴回原点 */ public void transferZMoveOrigin() throws Exception { @@ -114,23 +79,6 @@ public class TransferModuleService { CommandUtil.wait(deviceCommandFuture); } - - /** - * 转运机械臂Z轴回原点 - */ - public void transferZMoveOriginQueue() throws Exception { - transferZMoveOriginQueue(null, null); - } - - /** - * 转运机械臂Z轴回原点 - */ - public void transferZMoveOriginQueue(String cmdId, String cmdCode) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZOrigin(); - CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFutureArr); - } - /** * 转运机械臂X轴移动到指定点 */ @@ -148,22 +96,6 @@ public class TransferModuleService { } /** - * 转运机械臂X轴移动到指定点 - */ - public void transferXMoveQueue(double position) throws Exception { - transferXMoveQueue(null, null, position); - } - - /** - * 转运机械臂X轴移动到指定点 - */ - public void transferXMoveQueue(String cmdId, String cmdCode, double position) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMove(position); - CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFutureArr); - } - - /** * 转运机械臂Z轴移动到指定点 */ public void transferZMove(double position) throws Exception { @@ -181,22 +113,6 @@ public class TransferModuleService { } /** - * 转运机械臂Z轴移动到指定点 - */ - public void transferZMoveQueue(double position) throws Exception { - transferZMoveQueue(null, null, position); - } - - /** - * 转运机械臂Z轴移动到指定点 - */ - public void transferZMoveQueue(String cmdId, String cmdCode, double position) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMove(position); - CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFutureArr); - } - - /** * 转运机械臂X轴相对移动到指定点 */ public void transferXMoveBy(double position) throws Exception { @@ -213,22 +129,6 @@ public class TransferModuleService { } /** - * 转运机械臂X轴相对移动到指定点 - */ - public void transferXMoveByQueue(double position) throws Exception { - transferXMoveByQueue(null, null, position); - } - - /** - * 转运机械臂X轴相对移动到指定点 - */ - public void transferXMoveByQueue(String cmdId, String cmdCode, double position) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferXMoveBy(position); - CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFutureArr); - } - - /** * 转运机械臂Z轴相对移动到指定点 */ public void transferZMoveBy(double position) throws Exception { @@ -243,20 +143,4 @@ public class TransferModuleService { CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); CommandUtil.wait(deviceCommandFuture); } - - /** - * 转运机械臂Z轴相对移动到指定点 - */ - public void transferZMoveByQueue(double position) throws Exception { - transferZMoveByQueue(null, null, position); - } - - /** - * 转运机械臂Z轴相对移动到指定点 - */ - public void transferZMoveByQueue(String cmdId, String cmdCode, double position) throws Exception { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZMoveBy(position); - CommandFuture[] deviceCommandFutureArr = deviceCommandService.sendCommandGantryQueue(cmdId, cmdCode, deviceCommand); - CommandUtil.wait(deviceCommandFutureArr); - } } diff --git a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java index 20e0964..9aa7c2f 100644 --- a/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java @@ -94,7 +94,7 @@ public class DeviceCommandGenerator { /** - * 龙门架 x轴回原点 + * 转运 x轴回原点 */ public static DeviceCommandBundle transferXOrigin() { return controlMotorCmd(CmdDevice.x_motor, CmdAction.origin, null, "x轴回原点");