Browse Source

改为使用CommandUtil.wait等待

master
白凤吉 2 months ago
parent
commit
d2dd77516c
  1. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java
  2. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java
  3. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorSetCommand.java
  4. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorStopCommand.java
  5. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugFanStartCommand.java
  6. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugFanStopCommand.java
  7. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStartCommand.java
  8. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStopCommand.java
  9. 9
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveByCommand.java
  10. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java
  11. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorOriginCommand.java
  12. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorSetCommand.java
  13. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorStopCommand.java
  14. 6
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java
  15. 11
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpMoveByCommand.java
  16. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java
  17. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpSetCommand.java
  18. 9
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java
  19. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStopCommand.java
  20. 9
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java
  21. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java
  22. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java
  23. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXSetCommand.java
  24. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java
  25. 10
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java
  26. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java
  27. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java
  28. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java
  29. 3
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java
  30. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveCloseCommand.java
  31. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenThickWayCommand.java
  32. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenThinWayCommand.java
  33. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenVacantWayCommand.java
  34. 5
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenWasteWayCommand.java
  35. 23
      src/main/java/com/iflytop/sgs/common/utils/CommandUtil.java

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorCloseCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +29,7 @@ public class DebugDoorCloseCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(Double.valueOf(0));
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java

@ -10,6 +10,7 @@ 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.data.DevicePositionCode;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -33,7 +34,7 @@ public class DebugDoorOpenCommand extends BaseCommandHandler {
DevicePosition devicePosition = devicePositionService.getPosition(DevicePositionCode.doorOpen);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(devicePosition.getDistance());
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorSetCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,10 +27,10 @@ public class DebugDoorSetCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed=cmdDTO.getDoubleParam("speed");
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorStopCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +29,7 @@ public class DebugDoorStopCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugFanStartCommand.java

@ -8,6 +8,7 @@ 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.HeatModuleCode;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -38,7 +39,7 @@ public class DebugFanStartCommand extends BaseCommandHandler {
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugFanStopCommand.java

@ -8,6 +8,7 @@ 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.HeatModuleCode;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -38,7 +39,7 @@ public class DebugFanStopCommand extends BaseCommandHandler {
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStartCommand.java

@ -8,6 +8,7 @@ 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.HeatModuleCode;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -39,7 +40,7 @@ public class DebugHeaterStartCommand extends BaseCommandHandler {
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStopCommand.java

@ -8,6 +8,7 @@ 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.HeatModuleCode;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -38,7 +39,7 @@ public class DebugHeaterStopCommand extends BaseCommandHandler {
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

9
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveByCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -36,7 +37,7 @@ public class DebugLiquidMotorMoveByCommand extends BaseCommandHandler {
if (speed != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (times != null) {
for (int i = 0; i < times; i++) {
@ -46,19 +47,19 @@ public class DebugLiquidMotorMoveByCommand extends BaseCommandHandler {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}
} else {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -30,7 +31,7 @@ public class DebugLiquidMotorMoveToCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidSet(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorOriginCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +29,7 @@ public class DebugLiquidMotorOriginCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorSetCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,10 +27,10 @@ public class DebugLiquidMotorSetCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed=cmdDTO.getDoubleParam("speed");
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorStopCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +29,7 @@ public class DebugLiquidMotorStopCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

6
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java

@ -8,7 +8,7 @@ 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 io.swagger.v3.oas.models.security.SecurityScheme;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -30,7 +30,7 @@ public class DebugLiquidPumpAddCommand extends BaseCommandHandler {
Double volume = cmdDTO.getDoubleParam("volume");
//todo 量转换成转数
Double position = Double.valueOf(1000);
Double speed=cmdDTO.getDoubleParam("speed");
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
CmdDirection cmdDirection = CmdDirection.forward;
@ -38,7 +38,7 @@ public class DebugLiquidPumpAddCommand extends BaseCommandHandler {
if (speed != null) {
deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
});
}

11
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpMoveByCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -35,9 +36,9 @@ public class DebugLiquidPumpMoveByCommand extends BaseCommandHandler {
Integer channel = 1;
if (dimVelocity != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(dimVelocity,channel);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(dimVelocity, channel);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (times != null) {
for (int i = 0; i < times; i++) {
@ -47,19 +48,19 @@ public class DebugLiquidPumpMoveByCommand extends BaseCommandHandler {
if (dimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(dimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (dimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-dimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}
} else {
if (dimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(dimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java

@ -8,6 +8,7 @@ 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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -37,7 +38,7 @@ public class DebugLiquidPumpReduceCommand extends BaseCommandHandler {
if (speed != null) {
deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
});
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpSetCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,9 +29,9 @@ public class DebugLiquidPumpSetCommand extends BaseCommandHandler {
return runAsync(() -> {
double speed = cmdDTO.getDoubleParam("speed");
Integer channel = 1;
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed,channel);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed, channel);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

9
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java

@ -8,6 +8,7 @@ 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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,14 +29,14 @@ public class DebugLiquidPumpStartCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
Double speed = cmdDTO.getDoubleParam("speed");
String direction=cmdDTO.getStringParam("direction");//front back 正转倒转
Integer channel=1;
CmdDirection cmdDirection=CmdDirection.valueOf(direction);
String direction = cmdDTO.getStringParam("direction");//front back 正转倒转
Integer channel = 1;
CmdDirection cmdDirection = CmdDirection.valueOf(direction);
DeviceCommandBundle deviceCommand;
if (speed != null) {
deviceCommand = DeviceCommandGenerator.liquidPumpStart(cmdDirection);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
});
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStopCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -25,11 +26,11 @@ public class DebugLiquidPumpStopCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Integer channel=1;
Integer channel = 1;
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

9
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveByCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -38,7 +39,7 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler {
if (speed != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (times != null) {
for (int i = 0; i < times; i++) {
@ -48,13 +49,13 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}
@ -62,7 +63,7 @@ public class DebugMotorXMoveByCommand extends BaseCommandHandler {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXMoveToCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -29,7 +30,7 @@ public class DebugMotorXMoveToCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMove(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXOriginCommand.java

@ -7,12 +7,11 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
@ -30,7 +29,7 @@ public class DebugMotorXOriginCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXSetCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,10 +27,10 @@ public class DebugMotorXSetCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed=cmdDTO.getDoubleParam("speed");
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXStopCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +29,7 @@ public class DebugMotorXStopCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

10
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveByCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -15,7 +16,6 @@ import java.util.concurrent.CompletableFuture;
/**
* z轴电机相对移动
*
*/
@Slf4j
@Component
@ -38,7 +38,7 @@ public class DebugMotorZMoveByCommand extends BaseCommandHandler {
if (speed != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (times != null) {
for (int i = 0; i < times; i++) {
@ -48,19 +48,19 @@ public class DebugMotorZMoveByCommand extends BaseCommandHandler {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}
} else {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZMoveToCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -30,7 +31,7 @@ public class DebugMotorZMoveToCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMove(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZOriginCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +29,7 @@ public class DebugMotorZOriginCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZOrigin();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,10 +27,10 @@ public class DebugMotorZSetCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed=cmdDTO.getDoubleParam("speed");
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

3
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZStopCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,7 +29,7 @@ public class DebugMotorZStopCommand extends BaseCommandHandler {
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveCloseCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,9 +27,9 @@ public class DebugValveCloseCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand=DeviceCommandGenerator.valveClose();
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveClose();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenThickWayCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,9 +27,9 @@ public class DebugValveOpenThickWayCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand=DeviceCommandGenerator.valveTurn(1);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(1);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenThinWayCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,9 +27,9 @@ public class DebugValveOpenThinWayCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand=DeviceCommandGenerator.valveTurn(2);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(2);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenVacantWayCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,9 +27,9 @@ public class DebugValveOpenVacantWayCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand=DeviceCommandGenerator.valveTurn(3);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(3);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

5
src/main/java/com/iflytop/sgs/app/cmd/debug/DebugValveOpenWasteWayCommand.java

@ -7,6 +7,7 @@ import com.iflytop.sgs.common.annotation.CommandMapping;
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.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -26,9 +27,9 @@ public class DebugValveOpenWasteWayCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
DeviceCommandBundle deviceCommand=DeviceCommandGenerator.valveTurn(4);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.valveTurn(4);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
CommandUtil.wait(deviceCommandFuture);
});
}
}

23
src/main/java/com/iflytop/sgs/common/utils/CommandUtil.java

@ -0,0 +1,23 @@
package com.iflytop.sgs.common.utils;
import com.iflytop.sgs.common.cmd.CommandFuture;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
public class CommandUtil {
public static void wait(CommandFuture... futures) throws Exception {
wait(120L, futures);
}
public static void wait(Long timeout, CommandFuture... futures) throws Exception {
CompletableFuture<?>[] responseFutures = Arrays.stream(futures)
.map(CommandFuture::getResponseFuture)
.toArray(CompletableFuture[]::new);
CompletableFuture.allOf(responseFutures)
.get(timeout, TimeUnit.SECONDS);
}
}
Loading…
Cancel
Save