|
@ -1,10 +1,18 @@ |
|
|
package com.iflytop.handacid.app.command.control; |
|
|
package com.iflytop.handacid.app.command.control; |
|
|
|
|
|
|
|
|
import com.iflytop.handacid.app.common.annotation.CommandMapping; |
|
|
import com.iflytop.handacid.app.common.annotation.CommandMapping; |
|
|
|
|
|
import com.iflytop.handacid.app.common.enums.ChannelCode; |
|
|
|
|
|
import com.iflytop.handacid.app.common.enums.ChannelStateCode; |
|
|
|
|
|
import com.iflytop.handacid.app.common.enums.Direction; |
|
|
|
|
|
import com.iflytop.handacid.app.common.utils.CommandUtil; |
|
|
import com.iflytop.handacid.app.core.command.BaseCommandHandler; |
|
|
import com.iflytop.handacid.app.core.command.BaseCommandHandler; |
|
|
|
|
|
import com.iflytop.handacid.app.core.command.CommandFuture; |
|
|
|
|
|
import com.iflytop.handacid.app.core.command.DeviceCommand; |
|
|
|
|
|
import com.iflytop.handacid.app.core.state.ChannelState; |
|
|
import com.iflytop.handacid.app.core.state.DeviceState; |
|
|
import com.iflytop.handacid.app.core.state.DeviceState; |
|
|
import com.iflytop.handacid.app.model.dto.CommandDTO; |
|
|
import com.iflytop.handacid.app.model.dto.CommandDTO; |
|
|
import com.iflytop.handacid.app.service.ChannelCtrlService; |
|
|
import com.iflytop.handacid.app.service.ChannelCtrlService; |
|
|
|
|
|
import com.iflytop.handacid.app.service.DeviceCommandService; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
@ -19,14 +27,24 @@ import java.util.concurrent.CompletableFuture; |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
@CommandMapping("solution_add_start") |
|
|
@CommandMapping("solution_add_start") |
|
|
public class SolutionAddStartCommand extends BaseCommandHandler { |
|
|
public class SolutionAddStartCommand extends BaseCommandHandler { |
|
|
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
private final ChannelCtrlService channelCtrlService; |
|
|
private final ChannelCtrlService channelCtrlService; |
|
|
private final DeviceState deviceState; |
|
|
private final DeviceState deviceState; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
|
public CompletableFuture<Void> handle(CommandDTO commandDTO) { |
|
|
|
|
|
|
|
|
|
|
|
ChannelCode channelCode = commandDTO.getEnumParam("channelCode", ChannelCode.class); |
|
|
|
|
|
if (channelCode == null) { |
|
|
|
|
|
throw new IllegalArgumentException("参数 channelCode 不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
Double position = commandDTO.getDoubleParam("position"); |
|
|
|
|
|
if (position == null) { |
|
|
|
|
|
throw new IllegalArgumentException("参数 position 不能为空"); |
|
|
|
|
|
} |
|
|
return runAsync(() -> { |
|
|
return runAsync(() -> { |
|
|
channelCtrlService.solutionAddStart(); |
|
|
|
|
|
|
|
|
DeviceCommand deviceCommand = channelCtrlService.getPumpMoveCommandByChannel(channelCode, position); |
|
|
|
|
|
CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); |
|
|
|
|
|
CommandUtil.wait(commandFuture); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|