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 253279a..afab811 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 @@ -65,34 +65,43 @@ public class LiquidAddCommand extends BaseCommandHandler { double volume = jsonObject.getDouble("volume");//量 Solutions solutions = solutionsService.getById(solutionId);//获取溶液 ValveStateCode valveStateCode = ValveStateCode.valueOf(solutions.getName());//根据溶液获取电磁阀code - ValveState valveState=deviceStateService.getDeviceState().getSolutionModule().getValveState();//获取当前电磁阀的值 - if(!valveState.getState().equals(valveStateCode)) {//判断是否与当前加酸的通道一致 - switch (valveStateCode) { + ValveStateCode oldValveState = deviceStateService.getDeviceState().getSolutionModule().getValveState().getState();//获取当前电磁阀的值 + double preFillDistance = 0; + if (!oldValveState.equals(valveStateCode)) {//判断是否与当前加酸的通道一致 不一致排空 + switch (oldValveState) { case ValveStateCode.thin -> { solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//废液通道打开 - double distance=devicePositionService.getPosition(DevicePositionCode.thinPreFillDistance).getDistance();//稀硝酸预充距离 + double distance = devicePositionService.getPosition(DevicePositionCode.thinPreFillDistance).getDistance();//稀硝酸预充距离 solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//排空 - solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.thin);//废液通道打开 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), distance);//预充 } case ValveStateCode.thick -> { - solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 - double distance=devicePositionService.getPosition(DevicePositionCode.thickPreFillDistance).getDistance();//浓硝酸预充距离 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), distance);//预充 + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//废液通道打开 + double distance = devicePositionService.getPosition(DevicePositionCode.thickPreFillDistance).getDistance();//浓硝酸预充距离 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//排空 } case ValveStateCode.water -> { - solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 - double distance=devicePositionService.getPosition(DevicePositionCode.thickPreFillDistance).getDistance();//水预充距离 - solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), distance);//预充 + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//废液通道打开 + double distance = devicePositionService.getPosition(DevicePositionCode.waterPreFillDistance).getDistance();//蒸馏水预充距离 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//排空 + } + } + switch (valveStateCode) { + case ValveStateCode.thin -> { + double distance = devicePositionService.getPosition(DevicePositionCode.thinPreFillDistance).getDistance();//稀硝酸预充距离 + preFillDistance += distance; + } + case ValveStateCode.thick -> { + double distance = devicePositionService.getPosition(DevicePositionCode.thickPreFillDistance).getDistance();//浓硝酸预充距离 + preFillDistance += distance; + } + case ValveStateCode.water -> { + double distance = devicePositionService.getPosition(DevicePositionCode.waterPreFillDistance).getDistance();//蒸馏水预充距离 + preFillDistance += distance; } - case ValveStateCode.waste -> { - solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 - - }//已经排空 } } double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比 - double position = volume * scale * 8;//加液泵的转数 + double position = volume * scale * 8 + preFillDistance;//加液泵的转数 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//机械臂左移距离 transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//机械臂左移 @@ -100,9 +109,6 @@ public class LiquidAddCommand extends BaseCommandHandler { solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//加液 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 - - - } solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 diff --git a/src/main/resources/sql/init.sql b/src/main/resources/sql/init.sql index 72bc28d..ae3ae41 100644 --- a/src/main/resources/sql/init.sql +++ b/src/main/resources/sql/init.sql @@ -124,10 +124,10 @@ CREATE TABLE IF NOT EXISTS container ); INSERT OR IGNORE INTO container (id, type, code, solution_id, pump_id, capacity_total, capacity_used) -VALUES (1, 0, 'container_01', 1, 'liquid_pump', 5000, 0), - (2, 0, 'container_02', 2, 'liquid_pump', 5000, 2500), - (3, 0, 'container_03', 3, 'liquid_pump', 5000, 2600), - (4, 1, 'container_04', 4, 'liquid_pump', 5000, 0); +VALUES (1, 0, 'container_01', 1, 'liquid_pump', 10000, 0), + (2, 0, 'container_02', 2, 'liquid_pump', 5000, 0), + (3, 0, 'container_03', 3, 'liquid_pump', 20000, 0), + (4, 1, 'container_04', 4, 'liquid_pump', 40000, 0); -- solutions 溶液 表