diff --git a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmSampleTube.java b/src/main/java/com/dreamworks/boditech/driver/consumable/CsmSampleTube.java index 30b4288..ed7a1a5 100644 --- a/src/main/java/com/dreamworks/boditech/driver/consumable/CsmSampleTube.java +++ b/src/main/java/com/dreamworks/boditech/driver/consumable/CsmSampleTube.java @@ -53,6 +53,8 @@ public class CsmSampleTube { return this.device.getLocationByName("regularBloodTube5mlDepth"); } else if ( CsmSampleTube.TYPE_BLOOD_TUBE_3ML.equals(this.type) ) { return this.device.getLocationByName("regularBloodTube3mlDepth"); + } else if (CsmSampleTube.TYPE_EPP05.equals(this.type)) { + return this.device.getLocationByName("regularEpp0.5mlDepth"); } else { throw new RuntimeException("unknown tube type " + this.type); } diff --git a/src/main/java/com/dreamworks/boditech/driver/task/TaskTestTubeRackPrepare.java b/src/main/java/com/dreamworks/boditech/driver/task/TaskTestTubeRackPrepare.java index 00399b2..7578d8f 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/TaskTestTubeRackPrepare.java +++ b/src/main/java/com/dreamworks/boditech/driver/task/TaskTestTubeRackPrepare.java @@ -72,21 +72,23 @@ public class TaskTestTubeRackPrepare extends TaskBase { } // 03. 试管架类型检测 - this.testTubeRackTypeDetect(); + MdbTestTube testTube = this.testTubeRackTypeDetect(); // 03. 逐个扫描试管 this.testTubeBarcodes = new String[10]; - int scanStartPos = this.device.getLocationByName("testTubeRackScanStart"); - for ( int i = 0; i < 10; i++ ) { - if ( !this.testTubeExistsStatus[i] ) { - this.testTubeBarcodes[i] = ""; - continue ; + if ( testTube.scanable ) { + int scanStartPos = this.device.getLocationByName("testTubeRackScanStart"); + for ( int i = 0; i < 10; i++ ) { + if ( !this.testTubeExistsStatus[i] ) { + this.testTubeBarcodes[i] = ""; + continue ; + } + this.testTubeMoveMotor.moveTo(scanStartPos + i * tubeDistance); + testTubeRotateMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); + String code = this.testTubeScanner.scan(1000); + testTubeRotateMotor.reset(); + this.testTubeBarcodes[i] = code; } - this.testTubeMoveMotor.moveTo(scanStartPos + i * tubeDistance); - testTubeRotateMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); - String code = this.testTubeScanner.scan(1000); - testTubeRotateMotor.reset(); - this.testTubeBarcodes[i] = code; } // 04. 扫描完成后推送到预备区域 @@ -111,6 +113,9 @@ public class TaskTestTubeRackPrepare extends TaskBase { if ( tube.barCode.isEmpty() ) { tube.barCode = this.testTubeBarcodes[tube.index]; + if ( null == tube.barCode ) { + tube.barCode = ""; + } } List projectIds = (List) MyCommon.jsonToObject(tube.projectIds, List.class); @@ -162,9 +167,9 @@ public class TaskTestTubeRackPrepare extends TaskBase { } // 试管架类型检测 - private void testTubeRackTypeDetect() { + private MdbTestTube testTubeRackTypeDetect() { if ( !this.mdbTask.tubeType.isEmpty() ) { - return ; + return this.testService.testTubeFindByKey(this.mdbTask.tubeType); } this.testTubeMoveMotor.moveTo("testTubeRackTubeTypeScan"); @@ -193,5 +198,6 @@ public class TaskTestTubeRackPrepare extends TaskBase { } this.mdbTask.tubeType = testTube.key; this.testService.regularTaskUpdate(this.mdbTask); + return testTube; } } diff --git a/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java b/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java index af3294b..b5c126a 100644 --- a/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java +++ b/src/main/java/com/dreamworks/boditech/driver/task/step/StepPretreatment.java @@ -1,12 +1,16 @@ package com.dreamworks.boditech.driver.task.step; import com.dreamworks.boditech.driver.Device; +import com.dreamworks.boditech.driver.actuator.*; +import com.dreamworks.boditech.driver.consumable.CsmPipetteTip; import com.dreamworks.boditech.driver.consumable.CsmSampleTube; import com.dreamworks.boditech.driver.task.Task; import com.dreamworks.boditech.driver.task.Executor; -import com.dreamworks.boditech.driver.actuator.ActMotor; -import com.dreamworks.boditech.driver.actuator.ActuatorModule; import com.dreamworks.boditech.driver.task.TaskTest; +import com.dreamworks.boditech.entity.MdbTestTube; import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; + public class StepPretreatment extends StepBase { @JsonProperty public Boolean shaking; @@ -36,38 +40,78 @@ public class StepPretreatment extends StepBase { this.testTubeShakeMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_SHAKE_MOTOR); this.testTubeClipMotor = (ActMotor)device.getActuator(ActuatorModule.TEST_TUBE_SHAKING_CLIP_MOTOR); + CsmSampleTube tube = this.taskTest.getSampleTube(); + MdbTestTube testTube = executor.getDevice().testService.testTubeFindByKey(tube.type); if ( this.shaking ) { - this.shake(); + if (Objects.equals(tube.type, CsmSampleTube.TYPE_BLOOD_TUBE_5ML)) { + this.shakeBloodTube5ml(); + } else if ( Objects.equals(tube.type, CsmSampleTube.TYPE_BLOOD_TUBE_3ML) ) { + this.shakeBloodTube3ml(); + } else if (Objects.equals(MdbTestTube.MIX_TYPE_PIPETTE, testTube.mixType)) { + this.mixByPipette(executor); + } else { + throw new RuntimeException("不支持的摇匀试管类型:"+tube.type); + } } + if ( this.uncap ) { this.uncap("none"); } } - // shake - private void shake() { - if ( !this.taskTest.getSampleTube().isShakable() ) { - return ; + // 通过移液枪混匀 + private void mixByPipette(Executor executor) { + Device device = executor.getDevice(); + ActPipette pipette = (ActPipette)device.getActuator(ActuatorModule.ARM_Z_PIPETTE); + ActArmXY armXY = (ActArmXY)device.getActuator(ActuatorModule.ARM_XY); + ActMotor armZMotor = (ActMotor)device.getActuator(ActuatorModule.ARM_Z_MOTOR); + CsmSampleTube sampleTube = this.taskTest.getSampleTube(); + + CsmPipetteTip tip = device.pipetteTips.tipAlloc(); + pipette.useTip(tip); + armXY.moveTo(sampleTube.getLocationX(), sampleTube.getLocationY()); + armZMotor.moveTo(sampleTube.getLocationZ()); + + for ( int i=0; i<5; i++ ) { + pipette.aspiration(100); + pipette.dispense(); } + armZMotor.moveTo(0); + pipette.dropTip(); + } + + // 全血3ml试管 + private void shakeBloodTube3ml() { this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipOpen"); - if (CsmSampleTube.TYPE_BLOOD_TUBE_5ML.equals(this.taskTest.getSampleTube().type)) { // 全血试管:高 - this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); - this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipClose"); - } else if ( CsmSampleTube.TYPE_BLOOD_TUBE_3ML.equals(this.taskTest.getSampleTube().type) ) { // 全血试管:低 - this.testTubeMoveMotor.moveTo("shakeTestTubeCapBodyClipDepth"); // 下降到试管帽中间位置,用于夹住试管帽=1200 - this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipBodyClose"); //夹住试管帽=850 - this.testTubeMoveMotor.moveTo("shakeTestTubeBT3mlPullUpDepth"); //往上提一点=980 - this.testTubeClipMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); //试管夹夹住试管 - this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipOpen"); //试管帽夹松开 - this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); //试管帽夹下降 - this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipBt3mlClose"); // 试管帽夹夹住整个试管帽=850 - this.testTubeClipMotor.rotate(ActMotor.ROTATE_DIRECTION_COUNTER_CLOCKWISE); //试管夹松开 - this.testTubeClipMotor.stop(); //试管夹停止 - } + this.testTubeMoveMotor.moveTo("shakeTestTubeCapBodyClipDepth"); // 下降到试管帽中间位置,用于夹住试管帽=1200 + this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipBodyClose"); //夹住试管帽=850 + this.testTubeMoveMotor.moveTo("shakeTestTubeBT3mlPullUpDepth"); //往上提一点=980 + this.testTubeClipMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); //试管夹夹住试管 + this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipOpen"); //试管帽夹松开 + this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); //试管帽夹下降 + this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipBt3mlClose"); // 试管帽夹夹住整个试管帽=850 + this.testTubeClipMotor.rotate(ActMotor.ROTATE_DIRECTION_COUNTER_CLOCKWISE); //试管夹松开 + this.testTubeClipMotor.stop(); //试管夹停止 + this.testTubeMoveMotor.moveTo("shakeTestTubeMoveStandby"); + this.shakeMotorExecute(); + this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); + this.uncap("shaking"); + } + // 全血5ml试管 + private void shakeBloodTube5ml() { + this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipOpen"); + this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); + this.testTubeCapClipMotor.moveTo("shakeTestTubeCapClipClose"); this.testTubeMoveMotor.moveTo("shakeTestTubeMoveStandby"); + this.shakeMotorExecute(); + this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); + this.uncap("shaking"); + } + // 执行摇匀 + private void shakeMotorExecute() { // 05. 摇晃 // @TODO : 摇不得摇不得, 没限位, 要乱的 // this.testTubeShakeMotor.rotate(ActMotor.ROTATE_DIRECTION_CLOCKWISE); @@ -77,9 +121,6 @@ public class StepPretreatment extends StepBase { // throw new RuntimeException(e); // } // this.testTubeShakeMotor.stop(); - - this.testTubeMoveMotor.moveTo("shakeTestTubeMoveCapClip"); - this.uncap("shaking"); } // uncap diff --git a/src/main/java/com/dreamworks/boditech/entity/MdbTestTube.java b/src/main/java/com/dreamworks/boditech/entity/MdbTestTube.java index d90e214..d88544c 100644 --- a/src/main/java/com/dreamworks/boditech/entity/MdbTestTube.java +++ b/src/main/java/com/dreamworks/boditech/entity/MdbTestTube.java @@ -1,5 +1,7 @@ package com.dreamworks.boditech.entity; public class MdbTestTube { + public static String MIX_TYPE_PIPETTE = "PIPETTE"; + // id public Integer id; // key @@ -8,4 +10,8 @@ public class MdbTestTube { public String name; // code public String code; + // scanable + public Boolean scanable; + // mix type + public String mixType; } diff --git a/src/main/java/com/dreamworks/boditech/mapper/TestTubeMapper.java b/src/main/java/com/dreamworks/boditech/mapper/TestTubeMapper.java index 2533339..a309505 100644 --- a/src/main/java/com/dreamworks/boditech/mapper/TestTubeMapper.java +++ b/src/main/java/com/dreamworks/boditech/mapper/TestTubeMapper.java @@ -6,4 +6,7 @@ import org.apache.ibatis.annotations.Select; public interface TestTubeMapper { @Select("SELECT * FROM bdt_test_tubes WHERE code = #{code}") MdbTestTube findByCode(String code); + + @Select("SELECT * FROM bdt_test_tubes WHERE `key` = #{key}") + MdbTestTube findByKey(String key); } diff --git a/src/main/java/com/dreamworks/boditech/service/TestService.java b/src/main/java/com/dreamworks/boditech/service/TestService.java index 78ccc11..35fc085 100644 --- a/src/main/java/com/dreamworks/boditech/service/TestService.java +++ b/src/main/java/com/dreamworks/boditech/service/TestService.java @@ -419,4 +419,9 @@ public class TestService { public MdbTestTube testTubeFindByCode( String code) { return this.testTubeMapper.findByCode(code); } + + // test tube by key + public MdbTestTube testTubeFindByKey( String key ) { + return this.testTubeMapper.findByKey(key); + } }