From ba6fd57f8d10801dc399693fbd3f061f83548c76 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 17 Oct 2024 16:13:42 +0800 Subject: [PATCH] update --- app.db | Bin 225280 -> 225280 bytes src/main/java/a8k/constant/MiniServoConstant.java | 3 +- .../java/a8k/extapi_controler/ExtApiControler.java | 10 +-- .../java/a8k/hardware/A8kModParamInitializer.java | 2 +- .../hardware/type/a8kcanprotocol/A8kPacket.java | 75 +++++++++++++-------- .../hardware/type/a8kcanprotocol/ModuleStatus.java | 3 +- src/main/java/a8k/optalgo/OptAlgo.java | 60 ++++++++--------- .../app/appctrl/AppConsumablesScanService.java | 9 +-- .../action/DO_FINISH_TUBE_PROCESS.java | 3 +- .../action/SEQ1_ENTER_TUBEHOLDER_AND_SCAN.java | 4 +- .../action/SEQ2_SWITCH_TO_THE_NEXT_TUBE.java | 5 +- .../mainflowctrl/action/SEQ3_APPLAY_RESOURCE.java | 9 +-- .../appstate/ProjectProcessContextMgrService.java | 13 ++-- .../service/app/appstate/ResourceMgrService.java | 3 +- .../devicedriver/basectrl/type/MiniServoMId.java | 3 +- .../basectrl/type/PipetteRegIndex.java | 54 ++++++++------- .../devicedriver/basectrl/type/StepMotorMId.java | 3 +- .../HbotLittleBottleConsumableCalibration.java | 74 ++++++++++++-------- .../app/devicedriver/ctrl/HbotControler.java | 12 ++-- .../app/devicedriver/pos/HbotConsumablePosMgr.java | 30 ++++++--- src/main/java/a8k/type/HbotConsumablePosParam.java | 7 ++ .../a8k/utils/state_machine/AppStateMachine.java | 45 ++++++------- 22 files changed, 245 insertions(+), 182 deletions(-) diff --git a/app.db b/app.db index 34d40e216892f3f836536224b40b3fbd35381887..da2892a4277c31c711e4b175368683fc071ac54b 100644 GIT binary patch delta 107 zcmZp8z}xVEcY?IwRR#tIb09VYVr2#fE}@A!#*9}tCLB1=*Cod;Zfwlh5?hj(l#@Ey z@q+MX#|w6hOkJ{@8!t*TF?Gpoo_F~dkT1P?*3}0}00-zMF#rGn delta 107 zcmZp8z}xVEcY?Ga8v_G_IS`uxu`&Y#=Z=Xw#*Azm6Aql`>nvm!H#TN$i7iP?%1NE< zctLox;{`iLrp|)RjTfbvm^$+}&%68!$j{q6>*@m_ox8c_`cZbK&cbHr`|Zy68Miy% IXWBaf0QI9MBme*a diff --git a/src/main/java/a8k/constant/MiniServoConstant.java b/src/main/java/a8k/constant/MiniServoConstant.java index 7b0ff01..5b72181 100644 --- a/src/main/java/a8k/constant/MiniServoConstant.java +++ b/src/main/java/a8k/constant/MiniServoConstant.java @@ -1,6 +1,7 @@ package a8k.constant; import a8k.service.app.devicedriver.basectrl.type.MiniServoMId; +import org.springframework.util.Assert; public class MiniServoConstant { static public final Integer actionOvertime = 5000; @@ -42,7 +43,7 @@ public class MiniServoConstant { case ShakeModTubeScanerClampingSV: return ShakeModTubeScanerClampingSVPos; case ShakeModTubeScanerRotateSV: - assert false; + Assert.isTrue(false, "ShakeModTubeScanerRotateSV not support"); } return 0; } diff --git a/src/main/java/a8k/extapi_controler/ExtApiControler.java b/src/main/java/a8k/extapi_controler/ExtApiControler.java index 7364e26..6c86bad 100644 --- a/src/main/java/a8k/extapi_controler/ExtApiControler.java +++ b/src/main/java/a8k/extapi_controler/ExtApiControler.java @@ -6,6 +6,7 @@ import a8k.type.appret.AppRet; import a8k.utils.*; import org.springframework.stereotype.Controller; +import org.springframework.util.Assert; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.ResponseBody; @@ -81,7 +82,7 @@ public class ExtApiControler { Map newParams = (Map) params.get("params"); var paramService = this.getServiceParamHandlerByServiceKey(serviceKey); - assert paramService != null; + Assert.isTrue(paramService != null,"paramService != null"); var paramServiceClass = paramService.getClass(); for (var param : newParams.entrySet()) { var name = param.getKey(); @@ -246,7 +247,7 @@ public class ExtApiControler { public AppRet serviceActionExecute(@RequestBody Map params) throws Throwable { String serviceKey = (String) params.get("serviceKey"); var service = this.getServiceInstanceByServiceKey(serviceKey); - assert service != null; + Assert.isTrue(service != null, "service not found"); var actionName = (String) params.get("action"); var actionParams = (List) params.get("params"); @@ -279,7 +280,8 @@ public class ExtApiControler { public AppRet serviceActionExecuteByMap(@RequestBody Map params) throws Throwable { String serviceKey = (String) params.get("serviceKey"); var service = this.getServiceInstanceByServiceKey(serviceKey); - assert service != null; + Assert.isTrue(service != null, "service not found"); + var actionName = (String) params.get("action"); var actionParams = (Map) params.get("params"); @@ -314,7 +316,7 @@ public class ExtApiControler { method = methodItem; break; } - assert method != null; + Assert.isTrue(method != null, "method not found"); return this.executeServiceActionAndGetResponse(service, method, actionParamList); } diff --git a/src/main/java/a8k/hardware/A8kModParamInitializer.java b/src/main/java/a8k/hardware/A8kModParamInitializer.java index d3ccd58..a721346 100644 --- a/src/main/java/a8k/hardware/A8kModParamInitializer.java +++ b/src/main/java/a8k/hardware/A8kModParamInitializer.java @@ -70,7 +70,7 @@ public class A8kModParamInitializer { canBus.moduleSetReg(MId.PlatesBoxPusherM, RegIndex.kret_step_motor_io_trigger_append_distance, 3); canBus.moduleSetReg(MId.OptModPullM, RegIndex.kret_step_motor_io_trigger_append_distance, 10); canBus.moduleSetReg(MId.OptModScannerM, RegIndex.kret_step_motor_io_trigger_append_distance, 10); - pipetteCtrlModule.setReg(PipetteRegIndex.kreg_pipette_zm_io_trigger_append_distance, 10); +// pipetteCtrlModule.setReg(PipetteRegIndex.kreg_pipette_zm_io_trigger_append_distance, 0); canBus.moduleSetReg(MId.IncubatorRotateCtrlM, RegIndex.kret_step_motor_io_trigger_append_distance, 10); canBus.moduleSetReg(MId.ShakeModGripperYSV, RegIndex.kreg_mini_servo_limit_torque, 700); diff --git a/src/main/java/a8k/hardware/type/a8kcanprotocol/A8kPacket.java b/src/main/java/a8k/hardware/type/a8kcanprotocol/A8kPacket.java index c9a5b0a..73d11a1 100644 --- a/src/main/java/a8k/hardware/type/a8kcanprotocol/A8kPacket.java +++ b/src/main/java/a8k/hardware/type/a8kcanprotocol/A8kPacket.java @@ -4,16 +4,17 @@ import a8k.hardware.type.regindex.RegIndex; import a8k.utils.ByteArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; public class A8kPacket { /** * typedef struct { * uint16_t packetindex; // 0: - * uint16_t cmdMainId; // 2: - * uint8_t cmdSubId; // 4: - * uint8_t packetType; // 5: - * uint16_t moduleid; // 6: - * uint8_t data[]; // 8: + * uint16_t cmdMainId; // 2: + * uint8_t cmdSubId; // 4: + * uint8_t packetType; // 5: + * uint16_t moduleid; // 6: + * uint8_t data[]; // 8: * } zcr_cmd_header_t; *

