11 changed files with 301 additions and 27 deletions
-
6README.md
-
BINapp.db
-
1src/main/java/a8k/extapi_controler/pagecontrol/ExtApiTabConfig.java
-
200src/main/java/a8k/service/app/devicedriver/calibration/HbotLargeBottleBSPosCalibration.java
-
31src/main/java/a8k/service/app/devicedriver/calibration/HbotLittleBottleConsumableCalibration.java
-
24src/main/java/a8k/service/app/devicedriver/pos/HbotConsumablePosMgr.java
-
3src/main/java/a8k/type/HbotConsumablePosParam.java
-
22src/main/java/a8k/type/LargeBottleConsumableRefPoint.java
-
17src/main/java/a8k/type/LargeBottoleConsumablePosInfo.java
-
3src/main/java/a8k/utils/ZJsonHelper.java
-
17src/main/java/a8k/utils/ZSqliteJdbcHelper.java
@ -0,0 +1,200 @@ |
|||
package a8k.service.app.devicedriver.calibration; |
|||
|
|||
|
|||
import a8k.extapi_controler.pagecontrol.ExtApiTabConfig; |
|||
import a8k.extapi_controler.utils.ExtApiFn; |
|||
import a8k.extapi_controler.utils.ExtApiTab; |
|||
import a8k.service.app.devicedriver.basectrl.HbotModule; |
|||
import a8k.service.app.devicedriver.basectrl.PipetteCtrlModule; |
|||
import a8k.service.app.devicedriver.ctrl.HbotControler; |
|||
import a8k.service.app.devicedriver.pos.HbotConsumablePosMgr; |
|||
import a8k.type.*; |
|||
import a8k.type.cfg.Pos2d; |
|||
import a8k.type.cfg.Pos3d; |
|||
import a8k.type.exception.AppException; |
|||
import a8k.utils.ZJsonHelper; |
|||
import a8k.utils.ZSimplAlgo; |
|||
import com.fasterxml.jackson.databind.node.ObjectNode; |
|||
import jakarta.annotation.Resource; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.slf4j.Logger; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
@ExtApiTab(cfg = ExtApiTabConfig.HbotLargeBottleBSPosCalibration) |
|||
@Component |
|||
@Aspect |
|||
public class HbotLargeBottleBSPosCalibration { |
|||
static Logger logger = org.slf4j.LoggerFactory.getLogger(HbotLargeBottleBSPosCalibration.class); |
|||
|
|||
@Resource |
|||
PipetteCtrlModule pipetteCtrlModule; |
|||
@Resource |
|||
HbotModule hbotModule; |
|||
|
|||
|
|||
@Resource |
|||
HbotControler hbotControler; |
|||
@Resource |
|||
HbotConsumablePosMgr hbotConsumablePosMgr; |
|||
|
|||
Boolean stopFlag = false; |
|||
|
|||
Boolean checkStopFlag() { |
|||
if (stopFlag) { |
|||
stopFlag = false; |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
void resetStopFlag() { |
|||
stopFlag = false; |
|||
} |
|||
|
|||
void setStopFlag() { |
|||
stopFlag = true; |
|||
} |
|||
|
|||
|
|||
@ExtApiFn(name = "获取坐标", group = "基础", order = 1) |
|||
public Object getPoss() throws AppException { |
|||
return hbotConsumablePosMgr.getParams(); |
|||
} |
|||
|
|||
|
|||
// 测试工具 |
|||
@ExtApiFn(name = "归零", group = "测试工具", order = 11) |
|||
public void moveToZero() throws AppException { |
|||
enableModule(); |
|||
pipetteCtrlModule.zMotorMoveZeroBlock(); |
|||
hbotModule.moveToZeroBlock(); |
|||
} |
|||
|
|||
@ExtApiFn(name = "使能相关模块", group = "测试工具", order = 12) |
|||
public void enableModule() throws AppException { |
|||
pipetteCtrlModule.zMotorEnable(1); |
|||
hbotModule.enable(1); |
|||
} |
|||
|
|||
@ExtApiFn(name = "失能相关模块", group = "测试工具", order = 13) |
|||
public void disableModule() throws AppException { |
|||
pipetteCtrlModule.zMotorEnable(0); |
|||
hbotModule.enable(0); |
|||
} |
|||
|
|||
|
|||
List<LargeBottleConsumableRefPoint> refpoints = new java.util.ArrayList<>(); |
|||
|
|||
|
|||
@ExtApiFn(name = "开始标定大瓶坐标", group = "标定大瓶缓液XY坐标", order = 30) |
|||
public void startCalibrate() throws AppException { |
|||
refpoints = new java.util.ArrayList<>(); |
|||
moveToZero(); |
|||
disableModule(); |
|||
} |
|||
|
|||
@ExtApiFn(name = "添加大瓶参考点", group = "标定大瓶缓液XY坐标", order = 31) |
|||
public Object addRefPoint(ConsumableGroup group) throws AppException { |
|||
enableModule(); |
|||
Pos2d xypos = hbotModule.readPos(); |
|||
// pipetteCtrlModule.zMotorMeasureDistance(); |
|||
// Integer z = pipetteCtrlModule.zMotorReadMeasureDistanceResult(); |
|||
LargeBottleConsumableRefPoint refPoints = new LargeBottleConsumableRefPoint(group, new Pos3d(xypos.x, xypos.y, 0)); |
|||
this.refpoints.add(refPoints); |
|||
disableModule(); |
|||
ObjectNode node = ZJsonHelper.createObjectNode(); |
|||
node.put("newPoint", ZJsonHelper.createObjectNode(refPoints)); |
|||
node.put("computeResult", ZJsonHelper.createObjectNode(computeLittleBottlePosInfo())); |
|||
return node; |
|||
} |
|||
|
|||
@ExtApiFn(name = "移除最后一个参考点", group = "标定大瓶缓液XY坐标", order = 32) |
|||
public void removeTheLastRefPoint() { |
|||
if (!refpoints.isEmpty()) { |
|||
refpoints.remove(refpoints.size() - 1); |
|||
} |
|||
} |
|||
|
|||
|
|||
@ExtApiFn(name = "读取坐标计算结果", group = "标定大瓶缓液XY坐标", order = 33) |
|||
public LargeBottoleConsumablePosInfo computeLittleBottlePosInfo() { |
|||
//第一排x求平均 |
|||
// x[0] = ZSimplAlgo.computeAverage( |
|||
// littleBottleConsumableRefPoint.stream().filter(point -> point.group.ordinal() % 3 == 0 && point.index % 5 == 0). |
|||
// map(point -> point.pos.x).toList() |
|||
// ); |
|||
|
|||
var p00 = refpoints.stream().filter(point -> point.group == ConsumableGroup.GROUP0).findFirst().orElse(null); |
|||
Double x, y, dx = null, dy = null; |
|||
|
|||
x = ZSimplAlgo.computeAverage( |
|||
refpoints.stream().filter(point -> point.group.ordinal() / 3 == 0). |
|||
map(point -> point.pos.x).toList()); |
|||
//第一列y求平均 |
|||
y = ZSimplAlgo.computeAverage( |
|||
refpoints.stream().filter(point -> point.group.ordinal() % 3 == 0). |
|||
map(point -> point.pos.y).toList()); |
|||
//除了第一列的所有点,减少x,相加,求平均 |
|||
if (p00 != null) { |
|||
dx = ZSimplAlgo.computeAverage( |
|||
refpoints.stream().filter(point -> point.getCol() != 0). |
|||
map(point -> (point.pos.x - p00.pos.x) * 1.0 / point.getCol()).toList()); |
|||
//除了第一排的所有点,减少y,相加,求平均 |
|||
dy = ZSimplAlgo.computeAverage( |
|||
refpoints.stream().filter(point -> point.getRow() != 0). |
|||
map(point -> (point.pos.y - p00.pos.y) * 1.0 / point.getRow()).toList()); |
|||
} |
|||
|
|||
return new LargeBottoleConsumablePosInfo(new Pos3d(x.intValue(), y.intValue(), 0), dx, dy); |
|||
} |
|||
|
|||
@ExtApiFn(name = "保存计算结果", group = "标定大瓶缓液XY坐标", order = 34) |
|||
public void savePosInfo() throws AppException { |
|||
hbotConsumablePosMgr.setLargeBufferGroupPosInfo(computeLittleBottlePosInfo()); |
|||
} |
|||
|
|||
@ExtApiFn(name = "读取所有参考点", group = "标定大瓶缓液XY坐标", order = 35) |
|||
public Object readAllRefPoint() throws AppException { |
|||
return refpoints; |
|||
} |
|||
|
|||
// |
|||
// 标定Z轴 |
|||
// |
|||
public void setZPos(HbotConsumablePosParam posName) throws AppException { |
|||
enableModule(); |
|||
pipetteCtrlModule.zMotorMeasureDistance(); |
|||
hbotConsumablePosMgr.setParam(posName, pipetteCtrlModule.zMotorReadMeasureDistanceResult()); |
|||
disableModule(); |
|||
} |
|||
|
|||
@ExtApiFn(name = "校准.大瓶缓冲液Z轴位置", group = "标定Z轴", order = 104) |
|||
public void setLargeBSSSampleZPos() throws AppException {setZPos(HbotConsumablePosParam.LargeBSSSampleZPos);} |
|||
|
|||
@ExtApiFn(name = "校准.大瓶缓冲液Z轴结束位置", group = "标定Z轴", order = 105) |
|||
public void setLargeBSSSampleEndZPos() throws AppException {setZPos(HbotConsumablePosParam.LargeBSSSampleEndZPos);} |
|||
|
|||
// |
|||
// 校验 |
|||
// |
|||
|
|||
@ExtApiFn(name = "校验大瓶缓冲液坐标", group = "校验", order = 303) |
|||
public void testMoveToLargeBufferPos() throws AppException { |
|||
resetStopFlag(); |
|||
enableModule(); |
|||
for (ConsumableGroup group : ConsumableGroup.values()) { |
|||
hbotControler.moveToLargeBufferPos(group); |
|||
if (checkStopFlag()) |
|||
return; |
|||
} |
|||
} |
|||
|
|||
@ExtApiFn(name = "停止校验", group = "校验", order = 304) |
|||
public void stopTest() throws AppException { |
|||
setStopFlag(); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package a8k.type; |
|||
|
|||
import a8k.type.cfg.Pos3d; |
|||
|
|||
public class LargeBottleConsumableRefPoint { |
|||
public ConsumableGroup group; |
|||
|
|||
public Pos3d pos; |
|||
|
|||
public LargeBottleConsumableRefPoint(ConsumableGroup group, Pos3d pos) { |
|||
this.group = group; |
|||
this.pos = pos; |
|||
} |
|||
|
|||
public Integer getRow() { |
|||
return group.ordinal() / 3; |
|||
} |
|||
|
|||
public Integer getCol() { |
|||
return group.ordinal() % 3; |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
package a8k.type; |
|||
|
|||
import a8k.type.cfg.Pos3d; |
|||
|
|||
public class LargeBottoleConsumablePosInfo { |
|||
public Pos3d pos00; |
|||
public Double dx; |
|||
public Double dy; |
|||
|
|||
public LargeBottoleConsumablePosInfo(Pos3d pos00, Double dx, Double dy) { |
|||
this.pos00 = pos00; |
|||
this.dx = dx; |
|||
this.dy = dy; |
|||
} |
|||
|
|||
public LargeBottoleConsumablePosInfo(){} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue