Browse Source

小缓冲液整理

master
sige 2 years ago
parent
commit
ebd5a81d36
  1. 2
      src/main/java/com/dreamworks/boditech/controller/DeviceController.java
  2. 62
      src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTube.java
  3. 37
      src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeA.java
  4. 37
      src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeB.java
  5. 129
      src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeManager.java
  6. 2
      src/main/java/com/dreamworks/boditech/driver/entity/ParamBufferTubeUpdateByBox.java
  7. 5
      src/main/java/com/dreamworks/boditech/driver/task/TaskBatchTubePrepare.java
  8. 16
      src/main/java/com/dreamworks/boditech/driver/task/TaskBufferTubeLoad.java
  9. 4
      src/main/java/com/dreamworks/boditech/driver/task/step/StepBase.java
  10. 19
      src/main/java/com/dreamworks/boditech/driver/task/step/StepPuncture.java
  11. 51
      src/main/java/com/dreamworks/boditech/service/DeviceService.java

2
src/main/java/com/dreamworks/boditech/controller/DeviceController.java

@ -1,7 +1,7 @@
package com.dreamworks.boditech.controller;
import com.dreamworks.boditech.controller.entity.ApiResponse;
import com.dreamworks.boditech.driver.consumable.CsmLargeBufferTube;
import com.dreamworks.boditech.driver.consumable.CsmBufferTube;
import com.dreamworks.boditech.driver.consumable.CsmLargeBufferTube;
import com.dreamworks.boditech.driver.entity.ParamBufferTubeUpdateByBox;
import com.dreamworks.boditech.driver.entity.ParamLargeBufferTubeUpdate;
import com.dreamworks.boditech.driver.entity.ParamPipetteTipUpdate;

62
src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTube.java

