From 6c385c2911f449e675371762b799b8bfa346bf68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Thu, 29 May 2025 11:02:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=8E=B7=E5=8F=96=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgs/app/cmd/control/CleanStartCommand.java | 8 ++--- .../sgs/app/cmd/control/LiquidAddCommand.java | 2 +- .../sgs/app/cmd/control/LiquidReduceCommand.java | 2 +- .../app/cmd/debug/DebugLiquidPumpAddCommand.java | 4 +-- .../cmd/debug/DebugLiquidPumpReduceCommand.java | 4 +-- .../app/cmd/debug/DebugLiquidPumpStartCommand.java | 2 +- .../sgs/app/controller/MotorController.java | 35 +++++++++++++++------- .../sgs/app/service/api/SystemConfigService.java | 10 ++++++- 8 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java index 03f53d4..1894f89 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java @@ -44,12 +44,12 @@ public class CleanStartCommand extends BaseCommandHandler { @Override public CompletableFuture 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();//获取托盘试管水平间距 diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java index ecbf907..e1896df 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java +++ b/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);//设置阀门状态 diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java index 2710362..0579371 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java +++ b/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轴移动至加液时托盘位置点 diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java index 715f961..ec8e208 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java @@ -33,14 +33,14 @@ public class DebugLiquidPumpAddCommand extends BaseCommandHandler { @Override public CompletableFuture 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); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java index d7190aa..c9ee6a7 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java @@ -33,12 +33,12 @@ public class DebugLiquidPumpReduceCommand extends BaseCommandHandler { @Override public CompletableFuture 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); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java index 7ab566c..61d7948 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java +++ b/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); diff --git a/src/main/java/com/iflytop/sgs/app/controller/MotorController.java b/src/main/java/com/iflytop/sgs/app/controller/MotorController.java index db259f1..a3dbba8 100644 --- a/src/main/java/com/iflytop/sgs/app/controller/MotorController.java +++ b/src/main/java/com/iflytop/sgs/app/controller/MotorController.java @@ -27,18 +27,31 @@ public class MotorController { @Operation(summary = "获取当前电机位置") @GetMapping("/position/{motor}") - public Result 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 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); } } } diff --git a/src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java b/src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java index 8f16b93..c465ad4 100644 --- a/src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java +++ b/src/main/java/com/iflytop/sgs/app/service/api/SystemConfigService.java @@ -75,8 +75,16 @@ public class SystemConfigService extends ServiceImpl().eq(SystemConfig::getCode, systemConfigCode.name())); + return Integer.valueOf(systemConfig.getValue()); + } + public String getSystemConfigStringByCode(SystemConfigCode systemConfigCode) { SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper().eq(SystemConfig::getCode, systemConfigCode.name())); return systemConfig.getValue(); } + public Double getSystemConfigDoubleByCode(SystemConfigCode systemConfigCode) { + SystemConfig systemConfig = this.getOne(new LambdaQueryWrapper().eq(SystemConfig::getCode, systemConfigCode.name())); + return Double.parseDouble(systemConfig.getValue()); + } }