* kptv2_cmd = 0, @@ -27,15 +28,16 @@ public class A8kPacket { public static final int PACKET_MIN_LEN = 8; - public static final int PACKET_TYPE_CMD = 0; - public static final int PACKET_TYPE_ACK = 1; + public static final int PACKET_TYPE_CMD = 0; + public static final int PACKET_TYPE_ACK = 1; public static final int PACKET_TYPE_ERROR_ACK = 2; - public static final int PACKET_TYPE_EVENT = 3; + public static final int PACKET_TYPE_EVENT = 3; public static final int CMD_OVERTIME = 2000; public A8kPacket(byte[] cmd) { - raw = new byte[cmd.length]; System.arraycopy(cmd, 0, raw, 0, cmd.length); + raw = new byte[cmd.length]; + System.arraycopy(cmd, 0, raw, 0, cmd.length); } public void setPacketIndex(int packetIndex) { @@ -61,7 +63,10 @@ public class A8kPacket { public byte[] getCmdContent() { if (raw.length < 8) { return new byte[0]; - } byte[] cmdcontent = new byte[raw.length - 8]; System.arraycopy(raw, 8, cmdcontent, 0, raw.length - 8); return cmdcontent; + } + byte[] cmdcontent = new byte[raw.length - 8]; + System.arraycopy(raw, 8, cmdcontent, 0, raw.length - 8); + return cmdcontent; } public int getContentI32(int index) { @@ -73,52 +78,66 @@ public class A8kPacket { } public String toString() { - int packetType = getPacketType(); String ret = ""; + int packetType = getPacketType(); + String ret = ""; CmdId cmdId = CmdId.valueOf(getCmdId()); - assert cmdId != null; + Assert.isTrue(cmdId != null, "cmdId is null"); if (packetType == PACKET_TYPE_CMD) { if (cmdId.equals(CmdId.module_get_reg) || cmdId.equals(CmdId.module_set_reg)) { RegIndex regIndex = RegIndex.valueOf(getContentI32(0)); if (regIndex != null) { - ret = String.format("[CMD ] index:[%d] %s %s %s(%d) %d", getPacketIndex(), cmdId, MId.valueOf(getModuleId()),regIndex, regIndex.index, getContentI32(1)); + ret = String.format("[CMD ] index:[%d] %s %s %s(%d) %d", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), regIndex, regIndex.index, getContentI32(1)); } else { - ret = String.format("[CMD ] index:[%d] %s unkown_index(%d) %d", getPacketIndex(), cmdId, getContentI32(0), getContentI32(1)); + ret = String.format("[CMD ] index:[%d] %s unkown_index(%d) %d", getPacketIndex(), cmdId, + getContentI32(0), getContentI32(1)); } } else { if (cmdId.cmdAttachType == CmdId.ATTACH_IS_INT32) { - ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); + ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); } else { - ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent())); + ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent())); } } } else if (packetType == PACKET_TYPE_ACK) { if (cmdId.receiptAttachType == CmdId.ATTACH_IS_INT32) { - ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, formatInt32ATTACH(getCmdContent())); + ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, + formatInt32ATTACH(getCmdContent())); } else { - ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, ByteArray.toByteString(getCmdContent())); + ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, + ByteArray.toByteString(getCmdContent())); } } else if (packetType == PACKET_TYPE_ERROR_ACK) { ret = String.format("[EACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, (getContentI32(0))); } else if (packetType == PACKET_TYPE_EVENT) { if (cmdId.cmdAttachType == CmdId.ATTACH_IS_INT32) { - ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); + ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); } else { - ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent())); + ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent())); } } else { ret = String.format("Unknown packet type: %d", packetType); - } return ret; + } + return ret; } private String formatInt32ATTACH(byte[] attach) { - StringBuilder ret = new StringBuilder(); for (int i = 0; i < attach.length; i += 4) { + StringBuilder ret = new StringBuilder(); + for (int i = 0; i < attach.length; i += 4) { if (i + 3 >= attach.length) - break; if (i != 0) - ret.append(","); ret.append(String.format("%d", ByteArray.read32bit(attach, i))); - } return ret.toString(); + break; + if (i != 0) + ret.append(","); + ret.append(String.format("%d", ByteArray.read32bit(attach, i))); + } + return ret.toString(); } public Boolean isSupportPacket() { @@ -135,17 +154,17 @@ public class A8kPacket { return true; } - public Boolean isTrace() { if (!isSupportPacket()) { return false; } CmdId cmdid = CmdId.valueOf(getCmdId()); - assert cmdid != null; + Assert.isTrue(cmdid != null, "cmdid is null"); if (CmdId.module_get_reg.equals(cmdid) || CmdId.module_set_reg.equals(cmdid)) { RegIndex regIndex = RegIndex.valueOf(getContentI32(0)); - assert regIndex != null; + Assert.isTrue(regIndex != null, "regIndex != null"); + return regIndex.trace; } else { return cmdid.trace; diff --git a/src/main/java/a8k/hardware/type/a8kcanprotocol/ModuleStatus.java b/src/main/java/a8k/hardware/type/a8kcanprotocol/ModuleStatus.java index 49d894d..57afefa 100644 --- a/src/main/java/a8k/hardware/type/a8kcanprotocol/ModuleStatus.java +++ b/src/main/java/a8k/hardware/type/a8kcanprotocol/ModuleStatus.java @@ -1,4 +1,5 @@ package a8k.hardware.type.a8kcanprotocol; +import org.springframework.util.Assert; public enum ModuleStatus { IDLE(0), // @@ -17,7 +18,7 @@ public enum ModuleStatus { } public static ModuleStatus valueOf(int value) { // 手写的从int到enum的转换函数 - assert (value >= 0 && value < 2); + Assert.isTrue((value >= 0 && value < 2),"(value >= 0 && value < 2)"); return values()[value]; } diff --git a/src/main/java/a8k/optalgo/OptAlgo.java b/src/main/java/a8k/optalgo/OptAlgo.java index 2fb0c92..4f7cef4 100644 --- a/src/main/java/a8k/optalgo/OptAlgo.java +++ b/src/main/java/a8k/optalgo/OptAlgo.java @@ -2,10 +2,11 @@ package a8k.optalgo; import a8k.optalgo.type.LinearResult; import a8k.optalgo.type.OptAlgoResult; +import org.springframework.util.Assert; +import org.springframework.util.Assert; public class OptAlgo { - OptAlgoResult processOptData(Integer expectPeakNum, Float[] data) { return null; } @@ -22,7 +23,7 @@ public class OptAlgo { * @brief * */ - int nOutputLength = nInputLength * nUpSampleRate; + int nOutputLength = nInputLength * nUpSampleRate; Float[] upSamplingRaw = new Float[nOutputLength]; for (int si = 0, di = 0; si < nInputLength - 1; di++) { @@ -41,10 +42,10 @@ public class OptAlgo { } Float[] sub_sampling(Float[] inputRaw, int nSubSampleRate) { - int nSum = 0; - float fAvg = 0; - int subIndex = 0; - int nOutputLength = inputRaw.length / nSubSampleRate; + int nSum = 0; + float fAvg = 0; + int subIndex = 0; + int nOutputLength = inputRaw.length / nSubSampleRate; Float[] subSampledRaw = new Float[nOutputLength]; @@ -65,8 +66,8 @@ public class OptAlgo { } Float[] smooth_windows(Float[] inputRaw, int windows_size) { - Float[] smoothRaw = new Float[inputRaw.length]; - int windows_size_half = (windows_size - 1) / 2; + Float[] smoothRaw = new Float[inputRaw.length]; + int windows_size_half = (windows_size - 1) / 2; for (int index = windows_size_half; index < inputRaw.length - windows_size_half; index++) { float sum = 0; @@ -89,7 +90,7 @@ public class OptAlgo { Float[] median_filtering(Float[] inputRaw, int windows_size) { Float[] medianRaw = new Float[inputRaw.length]; - Float[] windows = new Float[windows_size]; + Float[] windows = new Float[windows_size]; int windows_size_half = (windows_size - 1) / 2; @@ -97,7 +98,7 @@ public class OptAlgo { for (int i = 0; i < windows_size; i++) { windows[i] = inputRaw[index + i - windows_size_half]; } - sort_vector(windows); // 从小到大顺序排序 + sort_vector(windows); // 从小到大顺序排序 medianRaw[index] = windows[windows_size_half + 1]; } @@ -120,8 +121,8 @@ public class OptAlgo { */ float find_avg_line(Float[] inputRaw) { float base_min = 500; - float fsum = 0; - int cnt = 0; + float fsum = 0; + int cnt = 0; int range = inputRaw.length; @@ -144,7 +145,7 @@ public class OptAlgo { Float[] differentiate(Float[] inputRaw) { /** * @brief - * 巴迪泰源码,对原始数据添加了一些微小的值,原因未知 + * 巴迪泰源码,对原始数据添加了一些微小的值,原因未知 */ for (int i = 0; i <= inputRaw.length - 8; i += 8) { inputRaw[i + 1] = inputRaw[i + 1] + 0.001f; @@ -160,8 +161,8 @@ public class OptAlgo { /** * @brief * @Warning: 此处求导和巴迪泰的存在差异, - * 巴迪泰的是当前数值减去下一个数值, - * 而此处是当前数值减去上一个数值 + * 巴迪泰的是当前数值减去下一个数值, + * 而此处是当前数值减去上一个数值 */ Float[] differentiateRaw = new Float[inputRaw.length]; @@ -173,19 +174,19 @@ public class OptAlgo { } Float[] least_square_method_differentiate(Float[] inputRaw, int windows_size) { - assert (windows_size > 0); - assert (windows_size % 2 == 1); - + Assert.isTrue((windows_size > 0), "windows_size > 0"); + Assert.isTrue((windows_size % 2 == 1), "windows_size % 2 == 1"); Float[] differentiateRaw = new Float[inputRaw.length]; - Float[] windowsRaw = new Float[windows_size]; + Float[] windowsRaw = new Float[windows_size]; int windows_size_half = (windows_size - 1) / 2; for (int index = windows_size_half; index < inputRaw.length - windows_size_half; index++) { -// windowsRaw = getwindowspoint(inputRaw, index, windows_size); + // windowsRaw = getwindowspoint(inputRaw, index, windows_size); float intercept = 0; - // linear_least_squares(windowsRaw, windows_size, differentiateRaw[index], intercept); + // linear_least_squares(windowsRaw, windows_size, differentiateRaw[index], + // intercept); } for (int i = 0; i < windows_size_half; i++) { @@ -199,8 +200,8 @@ public class OptAlgo { } Boolean is_maxval_in_windows(Float[] data, int pos, int windows_size) { - assert (windows_size > 0); - assert (windows_size % 2 == 1); + Assert.isTrue((windows_size > 0),"windows_size > 0"); + Assert.isTrue((windows_size % 2 == 1),"windows_size % 2 == 1"); boolean ret = true; int startPos = pos - windows_size / 2; @@ -231,13 +232,12 @@ public class OptAlgo { double xMean = sumX / n; double yMean = sumY / n; - assert (!feq((sumXX - n * xMean * xMean), 0, 0.0001)); + Assert.isTrue((!feq((sumXX - n * xMean * xMean), 0, 0.0001)),"!feq((sumXX - n * xMean * xMean), 0, 0.0001)"); result.slope = (sumXY - n * xMean * yMean) / (sumXX - n * xMean * xMean); result.intercept = yMean - result.slope * xMean; return result; } - // LinearResult linear_least_squares(double[] y, int size) { double[] xpoint = new double[size]; @@ -265,10 +265,9 @@ public class OptAlgo { return linear_least_squares(xpoint, ypoint); } - float get_avg_in_windows(double[] src, int off, int windows) { float sum = 0; - assert (windows % 2 == 1); + Assert.isTrue((windows % 2 == 1),"(windows % 2 == 1)"); for (int i = off - windows / 2; i <= off + windows / 2; i++) { sum += (float) src[i]; } @@ -281,7 +280,7 @@ public class OptAlgo { for (int j = 0; j < src.length - i - 1; j++) { if (src[j] > src[j + 1]) { float temp = src[j]; - src[j] = src[j + 1]; + src[j] = src[j + 1]; src[j + 1] = temp; } } @@ -289,8 +288,8 @@ public class OptAlgo { } double[] getwindowspoint(double[] src, int off, int windows) { - double[] ret = new double[windows]; - int retindex = 0; + double[] ret = new double[windows]; + int retindex = 0; for (int i = off - windows / 2; i <= off + windows / 2; i++) { ret[retindex] = src[i]; retindex++; @@ -298,5 +297,4 @@ public class OptAlgo { return ret; } - } diff --git a/src/main/java/a8k/service/app/appctrl/AppConsumablesScanService.java b/src/main/java/a8k/service/app/appctrl/AppConsumablesScanService.java index 3346f24..a29c678 100644 --- a/src/main/java/a8k/service/app/appctrl/AppConsumablesScanService.java +++ b/src/main/java/a8k/service/app/appctrl/AppConsumablesScanService.java @@ -24,6 +24,7 @@ import jakarta.annotation.Resource; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.util.Date; import java.util.List; @@ -162,7 +163,7 @@ public class AppConsumablesScanService { void LoadingConsumables(Integer ch, ConsumablesScanResult result) { var cState = gstate.getConsumableState(); - assert ch.equals(result.chNum); + Assert.isTrue(ch.equals(result.chNum),"ch.equals(result.chNum)"); if (result.state != ConsumablesErrorType.PASS) { return; } @@ -171,9 +172,9 @@ public class AppConsumablesScanService { A8kReactionFlowType reactionType = appProjMgr.getA8kReactionFlowTypeByProjIndex(result.projIndex); A8kProjectInfo projInfo = appProjMgr.getProjInfoByProjIndex(result.projIndex); - assert a8kIdCardInfo != null; - assert reactionType != null; - assert projInfo != null; + Assert.isTrue(a8kIdCardInfo != null,"a8kIdCardInfo != null"); + Assert.isTrue(reactionType != null,"reactionType != null"); + Assert.isTrue(projInfo != null,"projInfo != null"); cState.reactionPlateGroup[ch] = new ReactionPlateGroup(result.projIndex, a8kIdCardInfo.projName, projInfo.projShortName, result.lotId, a8kIdCardInfo.color, AppConstant.CONSUMABLE_NUM); if (reactionType.equals(A8kReactionFlowType.FlowType1)) { diff --git a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/DO_FINISH_TUBE_PROCESS.java b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/DO_FINISH_TUBE_PROCESS.java index 6dd6d91..be22344 100644 --- a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/DO_FINISH_TUBE_PROCESS.java +++ b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/DO_FINISH_TUBE_PROCESS.java @@ -19,6 +19,7 @@ import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.util.List; @@ -59,7 +60,7 @@ public class DO_FINISH_TUBE_PROCESS extends A8kStepAction { //ProcessErrorBeforeContinue Tube tube = gstate.getCurProcessingTube(); - assert tube != null; + Assert.isTrue(tube != null,"tube != null"); if(tube.getState().equals(TubeState.POST_PROCESSED)){ projectProcessContextMgrService.finishedTubeProcess(); return; diff --git a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ1_ENTER_TUBEHOLDER_AND_SCAN.java b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ1_ENTER_TUBEHOLDER_AND_SCAN.java index f8bcd9a..db1c292 100644 --- a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ1_ENTER_TUBEHOLDER_AND_SCAN.java +++ b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ1_ENTER_TUBEHOLDER_AND_SCAN.java @@ -26,6 +26,7 @@ import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.util.List; @@ -123,7 +124,8 @@ public class SEQ1_ENTER_TUBEHOLDER_AND_SCAN extends A8kStepAction { return null; } - assert setting == null || setting.tubeSettings.length == tubeholder.tubes.length; +// Assert.isTrue(setting == null || setting.tubeSettings.length == tubeholder.tubes.length; + Assert.isTrue(setting == null || setting.tubeSettings.length == tubeholder.tubes.length, "试管架配置信息与试管数量不匹配"); //逐个赋值试管配置信息 updaetGroupId(); diff --git a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ2_SWITCH_TO_THE_NEXT_TUBE.java b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ2_SWITCH_TO_THE_NEXT_TUBE.java index af9feb5..1e77781 100644 --- a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ2_SWITCH_TO_THE_NEXT_TUBE.java +++ b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ2_SWITCH_TO_THE_NEXT_TUBE.java @@ -18,6 +18,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.util.List; @@ -56,7 +57,7 @@ public class SEQ2_SWITCH_TO_THE_NEXT_TUBE extends A8kStepAction { int getNextTubeIndex() { TubeHolder state = gstate.getTubeHolder(); - assert state.tubes.length == 10; + Assert.isTrue(state.tubes.length == 10,"state.tubes.length == 10"); int nextTubeIndex = -1; for (int i = 0; i < 10; i++) { Tube tube = state.tubes[i]; @@ -94,7 +95,7 @@ public class SEQ2_SWITCH_TO_THE_NEXT_TUBE extends A8kStepAction { isEmergencyTube = true; } else { nextTubeIndex = getNextTubeIndex(); - assert nextTubeIndex != -1; + Assert.isTrue(nextTubeIndex != -1,"nextTubeIndex != -1"); nextProcessTube = gstate.getTubeHolder().tubes[nextTubeIndex]; } //设置状态 diff --git a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ3_APPLAY_RESOURCE.java b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ3_APPLAY_RESOURCE.java index 1cf1297..770d650 100644 --- a/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ3_APPLAY_RESOURCE.java +++ b/src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ3_APPLAY_RESOURCE.java @@ -18,6 +18,7 @@ import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.util.List; @@ -65,7 +66,7 @@ public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { projectProcessContextMgrService.startPrepareRecourseOK(); - assert tube != null; + Assert.isTrue(tube != null,"tube != null"); boolean applyConsumable = projectProcessContextMgrService.takeResourceConsumable(tube); boolean applyTips = applyConsumable && projectProcessContextMgrService.takeResourceTip(tube); boolean applyIncubatorPos = applyTips && projectProcessContextMgrService.takeResourceIncubatorPos(tube); @@ -73,7 +74,7 @@ public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { if (!applyConsumable) { for (Integer projIndex : tube.getProjIndex()) { ProjProcessContext cxt = projectProcessContextMgrService.getProjProcessContext(tube.getSampleId(), projIndex); - assert cxt != null; + Assert.isTrue(cxt != null,"cxt != null"); if (cxt.consumable == null) { logger.error("申请耗材失败,sampleId == {} projindex == {}", cxt.sampleId, projIndex); projectProcessContextMgrService.bakAllTubeAResource(tube); @@ -87,11 +88,11 @@ public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { projectProcessContextMgrService.bakAllTubeAResource(tube); throw ebuilder.buildAppException(A8kEcode.APPE_TIP_NOT_ENOUGH); } - assert applyIncubatorPos; + Assert.isTrue(applyIncubatorPos,"applyIncubatorPos"); logger.info("Tube:{} 申请资源成功", tube.getSampleId()); boolean assProjInfoSuc = projectProcessContextMgrService.prepareProjInfoData(tube); - assert assProjInfoSuc; + Assert.isTrue(assProjInfoSuc,"assProjInfoSuc"); //创建项目处理上下文 diff --git a/src/main/java/a8k/service/app/appstate/ProjectProcessContextMgrService.java b/src/main/java/a8k/service/app/appstate/ProjectProcessContextMgrService.java index 44d82ce..7ca9994 100644 --- a/src/main/java/a8k/service/app/appstate/ProjectProcessContextMgrService.java +++ b/src/main/java/a8k/service/app/appstate/ProjectProcessContextMgrService.java @@ -14,6 +14,7 @@ import a8k.utils.ProjBriefInfo; import jakarta.annotation.Resource; import org.slf4j.Logger; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -230,7 +231,7 @@ public class ProjectProcessContextMgrService { synchronized public Boolean takeResourceConsumable(Tube tube) { for (Integer projIndex : tube.getProjIndex()) { ProjProcessContext cxt = getProjProcessContext(tube.getSampleId(), projIndex); - assert cxt != null; + Assert.isTrue(cxt != null,"cxt != null"); cxt.consumable = consumablesMgrService.takeConsumables(projIndex); if (cxt.consumable == null) { return false; @@ -244,7 +245,7 @@ public class ProjectProcessContextMgrService { var subtanks = incubationState.subtanks; for (Integer projIndex : tube.getProjIndex()) { ProjProcessContext cxt = getProjProcessContext(tube.getSampleId(), projIndex); - assert cxt != null; + Assert.isTrue(cxt != null,"cxt != null"); cxt.incubatorPos = incubationPlateStateMgrService.takeOneIncubationIDLEPos(); if (cxt.incubatorPos == null) { return false; @@ -258,7 +259,7 @@ public class ProjectProcessContextMgrService { synchronized public Boolean takeResourceTip(Tube tube) { for (Integer projIndex : tube.getProjIndex()) { ProjProcessContext cxt = getProjProcessContext(tube.getSampleId(), projIndex); - assert cxt != null; + Assert.isTrue(cxt != null,"cxt != null"); A8kReactionFlowType flow = appProjInfoMgrService.getA8kReactionFlowTypeByProjIndex(projIndex); cxt.tipPos = consumablesMgrService.takeTip(flow); if (cxt.tipPos == null) { @@ -271,7 +272,7 @@ public class ProjectProcessContextMgrService { synchronized public void bakAllTubeAResource(Tube tube) { for (Integer projIndex : tube.getProjIndex()) { ProjProcessContext cxt = getProjProcessContext(tube.getSampleId(), projIndex); - assert cxt != null; + Assert.isTrue(cxt != null,"cxt != null"); if (cxt.tipPos != null) { consumablesMgrService.backTipList(cxt.tipPos); @@ -291,7 +292,7 @@ public class ProjectProcessContextMgrService { synchronized public Boolean prepareProjInfoData(Tube tube) { for (Integer projIndex : tube.getProjIndex()) { ProjProcessContext cxt = getProjProcessContext(tube.getSampleId(), projIndex); - assert cxt != null; + Assert.isTrue(cxt != null,"cxt != null"); cxt.projCfg = appProjInfoMgrService.getProjCfgByProjIndex(cxt.consumable.lotId); if (cxt.projCfg == null) { return false; @@ -368,7 +369,7 @@ public class ProjectProcessContextMgrService { synchronized public void finishProcessProj(String sampleId, Integer projIndex) { ProjProcessContext cxt = getProjProcessContext(sampleId, projIndex); - assert cxt != null; + Assert.isTrue(cxt != null,"cxt != null"); cxt.state = ProjProcessState.FINISH; } diff --git a/src/main/java/a8k/service/app/appstate/ResourceMgrService.java b/src/main/java/a8k/service/app/appstate/ResourceMgrService.java index f9a2684..4faab74 100644 --- a/src/main/java/a8k/service/app/appstate/ResourceMgrService.java +++ b/src/main/java/a8k/service/app/appstate/ResourceMgrService.java @@ -6,6 +6,7 @@ import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.util.List; import java.util.Vector; @@ -86,7 +87,7 @@ public class ResourceMgrService { //租用所有资源 for (A8kPublicResourceType type : types) { Boolean suc = applyForResource(applyer, type); - assert suc; + Assert.isTrue(suc,"applyForResource(applyer, type) fail"); } return true; diff --git a/src/main/java/a8k/service/app/devicedriver/basectrl/type/MiniServoMId.java b/src/main/java/a8k/service/app/devicedriver/basectrl/type/MiniServoMId.java index 12d9984..c1fd74f 100644 --- a/src/main/java/a8k/service/app/devicedriver/basectrl/type/MiniServoMId.java +++ b/src/main/java/a8k/service/app/devicedriver/basectrl/type/MiniServoMId.java @@ -1,6 +1,7 @@ package a8k.service.app.devicedriver.basectrl.type; import a8k.hardware.type.a8kcanprotocol.MId; +import org.springframework.util.Assert; public enum MiniServoMId { ShakeModGripperYSV(MId.ShakeModGripperYSV),// @@ -12,7 +13,7 @@ public enum MiniServoMId { final public MId mid; MiniServoMId(MId mid) { - assert this.name().equals(mid.name()); + Assert.isTrue(this.name().equals(mid.name()),"MiniServoMid Init fail"); this.mid = mid; } diff --git a/src/main/java/a8k/service/app/devicedriver/basectrl/type/PipetteRegIndex.java b/src/main/java/a8k/service/app/devicedriver/basectrl/type/PipetteRegIndex.java index d04e782..3387d4d 100644 --- a/src/main/java/a8k/service/app/devicedriver/basectrl/type/PipetteRegIndex.java +++ b/src/main/java/a8k/service/app/devicedriver/basectrl/type/PipetteRegIndex.java @@ -1,6 +1,8 @@ package a8k.service.app.devicedriver.basectrl.type; import a8k.hardware.type.regindex.RegIndex; +import org.springframework.util.Assert; +import org.springframework.util.Assert; public enum PipetteRegIndex { kreg_module_version(RegIndex.kreg_module_version), // 模块版本 @@ -29,37 +31,37 @@ public enum PipetteRegIndex { kreg_pipette_zm_is_enable(RegIndex.kreg_pipette_zm_is_enable), kreg_pipette_zm_dpos(RegIndex.kreg_pipette_zm_dpos), - kreg_pipette_zm_shaft(RegIndex.kreg_pipette_zm_shift), - kreg_pipette_zm_one_circle_pulse(RegIndex.kreg_pipette_zm_shaft), - kreg_pipette_zm_one_circle_pulse_denominator(RegIndex.kreg_pipette_zm_one_circle_pulse), - kreg_pipette_zm_default_velocity(RegIndex.kreg_pipette_zm_one_circle_pulse_denominator), - kreg_pipette_zm_ihold(RegIndex.kreg_pipette_zm_default_velocity), - kreg_pipette_zm_irun(RegIndex.kreg_pipette_zm_ihold), - kreg_pipette_zm_iholddelay(RegIndex.kreg_pipette_zm_irun), - kreg_pipette_zm_iglobalscaler(RegIndex.kreg_pipette_zm_iholddelay), - kreg_pipette_zm_run_to_zero_speed(RegIndex.kreg_pipette_zm_iglobalscaler), - kreg_pipette_zm_look_zero_edge_speed(RegIndex.kreg_pipette_zm_run_to_zero_speed), - kreg_pipette_zm_max_d(RegIndex.kreg_pipette_zm_look_zero_edge_speed), - kreg_pipette_zm_min_d(RegIndex.kreg_pipette_zm_max_d), + kreg_pipette_zm_shaft(RegIndex.kreg_pipette_zm_shaft), + kreg_pipette_zm_one_circle_pulse(RegIndex.kreg_pipette_zm_one_circle_pulse), + kreg_pipette_zm_one_circle_pulse_denominator(RegIndex.kreg_pipette_zm_one_circle_pulse_denominator), + kreg_pipette_zm_default_velocity(RegIndex.kreg_pipette_zm_default_velocity), + kreg_pipette_zm_ihold(RegIndex.kreg_pipette_zm_ihold), + kreg_pipette_zm_irun(RegIndex.kreg_pipette_zm_irun), + kreg_pipette_zm_iholddelay(RegIndex.kreg_pipette_zm_iholddelay), + kreg_pipette_zm_iglobalscaler(RegIndex.kreg_pipette_zm_iglobalscaler), + kreg_pipette_zm_run_to_zero_speed(RegIndex.kreg_pipette_zm_run_to_zero_speed), + kreg_pipette_zm_look_zero_edge_speed(RegIndex.kreg_pipette_zm_look_zero_edge_speed), + kreg_pipette_zm_max_d(RegIndex.kreg_pipette_zm_max_d), + kreg_pipette_zm_min_d(RegIndex.kreg_pipette_zm_min_d), - kreg_pipette_zm_vstart(RegIndex.kreg_pipette_zm_min_d), - kreg_pipette_zm_a1(RegIndex.kreg_pipette_zm_in_debug_mode), - kreg_pipette_zm_amax(RegIndex.kreg_pipette_zm_vstart), - kreg_pipette_zm_v1(RegIndex.kreg_pipette_zm_a1), - kreg_pipette_zm_dmax(RegIndex.kreg_pipette_zm_amax), - kreg_pipette_zm_d1(RegIndex.kreg_pipette_zm_v1), - kreg_pipette_zm_vstop(RegIndex.kreg_pipette_zm_dmax), - kreg_pipette_zm_tzerowait(RegIndex.kreg_pipette_zm_d1), - kreg_pipette_zm_enc_resolution(RegIndex.kreg_pipette_zm_vstop), - kreg_pipette_zm_enable_enc(RegIndex.kreg_pipette_zm_tzerowait), - kreg_pipette_zm_dzero(RegIndex.kreg_pipette_zm_enc_resolution), - kreg_pipette_zm_pos_devi_tolerance(RegIndex.kreg_pipette_zm_enable_enc), - kreg_pipette_zm_io_trigger_append_distance(RegIndex.kreg_pipette_zm_dzero); + kreg_pipette_zm_vstart(RegIndex.kreg_pipette_zm_vstart), + kreg_pipette_zm_a1(RegIndex.kreg_pipette_zm_a1), + kreg_pipette_zm_amax(RegIndex.kreg_pipette_zm_amax), + kreg_pipette_zm_v1(RegIndex.kreg_pipette_zm_v1), + kreg_pipette_zm_dmax(RegIndex.kreg_pipette_zm_dmax), + kreg_pipette_zm_d1(RegIndex.kreg_pipette_zm_d1), + kreg_pipette_zm_vstop(RegIndex.kreg_pipette_zm_vstop), + kreg_pipette_zm_tzerowait(RegIndex.kreg_pipette_zm_tzerowait), + kreg_pipette_zm_enc_resolution(RegIndex.kreg_pipette_zm_enc_resolution), + kreg_pipette_zm_enable_enc(RegIndex.kreg_pipette_zm_enable_enc), + kreg_pipette_zm_dzero(RegIndex.kreg_pipette_zm_dzero), + kreg_pipette_zm_pos_devi_tolerance(RegIndex.kreg_pipette_zm_pos_devi_tolerance), + kreg_pipette_zm_io_trigger_append_distance(RegIndex.kreg_pipette_zm_io_trigger_append_distance); public final RegIndex regIndex; PipetteRegIndex(RegIndex regIndex) { - assert this.name().equals(regIndex.name()); + Assert.isTrue(this.name().equals(regIndex.name()), "PipetteRegIndex name must be equal to RegIndex name"); this.regIndex = regIndex; } diff --git a/src/main/java/a8k/service/app/devicedriver/basectrl/type/StepMotorMId.java b/src/main/java/a8k/service/app/devicedriver/basectrl/type/StepMotorMId.java index 9c86ded..0676737 100644 --- a/src/main/java/a8k/service/app/devicedriver/basectrl/type/StepMotorMId.java +++ b/src/main/java/a8k/service/app/devicedriver/basectrl/type/StepMotorMId.java @@ -1,6 +1,7 @@ package a8k.service.app.devicedriver.basectrl.type; import a8k.hardware.type.a8kcanprotocol.MId; +import org.springframework.util.Assert; public enum StepMotorMId { PlatesBoxYM(MId.PlatesBoxYM),// @@ -18,7 +19,7 @@ public enum StepMotorMId { final public MId mid; StepMotorMId(MId mid) { - assert this.name().equals(mid.name()); + Assert.isTrue(this.name().equals(mid.name()),"StepMotorMId init fail"); this.mid = mid; } } diff --git a/src/main/java/a8k/service/app/devicedriver/calibration/HbotLittleBottleConsumableCalibration.java b/src/main/java/a8k/service/app/devicedriver/calibration/HbotLittleBottleConsumableCalibration.java index 2a77595..cf52195 100644 --- a/src/main/java/a8k/service/app/devicedriver/calibration/HbotLittleBottleConsumableCalibration.java +++ b/src/main/java/a8k/service/app/devicedriver/calibration/HbotLittleBottleConsumableCalibration.java @@ -15,7 +15,6 @@ import a8k.type.cfg.Pos3d; import a8k.type.exception.AppException; import a8k.utils.ZJsonHelper; import a8k.utils.ZSimplAlgo; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.annotation.Resource; import org.aspectj.lang.annotation.Aspect; @@ -61,8 +60,8 @@ public class HbotLittleBottleConsumableCalibration { @ExtApiFn(name = "获取坐标", group = "基础", order = 1) - public Object getPoss(LittleBottleConsumableType type) throws AppException { - return hbotConsumablePosMgr.getLittleBottleConsumablePosInfo(type); + public Object getPoss() throws AppException { + return hbotConsumablePosMgr.getParams(); } @@ -90,20 +89,18 @@ public class HbotLittleBottleConsumableCalibration { LittleBottleConsumableType littleBottleConsumableType = LittleBottleConsumableType.BufferSolution; List littleBottleConsumableRefPoint = new java.util.ArrayList<>(); LittleBottleConsumablePosInfo littleBottleConsumablePosInfo; - List zpos = new java.util.ArrayList<>(); - @ExtApiFn(name = "开始标定小瓶坐标", group = "标定小瓶坐标", order = 30) + @ExtApiFn(name = "开始标定小瓶坐标", group = "标定小瓶XY坐标", order = 30) public void startCalibrateLittleBottleGroup(LittleBottleConsumableType type) throws AppException { littleBottleConsumablePosInfo = null; littleBottleConsumableRefPoint = new java.util.ArrayList<>(); littleBottleConsumableType = type; - zpos.clear(); moveToZero(); disableModule(); } - @ExtApiFn(name = "添加小瓶参考点", group = "标定小瓶坐标", order = 31) + @ExtApiFn(name = "添加小瓶参考点", group = "标定小瓶XY坐标", order = 31) public Object addLittleBottleGroupRefPoint(ConsumableGroup group, Integer off0To24) throws AppException { enableModule(); Pos2d xypos = hbotModule.readPos(); @@ -118,17 +115,8 @@ public class HbotLittleBottleConsumableCalibration { return node; } - @ExtApiFn(name = "添加Z轴坐标点", group = "标定小瓶坐标", order = 32) - public Object addLittleBottleGroupRefPoint() throws AppException { - enableModule(); - pipetteCtrlModule.zMotorMeasureDistance(); - Integer z = pipetteCtrlModule.zMotorReadMeasureDistanceResult(); - zpos.add(z); - disableModule(); - return z; - } - @ExtApiFn(name = "计算坐标", group = "标定小瓶坐标", order = 32) + @ExtApiFn(name = "计算坐标", group = "标定小瓶XY坐标", order = 32) public LittleBottleConsumablePosInfo computeLittleBottlePosInfo() { //计算y0,所有group==0,1,2,同时0<=off<5的点,求平均 Double[] y = new Double[2]; @@ -137,7 +125,7 @@ public class HbotLittleBottleConsumableCalibration { Double[] dys = new Double[6]; Double dx; Double dy; - double z = 0.0; + // double z = 0.0; LittleBottleConsumableRefPoint[] gx_00 = new LittleBottleConsumableRefPoint[6]; @@ -173,7 +161,7 @@ public class HbotLittleBottleConsumableCalibration { littleBottleConsumableRefPoint.stream().filter(point -> point.group.ordinal() % 3 == 2 && point.index % 5 == 0). map(point -> point.pos.x).toList() ); - z = ZSimplAlgo.computeAverage(zpos); + // z = ZSimplAlgo.computeAverage(zpos); //计算d0x,所有 非0,5,10,15,20的点,到x0的距离/偏移差值,求平均 for (int i = 0; i < 6; i++) { int finalI = i; @@ -201,29 +189,55 @@ public class HbotLittleBottleConsumableCalibration { } dy = ZSimplAlgo.computeAverage(dys); + var oldposInfo = hbotConsumablePosMgr.getLittleBottleConsumablePosInfo(littleBottleConsumableType); + littleBottleConsumablePosInfo = new LittleBottleConsumablePosInfo(); - littleBottleConsumablePosInfo.g0_000 = new Pos3d(x[0].intValue(), y[0].intValue(), (int) z); - littleBottleConsumablePosInfo.g1_000 = new Pos3d(x[1].intValue(), y[0].intValue(), (int) z); - littleBottleConsumablePosInfo.g2_000 = new Pos3d(x[2].intValue(), y[0].intValue(), (int) z); - littleBottleConsumablePosInfo.g3_000 = new Pos3d(x[0].intValue(), y[1].intValue(), (int) z); - littleBottleConsumablePosInfo.g4_000 = new Pos3d(x[1].intValue(), y[1].intValue(), (int) z); - littleBottleConsumablePosInfo.g5_000 = new Pos3d(x[2].intValue(), y[1].intValue(), (int) z); + littleBottleConsumablePosInfo.g0_000 = new Pos3d(x[0].intValue(), y[0].intValue(), oldposInfo.g0_000.z); + littleBottleConsumablePosInfo.g1_000 = new Pos3d(x[1].intValue(), y[0].intValue(), oldposInfo.g1_000.z); + littleBottleConsumablePosInfo.g2_000 = new Pos3d(x[2].intValue(), y[0].intValue(), oldposInfo.g2_000.z); + littleBottleConsumablePosInfo.g3_000 = new Pos3d(x[0].intValue(), y[1].intValue(), oldposInfo.g3_000.z); + littleBottleConsumablePosInfo.g4_000 = new Pos3d(x[1].intValue(), y[1].intValue(), oldposInfo.g4_000.z); + littleBottleConsumablePosInfo.g5_000 = new Pos3d(x[2].intValue(), y[1].intValue(), oldposInfo.g5_000.z); littleBottleConsumablePosInfo.dx = dx; littleBottleConsumablePosInfo.dy = dy; return littleBottleConsumablePosInfo; } - @ExtApiFn(name = "保存计算结果", group = "标定小瓶坐标", order = 33) + @ExtApiFn(name = "保存计算结果", group = "标定小瓶XY坐标", order = 33) public void saveLittleBottleConsumablePosInfo() throws AppException { hbotConsumablePosMgr.setLittleBottleConsumablePosInfo(littleBottleConsumableType, littleBottleConsumablePosInfo); } - @ExtApiFn(name = "读取所有参考点", group = "标定小瓶坐标", order = 33) + @ExtApiFn(name = "读取所有参考点", group = "标定小瓶XY坐标", order = 33) public Object readAllRefPoint() throws AppException { return littleBottleConsumableRefPoint; } // + // 标定Z轴 + // + + + @ExtApiFn(name = "校准.小瓶穿孔Z轴位置", group = "标定Z轴", order = 101) + public void setLittleBSPierceZPos() throws AppException { + pipetteCtrlModule.zMotorMeasureDistance(); + hbotConsumablePosMgr.setParam(HbotConsumablePosParam.LittleBSPierceZPos, pipetteCtrlModule.zMotorReadMeasureDistanceResult()); + } + + @ExtApiFn(name = "校准.小瓶取样Z轴位置", group = "标定Z轴", order = 102) + public void setLittleBSSampleZPos() throws AppException { + pipetteCtrlModule.zMotorMeasureDistance(); + hbotConsumablePosMgr.setParam(HbotConsumablePosParam.LittleBSSampleZPos, pipetteCtrlModule.zMotorReadMeasureDistanceResult()); + } + + @ExtApiFn(name = "校准.探测物质取样Z轴位置", group = "标定Z轴", order = 103) + public void setProbeSubstanceSampleZPos() throws AppException { + pipetteCtrlModule.zMotorMeasureDistance(); + hbotConsumablePosMgr.setParam(HbotConsumablePosParam.ProbeSubstanceSampleZPos, pipetteCtrlModule.zMotorReadMeasureDistanceResult()); + } + + + // // 校验 // @@ -232,19 +246,21 @@ public class HbotLittleBottleConsumableCalibration { resetStopFlag(); enableModule(); for (int i = 0; i < AppConstant.CONSUMABLE_NUM; i++) { - hbotControler.moveToLittleBufferPos(group, i); + hbotControler.moveToLittleBufferPiercePos(group, i); pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); if (checkStopFlag()) return; } } + //TODO:添加取样校验 + @ExtApiFn(name = "校验探测物质坐标", group = "校验", order = 302) public void testMoveToProbeSubstancePos(ConsumableGroup group) throws AppException { resetStopFlag(); enableModule(); for (int i = 0; i < AppConstant.CONSUMABLE_NUM; i++) { - hbotControler.moveToProbeSubstancePos(group, i); + hbotControler.moveToProbeSubstanceSamplePos(group, i); pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); if (checkStopFlag()) return; diff --git a/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControler.java b/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControler.java index 5f65209..8b80915 100644 --- a/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControler.java +++ b/src/main/java/a8k/service/app/devicedriver/ctrl/HbotControler.java @@ -3,7 +3,6 @@ package a8k.service.app.devicedriver.ctrl; import a8k.constant.AppConstant; import a8k.hardware.type.a8kcanprotocol.A8kEcode; import a8k.service.app.devicedriver.basectrl.HbotBaseMoveControler; -import a8k.service.app.devicedriver.basectrl.HbotModule; import a8k.service.app.devicedriver.basectrl.PipetteCtrlModule; import a8k.service.app.devicedriver.pos.HbotConsumablePosMgr; import a8k.service.app.devicedriver.pos.HbotFixPosMgr; @@ -13,7 +12,6 @@ import a8k.type.HbotSamplePos; import a8k.type.cfg.Pos3d; import a8k.type.exception.AppException; import a8k.type.type.TipGroup; -import a8k.utils.HbotScanerPosComputer; import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,16 +90,16 @@ public class HbotControler { hbotBaseMoveControler.hbotMoveTo(hbotSamplePosMgr.getSamplePos(pos)); } - public void moveToLittleBufferPos(ConsumableGroup group, Integer off) throws AppException { - hbotBaseMoveControler.hbotMoveTo(hbotConsumablePosMgr.getLittleBufferPos(group, off)); + public void moveToLittleBufferPiercePos(ConsumableGroup group, Integer off) throws AppException { + hbotBaseMoveControler.hbotMoveTo(hbotConsumablePosMgr.getLittleBufferPiercePos(group, off)); } - public void moveToProbeSubstancePos(ConsumableGroup group, Integer off) throws AppException { - hbotBaseMoveControler.hbotMoveTo(hbotConsumablePosMgr.getProbeSubstancePos(group, off)); + public void moveToProbeSubstanceSamplePos(ConsumableGroup group, Integer off) throws AppException { + hbotBaseMoveControler.hbotMoveTo(hbotConsumablePosMgr.getProbeSubstanceSamplePos(group, off)); } public void moveToLargeBufferPos(ConsumableGroup group) throws AppException { - hbotBaseMoveControler.hbotMoveTo(hbotConsumablePosMgr.getLargeBufferPos(group)); + hbotBaseMoveControler.hbotMoveTo(hbotConsumablePosMgr.getLargeBufferSamplePos(group)); } diff --git a/src/main/java/a8k/service/app/devicedriver/pos/HbotConsumablePosMgr.java b/src/main/java/a8k/service/app/devicedriver/pos/HbotConsumablePosMgr.java index f935179..15aa554 100644 --- a/src/main/java/a8k/service/app/devicedriver/pos/HbotConsumablePosMgr.java +++ b/src/main/java/a8k/service/app/devicedriver/pos/HbotConsumablePosMgr.java @@ -18,6 +18,7 @@ import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import org.springframework.util.Assert; import java.util.List; @@ -126,7 +127,7 @@ public class HbotConsumablePosMgr { tipDyPos = HbotConsumablePosParam.TipGroup2_SpaceingY; } - assert tip000Pos != null; + Assert.isTrue(tip000Pos != null,"tip000Pos != null"); posReader.updatePos(tip000Pos, tip000); posReader.updatePos(tipDxPos, dx); @@ -226,9 +227,9 @@ public class HbotConsumablePosMgr { dx = posReader.getPos(HbotConsumablePosParam.TipGroup2_SpaceingX, Double.class); dy = posReader.getPos(HbotConsumablePosParam.TipGroup2_SpaceingY, Double.class); } - assert tip000 != null; - assert dx != null; - assert dy != null; + Assert.isTrue(tip000 != null,"tip000 != null"); + Assert.isTrue(dx != null,"dx != null"); + Assert.isTrue(dy != null,"dy != null"); int xoff = tipoff % 12; int yoff = tipoff / 12; @@ -241,7 +242,7 @@ public class HbotConsumablePosMgr { } - public Pos3d getLittleBufferPos(ConsumableGroup group, Integer off) { + public Pos3d getLittleBufferPiercePos(ConsumableGroup group, Integer off) { HbotConsumablePosParam param = HbotConsumablePosParam.valueOf(HbotConsumablePosParam.LittleBufferGroup0_000Pos.ordinal() + group.ordinal()); Pos3d pos00 = posReader.getPos(param, Pos3d.class); @@ -254,11 +255,19 @@ public class HbotConsumablePosMgr { double x = pos00.x + xoff * dx; double y = pos00.y + yoff * dy; + Double z = posReader.getPos(HbotConsumablePosParam.LittleBSPierceZPos, Double.class); - return new Pos3d((int) x, (int) y, (int) pos00.z); + + return new Pos3d((int) x, (int) y, z.intValue()); + } + + public Pos3d getLittleBufferSamplePos(ConsumableGroup group, Integer off) { + Pos3d pos = getLittleBufferPiercePos(group, off); + pos.z = posReader.getPos(HbotConsumablePosParam.LittleBSSampleZPos, Double.class).intValue(); + return pos; } - public Pos3d getProbeSubstancePos(ConsumableGroup group, Integer off) { + public Pos3d getProbeSubstanceSamplePos(ConsumableGroup group, Integer off) { HbotConsumablePosParam param = HbotConsumablePosParam.valueOf(HbotConsumablePosParam.ProbeSubstanceGroup0_000Pos.ordinal() + group.ordinal()); Pos3d pos00 = posReader.getPos(param, Pos3d.class); @@ -270,11 +279,12 @@ public class HbotConsumablePosMgr { double x = pos00.x + xoff * dx; double y = pos00.y + yoff * dy; + double z = posReader.getPos(HbotConsumablePosParam.ProbeSubstanceSampleZPos, Double.class); - return new Pos3d((int) x, (int) y, (int) pos00.z); + return new Pos3d((int) x, (int) y, (int) z); } - public Pos3d getLargeBufferPos(ConsumableGroup group) { + public Pos3d getLargeBufferSamplePos(ConsumableGroup group) { Pos3d pos00 = posReader.getPos(HbotConsumablePosParam.LargeBuffer_0Pos.name(), Pos3d.class); Double dx = posReader.getPos(HbotConsumablePosParam.LargeBuffer_DX, Double.class); Double dy = posReader.getPos(HbotConsumablePosParam.LargeBuffer_DY, Double.class); @@ -285,7 +295,7 @@ public class HbotConsumablePosMgr { double x = pos00.x + xoff * dx; double y = pos00.y + yoff * dy; - double z = pos00.z; + double z = posReader.getPos(HbotConsumablePosParam.LargeBSSSampleZPos, Double.class); return new Pos3d((int) x, (int) y, (int) z); } } diff --git a/src/main/java/a8k/type/HbotConsumablePosParam.java b/src/main/java/a8k/type/HbotConsumablePosParam.java index acdd42a..7368d39 100644 --- a/src/main/java/a8k/type/HbotConsumablePosParam.java +++ b/src/main/java/a8k/type/HbotConsumablePosParam.java @@ -35,6 +35,13 @@ public enum HbotConsumablePosParam { LargeBuffer_0Pos("大瓶缓冲液的第1个位置"), LargeBuffer_DX("大瓶缓冲液的X间距"), LargeBuffer_DY("大瓶缓冲液的Y间距"), + + LittleBSPierceZPos("小瓶缓冲液刺破Z坐标"), + LittleBSSampleZPos("小瓶缓冲液刺破取样Z坐标"), + ProbeSubstanceSampleZPos("探测物质取样Z坐标"), + LargeBSSSampleZPos("大瓶缓冲液取样Z坐标"), + + ; final public String chName; diff --git a/src/main/java/a8k/utils/state_machine/AppStateMachine.java b/src/main/java/a8k/utils/state_machine/AppStateMachine.java index 5362436..c1f902d 100644 --- a/src/main/java/a8k/utils/state_machine/AppStateMachine.java +++ b/src/main/java/a8k/utils/state_machine/AppStateMachine.java @@ -12,6 +12,7 @@ import a8k.utils.state_machine.type.event.UsrStopEvent; import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; import java.util.List; import java.util.Vector; @@ -33,32 +34,32 @@ public class AppStateMachine { static Logger logger = LoggerFactory.getLogger(AppStateMachine.class); /* - * pause - * continue + * pause + * continue * - * getState + * getState * */ List> stateProcessers = new Vector<>(); - List receiptQueue = new Vector<>(); - Thread workThread; - String name; + List receiptQueue = new Vector<>(); + Thread workThread; + String name; AppStateProcesser idleState; AppStateProcesser currentState; Boolean pauseFlag = false; - Boolean selfStopFlagPending = false; + Boolean selfStopFlagPending = false; Boolean selfPauseFlagPending = false; @Resource AppEventBusService ebus; - AppStateProcesser getStateProcesser(T state) { - return stateProcessers.stream().filter(stateProcesser -> stateProcesser.state.equals(state)).findFirst().orElse(null); + return stateProcessers.stream().filter(stateProcesser -> stateProcesser.state.equals(state)).findFirst() + .orElse(null); } synchronized AppStateProcesser getCurrentStateProcesser() { @@ -69,7 +70,6 @@ public class AppStateMachine { currentState = stateProcesser; } - void doWork() { if (receiptQueue.isEmpty()) { if (!pauseFlag) @@ -81,8 +81,8 @@ public class AppStateMachine { receiptQueue.remove(0); if (event instanceof StateChangeEvent) { pauseFlag = false; - StateChangeEvent stateChangeEvent = (StateChangeEvent) event; - AppStateProcesser nextState = getStateProcesser(stateChangeEvent.changeTo); + StateChangeEvent stateChangeEvent = (StateChangeEvent) event; + AppStateProcesser nextState = getStateProcesser(stateChangeEvent.changeTo); setCurrentStateProcesser(nextState); processEvent(new StateEnterEvent()); } else if (event instanceof UsrContinueEvent) { @@ -112,7 +112,8 @@ public class AppStateMachine { void processEvent(AppStateMachineEvent event) { if (event instanceof PeriodicSchedulingEvent) { } else { - logger.info("{} {} processEvent: {}", name, currentState.state.getClass().getSimpleName(), event.getClass().getSimpleName()); + logger.info("{} {} processEvent: {}", name, currentState.state.getClass().getSimpleName(), + event.getClass().getSimpleName()); } try { currentState.onStateProcess.processer(event); @@ -129,13 +130,15 @@ public class AppStateMachine { if (selfPauseFlagPending) { selfPauseFlagPending = false; - pauseFlag = true; + pauseFlag = true; } } - /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /* + * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * PUBLIC - *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + */ public AppStateMachine(String name) { this.name = name; @@ -147,19 +150,19 @@ public class AppStateMachine { public void startSchedule() { currentState = idleState; - assert currentState != null; + Assert.isTrue(currentState != null, "currentState != null"); workThread = new Thread(this::doWorkLoop); workThread.start(); } public void regIdleStateProcesser(AppStateProcesser stateProcesser) { - assert stateProcesser != null; + Assert.isTrue(stateProcesser != null, "stateProcesser != null"); idleState = stateProcesser; stateProcessers.add(stateProcesser); } public void regStateProcesser(AppStateProcesser stateProcesser) { - assert stateProcesser != null; + Assert.isTrue(stateProcesser != null, "stateProcesser != null"); stateProcessers.add(stateProcesser); } @@ -171,7 +174,6 @@ public class AppStateMachine { regIdleStateProcesser(new AppStateProcesser<>(state, onStateProcess)); } - public void usrPause() { pushEvent(new UsrPauseEvent()); } @@ -188,7 +190,6 @@ public class AppStateMachine { pushEvent(new UsrStopEvent()); } - // public void selfPause() { selfPauseFlagPending = true; @@ -198,7 +199,6 @@ public class AppStateMachine { selfStopFlagPending = false; } - public void changeToNextState() { int index = stateProcessers.indexOf(currentState); if (index == stateProcessers.size() - 1) { @@ -214,7 +214,6 @@ public class AppStateMachine { return getCurrentStateProcesser().state; } - public void sleep(Integer time) { try { Thread.sleep(time);