@ -1,11 +1,63 @@
package com.dreamworks.boditech.driver.consumable;
public interface CsmBufferTube {
import com.dreamworks.boditech.driver.Device;
import java.util.Objects;
public class CsmBufferTube {
// tube type : db rack cover 500μl
public static final String COVER_TYPE_500 = "DBRC500";
// tube type : db rack cover 150μl
public static final String COVER_TYPE_150 = "DBRC150";
// project name
public String projectName;
// area index
public Integer areaIndex;
// position
public Integer position;
// tube type
public String coverType = CsmBufferTube.COVER_TYPE_500;
// manager
private final CsmBufferTubeManager manager;
// constructor
public CsmBufferTube( CsmBufferTubeManager manager ) {
this.manager = manager;
}
// get location x
public Integer getLocationX();
public Integer getLocationX() {
Device device = this.manager.getDevice();
String keyPrefix = "bufferTube" + this.coverType;
String lineKeyPrefix = keyPrefix + "Line" + (Integer.toString(this.areaIndex / 3));
Integer areaStartX = device.getLocationByName(lineKeyPrefix+"Start.x");
Integer areaDistanceX = device.getLocationByName(keyPrefix+"BoxDistance");
Integer tubeDistanceX = device.getLocationByName(keyPrefix+"TubeDistanceX");
return areaStartX - areaDistanceX * (this.areaIndex%3) - tubeDistanceX * (this.position % 5);
}
// get location y
public Integer getLocationY();
public Integer getLocationY() {
Device device = this.manager.getDevice();
String keyPrefix = "bufferTube" + this.coverType;
String lineKeyPrefix = keyPrefix + "Line" + (Integer.valueOf(this.areaIndex / 3).toString());
Integer areaStartY = device.getLocationByName(lineKeyPrefix+"Start.y");
Integer tubeDistanceY = device.getLocationByName(keyPrefix+"TubeDistanceY");
return areaStartY - tubeDistanceY * (this.position / 5);
}
// get puncture depth
public Integer getPunctureDepth() {
Device device = this.manager.getDevice();
if (Objects.equals(this.coverType, CsmBufferTube.COVER_TYPE_500)) {
return device.getLocationByName("bufferTubeDBRC500PunctureDepth");
} else if (Objects.equals(this.coverType, CsmBufferTube.COVER_TYPE_150)) {
return device.getLocationByName("bufferTubeDBRC150PunctureDepth");
} else {
throw new RuntimeException("unknown cover type " + this.coverType);
}
}
// get location z
public Integer getLocationZ();
public Integer getLocationZ() {
// @TODO : 这里没法判断是那种盖子所以都做 500μl 处理
return 0;
}
}

37
src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeA.java

@ -1,37 +0,0 @@
package com.dreamworks.boditech.driver.consumable;
public class CsmBufferTubeA implements CsmBufferTube {
// project name
public String projectName;
// area index
public Integer areaIndex;
// position
public Integer position;
// manager
private final CsmBufferTubeManager manager;
// constructor
public CsmBufferTubeA( CsmBufferTubeManager manager ) {
this.manager = manager;
}
// get location x
public Integer getLocationX() {
Integer areaStartX = this.manager.getDevice().getLocationByName("bufferTubeAStart.x");
Integer areaDistanceX = this.manager.getDevice().getLocationByName("bufferTubeABoxDistance");
Integer tubeDistanceX = this.manager.getDevice().getLocationByName("bufferTubeATubeDistanceX");
return areaStartX - areaDistanceX * this.areaIndex - tubeDistanceX * (this.position % 5);
}
// get location y
public Integer getLocationY() {
Integer areaStartY = this.manager.getDevice().getLocationByName("bufferTubeAStart.y");
Integer tubeDistanceY = this.manager.getDevice().getLocationByName("bufferTubeATubeDistanceY");
return areaStartY - tubeDistanceY * (this.position / 5);
}
// get location z
public Integer getLocationZ() {
// @TODO : 需要根据探测距离计算出z坐标
return 850;
}
}

37
src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeB.java

@ -1,37 +0,0 @@
package com.dreamworks.boditech.driver.consumable;
public class CsmBufferTubeB implements CsmBufferTube {
// project name
public String projectName;
// area index
public Integer areaIndex;
// position
public Integer position;
// manager
private final CsmBufferTubeManager manager;
// constructor
public CsmBufferTubeB( CsmBufferTubeManager manager ) {
this.manager = manager;
}
// get location x
public Integer getLocationX() {
Integer areaStartX = this.manager.getDevice().getLocationByName("bufferTubeBStart.x");
Integer areaDistanceX = this.manager.getDevice().getLocationByName("bufferTubeBBoxDistance");
Integer tubeDistanceX = this.manager.getDevice().getLocationByName("bufferTubeBTubeDistanceX");
return areaStartX - areaDistanceX * this.areaIndex - tubeDistanceX * (this.position % 5);
}
// get location y
public Integer getLocationY() {
Integer areaStartY = this.manager.getDevice().getLocationByName("bufferTubeBStart.y");
Integer tubeDistanceY = this.manager.getDevice().getLocationByName("bufferTubeBTubeDistanceY");
return areaStartY - tubeDistanceY * (this.position / 5);
}
// get location z
public Integer getLocationZ() {
// @TODO : 需要根据探测距离计算出z坐标
return 850;
}
}

129
src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeManager.java

@ -7,10 +7,8 @@ import java.util.List;
public class CsmBufferTubeManager {
// device instance
private final Device device;
// list of buffer tube A
private final List<CsmBufferTubeA> bufferTubeAList = new ArrayList<>();
// list of buffer tube B
private final List<CsmBufferTubeB> bufferTubeBList = new ArrayList<>();
// list of buffer tube
private final List<CsmBufferTube> bufferTubeList = new ArrayList<>();
// constructor
public CsmBufferTubeManager(Device device) {
@ -23,55 +21,24 @@ public class CsmBufferTubeManager {
}
// tube alloc by project name
public CsmBufferTube tubeAllocByProjectName( String projectName ) {
return this.tubeAAllocByProjectName(projectName);
}
// get all buffer tube A
public List<CsmBufferTubeA> getAllA() {
return this.bufferTubeAList;
}
// get all buffer tube B
public List<CsmBufferTubeB> getAllB() {
return this.bufferTubeBList;
}
// get buffer tube A
// @DEPRECATED
public CsmBufferTubeA tubeAAllocByProjectName( String projectName ) {
for (CsmBufferTubeA tube : this.bufferTubeAList) {
public CsmBufferTube tubeAllocByProjectName(String projectName) {
for (CsmBufferTube tube : this.bufferTubeList) {
if (!tube.projectName.equals(projectName)) {
continue;
}
this.bufferTubeAList.remove(tube);
this.bufferTubeList.remove(tube);
return tube;
}
throw new RuntimeException("no buffer tube A for project " + projectName);
throw new RuntimeException("no buffer tube for project " + projectName);
}
// get buffer tube B
public CsmBufferTubeB tubeBAllocByProjectName( String projectName ) {
for (CsmBufferTubeB tube : this.bufferTubeBList) {
if (!tube.projectName.equals(projectName)) {
continue;
}
this.bufferTubeBList.remove(tube);
return tube;
}
throw new RuntimeException("no buffer tube B for project " + projectName);
// get all buffer tube A
public List<CsmBufferTube> getAll() {
return this.bufferTubeList;
}
// append buffer tube A
public void appendAByCode( Integer areaIndex, String code ) {
public void appendByCode( Integer areaIndex, String code ) {
// @TODO : 由于缺少 code 格式所以都做 "hsCRP" 项目处理
String projectName = "hsCRP";
Project project = this.device.projectService.findByName(projectName);
@ -80,78 +47,32 @@ public class CsmBufferTubeManager {
}
// remove all buffer tube A with matched zoneIndex
this.bufferTubeAList.removeIf(bufferTubeA -> bufferTubeA.areaIndex.equals(areaIndex));
this.bufferTubeList.removeIf(bufferTubeA -> bufferTubeA.areaIndex.equals(areaIndex));
for ( int i=0; i<25; i++ ) {
// append new buffer tube A
CsmBufferTubeA bufferTubeA = new CsmBufferTubeA(this);
bufferTubeA.areaIndex = areaIndex;
bufferTubeA.position = i;
bufferTubeA.projectName = project.name;
this.bufferTubeAList.add(bufferTubeA);
}
}
// append buffer tube B
public void appendBByCode( Integer areaIndex, String code ) {
// @TODO : 由于缺少 code 格式所以都做 "hsCRP" 项目处理
String projectName = "hsCRP";
Project project = this.device.projectService.findByName(projectName);
if ( null == project ) {
throw new RuntimeException("project not found");
}
// remove all buffer tube B with matched zoneIndex
this.bufferTubeBList.removeIf(bufferTubeB -> bufferTubeB.areaIndex.equals(areaIndex));
for ( int i=0; i<25; i++ ) {
// append new buffer tube B
CsmBufferTubeB bufferTubeB = new CsmBufferTubeB(this);
bufferTubeB.areaIndex = areaIndex;
bufferTubeB.position = i;
bufferTubeB.projectName = project.name;
this.bufferTubeBList.add(bufferTubeB);
CsmBufferTube bufferTube = new CsmBufferTube(this);
bufferTube.areaIndex = areaIndex;
bufferTube.position = i;
bufferTube.projectName = project.name;
// @TODO : 这里没法判断是那种盖子所以都做 500μl 处理
bufferTube.coverType = CsmBufferTube.COVER_TYPE_150;
this.bufferTubeList.add(bufferTube);
}
}
// update by box
public void updateByBox(ParamBufferTubeUpdateByBox param ) {
if ( param.type.equals("A") ) {
this.updateAByBox(param);
} else if ( param.type.equals("B") ) {
this.updateBByBox(param);
} else {
throw new RuntimeException("unknown buffer tube type");
}
}
// update buffer tube B by box
private void updateBByBox( ParamBufferTubeUpdateByBox param ) {
// remove all buffer tube B with matched zoneIndex
this.bufferTubeBList.removeIf(bufferTubeB -> bufferTubeB.areaIndex.equals(param.areaIndex));
this.bufferTubeList.removeIf(bufferTube -> bufferTube.areaIndex.equals(param.areaIndex));
for ( int i=0; i< param.amount; i++ ) {
// append new buffer tube B
CsmBufferTubeB bufferTubeB = new CsmBufferTubeB(this);
bufferTubeB.areaIndex = param.areaIndex;
bufferTubeB.position = i;
bufferTubeB.projectName = param.projectName;
this.bufferTubeBList.add(bufferTubeB);
}
}
// update buffer tube A by box
private void updateAByBox( ParamBufferTubeUpdateByBox param ) {
// remove all buffer tube A with matched zoneIndex
this.bufferTubeAList.removeIf(bufferTubeA -> bufferTubeA.areaIndex.equals(param.areaIndex));
for ( int i=0; i< param.amount; i++ ) {
// append new buffer tube A
CsmBufferTubeA bufferTubeA = new CsmBufferTubeA(this);
bufferTubeA.areaIndex = param.areaIndex;
bufferTubeA.position = i;
bufferTubeA.projectName = param.projectName;
this.bufferTubeAList.add(bufferTubeA);
CsmBufferTube bufferTube = new CsmBufferTube(this);
bufferTube.coverType = param.coverType;
bufferTube.areaIndex = param.areaIndex;
bufferTube.position = i;
bufferTube.projectName = param.projectName;
this.bufferTubeList.add(bufferTube);
}
}
}

2
src/main/java/com/dreamworks/boditech/driver/entity/ParamBufferTubeUpdateByBox.java

@ -1,7 +1,7 @@
package com.dreamworks.boditech.driver.entity;
public class ParamBufferTubeUpdateByBox {
// type
public String type;
public String coverType;
// area index
public Integer areaIndex;
// project name

5
src/main/java/com/dreamworks/boditech/driver/task/TaskBatchTubePrepare.java

@ -1,9 +1,6 @@
package com.dreamworks.boditech.driver.task;
import com.dreamworks.boditech.driver.Device;
import com.dreamworks.boditech.driver.actuator.ActCodeScanner;
import com.dreamworks.boditech.driver.actuator.ActModuleTestTubeRackMovement;
import com.dreamworks.boditech.driver.actuator.ActuatorModule;
import com.dreamworks.boditech.driver.actuator.ActMotor;
import com.dreamworks.boditech.driver.actuator.*;
import com.dreamworks.boditech.driver.entity.TaskBatchTubeTestInfo;
import java.util.List;
import java.util.Objects;

16
src/main/java/com/dreamworks/boditech/driver/task/TaskBufferTubeLoad.java

@ -10,29 +10,29 @@ public class TaskBufferTubeLoad extends TaskBase {
ActArmXY armXY = (ActArmXY)device.getActuator(ActuatorModule.ARM_XY);
ActCodeScanner codeScanner = (ActCodeScanner)device.getActuator(ActuatorModule.ARM_Z_SCANNER);
Integer scanStartX = device.getLocationByName("bufferTubeAScanStart.x");
Integer scanStartY = device.getLocationByName("bufferTubeAScanStart.y");
Integer scanStartX = device.getLocationByName("bufferTubeLineOneScanStart.x");
Integer scanStartY = device.getLocationByName("bufferTubeLineOneScanStart.y");
// buffer tube A
// buffer tube line one
for ( int i=0; i<3; i++ ) {
armXY.moveTo(scanStartX - i * 1200, scanStartY);
String code = codeScanner.scan(500);
if ( "".equals(code) ) {
continue ;
}
device.bufferTubes.appendAByCode(i, code);
device.bufferTubes.appendByCode(i, code);
}
// buffer tube B
scanStartX = device.getLocationByName("bufferTubeBScanStart.x");
scanStartY = device.getLocationByName("bufferTubeBScanStart.y");
// buffer tube line two
scanStartX = device.getLocationByName("bufferTubeLineTwoScanStart.x");
scanStartY = device.getLocationByName("bufferTubeLineTwoScanStart.y");
for ( int i=0; i<3; i++ ) {
armXY.moveTo(scanStartX - i * 1200, scanStartY);
String code = codeScanner.scan(500);
if ( "".equals(code) ) {
continue ;
}
device.bufferTubes.appendBByCode(i, code);
device.bufferTubes.appendByCode(i+3, code);
}
armXY.reset();

4
src/main/java/com/dreamworks/boditech/driver/task/step/StepBase.java

@ -15,4 +15,8 @@ abstract public class StepBase implements Step {
public void postExecute() {
// nothing to do here as default
}
public boolean isExecutable() {
return true;
}
}

19
src/main/java/com/dreamworks/boditech/driver/task/step/StepPuncture.java

@ -1,13 +1,12 @@
package com.dreamworks.boditech.driver.task.step;
import com.dreamworks.boditech.driver.Device;
import com.dreamworks.boditech.driver.actuator.ActPipette;
import com.dreamworks.boditech.driver.consumable.CsmBufferTube;
import com.dreamworks.boditech.driver.task.Task;
import com.dreamworks.boditech.driver.task.Executor;
import com.dreamworks.boditech.driver.actuator.ActArmXY;
import com.dreamworks.boditech.driver.actuator.ActMotor;
import com.dreamworks.boditech.driver.actuator.ActuatorModule;
import com.dreamworks.boditech.driver.consumable.CsmBufferTubeA;
import com.dreamworks.boditech.driver.consumable.CsmBufferTubeB;
import com.dreamworks.boditech.driver.consumable.CsmPipetteTip;
import com.dreamworks.boditech.driver.task.TaskTest;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -31,21 +30,11 @@ public class StepPuncture extends StepBase {
pipette.useTip(tip);
// 04. 移动到穿刺区域
Integer punctureDepth = 0;
if ( "A".equals(this.tubeType) ) {
CsmBufferTubeA tube = device.bufferTubes.tubeAAllocByProjectName(taskTest.getProjectName());
armXY.moveTo(tube.getLocationX(), tube.getLocationY());
punctureDepth = device.getLocationByName("bufferTubeAPunctureDepth");
} else if ( "B".equals(this.tubeType) ) {
CsmBufferTubeB tube = device.bufferTubes.tubeBAllocByProjectName(taskTest.getProjectName());
armXY.moveTo(tube.getLocationX(), tube.getLocationY());
punctureDepth = device.getLocationByName("bufferTubeBPunctureDepth");
} else {
throw new RuntimeException("unknown tube type " + this.tubeType);
}
CsmBufferTube bufferTube = taskTest.getReactionTube();
armXY.moveTo(bufferTube.getLocationX(), bufferTube.getLocationY());
// 05. 下降到穿刺区域
armZMotor.moveTo(punctureDepth);
armZMotor.moveTo(bufferTube.getPunctureDepth());
// 06. 上升到准备区域
armZMotor.moveTo(0);

51
src/main/java/com/dreamworks/boditech/service/DeviceService.java

@ -57,18 +57,7 @@ public class DeviceService {
public List<CsmBufferTube> bufferTubeLoad() {
TaskBufferTubeLoad task = new TaskBufferTubeLoad();
Executor.executeTask(this.device, task);
List<CsmBufferTube> list = new ArrayList<>();
List<CsmBufferTubeA> aList = this.device.bufferTubes.getAllA();
for ( CsmBufferTubeA a : aList ) {
list.add((CsmBufferTube)a);
}
List<CsmBufferTubeB> bList = this.device.bufferTubes.getAllB();
for ( CsmBufferTubeB b : bList ) {
list.add((CsmBufferTube)b);
}
return list;
return this.device.bufferTubes.getAll();
}
// update buffer tubes by box
@ -120,32 +109,18 @@ public class DeviceService {
status.put("largeBufferTubes", largeBufferTubes);
// buffer tube area
BufferTubeArea[] bufferTubeAAreas = new BufferTubeArea[3];
for ( int i=0; i<bufferTubeAAreas.length; i++ ) {
bufferTubeAAreas[i] = new BufferTubeArea();
}
List<CsmBufferTubeA> bufferTubeAList = this.device.bufferTubes.getAllA();
for ( CsmBufferTubeA bufferTubeA : bufferTubeAList ) {
Integer index = bufferTubeA.areaIndex;
bufferTubeAAreas[index].areaIndex = index;
bufferTubeAAreas[index].amount ++;
bufferTubeAAreas[index].projectName = bufferTubeA.projectName;
}
status.put("bufferTubeAAreas", bufferTubeAAreas);
// buffer tube area
BufferTubeArea[] bufferTubeBAreas = new BufferTubeArea[3];
for ( int i=0; i<bufferTubeBAreas.length; i++ ) {
bufferTubeBAreas[i] = new BufferTubeArea();
}
List<CsmBufferTubeB> bufferTubeBList = this.device.bufferTubes.getAllB();
for ( CsmBufferTubeB bufferTubeB : bufferTubeBList ) {
Integer index = bufferTubeB.areaIndex;
bufferTubeBAreas[index].areaIndex = index;
bufferTubeBAreas[index].amount ++;
bufferTubeBAreas[index].projectName = bufferTubeB.projectName;
}
status.put("bufferTubeBAreas", bufferTubeBAreas);
BufferTubeArea[] bufferTubeAreas = new BufferTubeArea[6];
for ( int i=0; i<bufferTubeAreas.length; i++ ) {
bufferTubeAreas[i] = new BufferTubeArea();
}
List<CsmBufferTube> bufferTubeList = this.device.bufferTubes.getAll();
for ( CsmBufferTube bufferTube : bufferTubeList ) {
Integer index = bufferTube.areaIndex;
bufferTubeAreas[index].areaIndex = index;
bufferTubeAreas[index].amount ++;
bufferTubeAreas[index].projectName = bufferTube.projectName;
}
status.put("bufferTubeAreas", bufferTubeAreas);
return status;
}

Loading…
Cancel
Save