diff --git a/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java b/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java index 882bc08..df1605e 100644 --- a/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java +++ b/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java @@ -1,10 +1,18 @@ package com.iflytop.handacid.app.command.control; 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.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.model.dto.CommandDTO; import com.iflytop.handacid.app.service.ChannelCtrlService; +import com.iflytop.handacid.app.service.DeviceCommandService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -19,14 +27,24 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("solution_add_start") public class SolutionAddStartCommand extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; private final ChannelCtrlService channelCtrlService; private final DeviceState deviceState; @Override public CompletableFuture 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(() -> { - channelCtrlService.solutionAddStart(); + DeviceCommand deviceCommand = channelCtrlService.getPumpMoveCommandByChannel(channelCode, position); + CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); + CommandUtil.wait(commandFuture); }); } } diff --git a/src/main/java/com/iflytop/handacid/app/command/control/SolutionPreFillStartCommand.java b/src/main/java/com/iflytop/handacid/app/command/control/SolutionPreFillStartCommand.java index 8521422..2fc43ae 100644 --- a/src/main/java/com/iflytop/handacid/app/command/control/SolutionPreFillStartCommand.java +++ b/src/main/java/com/iflytop/handacid/app/command/control/SolutionPreFillStartCommand.java @@ -1,7 +1,11 @@ package com.iflytop.handacid.app.command.control; import com.iflytop.handacid.app.common.annotation.CommandMapping; +import com.iflytop.handacid.app.common.enums.ChannelCode; +import com.iflytop.handacid.app.common.utils.CommandUtil; 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.DeviceState; import com.iflytop.handacid.app.model.dto.CommandDTO; import com.iflytop.handacid.app.service.ChannelCtrlService; @@ -13,7 +17,7 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 开始预充(废弃) + * 开始预充 */ @Slf4j @Component @@ -26,8 +30,14 @@ public class SolutionPreFillStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CommandDTO commandDTO) { + ChannelCode channelCode = commandDTO.getEnumParam("channelCode", ChannelCode.class); + if (channelCode == null) { + throw new IllegalArgumentException("参数 channelCode 不能为空"); + } return runAsync(() -> { - channelCtrlService.solutionPreFillStart(); + DeviceCommand deviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode); + CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); + CommandUtil.wait(commandFuture); }); } } diff --git a/src/main/java/com/iflytop/handacid/app/controller/TestController.java b/src/main/java/com/iflytop/handacid/app/controller/TestController.java index 40c7566..7b749ad 100644 --- a/src/main/java/com/iflytop/handacid/app/controller/TestController.java +++ b/src/main/java/com/iflytop/handacid/app/controller/TestController.java @@ -2,6 +2,7 @@ package com.iflytop.handacid.app.controller; import com.iflytop.handacid.app.common.enums.ChannelCode; import com.iflytop.handacid.app.core.state.DeviceState; +import com.iflytop.handacid.app.service.TestService; import com.iflytop.handacid.common.result.Result; import com.iflytop.handacid.hardware.service.AppEventBusService; import com.iflytop.handacid.hardware.type.A8kPacket; @@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController; public class TestController { private final DeviceState deviceState; private final AppEventBusService eventBus; + private final TestService testService; @Operation(summary = "启动虚拟模式") @PostMapping("/virtual") diff --git a/src/main/java/com/iflytop/handacid/app/model/bo/SyncOperationsChannel.java b/src/main/java/com/iflytop/handacid/app/model/bo/SyncOperationsChannel.java index 6c8bc0b..9a83119 100644 --- a/src/main/java/com/iflytop/handacid/app/model/bo/SyncOperationsChannel.java +++ b/src/main/java/com/iflytop/handacid/app/model/bo/SyncOperationsChannel.java @@ -12,7 +12,7 @@ public class SyncOperationsChannel { private ChannelCode channelCode; @Schema(description = "是否选中") - private volatile boolean selected = false; + private volatile Boolean selected = false; @Schema(description = "目标加液量(单位:mL)") private Double targetVolume;