diff --git a/src/main/java/com/dreamworks/boditech/controller/DeviceController.java b/src/main/java/com/dreamworks/boditech/controller/DeviceController.java index 88f935e..15943cd 100644 --- a/src/main/java/com/dreamworks/boditech/controller/DeviceController.java +++ b/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; diff --git a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTube.java b/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTube.java index 86d07f9..048a268 100644 --- a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTube.java +++ b/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; + } } diff --git a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeA.java b/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeA.java deleted file mode 100644 index 78d4f1c..0000000 --- a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeA.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeB.java b/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeB.java deleted file mode 100644 index 3d40891..0000000 --- a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeB.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeManager.java b/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeManager.java index eeb8315..485b2c1 100644 --- a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmBufferTubeManager.java +++ b/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 bufferTubeAList = new ArrayList<>(); - // list of buffer tube B - private final List bufferTubeBList = new ArrayList<>(); + // list of buffer tube + private final List 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 getAllA() { - return this.bufferTubeAList; - } - - // get all buffer tube B - public List 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 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); } } } diff --git a/src/main/java/com/dreamworks/boditech/driver/entity/ParamBufferTubeUpdateByBox.java b/src/main/java/com/dreamworks/boditech/driver/entity/ParamBufferTubeUpdateByBox.java index 2a4a05d..0f5542f 100644 --- a/src/main/java/com/dreamworks/boditech/driver/entity/ParamBufferTubeUpdateByBox.java +++ b/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 diff --git a/src/main/java/com/dreamworks/boditech/driver/task/TaskBatchTubePrepare.java b/src/main/java/com/dreamworks/boditech/driver/task/TaskBatchTubePrepare.java index eb24513..d417c2c 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/TaskBatchTubePrepare.java +++ b/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; diff --git a/src/main/java/com/dreamworks/boditech/driver/task/TaskBufferTubeLoad.java b/src/main/java/com/dreamworks/boditech/driver/task/TaskBufferTubeLoad.java index a73d827..b31580c 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/TaskBufferTubeLoad.java +++ b/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(); diff --git a/src/main/java/com/dreamworks/boditech/driver/task/step/StepBase.java b/src/main/java/com/dreamworks/boditech/driver/task/step/StepBase.java index b2f1f37..e32cf03 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/step/StepBase.java +++ b/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; + } } diff --git a/src/main/java/com/dreamworks/boditech/driver/task/step/StepPuncture.java b/src/main/java/com/dreamworks/boditech/driver/task/step/StepPuncture.java index d30cbb2..db15d9b 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/step/StepPuncture.java +++ b/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); diff --git a/src/main/java/com/dreamworks/boditech/service/DeviceService.java b/src/main/java/com/dreamworks/boditech/service/DeviceService.java index 8bf6e62..7c5240a 100644 --- a/src/main/java/com/dreamworks/boditech/service/DeviceService.java +++ b/src/main/java/com/dreamworks/boditech/service/DeviceService.java @@ -57,18 +57,7 @@ public class DeviceService { public List bufferTubeLoad() { TaskBufferTubeLoad task = new TaskBufferTubeLoad(); Executor.executeTask(this.device, task); - List list = new ArrayList<>(); - - List aList = this.device.bufferTubes.getAllA(); - for ( CsmBufferTubeA a : aList ) { - list.add((CsmBufferTube)a); - } - - List 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 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 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 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; }