|
|
@ -2,11 +2,9 @@ package com.iflytop.sgs.app.cmd.control; |
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import com.iflytop.sgs.app.core.BaseCommandHandler; |
|
|
|
import com.iflytop.sgs.app.model.bo.Point3D; |
|
|
|
import com.iflytop.sgs.app.model.bo.status.device.TransferModuleState; |
|
|
|
import com.iflytop.sgs.app.model.bo.status.device.ValveState; |
|
|
|
import com.iflytop.sgs.app.model.dto.CmdDTO; |
|
|
|
import com.iflytop.sgs.app.model.entity.Solutions; |
|
|
|
import com.iflytop.sgs.app.service.api.DevicePositionService; |
|
|
@ -50,7 +48,11 @@ public class LiquidAddCommand extends BaseCommandHandler { |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 |
|
|
|
JSONArray jsonArray = cmdDTO.getJSONArrayParam("columns");//获取参数 |
|
|
|
Assert.notNull(jsonArray, () -> new AppException(ResultCode.INVALID_PARAMETER));//解析参数 |
|
|
|
Integer solutionId = cmdDTO.getIntegerParam("solutionId");//溶液ID |
|
|
|
double volume = cmdDTO.getDoubleParam("volume");//量 |
|
|
|
Solutions solutions = solutionsService.getById(solutionId);//获取溶液 |
|
|
|
ValveStateCode valveStateCode = ValveStateCode.valueOf(solutions.getName());//根据溶液获取电磁阀code |
|
|
|
Assert.isTrue(!jsonArray.isEmpty(), () -> new AppException(ResultCode.INVALID_PARAMETER));//确定选中了列 |
|
|
|
TransferModuleState transferModuleState = deviceStateService.getDeviceState().getTransferModule();//获取机械臂状态 |
|
|
|
Assert.isTrue(transferModuleState.isTrayStatus(), () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 |
|
|
|
Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方点位 |
|
|
@ -58,57 +60,56 @@ public class LiquidAddCommand extends BaseCommandHandler { |
|
|
|
Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance(); //托盘试管水平间距 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 |
|
|
|
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
JSONObject jsonObject = (JSONObject) jsonArray.get(i); |
|
|
|
Integer solutionId = jsonObject.getInt("solutionId");//溶液Id |
|
|
|
Integer column = jsonObject.getInt("column");//列数 |
|
|
|
double volume = jsonObject.getDouble("volume");//量 |
|
|
|
Solutions solutions = solutionsService.getById(solutionId);//获取溶液 |
|
|
|
ValveStateCode valveStateCode = ValveStateCode.valueOf(solutions.getName());//根据溶液获取电磁阀code |
|
|
|
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();//稀硝酸预充距离 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//排空 |
|
|
|
} |
|
|
|
case ValveStateCode.thick -> { |
|
|
|
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.waste);//废液通道打开 |
|
|
|
double distance = devicePositionService.getPosition(DevicePositionCode.waterPreFillDistance).getDistance();//蒸馏水预充距离 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//排空 |
|
|
|
} |
|
|
|
//预充 |
|
|
|
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();//稀硝酸预充距离 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//排空 |
|
|
|
} |
|
|
|
case ValveStateCode.thick -> { |
|
|
|
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.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; |
|
|
|
} |
|
|
|
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.thick -> { |
|
|
|
double distance = devicePositionService.getPosition(DevicePositionCode.thickPreFillDistance).getDistance();//浓硝酸预充距离 |
|
|
|
preFillDistance += distance; |
|
|
|
} |
|
|
|
case ValveStateCode.water -> { |
|
|
|
double distance = devicePositionService.getPosition(DevicePositionCode.waterPreFillDistance).getDistance();//蒸馏水预充距离 |
|
|
|
preFillDistance += distance; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比 |
|
|
|
double position = volume * scale * 8 + preFillDistance;//加液泵的转数 |
|
|
|
solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 |
|
|
|
deviceStateService.getDeviceState().getSolutionModule().getValveState().setState(valveStateCode);//设置阀门状态 |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
int column = jsonArray.getInt(i); |
|
|
|
if (column > 0 && column < 6) { |
|
|
|
double distance = (column - 1) * trayTubeHorizontalSpacingDistance;//机械臂左移距离 |
|
|
|
transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//机械臂左移 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeAddPositon);//加液机械臂下降 |
|
|
|
solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//加液 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 |
|
|
|
transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 |
|
|
|
} |
|
|
|
double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比 |
|
|
|
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);//机械臂左移 |
|
|
|
solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeAddPositon);//加液机械臂下降 |
|
|
|
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);//移动至加液位置 |
|
|
|