Browse Source

feat:增加循环次数

master
白凤吉 3 months ago
parent
commit
32b1dc9d9c
  1. 2
      src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommandHandler.java
  2. 31
      src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommandHandler.java
  3. 2
      src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommandHandler.java
  4. 61
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java
  5. 59
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java
  6. 4
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java
  7. 86
      src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommandHandler.java
  8. 2
      src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommandHandler.java

2
src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommandHandler.java

@ -34,7 +34,7 @@ public class CoverElevatorLiftDownCommandHandler extends BaseCommandHandler {
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
}
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
});

31
src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawOpenCommandHandler.java

@ -22,21 +22,44 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("debug_holding_jaw_open")
public class HoldingJawOpenCommandHandler extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private boolean stop = false;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
this.stop = false;
return runAsync(() -> {
Double velocity = cmdDTO.getDoubleParam("velocity");
Double distance = cmdDTO.getDoubleParam("distance");
if(velocity != null) {
Integer times = cmdDTO.getIntegerParam("times");
if (velocity != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawSet(velocity);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
}
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
if (times != null) {
for (int i = 0; i < times; i++) {
if (stop) {
return;
}
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
DeviceCommandBundle backDeviceCommand = DeviceCommandGenerator.clawMove(-distance);
CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), backDeviceCommand);
commandWait(backDeviceCommandFuture);
}
} else {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawMove(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
}
});
}
public synchronized void stop() {
this.stop = true;
}
}

2
src/main/java/com/iflytop/gd/app/cmd/debug/HoldingJawPauseCommandHandler.java

@ -22,9 +22,11 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("debug_holding_jaw_pause")
public class HoldingJawPauseCommandHandler extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final HoldingJawOpenCommandHandler holdingJawOpenCommandHandler;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
holdingJawOpenCommandHandler.stop();
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.clawStop();
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);

61
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java

@ -24,13 +24,16 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("debug_pallet_elevator_lift_down")
public class PalletElevatorLiftDownCommandHandler extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private boolean stop = false;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
this.stop = false;
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
Double distance =- cmdDTO.getDoubleParam("distance");
Double distance = -cmdDTO.getDoubleParam("distance");
Double velocity = cmdDTO.getDoubleParam("velocity");
Integer times = cmdDTO.getIntegerParam("times");
DeviceCommandBundle deviceCommand;
HeatModuleId heatModuleId = HeatModuleId.valueOf(index);
if (velocity != null) {
@ -47,18 +50,54 @@ public class PalletElevatorLiftDownCommandHandler extends BaseCommandHandler {
commandWait(deviceCommandFuture);
}
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance);
default -> throw new RuntimeException("index 未找到");
if (times != null) {
for (int i = 0; i < times; i++) {
if (stop) {
return;
}
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance);
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance);
default -> throw new RuntimeException("index 未找到");
}
CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(backDeviceCommandFuture);
}
} else {
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance);
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
});
}
public synchronized void stop() {
this.stop = true;
}
}

59
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java

@ -23,13 +23,16 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("debug_pallet_elevator_lift_up")
public class PalletElevatorLiftUpCommandHandler extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private boolean stop = false;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
this.stop = false;
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
Double distance = cmdDTO.getDoubleParam("distance");
Double velocity = cmdDTO.getDoubleParam("velocity");
Integer times = cmdDTO.getIntegerParam("times");
DeviceCommandBundle deviceCommand;
HeatModuleId heatModuleId = HeatModuleId.valueOf(index);
if (velocity != null) {
@ -45,19 +48,55 @@ public class PalletElevatorLiftUpCommandHandler extends BaseCommandHandler {
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
}
if (times != null) {
for (int i = 0; i < times; i++) {
if (stop) {
return;
}
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance);
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance);
default -> throw new RuntimeException("index 未找到");
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(-distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(-distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(-distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(-distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(-distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(-distance);
default -> throw new RuntimeException("index 未找到");
}
CommandFuture backDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(backDeviceCommandFuture);
}
} else {
switch (heatModuleId) {
case heat_module_01 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance);
case heat_module_02 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance);
case heat_module_03 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance);
case heat_module_04 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance);
case heat_module_05 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance);
case heat_module_06 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance);
default -> throw new RuntimeException("index 未找到");
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
}
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture);
});
}
public synchronized void stop() {
this.stop = true;
}
}

4
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorStopCommandHandler.java

@ -24,9 +24,13 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("debug_pallet_elevator_stop")
public class PalletElevatorStopCommandHandler extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final PalletElevatorLiftUpCommandHandler palletElevatorLiftUpCommandHandler;
private final PalletElevatorLiftDownCommandHandler palletElevatorLiftDownCommandHandler;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
palletElevatorLiftUpCommandHandler.stop();
palletElevatorLiftDownCommandHandler.stop();
return runAsync(() -> {
String index = cmdDTO.getStringParam("index");
HeatModuleId heatModuleId = HeatModuleId.valueOf(index);

86
src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmMoveCommandHandler.java

@ -24,9 +24,11 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("debug_transportation_arm_move")
public class TransportationArmMoveCommandHandler extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private boolean stop = false;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
this.stop = false;
return runAsync(() -> {
Double xDimDistance = cmdDTO.getDoubleParam("xDimDistance");
Double yDimDistance = cmdDTO.getDoubleParam("yDimDistance");
@ -35,18 +37,20 @@ public class TransportationArmMoveCommandHandler extends BaseCommandHandler {
Double xDimVelocity = cmdDTO.getDoubleParam("xDimVelocity");
Double yDimVelocity = cmdDTO.getDoubleParam("yDimVelocity");
Double zDimVelocity = cmdDTO.getDoubleParam("zDimVelocity");
Integer times = cmdDTO.getIntegerParam("times");
List<CommandFuture> futuresList = new ArrayList<>();
if(xDimVelocity != null){
if (xDimVelocity != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXSet(xDimVelocity);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if(yDimVelocity != null){
if (yDimVelocity != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYSet(yDimVelocity);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if(zDimVelocity != null){
if (zDimVelocity != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZSet(zDimVelocity);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
@ -54,24 +58,70 @@ public class TransportationArmMoveCommandHandler extends BaseCommandHandler {
commandWait(futuresList.toArray(new CommandFuture[0]));
futuresList.clear();
if (xDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (yDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (zDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
if (times != null) {
for (int i = 0; i < times; i++) {
if (stop) {
return;
}
if (xDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (yDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (zDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
commandWait(futuresList.toArray(new CommandFuture[0]));
if (xDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(-xDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (yDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(-yDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (zDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(-zDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
commandWait(futuresList.toArray(new CommandFuture[0]));
}
} else {
if (xDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryXMoveBy(xDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (yDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryYMoveBy(yDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
if (zDimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.gantryZMoveBy(zDimDistance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
futuresList.add(deviceCommandFuture);
}
commandWait(futuresList.toArray(new CommandFuture[0]));
}
commandWait(futuresList.toArray(new CommandFuture[0]));
});
}
public synchronized void stop() {
this.stop = true;
}
}

2
src/main/java/com/iflytop/gd/app/cmd/debug/TransportationArmStopCommandHandler.java

@ -24,9 +24,11 @@ import java.util.concurrent.CompletableFuture;
@CommandMapping("debug_transportation_arm_stop")
public class TransportationArmStopCommandHandler extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
private final TransportationArmMoveCommandHandler transportationArmMoveCommandHandler;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
transportationArmMoveCommandHandler.stop();
return runAsync(() -> {
List<String> dim = (List<String>) cmdDTO.getParams().get("dim");
List<CommandFuture> futuresList = new ArrayList<>();

Loading…
Cancel
Save