Browse Source

fix:修改调试指令

master
王梦远 2 months ago
parent
commit
da9273e16e
  1. 12
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorOpenCommand.java
  2. 37
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugDoorSetCommand.java
  3. 6
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveByCommand.java
  4. 8
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorMoveToCommand.java
  5. 37
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidMotorSetCommand.java
  6. 21
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpMoveByCommand.java
  7. 38
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpSetCommand.java
  8. 37
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorXSetCommand.java
  9. 37
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugMotorZSetCommand.java
  10. 13
      src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java

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

@ -1,5 +1,6 @@
package com.iflytop.sgs.app.cmd.debug;
import cn.hutool.core.lang.Assert;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.model.entity.DevicePosition;
@ -30,11 +31,14 @@ public class DebugDoorOpenCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
double speed = cmdDTO.getDoubleParam("speed");
DevicePosition devicePosition = devicePositionService.getPosition(DevicePositionCode.doorOpen);
return runAsync(() -> {
DevicePosition devicePosition = devicePositionService.getPosition(DevicePositionCode.doorOpen);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorMove(devicePosition.getDistance());
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
CommandFuture deviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.doorSet(speed));
CommandUtil.wait(deviceCommandSetFuture);
CommandFuture deviceCommandOpenFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.doorMove(devicePosition.getDistance()));
CommandUtil.wait(deviceCommandOpenFuture);
});
}
}

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

@ -1,37 +0,0 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
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.concurrent.CompletableFuture;
/**
* 门设置参数
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("door_set")
public class DebugDoorSetCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

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

@ -45,19 +45,19 @@ public class DebugLiquidMotorMoveByCommand extends BaseCommandHandler {
return;
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
}
} else {
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}

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

@ -28,10 +28,12 @@ public class DebugLiquidMotorMoveToCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
double position = cmdDTO.getDoubleParam("position");
double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidSet(position);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
CommandFuture deviceSetCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.motorLiquidSet(speed));
CommandUtil.wait(deviceSetCommandFuture);
CommandFuture deviceMoveCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), DeviceCommandGenerator.motorLiquidMove(position));
CommandUtil.wait(deviceMoveCommandFuture);
});
}
}

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

@ -1,37 +0,0 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
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.concurrent.CompletableFuture;
/**
* 加液臂电机设置参数
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("liquid_motor_set")
public class DebugLiquidMotorSetCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.motorLiquidSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

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

@ -29,14 +29,13 @@ public class DebugLiquidPumpMoveByCommand extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
this.stop = false;
return runAsync(() -> {
Double dimDistance = cmdDTO.getDoubleParam("distance");
Double distance = cmdDTO.getDoubleParam("distance");
Double dimVelocity = cmdDTO.getDoubleParam("velocity");
Double speed = cmdDTO.getDoubleParam("speed");
Integer times = cmdDTO.getIntegerParam("times");
Integer channel = 1;
if (dimVelocity != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(dimVelocity, channel);
if (speed != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
@ -45,20 +44,20 @@ public class DebugLiquidPumpMoveByCommand extends BaseCommandHandler {
if (stop) {
return;
}
if (dimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(dimDistance);
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
if (dimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-dimDistance);
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(-distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}
}
} else {
if (dimDistance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(dimDistance);
if (distance != null) {
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpMoveBy(distance);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
}

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

@ -1,38 +0,0 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
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.concurrent.CompletableFuture;
/**
* 加液臂电机设置参数
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("motor_liquid_set")
public class DebugLiquidPumpSetCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed = cmdDTO.getDoubleParam("speed");
Integer channel = 1;
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed, channel);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

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

@ -1,37 +0,0 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
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.concurrent.CompletableFuture;
/**
* 门设置参数
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("x_set")
public class DebugMotorXSetCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.doorSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

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

@ -1,37 +0,0 @@
package com.iflytop.sgs.app.cmd.debug;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
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.concurrent.CompletableFuture;
/**
* z轴电机参数设置
*/
@Slf4j
@Component
@RequiredArgsConstructor
@CommandMapping("z_set")
public class DebugMotorZSetCommand extends BaseCommandHandler {
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> {
double speed = cmdDTO.getDoubleParam("speed");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.transferZSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
CommandUtil.wait(deviceCommandFuture);
});
}
}

13
src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java

@ -193,16 +193,25 @@ public class DeviceCommandGenerator {
return controlMotorCmd(CmdDevice.liquid_motor, CmdAction.move, params, "加液升降电机移动");
}
/**
* 加液机械臂 相对移动
*
* @param position 加液量 单位mL
*/
public static DeviceCommandBundle motorLiquidMoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlCmd(CmdDevice.liquid_motor, CmdAction.move_by, params, "加液机械臂 相对移动");
}
/**
* 加液泵设置参数
*
* @param speed 速度 单位 mm/s
*/
public static DeviceCommandBundle liquidPumpSet(Double speed,Integer channel) {
public static DeviceCommandBundle liquidPumpSet(Double speed) {
DeviceCommandParams params = new DeviceCommandParams();
params.setSpeed(speed);
params.setChannel(channel);
return setInfoCmd(CmdDevice.liquid_pump, CmdAction.set, params, "加液泵设置参数");
}

Loading…
Cancel
Save