diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZDisableCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZDisableCommand.java new file mode 100644 index 0000000..5aca7c2 --- /dev/null +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZDisableCommand.java @@ -0,0 +1,36 @@ +package com.iflytop.sgs.app.cmd.debug; + +import com.iflytop.sgs.app.core.BaseCommandHandler; +import com.iflytop.sgs.app.model.dto.CmdDTO; +import com.iflytop.sgs.app.service.device.DeviceCommandService; +import com.iflytop.sgs.common.annotation.CommandDebugMapping; +import com.iflytop.sgs.common.cmd.CommandFuture; +import com.iflytop.sgs.common.cmd.DeviceCommandBundle; +import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; +import com.iflytop.sgs.common.utils.CommandUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * z轴电机失能 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandDebugMapping("z_disable") +public class DebugMotorZDisableCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZDisable(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + CommandUtil.wait(deviceCommandFuture); + }); + } +} + diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZEnableCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZEnableCommand.java new file mode 100644 index 0000000..4265ee3 --- /dev/null +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZEnableCommand.java @@ -0,0 +1,36 @@ +package com.iflytop.sgs.app.cmd.debug; + +import com.iflytop.sgs.app.core.BaseCommandHandler; +import com.iflytop.sgs.app.model.dto.CmdDTO; +import com.iflytop.sgs.app.service.device.DeviceCommandService; +import com.iflytop.sgs.common.annotation.CommandDebugMapping; +import com.iflytop.sgs.common.cmd.CommandFuture; +import com.iflytop.sgs.common.cmd.DeviceCommandBundle; +import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; +import com.iflytop.sgs.common.utils.CommandUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +/** + * z轴电机使能 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandDebugMapping("z_enable") +public class DebugMotorZEnableCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public CompletableFuture handle(CmdDTO cmdDTO) { + return runAsync(() -> { + DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZEnable(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + CommandUtil.wait(deviceCommandFuture); + }); + } +} +