From aca1a247eee280a956e2500e0bea71f3a4c9e557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Mon, 2 Jun 2025 14:29:09 +0800 Subject: [PATCH] 1 --- .../gd/app/command/control/HeatStartCommand.java | 17 +++++++++++++++++ .../iflytop/gd/app/command/control/TrayDownCommand.java | 11 ----------- .../com/iflytop/gd/app/controller/TestController.java | 10 +++++++++- .../java/com/iflytop/gd/app/core/CraftsContext.java | 2 +- .../gd/app/service/crafts/CraftsStepService.java | 15 +++++++++++---- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java b/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java index 25897f7..58007ab 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java @@ -2,11 +2,13 @@ package com.iflytop.gd.app.command.control; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.api.DevicePositionService; import com.iflytop.gd.app.service.device.DeviceStateService; import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; import com.iflytop.gd.common.enums.HeatingType; +import com.iflytop.gd.common.enums.data.DevicePositionCode; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -23,6 +25,7 @@ import java.util.concurrent.CompletableFuture; public class HeatStartCommand extends BaseCommandHandler { private final HeatModuleService heatModuleService; private final DeviceStateService deviceStateService; + private final DevicePositionService devicePositionService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { @@ -32,12 +35,26 @@ public class HeatStartCommand extends BaseCommandHandler { Integer seconds = cmdDTO.getIntegerParam("seconds"); Double temperature = cmdDTO.getDoubleParam("temperature"); HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); + + double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); + double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); + return runAsync(() -> { heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, temperature); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(time); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatTemperature(temperature); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTemperature(temperature); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.thermostatic); +// if (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getHeatingType() == HeatingType.thermostatic) { +// schedulerManager.scheduleOnce(heatModuleCode, () -> { +// try { +// heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift); +// deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1); +// } catch (Exception e) { +// log.error("加热完毕抬起托盘错误{}", heatModuleCode, e); +// } +// }, deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTargetTime(), TimeUnit.SECONDS); +// } }); } } diff --git a/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java b/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java index 55971bb..39f864c 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java @@ -40,22 +40,11 @@ public class TrayDownCommand extends BaseCommandHandler { HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); //从数据库获取加热位下降托盘位置 double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); - double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); return runAsync(() -> { try { //下降加热位托盘 heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLower); deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(0); -// if (deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getHeatingType() == HeatingType.thermostatic) { -// schedulerManager.scheduleOnce(heatModuleCode,() -> { -// try { -// heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift); -// deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1); -// } catch (Exception e) { -// log.error("加热完毕抬起托盘错误{}", heatModuleCode, e); -// } -// }, deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTargetTime(), TimeUnit.SECONDS); -// } } catch (Exception e) { log.error("降下托盘失败", e); } diff --git a/src/main/java/com/iflytop/gd/app/controller/TestController.java b/src/main/java/com/iflytop/gd/app/controller/TestController.java index cb20f7c..a96e957 100644 --- a/src/main/java/com/iflytop/gd/app/controller/TestController.java +++ b/src/main/java/com/iflytop/gd/app/controller/TestController.java @@ -6,6 +6,7 @@ import com.iflytop.gd.app.service.api.TestService; import com.iflytop.gd.app.service.device.DeviceEmergencyStopService; import com.iflytop.gd.app.service.device.DeviceStateService; import com.iflytop.gd.app.service.device.module.CapModuleService; +import com.iflytop.gd.app.service.device.module.OtherModuleService; import com.iflytop.gd.app.service.device.module.SolutionModuleService; import com.iflytop.gd.common.result.Result; import com.iflytop.gd.hardware.exception.HardwareException; @@ -32,7 +33,7 @@ public class TestController { private final TestService testService; private final CapModuleService capModuleService; private final DeviceStateService deviceStateService; - private final SolutionModuleService solutionModuleService; + private final OtherModuleService otherModuleService; private final DeviceEmergencyStopService deviceEmergencyStopService; @Operation(summary = "获取所有传感器读数") @@ -84,4 +85,11 @@ public class TestController { deviceEmergencyStopService.release(); return Result.success(); } + + @Operation(summary = "工艺执行完毕蜂鸣器提醒") + @PostMapping("/crafts-finish-beep-remind") + public Result craftsFinishBeepRemind() throws Exception { + otherModuleService.craftsFinishBeepRemind(); + return Result.success(); + } } diff --git a/src/main/java/com/iflytop/gd/app/core/CraftsContext.java b/src/main/java/com/iflytop/gd/app/core/CraftsContext.java index 536d286..a98743f 100644 --- a/src/main/java/com/iflytop/gd/app/core/CraftsContext.java +++ b/src/main/java/com/iflytop/gd/app/core/CraftsContext.java @@ -94,7 +94,7 @@ public class CraftsContext implements Runnable { } } if (sm.getState().getId() == CraftStates.RUNNING) { - craftsStepService.finish(heatModuleCode); + craftsStepService.finish(heatModuleCode);//工艺执行完毕将托盘移动至加液模块 Message finishMsg = MessageBuilder.withPayload(CraftEvents.FINISH).build(); Mono.from(sm.sendEvent(Mono.just(finishMsg))).block(); } diff --git a/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java b/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java index 2836a6c..d92a769 100644 --- a/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java +++ b/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java @@ -9,20 +9,24 @@ import com.iflytop.gd.app.service.api.ContainerService; import com.iflytop.gd.app.service.api.DevicePositionService; import com.iflytop.gd.app.service.device.DeviceCommandTempUtilService; import com.iflytop.gd.app.service.device.DeviceStateService; -import com.iflytop.gd.app.service.device.module.CapModuleService; -import com.iflytop.gd.app.service.device.module.GantryModuleService; -import com.iflytop.gd.app.service.device.module.HeatModuleService; -import com.iflytop.gd.app.service.device.module.SolutionModuleService; +import com.iflytop.gd.app.service.device.module.*; import com.iflytop.gd.app.ws.server.WebSocketSender; import com.iflytop.gd.common.enums.AcidPumpDeviceCode; 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; +import com.iflytop.gd.hardware.drivers.DODriver.OutputIOCtrlDriver; +import com.iflytop.gd.hardware.drivers.TricolorLightDriver; +import com.iflytop.gd.hardware.exception.HardwareException; +import com.iflytop.gd.hardware.type.IO.OutputIOMId; +import com.iflytop.gd.hardware.type.MId; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.concurrent.CompletableFuture; + /** * 工艺步骤执行服务 */ @@ -40,6 +44,7 @@ public class CraftsStepService { private final DevicePositionService devicePositionService; private final DeviceStateService deviceStateService; private final DeviceCommandTempUtilService deviceCommandTempUtilService; + private final OtherModuleService otherModuleService; /** * 执行单个工艺步骤 @@ -160,6 +165,8 @@ public class CraftsStepService { */ public void finish(HeatModuleCode heatModuleCode) throws Exception { moveToSolutionModule(heatModuleCode); + //蜂鸣器提示 + otherModuleService.craftsFinishBeepRemind(); } /**