From 9a3057e2dc7f19561c4c77c20d59811496c7f472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Sun, 15 Jun 2025 10:45:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=A1=A5=E5=85=89=E7=81=AF=E3=80=81?= =?UTF-8?q?=E4=B8=89=E8=89=B2=E7=81=AF=E8=B0=83=E8=AF=95=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/debug/DebugFillLightCloseCommand.java | 36 +++++++++++++++++++++ .../command/debug/DebugFillLightOpenCommand.java | 37 ++++++++++++++++++++++ .../debug/DebugTriColorLightCloseCommand.java | 33 +++++++++++++++++++ .../debug/DebugTriColorLightOpenCommand.java | 33 +++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightCloseCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightOpenCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightCloseCommand.java create mode 100644 src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightOpenCommand.java diff --git a/src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightCloseCommand.java b/src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightCloseCommand.java new file mode 100644 index 0000000..8b4b2a3 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightCloseCommand.java @@ -0,0 +1,36 @@ +package com.iflytop.gd.app.command.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.device.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.command.CommandFuture; +import com.iflytop.gd.common.command.DeviceCommandBundle; +import com.iflytop.gd.common.command.DeviceCommandGenerator; +import com.iflytop.gd.common.utils.CommandUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 补光灯关 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_fill_light_close") +public class DebugFillLightCloseCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.fillLightClose(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + CommandUtil.wait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightOpenCommand.java b/src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightOpenCommand.java new file mode 100644 index 0000000..b250e00 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/command/debug/DebugFillLightOpenCommand.java @@ -0,0 +1,37 @@ +package com.iflytop.gd.app.command.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.device.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.command.CommandFuture; +import com.iflytop.gd.common.command.DeviceCommandBundle; +import com.iflytop.gd.common.command.DeviceCommandGenerator; +import com.iflytop.gd.common.utils.CommandUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 补光灯开 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_fill_light_open") +public class DebugFillLightOpenCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + Double lightIntensity = cmdDTO.getDoubleParam("lightIntensity"); + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.fillLightOpen(lightIntensity); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + CommandUtil.wait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightCloseCommand.java b/src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightCloseCommand.java new file mode 100644 index 0000000..4728f5e --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightCloseCommand.java @@ -0,0 +1,33 @@ +package com.iflytop.gd.app.command.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.device.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.hardware.drivers.TricolorLightDriver; +import com.iflytop.gd.hardware.type.MId; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 三色灯关 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_tri_color_light_close") +public class DebugTriColorLightCloseCommand extends BaseCommandHandler { + private final TricolorLightDriver tricolorLightDriver; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + + return runAsync(() -> { + tricolorLightDriver.close(MId.TriColorLight); + }); + } +} + diff --git a/src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightOpenCommand.java b/src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightOpenCommand.java new file mode 100644 index 0000000..13d0aab --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/command/debug/DebugTriColorLightOpenCommand.java @@ -0,0 +1,33 @@ +package com.iflytop.gd.app.command.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.hardware.drivers.TricolorLightDriver; +import com.iflytop.gd.hardware.type.MId; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * 三色灯开 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_tri_color_light_open") +public class DebugTriColorLightOpenCommand extends BaseCommandHandler { + private final TricolorLightDriver tricolorLightDriver; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + String colorStr = cmdDTO.getStringParam("color"); + TricolorLightDriver.Color color = TricolorLightDriver.Color.valueOf(colorStr); + return runAsync(() -> { + tricolorLightDriver.open(MId.TriColorLight, color); + }); + } +} +