|
|
@ -1,22 +1,26 @@ |
|
|
|
package com.qyft.gd.device.service; |
|
|
|
|
|
|
|
import com.qyft.gd.model.bo.TubeSol; |
|
|
|
import com.qyft.gd.service.BaseDataService; |
|
|
|
import com.qyft.gd.service.CMDService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.function.Supplier; |
|
|
|
|
|
|
|
/** |
|
|
|
* 设备步骤操作 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class DeviceStepService { |
|
|
|
|
|
|
|
DeviceService deviceService; |
|
|
|
BaseDataService baseDataService; |
|
|
|
CMDService cmdService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 抬起托盘 |
|
|
@ -24,7 +28,9 @@ public class DeviceStepService { |
|
|
|
* @param heaterId 加热区id |
|
|
|
*/ |
|
|
|
public boolean upTray(String heaterId) { |
|
|
|
return deviceService.raiseTray(heaterId); |
|
|
|
Map<String, Object> params = Map.of("areaId", heaterId); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.upTray(params); |
|
|
|
return cmdList.stream().allMatch(Supplier::get); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -33,7 +39,9 @@ public class DeviceStepService { |
|
|
|
* @param heaterId 加热区id |
|
|
|
*/ |
|
|
|
public boolean downTray(String heaterId) { |
|
|
|
return deviceService.lowerTray(heaterId); |
|
|
|
Map<String, Object> params = Map.of("areaId", heaterId); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.downTray(params); |
|
|
|
return cmdList.stream().allMatch(Supplier::get); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -42,18 +50,17 @@ public class DeviceStepService { |
|
|
|
* @param tubeSolList 需要添加溶液的试管与溶液 |
|
|
|
*/ |
|
|
|
public boolean addLiquid(List<TubeSol> tubeSolList) { |
|
|
|
List<Boolean> results = new ArrayList<>(); |
|
|
|
for (TubeSol tubeSol : tubeSolList) { |
|
|
|
String[] tubeCoordinateArray = tubeSol.getTubeNum().split(","); //TODO 这里应该通过试管编号获取坐标 |
|
|
|
int x = Integer.parseInt(tubeCoordinateArray[0]); |
|
|
|
int y = Integer.parseInt(tubeCoordinateArray[1]); |
|
|
|
int z = Integer.parseInt(tubeCoordinateArray[2]); |
|
|
|
results.add(deviceService.moveLiquidArmToPoint(x, y, z));//加液孔对准试管 |
|
|
|
for (TubeSol.AddLiquid addLiquid : tubeSol.getAddLiquidList()) {//依次添加溶液 |
|
|
|
results.add(deviceService.addLiquid(addLiquid.getSolId(), addLiquid.getVolume()));//TODO 这里应该通过溶液id获取到泵id |
|
|
|
Map<String, Object> params = Map.of("tubeNum", tubeSol.getTubeNum(), "solutionId", addLiquid.getSolId(), "volume", addLiquid.getVolume()); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.downTray(params); |
|
|
|
boolean result = cmdList.stream().allMatch(Supplier::get); |
|
|
|
if(!result){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return results.stream().allMatch(Boolean::booleanValue); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -62,55 +69,57 @@ public class DeviceStepService { |
|
|
|
* @param heaterId 加热区id |
|
|
|
*/ |
|
|
|
public boolean moveToSol(String heaterId) { |
|
|
|
//从内存中获取加热区拍子点位 |
|
|
|
//机械臂移动到拍子上方 |
|
|
|
//张开夹爪 |
|
|
|
//向下移动机械臂,确保夹爪闭合可以夹住拍子 |
|
|
|
//闭合夹爪 |
|
|
|
//解除拍子密封 |
|
|
|
//向上移动机械臂,确保不会发生碰撞的高度 |
|
|
|
//拍子存放区高度 -1 |
|
|
|
//从内存中获取拍子存放区点位 |
|
|
|
//移动机械臂至拍子存放区点位 |
|
|
|
//向下移动机械臂,使拍子落入拍子存放区 |
|
|
|
//张开夹爪,放下拍子 |
|
|
|
//向上移动机械臂,脱离拍子存放区 |
|
|
|
//移动机械臂至加热区 |
|
|
|
//张开夹爪 |
|
|
|
//向下移动机械臂,确保夹爪闭合可以夹住托盘 |
|
|
|
//闭合夹爪 |
|
|
|
//向上移动机械臂,确保不会发生碰撞的高度 |
|
|
|
//从内存中获取加液区点位 |
|
|
|
//移动机械臂至加液区点位 |
|
|
|
//向下移动机械臂,放下托盘 |
|
|
|
//张开夹爪 |
|
|
|
//向上移动机械臂,脱离托盘 |
|
|
|
return true; |
|
|
|
Map<String, Object> params = Map.of("areaId", heaterId); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.moveToActionArea(params); |
|
|
|
return cmdList.stream().allMatch(Supplier::get); |
|
|
|
} |
|
|
|
|
|
|
|
//移至加热 |
|
|
|
/** |
|
|
|
* 移至加热 |
|
|
|
* @param heaterId 加热区id |
|
|
|
*/ |
|
|
|
public boolean moveToHeater(String heaterId) { |
|
|
|
return true; |
|
|
|
Map<String, Object> params = Map.of("areaId", heaterId); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.moveToHeatArea(params); |
|
|
|
return cmdList.stream().allMatch(Supplier::get); |
|
|
|
} |
|
|
|
|
|
|
|
//摇匀 |
|
|
|
/** |
|
|
|
* 摇匀 |
|
|
|
* @param second 摇匀时间 |
|
|
|
*/ |
|
|
|
public boolean shaking(int second) { |
|
|
|
return true; |
|
|
|
Map<String, Object> params = Map.of(); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.startShakeUp(params); |
|
|
|
boolean result = cmdList.stream().allMatch(Supplier::get); |
|
|
|
if(result){ |
|
|
|
this.delay(second); |
|
|
|
cmdList = cmdService.stopShakeUp(params); |
|
|
|
result = cmdList.stream().allMatch(Supplier::get); |
|
|
|
return result; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
//开始加热 |
|
|
|
public boolean startHeating(String heaterId, double temperature) { |
|
|
|
return true; |
|
|
|
Map<String, Object> params = Map.of("areaId", heaterId,"temperature", temperature); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.startHeat(params); |
|
|
|
return cmdList.stream().allMatch(Supplier::get); |
|
|
|
} |
|
|
|
|
|
|
|
//停止加热 |
|
|
|
public boolean stopHeating(String heaterId) { |
|
|
|
return true; |
|
|
|
Map<String, Object> params = Map.of("areaId", heaterId); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.stopHeat(params); |
|
|
|
return cmdList.stream().allMatch(Supplier::get); |
|
|
|
} |
|
|
|
|
|
|
|
//拍照 |
|
|
|
public boolean takePhoto() { |
|
|
|
return true; |
|
|
|
Map<String, Object> params = Map.of(); |
|
|
|
List<Supplier<Boolean>> cmdList = cmdService.takePhoto(params); |
|
|
|
return cmdList.stream().allMatch(Supplier::get); |
|
|
|
} |
|
|
|
|
|
|
|
//移至异常 |
|
|
@ -138,4 +147,5 @@ public class DeviceStepService { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |