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 9505392..c59d8e9 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 @@ -15,6 +15,7 @@ import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.ValveStateCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; @@ -54,8 +55,8 @@ public class LiquidAddCommand extends BaseCommandHandler { 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));//判断机械臂是否有托盘 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 + Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方托盘点位 Double solutionModuleMotorDownInTubeAddPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeAddPositon).getPositon(); //加液模块电机下降进入试管加液位置 Double trayTubeHorizontalSpacingDistance = devicePositionService.getPosition(DevicePositionCode.trayTubeHorizontalSpacingDistance).getDistance(); //托盘试管水平间距 @@ -66,23 +67,20 @@ public class LiquidAddCommand extends BaseCommandHandler { double preFillDistance = 0; if (!oldValveState.equals(valveStateCode)) {//判断是否与当前加酸的通道一致 不一致排空 + double drainDistance = 0; 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);//排空 + drainDistance = devicePositionService.getPosition(DevicePositionCode.thinPreFillDistance).getDistance();//稀硝酸预充距离 } 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);//排空 + drainDistance = devicePositionService.getPosition(DevicePositionCode.thickPreFillDistance).getDistance();//浓硝酸预充距离 } 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);//排空 + drainDistance = devicePositionService.getPosition(DevicePositionCode.waterPreFillDistance).getDistance();//蒸馏水预充距离 } } + solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), ValveStateCode.waste);//废液通道打开 + solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -drainDistance);//排空 switch (valveStateCode) { case ValveStateCode.thin -> { double distance = devicePositionService.getPosition(DevicePositionCode.thinPreFillDistance).getDistance();//稀硝酸预充距离 @@ -99,7 +97,7 @@ public class LiquidAddCommand extends BaseCommandHandler { } } double scale = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(valveStateCode.getSystemConfigCode()));//根据溶液获取转换比 - double position = volume * scale * 8 + preFillDistance;//加液泵的转数 + double position = volume * scale * 8 + preFillDistance;// solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应通道打开 deviceStateService.getDeviceState().getSolutionModule().setValveState(valveStateCode);//设置阀门状态 for (int i = 0; i < jsonArray.size(); i++) { @@ -110,7 +108,6 @@ public class LiquidAddCommand extends BaseCommandHandler { 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);//加液机械臂上升 diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java index 3509417..af8a68a 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/LiquidPreFillStartCommand.java @@ -9,10 +9,12 @@ import com.iflytop.sgs.app.model.entity.Solutions; import com.iflytop.sgs.app.service.api.DevicePositionService; import com.iflytop.sgs.app.service.api.SolutionsService; import com.iflytop.sgs.app.service.api.SystemConfigService; +import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.SolutionModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.ValveStateCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; @@ -35,7 +37,7 @@ public class LiquidPreFillStartCommand extends BaseCommandHandler { private final DeviceStateService deviceStateService; private final DevicePositionService devicePositionService; private final TransferModuleService transferModuleService; - private final SystemConfigService systemConfigService; + private final DeviceSensorService deviceSensorService; private final SolutionsService solutionsService; @Override @@ -48,12 +50,16 @@ public class LiquidPreFillStartCommand extends BaseCommandHandler { Point3D liquidAreaTrayPoint = devicePositionService.getPosition(DevicePositionCode.liquidAreaTrayPoint).getPoint3D(); //获取加液区上方点位 double position=devicePositionService.getPosition(DevicePositionCode.solutionPreFillDistance).getDistance();//溶液首次预充距离 return runAsync(() -> { + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 + Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用 deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 solutionModuleService.liquidValveSwitch(cmdDTO.getCommandId(), cmdDTO.getCommand(), valveStateCode);//电磁阀对应的酸液通道打开 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液机械臂上升 transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint);//移动至加液位置 solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), position);//预充开始 + deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用 + deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置正在加液 }); } } 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 db2a62a..f706e70 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 @@ -48,11 +48,11 @@ public class LiquidReduceCommand extends BaseCommandHandler { Double solutionModuleMotorDownInTubeExtPositon = devicePositionService.getPosition(DevicePositionCode.solutionModuleMotorDownInTubeExtPositon).getPositon();//加液模块电机下降进入试管抽取位置 List trayStates = deviceStateService.getDeviceState().getTrays();//所有的托盘 TrayState trayState = trayStates.stream().filter(TrayState::isInSolutionPositon).findFirst().get();//加液位的托盘 - double reduceNumber= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce)); + double reduceNumber= Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.number_reduce));//抽液volume配置 return runAsync(() -> { - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 - boolean LIQUID_TRAY_EXIST=deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//监测加液位是否有托盘 - Assert.isTrue(LIQUID_TRAY_EXIST, () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//机械臂是否有托盘 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//将X轴移动至加液时托盘位置点 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 + Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 deviceStateService.getDeviceState().getSolutionModule().setIdle(true);//设置占用 deviceStateService.getDeviceState().getSolutionModule().setPumping(true);//设置正在加液 solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.0);//加液模块上升 @@ -62,11 +62,12 @@ public class LiquidReduceCommand extends BaseCommandHandler { solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), solutionModuleMotorDownInTubeExtPositon);//加液模块下降进入试管 solutionModuleService.liquidPumpMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), -reduceNumber);//抽液 double distance = (tubeState.getColumnNum() - 1) * trayTubeHorizontalSpacingDistance; + solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0.0);//加液模块上升 transferModuleService.transferXMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), -distance);//X轴依次按照试管间距移动 } } solutionModuleService.solutionMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), 0);//加液模块上升至最高,移出试管 - transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D.getX());//将X轴移动至加液时托盘位置点 + transferModuleService.transferMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidAreaTrayPoint3D);//移动至加液时托盘位置点 deviceStateService.getDeviceState().getSolutionModule().setIdle(false);//设置占用解除 deviceStateService.getDeviceState().getSolutionModule().setPumping(false);//设置加液结束 }); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java index bac2c60..f00a7fa 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java @@ -10,6 +10,7 @@ import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; @@ -43,7 +44,8 @@ public class MoveToFeedAreaCommand extends BaseCommandHandler { targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); } else { targetHeatModuleCode = null; - Assert.isTrue(deviceStateService.getDeviceState().getTransferModule().isTrayStatus(),()->new AppException(ResultCode.TRANSFER_MODULE_NO_TRAY));//转运模块是否有托盘 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 + Assert.isTrue(liquidTrayExist, () -> new AppException(ResultCode.OPERATION_NOT_ALLOWED));//判断机械臂是否有托盘 } Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java index d7c2e25..957b3e4 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToHeatAreaCommand.java @@ -5,10 +5,12 @@ import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.Point3D; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.service.api.DevicePositionService; +import com.iflytop.sgs.app.service.device.DeviceSensorService; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.app.service.device.module.TransferModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; +import com.iflytop.sgs.common.enums.DeviceSensorCode; import com.iflytop.sgs.common.enums.HeatModuleCode; import com.iflytop.sgs.common.enums.data.DevicePositionCode; import com.iflytop.sgs.common.exception.AppException; @@ -32,22 +34,20 @@ public class MoveToHeatAreaCommand extends BaseCommandHandler { private final DevicePositionService devicePositionService; private final DeviceStateService deviceStateService; + private final DeviceSensorService deviceSensorService; @Override public CompletableFuture handle(CmdDTO cmdDTO) throws Exception { String targetHeatModuleCodeStr = cmdDTO.getStringParam("heatModuleCode"); HeatModuleCode targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr);//目标加热模块 - if (!deviceStateService.getDeviceState().getTransferModule().isTrayStatus()) { //判断机械臂上是否有托盘 - Assert.isTrue(!deviceStateService.getDeviceState().getHeatModuleByCode(targetHeatModuleCode).isTrayStatus(), () -> new AppException(ResultCode.TARGET_HEAT_MODULE_NO_TRAY));//目标加热区有托盘 - - } Point3D targetHeatModuleTrayClawPoint3D = heatModuleService.getHeatModuleTrayClawPoint3D(targetHeatModuleCode);//获取目标加热模块托盘夹取点 Double transferModuleXPickTrayMoveDistance = devicePositionService.getPosition(DevicePositionCode.transferModuleXPickTrayMoveDistance).getDistance();//获取转运模块X轴拿取托盘进出卡槽移动距离 Double transferModuleZPickTrayDownPositon = devicePositionService.getPosition(DevicePositionCode.transferModuleZPickTrayDownPositon).getPositon();//获取转运模块Z轴拿取托盘时下降的高度位置 Point3D feedAreaTrayPoint3D = devicePositionService.getPosition(DevicePositionCode.feedAreaTrayPoint).getPoint3D();//获取上料区托盘夹爪位置点 return runAsync(() -> { - if (!deviceStateService.getDeviceState().getTransferModule().isTrayStatus()) { //判断机械臂上是否有托盘 + boolean liquidTrayExist = deviceSensorService.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST);//获取传感器状态 + if (!liquidTrayExist) { //判断机械臂上是否有托盘 //机械臂上无托盘,取上料区托盘 transferModuleService.transferXMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), feedAreaTrayPoint3D.getX() + transferModuleXPickTrayMoveDistance);//将X轴移动至上料区托盘夹取点 + 进出卡槽移动距离 transferModuleService.transferZMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), transferModuleZPickTrayDownPositon);//Z轴下降至夹取点,使托盘落入石墨加热盘 diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java index e9c7c9b..d7b5362 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/MoveToLiquidAreaCommand.java @@ -41,6 +41,7 @@ public class MoveToLiquidAreaCommand extends BaseCommandHandler { targetHeatModuleCode = HeatModuleCode.valueOf(targetHeatModuleCodeStr); } else { targetHeatModuleCode = null; + //todo 要改成传感器获取 Assert.isTrue(deviceStateService.getDeviceState().getSolutionModule().isFeedAreaTrayStatus(), () -> new AppException(ResultCode.FEED_AREA_NO_TRAY));//上料区无托盘 } diff --git a/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java b/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java index 3c3531d..322b28f 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/module/TransferModuleService.java @@ -38,10 +38,10 @@ public class TransferModuleService { * 转运机械臂移动到指定点 */ public void transferMove(String cmdId, String cmdCode, Point3D point) throws Exception { - DeviceCommandBundle transferXMoveDeviceCommand = DeviceCommandGenerator.transferXMove(point.getX()); - CommandFuture transferXMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, transferXMoveDeviceCommand); DeviceCommandBundle transferZMoveDeviceCommand = DeviceCommandGenerator.transferZMove(point.getZ()); CommandFuture transferZMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, transferZMoveDeviceCommand); + DeviceCommandBundle transferXMoveDeviceCommand = DeviceCommandGenerator.transferXMove(point.getX()); + CommandFuture transferXMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, transferXMoveDeviceCommand); CommandUtil.wait(transferXMoveDeviceCommandFuture, transferZMoveDeviceCommandFuture); } diff --git a/src/main/java/com/iflytop/sgs/hardware/config/StepMotorConfig.java b/src/main/java/com/iflytop/sgs/hardware/config/StepMotorConfig.java index 9232ada..280d749 100644 --- a/src/main/java/com/iflytop/sgs/hardware/config/StepMotorConfig.java +++ b/src/main/java/com/iflytop/sgs/hardware/config/StepMotorConfig.java @@ -34,7 +34,8 @@ public class StepMotorConfig { static final double DEFAULT_MAX_LIMIT = 0.0; // mm final static Map stepMotorMaxLimitMap = Map.ofEntries( Map.entry(StepMotorMId.DoorM, 200.0), - Map.entry(StepMotorMId.LiquidM, 150.0) + Map.entry(StepMotorMId.LiquidM, 150.0), + Map.entry(StepMotorMId.ZM, 100.0) ); // 是否安装编码器