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); + }); + } +} +