|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.iflytop.sgs.app.cmd.debug; |
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
import com.iflytop.sgs.app.core.BaseCommandHandler; |
|
|
|
import com.iflytop.sgs.app.model.dto.CmdDTO; |
|
|
|
import com.iflytop.sgs.app.service.device.DeviceCommandService; |
|
|
@ -8,6 +9,8 @@ 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.enums.cmd.CmdDirection; |
|
|
|
import com.iflytop.sgs.common.exception.AppException; |
|
|
|
import com.iflytop.sgs.common.result.ResultCode; |
|
|
|
import com.iflytop.sgs.common.utils.CommandUtil; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -29,14 +32,17 @@ public class DebugLiquidPumpStartCommand extends BaseCommandHandler { |
|
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
|
Double speed = cmdDTO.getDoubleParam("speed"); |
|
|
|
String direction = cmdDTO.getStringParam("direction");//front back 正转倒转 |
|
|
|
Assert.notNull(direction, ()->new AppException(ResultCode.INVALID_PARAMETER)); |
|
|
|
CmdDirection cmdDirection = CmdDirection.valueOf(direction); |
|
|
|
return runAsync(() -> { |
|
|
|
DeviceCommandBundle deviceCommand; |
|
|
|
if (speed != null) { |
|
|
|
deviceCommand = DeviceCommandGenerator.liquidPumpStart(cmdDirection); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
DeviceCommandBundle liquidPumpSetCommand = DeviceCommandGenerator.liquidPumpSet(speed); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpSetCommand); |
|
|
|
CommandUtil.wait(deviceCommandFuture); |
|
|
|
} |
|
|
|
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpStart(cmdDirection); |
|
|
|
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); |
|
|
|
CommandUtil.wait(deviceCommandFuture); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|