diff --git a/pom.xml b/pom.xml
index a46f33b..1e83266 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
com.iflytop
uf
- 0.0.19
+ 0.0.20
diff --git a/src/main/java/com/iflytop/a800/controller/DemoController.java b/src/main/java/com/iflytop/a800/controller/DemoController.java
index 919480c..86a1dba 100644
--- a/src/main/java/com/iflytop/a800/controller/DemoController.java
+++ b/src/main/java/com/iflytop/a800/controller/DemoController.java
@@ -1,5 +1,6 @@
package com.iflytop.a800.controller;
import com.iflytop.a800.device.Device;
+import com.iflytop.a800.resource.BufferTube;
import com.iflytop.uf.controller.UfApiControllerBase;
import com.iflytop.uf.controller.UfApiResponse;
import org.springframework.stereotype.Controller;
@@ -22,4 +23,13 @@ public class DemoController extends UfApiControllerBase {
pipette.tipDrop();
return this.success();
}
+
+ @PostMapping("/api/demo/pipette-dispense-detection")
+ @ResponseBody
+ public UfApiResponse pipetteDispenseDetection() {
+ var tube = Device.getInstance().bufferTube.alloc();
+ var pipette = Device.getInstance().pipette;
+ pipette.dispense(tube);
+ return this.success();
+ }
}
diff --git a/src/main/java/com/iflytop/a800/device/Device.java b/src/main/java/com/iflytop/a800/device/Device.java
index 2e6a099..fbd9b65 100644
--- a/src/main/java/com/iflytop/a800/device/Device.java
+++ b/src/main/java/com/iflytop/a800/device/Device.java
@@ -1,4 +1,7 @@
package com.iflytop.a800.device;
+
+import com.iflytop.a800.resource.BufferTubeManager;
+
public class Device {
// singleton instance
private static final Device instance = new Device();
@@ -6,6 +9,8 @@ public class Device {
public final Feeder feeder = new Feeder();
// pipette
public final Pipette pipette = new Pipette();
+ // buffer tube manager
+ public final BufferTubeManager bufferTube = new BufferTubeManager();
// get instance
public static Device getInstance() {
diff --git a/src/main/java/com/iflytop/a800/device/Pipette.java b/src/main/java/com/iflytop/a800/device/Pipette.java
index 6a7c9ed..818f800 100644
--- a/src/main/java/com/iflytop/a800/device/Pipette.java
+++ b/src/main/java/com/iflytop/a800/device/Pipette.java
@@ -1,4 +1,5 @@
package com.iflytop.a800.device;
+import com.iflytop.a800.resource.BufferTube;
import com.iflytop.uf.UfActuatorCmdExecutor;
import com.iflytop.uf.UfCmdSnippetExecutor;
import com.iflytop.uf.model.UfMdbOption;
@@ -18,10 +19,9 @@ public class Pipette {
//
public Pipette() {
- // @TODO : 删除下面三行,测试用
this.tipAmountList.add(0);
- this.tipAmountList.add(120-29);
- this.tipAmountList.add(120);
+ this.tipAmountList.add(0);
+ this.tipAmountList.add(0);
}
// set tip amount
@@ -114,4 +114,27 @@ public class Pipette {
}
return existsCount > 1;
}
+
+ // move to given position
+ public void dispense( BufferTube tube ) {
+ if ( !this.hasTip ) {
+ throw new RuntimeException("Pipette has no tip");
+ }
+
+ Integer startX = UfMdbOption.getInteger(String.format("%sZoneStartX.%d", tube.type, tube.zoneIndex));
+ Integer startY = UfMdbOption.getInteger(String.format("%sZoneStartY.%d", tube.type, tube.zoneIndex));
+ Integer distanceX = UfMdbOption.getInteger(String.format("%sDistanceX", tube.type));
+ Integer distanceY = UfMdbOption.getInteger(String.format("%sDistanceY", tube.type));
+ Integer indexX = tube.tubeIndex % 5;
+ Integer indexY = tube.tubeIndex / 5;
+ Integer tubeX = startX + indexX * distanceX;
+ Integer tubeY = startY + indexY * distanceY;
+ Map dispenseParams = Map.of("tubeX", tubeX, "tubeY", tubeY);
+
+ String snippetKey = "SampleReactionAtDetectionTube";
+ if ( "BufferTube".equals(tube.type) ) {
+ snippetKey = "SampleReactionAtBufferTube";
+ }
+ UfCmdSnippetExecutor.execute(snippetKey, dispenseParams);
+ }
}
diff --git a/src/main/java/com/iflytop/a800/resource/BufferTube.java b/src/main/java/com/iflytop/a800/resource/BufferTube.java
new file mode 100644
index 0000000..f685389
--- /dev/null
+++ b/src/main/java/com/iflytop/a800/resource/BufferTube.java
@@ -0,0 +1,9 @@
+package com.iflytop.a800.resource;
+public class BufferTube {
+ // zone index
+ public Integer zoneIndex;
+ // tube index
+ public Integer tubeIndex;
+ // buffer tube type : buffer, detection
+ public String type;
+}
diff --git a/src/main/java/com/iflytop/a800/resource/BufferTubeManager.java b/src/main/java/com/iflytop/a800/resource/BufferTubeManager.java
new file mode 100644
index 0000000..2747105
--- /dev/null
+++ b/src/main/java/com/iflytop/a800/resource/BufferTubeManager.java
@@ -0,0 +1,34 @@
+package com.iflytop.a800.resource;
+import java.util.ArrayList;
+import java.util.List;
+public class BufferTubeManager {
+ // list of buffer tube zones
+ private final List zones;
+
+ // constructor
+ public BufferTubeManager() {
+ this.zones = new ArrayList<>();
+ for (int i = 0; i < 6; i++) {
+ BufferTubeZone zone = new BufferTubeZone();
+ zone.index = i;
+ zone.tubeAmount = 25;
+ zones.add(zone);
+ }
+ }
+
+ // allocate buffer tube
+ public BufferTube alloc() {
+ for (BufferTubeZone zone : zones) {
+ if (!(zone.tubeAmount > 0)) {
+ continue;
+ }
+ BufferTube tube = new BufferTube();
+ tube.zoneIndex = zone.index;
+ tube.tubeIndex = 25 - zone.tubeAmount;
+ tube.type = "BufferTube";
+ zone.tubeAmount--;
+ return tube;
+ }
+ throw new RuntimeException("No buffer tube available");
+ }
+}
diff --git a/src/main/java/com/iflytop/a800/resource/BufferTubeZone.java b/src/main/java/com/iflytop/a800/resource/BufferTubeZone.java
new file mode 100644
index 0000000..74cbe47
--- /dev/null
+++ b/src/main/java/com/iflytop/a800/resource/BufferTubeZone.java
@@ -0,0 +1,5 @@
+package com.iflytop.a800.resource;
+public class BufferTubeZone {
+ public Integer index;
+ public Integer tubeAmount;
+}