diff --git a/src/main/java/com/iflytop/gd/hardware/HardwareService.java b/src/main/java/com/iflytop/gd/hardware/HardwareService.java index 7a14e98..edac94a 100644 --- a/src/main/java/com/iflytop/gd/hardware/HardwareService.java +++ b/src/main/java/com/iflytop/gd/hardware/HardwareService.java @@ -11,6 +11,7 @@ import com.iflytop.gd.common.enums.cmd.CmdDevice; import com.iflytop.gd.hardware.command.CommandHandler; import com.iflytop.gd.hardware.command.DeviceResponse; import com.iflytop.gd.hardware.command.checker.SupportMethod; +import com.iflytop.gd.hardware.exception.HardwareException; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -47,7 +48,6 @@ public class HardwareService { for (CmdDevice device : devices) { cmdHandlers.put(device, handler); } - } public boolean sendCommand(DeviceCommand cmd) { @@ -71,12 +71,18 @@ public class HardwareService { cmdHandlers.get(cmd.getDevice()).sendCommand(cmd); response.setSuccess(Boolean.TRUE); } else { + log.error("不支持的设备类型: {}", cmd.getDevice()); throw new InvalidParameterException(StrUtil.format("[Device]: {}", cmd.getDevice())); } + } catch (HardwareException e) { + log.error("HardwareException 指令执行失败: {}", e.getMessage(), e); + response.setSuccess(Boolean.FALSE); } catch (Exception e) { + log.error("指令执行失败: {}", e.getMessage(), e); response.setSuccess(Boolean.FALSE); - } finally { + } + finally { JSONObject jsonResponse = JSONUtil.parseObj(response); eventPublisher.publishEvent(new CommandFeedbackEvent(this, jsonResponse)); } diff --git a/src/main/java/com/iflytop/gd/hardware/constants/ActionOvertimeConstant.java b/src/main/java/com/iflytop/gd/hardware/constants/ActionOvertimeConstant.java index 5eab7b8..6b2a005 100644 --- a/src/main/java/com/iflytop/gd/hardware/constants/ActionOvertimeConstant.java +++ b/src/main/java/com/iflytop/gd/hardware/constants/ActionOvertimeConstant.java @@ -12,7 +12,7 @@ import java.util.List; @Component public class ActionOvertimeConstant { - final Integer defaultOvertime = 10 * 1000; + final Integer defaultOvertime = 60 * 1000; static class OvertimeConfigItem { public MId mid; diff --git a/src/main/java/com/iflytop/gd/hardware/drivers/StepMotorDriver/DoorDriver.java b/src/main/java/com/iflytop/gd/hardware/drivers/StepMotorDriver/DoorDriver.java index 1f0829f..2f99f0d 100644 --- a/src/main/java/com/iflytop/gd/hardware/drivers/StepMotorDriver/DoorDriver.java +++ b/src/main/java/com/iflytop/gd/hardware/drivers/StepMotorDriver/DoorDriver.java @@ -35,7 +35,7 @@ public class DoorDriver{ // ==== ==== ==== ==== ==== ==== Ctrl ==== ==== ==== ==== ==== ==== public void moveToHome(StepMotorMId stepMotorMId) throws Exception { - stepMotorCtrlDriver_.stepMotorEasyMoveToZero(stepMotorMId); + stepMotorCtrlDriver_.stepMotorEasyMoveToZeroBlock(stepMotorMId); } public void moveTo(StepMotorMId stepMotorMId, double position) throws Exception @@ -46,7 +46,7 @@ public class DoorDriver{ } int motorPosition = StepMotorHelper.toMotorPosition(position); - stepMotorCtrlDriver_.stepMotorEasyMoveTo(stepMotorMId, motorPosition); + stepMotorCtrlDriver_.stepMotorEasyMoveToBlock(stepMotorMId, motorPosition); } public void moveBy(StepMotorMId stepMotorMId, double distance) throws Exception @@ -57,7 +57,7 @@ public class DoorDriver{ } int motorPosition = StepMotorHelper.toMotorPosition(distance); - stepMotorCtrlDriver_.stepMotorEasyMoveBy(stepMotorMId, motorPosition); + stepMotorCtrlDriver_.stepMotorEasyMoveByBlock(stepMotorMId, motorPosition); } public void stop(StepMotorMId stepMotorMId) throws Exception { diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index f18b14b..0e6c853 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -46,7 +46,7 @@ - +