diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorClose.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorClose.java new file mode 100644 index 0000000..93ccc9d --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorClose.java @@ -0,0 +1,31 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 门电机 关门 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_close") +public class DebugDoorClose extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double position = cmdDTO.getDoubleParam("position"); + DeviceCommand deviceCommand = DeviceCommandGenerator.doorMove(position); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpen.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpen.java new file mode 100644 index 0000000..f0e44e2 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOpen.java @@ -0,0 +1,31 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 门电机 开门 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_open") +public class DebugDoorOpen extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double position = cmdDTO.getDoubleParam("position"); + DeviceCommand deviceCommand = DeviceCommandGenerator.doorMove(position); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOrigin.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOrigin.java new file mode 100644 index 0000000..4c5e815 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorOrigin.java @@ -0,0 +1,29 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 门电机 回原点 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_stop") +public class DebugDoorOrigin extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand deviceCommand = DeviceCommandGenerator.doorOrigin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorSet.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorSet.java new file mode 100644 index 0000000..7f9d45d --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorSet.java @@ -0,0 +1,32 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 门电机 设置参数 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_set") +public class DebugDoorSet extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Integer current = cmdDTO.getIntegerParam("current"); + Double speed = cmdDTO.getDoubleParam("speed"); + DeviceCommand deviceCommand = DeviceCommandGenerator.doorSet(current, speed); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStop.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStop.java new file mode 100644 index 0000000..b784a56 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugDoorStop.java @@ -0,0 +1,29 @@ +package com.iflytop.gd.app.cmd.debug; + +import com.iflytop.gd.app.core.BaseCommandHandler; +import com.iflytop.gd.app.model.dto.CmdDTO; +import com.iflytop.gd.app.service.DeviceCommandService; +import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.cmd.CommandFuture; +import com.iflytop.gd.common.cmd.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 门电机 停止移动 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_door_stop") +public class DebugDoorStop extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + DeviceCommand deviceCommand = DeviceCommandGenerator.doorStop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +}