Browse Source

fix:获取坐标功能修改

master
王梦远 2 months ago
parent
commit
6c385c2911
  1. 8
      src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java
  2. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java
  3. 2
      src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java
  4. 4
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java
  5. 4
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java
  6. 2
      src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java
  7. 35
      src/main/java/com/iflytop/sgs/app/controller/MotorController.java
  8. 10
      src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java

8
src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java

@ -44,12 +44,12 @@ public class CleanStartCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(), () -> new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//判断转运模块托盘状态
double cleanWaterVolume = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.volume_clean));//清洁时加水的量
double waterScale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));//水转换系数
double pumpPosition = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));//抽液时蠕动泵移动
double cleanWaterVolume = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.volume_clean);//清洁时加水的量
double waterScale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.scale_water);//水转换系数
double pumpPosition = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.number_reduce);//抽液时蠕动泵移动
Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置
Integer cycle = cmdDTO.getIntegerParam("cycle");//清洗次数
Integer maxCycles = Integer.valueOf(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.cycle_clean_max));//获取最大清洁次数配置
Integer maxCycles = systemConfigService.getSystemConfigIntegerByCode(SystemConfigCode.cycle_clean_max);//获取最大清洁次数配置
Assert.isTrue(cycle > 0 && cycle < maxCycles, () -> new AppException(ResultCode.INVALID_PARAMETER));//cycle参数校验
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距

2
src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java

@ -95,7 +95,7 @@ public class LiquidAddCommand extends BaseCommandHandler {
}
}
}
double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比
double scale = systemConfigService.getSystemConfigDoubleByCode(valveStateCode.getSystemConfigCode());//根据溶液获取转换比
double position = volume * scale * 8 + preFillDistance;//
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开
deviceStateService.getDeviceState().getSolutionModule().setValveState(valveStateCode);//设置阀门状态

2
src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java

@ -47,7 +47,7 @@ public class LiquidReduceCommand extends BaseCommandHandler {
Point3D liquidAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D();//获取加液时托盘位置点
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance();//获取托盘试管水平间距
Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置
double reduceNumber= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));//抽液volume配置
double reduceNumber= systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.number_reduce);//抽液volume配置
return runAsync(() -> {
solutionModuleService.solutionMotorMoveZero(cmdDTO.getCommandId(), cmdDTO.getCommand());//加液模块上升
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//将X轴移动至加液时托盘位置点

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

@ -33,14 +33,14 @@ public class DebugLiquidPumpAddCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double volume = cmdDTO.getDoubleParam("volume");
Double scale = Double.valueOf(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));
Double scale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.scale_water);
Double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
if (speed != null) {
double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed));
double max_speed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.liquid_max_speed);
Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER));
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);

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

@ -33,12 +33,12 @@ public class DebugLiquidPumpReduceCommand extends BaseCommandHandler {
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
Double volume = cmdDTO.getDoubleParam("volume");
double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.scale_water));
double scale = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.scale_water);
double position = volume * scale;
Double speed = cmdDTO.getDoubleParam("speed");
return runAsync(() -> {
if (speed != null) {
double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed));
double max_speed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.liquid_max_speed);
Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER));
DeviceCommandBundle liquidPumpSetCommand = DeviceCommandGenerator.liquidPumpSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpSetCommand);

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

@ -39,7 +39,7 @@ public class DebugLiquidPumpStartCommand extends BaseCommandHandler {
CmdDirection cmdDirection = CmdDirection.valueOf(direction);
return runAsync(() -> {
if (speed != null) {
double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed));
double max_speed = systemConfigService.getSystemConfigDoubleByCode(SystemConfigCode.liquid_max_speed);
Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER));
DeviceCommandBundle liquidPumpSetCommand = DeviceCommandGenerator.liquidPumpSet(speed);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpSetCommand);

35
src/main/java/com/iflytop/sgs/app/controller/MotorController.java

@ -27,18 +27,31 @@ public class MotorController {
@Operation(summary = "获取当前电机位置")
@GetMapping("/position/{motor}")
public Result<Double> getPosition(@PathVariable String motor) {
DevicePartId devicePartId = DevicePartId.valueOf(motor);
Double position;
try {
if (devicePartId.equals(DevicePartId.XSV)) {
position = deviceSensorService.getXYServoPosition(devicePartId);
} else {
position = deviceSensorService.getMotorPosition(devicePartId);
public Result<String> getPosition(@PathVariable String motor) {
if(motor.equals("Transfer")){
try {
double xPosition=deviceSensorService.getXYServoPosition(DevicePartId.XSV);
double zPosition=deviceSensorService.getXYServoPosition(DevicePartId.ZM);
String position=String.format("%.2f,0,%.2f",xPosition,zPosition);
return Result.success(position);
} catch (HardwareException e) {
throw new RuntimeException(e);
}
}else{
DevicePartId devicePartId = DevicePartId.valueOf(motor);
Double position;
try {
if (devicePartId.equals(DevicePartId.XSV)) {
position = deviceSensorService.getXYServoPosition(devicePartId);
} else {
position = deviceSensorService.getMotorPosition(devicePartId);
}
return Result.success(position.toString());
} catch (HardwareException e) {
throw new RuntimeException(e);
}
return Result.success(position);
} catch (HardwareException e) {
throw new RuntimeException(e);
}
}
}

10
src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java

@ -75,8 +75,16 @@ public class SystemConfigService extends ServiceImpl<SystemConfigMapper, SystemC
}
}
public String getSystemConfigValueByCode(SystemConfigCode systemConfigCode) {
public Integer getSystemConfigIntegerByCode(SystemConfigCode systemConfigCode) {
SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::getCode, systemConfigCode.name()));
return Integer.valueOf(systemConfig.getValue());
}
public String getSystemConfigStringByCode(SystemConfigCode systemConfigCode) {
SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::getCode, systemConfigCode.name()));
return systemConfig.getValue();
}
public Double getSystemConfigDoubleByCode(SystemConfigCode systemConfigCode) {
SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::getCode, systemConfigCode.name()));
return Double.parseDouble(systemConfig.getValue());
}
}
Loading…
Cancel
Save