Browse Source

增加泵根据code移动指令

修改正传业务指令
master
王梦远 4 days ago
parent
commit
02d7fc58a1
  1. 6
      src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java
  2. 12
      src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java

6
src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java

@ -40,13 +40,17 @@ public class PumpRotateStartCommand extends BaseCommandHandler {
if (direction == null) { if (direction == null) {
throw new IllegalArgumentException("参数 direction 不能为空"); throw new IllegalArgumentException("参数 direction 不能为空");
} }
Double position = commandDTO.getDoubleParam("position");
if (position == null) {
throw new IllegalArgumentException("参数 position 不能为空");
}
return runAsync(() -> { return runAsync(() -> {
if (Direction.FORWARD.equals(direction)) { if (Direction.FORWARD.equals(direction)) {
DeviceCommand getPositionDeviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode); DeviceCommand getPositionDeviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode);
CommandFuture positionCommandFuture = deviceCommandService.sendCommand(getPositionDeviceCommand); CommandFuture positionCommandFuture = deviceCommandService.sendCommand(getPositionDeviceCommand);
CommandUtil.wait(positionCommandFuture); CommandUtil.wait(positionCommandFuture);
Integer currentPosition = (Integer) positionCommandFuture.getResponseResult().get("position"); Integer currentPosition = (Integer) positionCommandFuture.getResponseResult().get("position");
DeviceCommand deviceCommand = channelCtrlService.getPumpForwardRotateCommandByChannel(channelCode);
DeviceCommand deviceCommand = channelCtrlService.getPumpMoveCommandByChannel(channelCode, position);
CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand); CommandFuture commandFuture = deviceCommandService.sendCommand(deviceCommand);
CommandUtil.wait(commandFuture); CommandUtil.wait(commandFuture);
Integer newPosition = (Integer) commandFuture.getResponseResult().get("position"); Integer newPosition = (Integer) commandFuture.getResponseResult().get("position");

12
src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java

@ -165,6 +165,18 @@ public class ChannelCtrlService {
}; };
} }
/**
* 根据通道code获取泵移动指令
*/
public DeviceCommand getPumpMoveCommandByChannel(ChannelCode channelCode, Double position) {
return switch (channelCode) {
case CHANNEL_1 -> DeviceCommandGenerator.pump1MoveBy(position);
case CHANNEL_2 -> DeviceCommandGenerator.pump2MoveBy(position);
case CHANNEL_3 -> DeviceCommandGenerator.pump3MoveBy(position);
case CHANNEL_4 -> DeviceCommandGenerator.pump4MoveBy(position);
};
}
/** /**
* 根据通道code获取泵转数指令 * 根据通道code获取泵转数指令

Loading…
Cancel
Save