|
|
@ -13,6 +13,8 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.concurrent.Semaphore; |
|
|
|
|
|
|
|
/** |
|
|
|
* 转运模块 |
|
|
|
*/ |
|
|
@ -22,6 +24,36 @@ import org.springframework.stereotype.Service; |
|
|
|
public class TransferModuleService { |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
private final PositionService positionService; |
|
|
|
private final Semaphore armSemaphore = new Semaphore(1, true); |
|
|
|
|
|
|
|
/** |
|
|
|
* 申请使用机械臂 |
|
|
|
*/ |
|
|
|
public void requestTransferModule() { |
|
|
|
log.info("申请使用转运机械臂"); |
|
|
|
try { |
|
|
|
armSemaphore.acquire(); |
|
|
|
log.info("转运机械臂申请成功"); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
throw new RuntimeException("等待转运机械臂空闲失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 释放机械臂 |
|
|
|
*/ |
|
|
|
public void releaseTransferModule() { |
|
|
|
log.info("释放转运机械臂占用"); |
|
|
|
armSemaphore.release(); //释放许可证 |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询机械臂是否繁忙 |
|
|
|
*/ |
|
|
|
public boolean isTransferModuleBusy() { |
|
|
|
return armSemaphore.availablePermits() == 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 机械臂回原点 |
|
|
@ -63,10 +95,8 @@ public class TransferModuleService { |
|
|
|
*/ |
|
|
|
public void roboticMoveToTitration(MultipleModuleCode moduleCode) throws Exception { |
|
|
|
Point3D position = switch (moduleCode) { //1、首先检测试管所在的托盘传感器的值 |
|
|
|
case MultipleModuleCode.MODULE_1 -> |
|
|
|
positionService.getPositionByCode(DevicePositionCode.titrationArea_1).getPoint3D(); |
|
|
|
case MultipleModuleCode.MODULE_2 -> |
|
|
|
positionService.getPositionByCode(DevicePositionCode.titrationArea_2).getPoint3D(); |
|
|
|
case MultipleModuleCode.MODULE_1 -> positionService.getPositionByCode(DevicePositionCode.titrationArea_1).getPoint3D(); |
|
|
|
case MultipleModuleCode.MODULE_2 -> positionService.getPositionByCode(DevicePositionCode.titrationArea_2).getPoint3D(); |
|
|
|
}; |
|
|
|
// Z轴回零点 |
|
|
|
DeviceCommand zOriginCommand = DeviceCommandGenerator.zMove(0.0); |
|
|
@ -86,10 +116,8 @@ public class TransferModuleService { |
|
|
|
*/ |
|
|
|
public void roboticMoveToHeat(MultipleModuleCode moduleCode) throws Exception { |
|
|
|
Point3D position = switch (moduleCode) { //1、首先检测试管所在的托盘传感器的值 |
|
|
|
case MultipleModuleCode.MODULE_1 -> |
|
|
|
positionService.getPositionByCode(DevicePositionCode.heatArea_1).getPoint3D(); |
|
|
|
case MultipleModuleCode.MODULE_2 -> |
|
|
|
positionService.getPositionByCode(DevicePositionCode.heatArea_2).getPoint3D(); |
|
|
|
case MultipleModuleCode.MODULE_1 -> positionService.getPositionByCode(DevicePositionCode.heatArea_1).getPoint3D(); |
|
|
|
case MultipleModuleCode.MODULE_2 -> positionService.getPositionByCode(DevicePositionCode.heatArea_2).getPoint3D(); |
|
|
|
}; |
|
|
|
// Z轴回零点 |
|
|
|
DeviceCommand zOriginCommand = DeviceCommandGenerator.zMove(0.0); |
|
|
|