From de9ceeaa61142726f898ab29da123e32143da7c3 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 26 Sep 2024 09:22:09 +0800 Subject: [PATCH] update --- .../java/a8k/baseservice/ActionReactorService.java | 119 ++++++ .../controler/extapi/EngineerPageControler.java | 2 +- .../extapi/utils/EnginnerParamReader.java | 2 +- .../java/a8k/dbservice/HardwareServiceSetting.java | 104 ++++++ .../java/a8k/hardware/HardwareServiceSetting.java | 104 ------ .../a8k/service/A8kDebugTaskExecutorService.java | 43 --- .../a8k/service/app/AppConsumablesMgrService.java | 4 +- .../service/app/AppDeviceInitializationModule.java | 2 +- .../app_basic_service/ActionReactorService.java | 120 ------- .../calibration/PositionCalibration.java | 119 ------ .../commonctrl/HardwareCommonCtrl.java | 395 -------------------- .../bak_devicectrl/ctrl/HbotControlService.java | 400 --------------------- .../bak_devicectrl/ctrl/PipetteGunCtrlService.java | 32 -- .../ctrl/ReactionPlatesTransmitCtrl.java | 211 ----------- .../bak_devicectrl/ctrl/SamplesPreProcesCtrl.java | 268 -------------- .../bak_devicectrl/ctrl/TubeRackMoveCtrl.java | 298 --------------- .../service/bak_devicectrl/param/DebugParam.java | 29 -- .../a8k/service/bak_devicectrl/param/PosParam.java | 393 -------------------- .../service/bak_devicectrl/param/TimeParam.java | 52 --- .../bak_devicectrl/status/DeviceStatus.java | 87 ----- .../bak_devicectrl/testscript/TestScript.java | 250 ------------- .../calibration/PositionCalibration.java | 119 ++++++ .../devicectrl/commonctrl/HardwareCommonCtrl.java | 395 ++++++++++++++++++++ .../devicectrl/ctrl/HbotControlService.java | 394 ++++++++++++++++++++ .../devicectrl/ctrl/PipetteGunCtrlService.java | 32 ++ .../ctrl/ReactionPlatesTransmitCtrl.java | 211 +++++++++++ .../devicectrl/ctrl/SamplesPreProcesCtrl.java | 268 ++++++++++++++ .../service/devicectrl/ctrl/TubeRackMoveCtrl.java | 298 +++++++++++++++ .../a8k/service/devicectrl/param/DebugParam.java | 29 ++ .../a8k/service/devicectrl/param/PosParam.java | 393 ++++++++++++++++++++ .../a8k/service/devicectrl/param/TimeParam.java | 52 +++ .../service/devicectrl/status/DeviceStatus.java | 87 +++++ .../service/devicectrl/testscript/TestScript.java | 242 +++++++++++++ src/main/java/a8k/utils/ZSqliteJdbcHelper.java | 7 + 34 files changed, 2755 insertions(+), 2806 deletions(-) create mode 100644 src/main/java/a8k/baseservice/ActionReactorService.java create mode 100644 src/main/java/a8k/dbservice/HardwareServiceSetting.java delete mode 100644 src/main/java/a8k/hardware/HardwareServiceSetting.java delete mode 100644 src/main/java/a8k/service/A8kDebugTaskExecutorService.java delete mode 100644 src/main/java/a8k/service/app_basic_service/ActionReactorService.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/calibration/PositionCalibration.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/commonctrl/HardwareCommonCtrl.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/ctrl/HbotControlService.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/ctrl/PipetteGunCtrlService.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/ctrl/ReactionPlatesTransmitCtrl.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/ctrl/SamplesPreProcesCtrl.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/ctrl/TubeRackMoveCtrl.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/param/DebugParam.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/param/PosParam.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/param/TimeParam.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/status/DeviceStatus.java delete mode 100644 src/main/java/a8k/service/bak_devicectrl/testscript/TestScript.java create mode 100644 src/main/java/a8k/service/devicectrl/calibration/PositionCalibration.java create mode 100644 src/main/java/a8k/service/devicectrl/commonctrl/HardwareCommonCtrl.java create mode 100644 src/main/java/a8k/service/devicectrl/ctrl/HbotControlService.java create mode 100644 src/main/java/a8k/service/devicectrl/ctrl/PipetteGunCtrlService.java create mode 100644 src/main/java/a8k/service/devicectrl/ctrl/ReactionPlatesTransmitCtrl.java create mode 100644 src/main/java/a8k/service/devicectrl/ctrl/SamplesPreProcesCtrl.java create mode 100644 src/main/java/a8k/service/devicectrl/ctrl/TubeRackMoveCtrl.java create mode 100644 src/main/java/a8k/service/devicectrl/param/DebugParam.java create mode 100644 src/main/java/a8k/service/devicectrl/param/PosParam.java create mode 100644 src/main/java/a8k/service/devicectrl/param/TimeParam.java create mode 100644 src/main/java/a8k/service/devicectrl/status/DeviceStatus.java create mode 100644 src/main/java/a8k/service/devicectrl/testscript/TestScript.java diff --git a/src/main/java/a8k/baseservice/ActionReactorService.java b/src/main/java/a8k/baseservice/ActionReactorService.java new file mode 100644 index 0000000..3f2018a --- /dev/null +++ b/src/main/java/a8k/baseservice/ActionReactorService.java @@ -0,0 +1,119 @@ +package a8k.baseservice; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.controler.extapi.utils.ExtApiStatu; +import a8k.controler.extapi.utils.ExtApiFn; +import a8k.controler.extapi.utils.ExtApiTab; +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.type.ZFunction; +import a8k.type.exception.AppException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.ActionReactorService) +public class ActionReactorService { + public enum DoWhatNext { + DoNextAction, + ReDoAction, + } + + static Logger logger = LoggerFactory.getLogger(ActionReactorService.class); + + static class ORDER { + static final int doNextStep = 1; + static final int reDoStep = 2; + static final int breakAction = 3; + static final int fullSpeedRun = 6; + static final int singleStepRun = 7; + + } + + Boolean reDo = false; + Boolean doNext = false; + Boolean breakAction = false; + Boolean fullSpeedRun = true; + String curStep; + + + DoWhatNext breakpoint() throws AppException { + while (true) { + if (reDo) { + reDo = false; + return DoWhatNext.ReDoAction; + } + if (doNext) { + doNext = false; + return DoWhatNext.DoNextAction; + } + + if (breakAction) { + breakAction = false; + throw new AppException(A8kEcode.ActionBreakByUsr.index); + } + + if (fullSpeedRun) { + return DoWhatNext.DoNextAction; + } + + try { + Thread.sleep(100); + } catch (InterruptedException e) { + throw new AppException(A8kEcode.ActionBreakByUsr.index); + } + } + } + + + public void dosome(String mark, ZFunction action) throws AppException, InterruptedException { + while (true) { + logger.info("do {}", mark); + curStep = mark; + action.fn(); + DoWhatNext next = breakpoint(); + if (next == DoWhatNext.DoNextAction) { + break; + } + } + + curStep = ""; + } + + @ExtApiFn(name = "下一步", order = ORDER.doNextStep) + public void doNextStep() { + doNext = true; + } + + @ExtApiFn(name = "重新执行当前步骤", order = ORDER.reDoStep) + public void reDoStep() { + reDo = true; + } + + @ExtApiFn(name = "中断动作", order = ORDER.breakAction) + public void breakAction() { + breakAction = true; + } + + + @ExtApiFn(name = "全速模式", order = ORDER.fullSpeedRun) + public void fullSpeedRun() { + fullSpeedRun = true; + } + + @ExtApiFn(name = "单步模式", order = ORDER.singleStepRun) + public void singleStepRun() { + fullSpeedRun = false; + } + + @ExtApiStatu(name = "全速运行") + public Boolean getFullSpeedRun() { + return fullSpeedRun; + } + + @ExtApiStatu(name = "当前步骤") + public String getCurStep() { + return curStep; + } + +} diff --git a/src/main/java/a8k/controler/extapi/EngineerPageControler.java b/src/main/java/a8k/controler/extapi/EngineerPageControler.java index cd75366..d2aff99 100644 --- a/src/main/java/a8k/controler/extapi/EngineerPageControler.java +++ b/src/main/java/a8k/controler/extapi/EngineerPageControler.java @@ -2,7 +2,7 @@ package a8k.controler.extapi; import a8k.type.appret.AppRet; import a8k.controler.extapi.utils.*; -import a8k.hardware.HardwareServiceSetting; +import a8k.dbservice.HardwareServiceSetting; import a8k.utils.*; import com.iflytop.uf.UfApplication; import com.iflytop.uf.util.UfClassHelper; diff --git a/src/main/java/a8k/controler/extapi/utils/EnginnerParamReader.java b/src/main/java/a8k/controler/extapi/utils/EnginnerParamReader.java index aefd7d1..1f7c6e0 100644 --- a/src/main/java/a8k/controler/extapi/utils/EnginnerParamReader.java +++ b/src/main/java/a8k/controler/extapi/utils/EnginnerParamReader.java @@ -1,6 +1,6 @@ package a8k.controler.extapi.utils; -import a8k.hardware.HardwareServiceSetting; +import a8k.dbservice.HardwareServiceSetting; import a8k.type.exception.AppException; diff --git a/src/main/java/a8k/dbservice/HardwareServiceSetting.java b/src/main/java/a8k/dbservice/HardwareServiceSetting.java new file mode 100644 index 0000000..f8675df --- /dev/null +++ b/src/main/java/a8k/dbservice/HardwareServiceSetting.java @@ -0,0 +1,104 @@ +package a8k.dbservice; + +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.type.exception.AppException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.iflytop.uf.UfActiveRecord; +import com.iflytop.uf.UfActiveRecordField; +import com.iflytop.uf.util.UfJsonHelper; + +import java.util.Map; + +public class HardwareServiceSetting extends UfActiveRecord { + @UfActiveRecordField + public String key; + @UfActiveRecordField + public String serviceName; //属于哪个服务的, hardware目录下的类名 + @UfActiveRecordField + public String valType; + @UfActiveRecordField + public String val; + + public static String getTableName() { + return "HardwareServiceSetting" + "Table"; + } + + public static void deleteAllByServiceName(String serviceName) { + var items = UfActiveRecord.find(HardwareServiceSetting.class, Map.of("ServiceName", serviceName)); + for (var item : items) { + item.delete(); + } + } + + public void setValue(Object value) throws Exception { + if (value instanceof String) { + this.val = (String) value; + } else if (value instanceof Integer) { + this.val = String.valueOf((Integer) value); + } else if (value instanceof Map) { + this.val = UfJsonHelper.objectToJson(value); + } else { + this.val = UfJsonHelper.objectToJson(value); + } + } + + public static HardwareServiceSetting getOption(String service, String key) { + var option = UfActiveRecord.findOne(HardwareServiceSetting.class, Map.of("serviceName", service, "key", key)); + if (null == option) { + option = new HardwareServiceSetting(); + option.serviceName = service; + option.key = key; + option.val = null; + } + return option; + } + + + public static void setOption(String service, String key, Object value) throws Exception { + var options = getOption(service, key); + options.setValue(value); + options.save(); + } + + public static T getObject(String service, String key, Class clazs) throws AppException { + var option = UfActiveRecord.findOne(HardwareServiceSetting.class, Map.of("serviceName", service, "key", key)); + if (option == null) { + throw new AppException(A8kEcode.GetParamFail.index); + } + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.readValue(option.val, clazs); + } catch (JsonProcessingException e) { + throw new AppException(A8kEcode.ParseParamFail.index); + } + } + + + public static T getObject(String service, String key, Class clazs, T defaultVal) { + var option = UfActiveRecord.findOne(HardwareServiceSetting.class, Map.of("serviceName", service, "key", key)); + if (option == null) { + return defaultVal; + } + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.readValue(option.val, clazs); + } catch (JsonProcessingException e) { + return defaultVal; + } + } + + public static Integer getInteger(String service, String key, Integer defaultValue) { + var option = HardwareServiceSetting.getOption(service, key); + if (null == option.val) { + return defaultValue; + } + return Integer.parseInt(option.val); + } + + public static void setInteger(String service, String key, Integer value) { + var option = HardwareServiceSetting.getOption(service, key); + option.val = String.valueOf(value); + option.save(); + } +} diff --git a/src/main/java/a8k/hardware/HardwareServiceSetting.java b/src/main/java/a8k/hardware/HardwareServiceSetting.java deleted file mode 100644 index da6b542..0000000 --- a/src/main/java/a8k/hardware/HardwareServiceSetting.java +++ /dev/null @@ -1,104 +0,0 @@ -package a8k.hardware; - -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.type.exception.AppException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.iflytop.uf.UfActiveRecord; -import com.iflytop.uf.UfActiveRecordField; -import com.iflytop.uf.util.UfJsonHelper; - -import java.util.Map; - -public class HardwareServiceSetting extends UfActiveRecord { - @UfActiveRecordField - public String key; - @UfActiveRecordField - public String serviceName; //属于哪个服务的, hardware目录下的类名 - @UfActiveRecordField - public String valType; - @UfActiveRecordField - public String val; - - public static String getTableName() { - return "HardwareServiceSetting" + "Table"; - } - - public static void deleteAllByServiceName(String serviceName) { - var items = UfActiveRecord.find(HardwareServiceSetting.class, Map.of("ServiceName", serviceName)); - for (var item : items) { - item.delete(); - } - } - - public void setValue(Object value) throws Exception { - if (value instanceof String) { - this.val = (String) value; - } else if (value instanceof Integer) { - this.val = String.valueOf((Integer) value); - } else if (value instanceof Map) { - this.val = UfJsonHelper.objectToJson(value); - } else { - this.val = UfJsonHelper.objectToJson(value); - } - } - - public static HardwareServiceSetting getOption(String service, String key) { - var option = UfActiveRecord.findOne(HardwareServiceSetting.class, Map.of("serviceName", service, "key", key)); - if (null == option) { - option = new HardwareServiceSetting(); - option.serviceName = service; - option.key = key; - option.val = null; - } - return option; - } - - - public static void setOption(String service, String key, Object value) throws Exception { - var options = getOption(service, key); - options.setValue(value); - options.save(); - } - - public static T getObject(String service, String key, Class clazs) throws AppException { - var option = UfActiveRecord.findOne(HardwareServiceSetting.class, Map.of("serviceName", service, "key", key)); - if (option == null) { - throw new AppException(A8kEcode.GetParamFail.index); - } - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.readValue(option.val, clazs); - } catch (JsonProcessingException e) { - throw new AppException(A8kEcode.ParseParamFail.index); - } - } - - - public static T getObject(String service, String key, Class clazs, T defaultVal) { - var option = UfActiveRecord.findOne(HardwareServiceSetting.class, Map.of("serviceName", service, "key", key)); - if (option == null) { - return defaultVal; - } - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.readValue(option.val, clazs); - } catch (JsonProcessingException e) { - return defaultVal; - } - } - - public static Integer getInteger(String service, String key, Integer defaultValue) { - var option = HardwareServiceSetting.getOption(service, key); - if (null == option.val) { - return defaultValue; - } - return Integer.parseInt(option.val); - } - - public static void setInteger(String service, String key, Integer value) { - var option = HardwareServiceSetting.getOption(service, key); - option.val = String.valueOf(value); - option.save(); - } -} diff --git a/src/main/java/a8k/service/A8kDebugTaskExecutorService.java b/src/main/java/a8k/service/A8kDebugTaskExecutorService.java deleted file mode 100644 index 9603e1e..0000000 --- a/src/main/java/a8k/service/A8kDebugTaskExecutorService.java +++ /dev/null @@ -1,43 +0,0 @@ -package a8k.service; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -public class A8kDebugTaskExecutorService { - public static final Logger logger = LoggerFactory.getLogger(A8kDebugTaskExecutorService.class); - - Thread task; - - synchronized void exec(Runnable runnable) { - if (task != null) { - task.interrupt(); - try { - task.join(); - } catch (InterruptedException ignored) { - return; - } - } - - task = new Thread(runnable); - task.start(); - } - - synchronized void stop() { - try { - task.join(); - task = null; - } catch (InterruptedException e) { - logger.error(e.getMessage()); - } - } - - synchronized boolean isRunning() { - if (task == null) { - return false; - } - return task.isAlive(); - } - -} diff --git a/src/main/java/a8k/service/app/AppConsumablesMgrService.java b/src/main/java/a8k/service/app/AppConsumablesMgrService.java index 4295770..7652e1a 100644 --- a/src/main/java/a8k/service/app/AppConsumablesMgrService.java +++ b/src/main/java/a8k/service/app/AppConsumablesMgrService.java @@ -2,8 +2,8 @@ package a8k.service.app; import a8k.hardware.type.a8kcanprotocol.A8kEcode; import a8k.service.app.app_consumables_mgr_service.ConsumablesScanRawResult; -import a8k.service.app_basic_service.ActionReactorService; -import a8k.service.bak_devicectrl.ctrl.HbotControlService; +import a8k.baseservice.ActionReactorService; +import a8k.service.devicectrl.ctrl.HbotControlService; import a8k.service.hardwareparam.Hbot2DCodeScanPosMgrService; import a8k.type.appret.AppRet; import a8k.controler.extapi.utils.ExtApiTab; diff --git a/src/main/java/a8k/service/app/AppDeviceInitializationModule.java b/src/main/java/a8k/service/app/AppDeviceInitializationModule.java index c752055..f5655e3 100644 --- a/src/main/java/a8k/service/app/AppDeviceInitializationModule.java +++ b/src/main/java/a8k/service/app/AppDeviceInitializationModule.java @@ -8,7 +8,7 @@ import a8k.hardware.type.a8kcanprotocol.A8kEcode; import a8k.hardware.type.a8kcanprotocol.IOId; import a8k.hardware.type.a8kcanprotocol.MId; import a8k.service.app.appstate.AppStateMgrService; -import a8k.service.app_basic_service.ActionReactorService; +import a8k.baseservice.ActionReactorService; import a8k.service.app.app_device_initialization_module.checkpoint.CheckPointType; import a8k.service.app.app_device_initialization_module.checkpoint.CheckResult; import a8k.service.app.app_device_initialization_module.checkpoint.Checkpoint; diff --git a/src/main/java/a8k/service/app_basic_service/ActionReactorService.java b/src/main/java/a8k/service/app_basic_service/ActionReactorService.java deleted file mode 100644 index 8f926dc..0000000 --- a/src/main/java/a8k/service/app_basic_service/ActionReactorService.java +++ /dev/null @@ -1,120 +0,0 @@ -package a8k.service.app_basic_service; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.controler.extapi.utils.ExtApiStatu; -import a8k.controler.extapi.utils.ExtApiFn; -import a8k.controler.extapi.utils.ExtApiTab; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.type.ZFunction; -import a8k.type.exception.ActionBreakException; -import a8k.type.exception.AppException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.ActionReactorService) -public class ActionReactorService { - public enum DoWhatNext { - DoNextAction, - ReDoAction, - } - - static Logger logger = LoggerFactory.getLogger(ActionReactorService.class); - - static class ORDER { - static final int doNextStep = 1; - static final int reDoStep = 2; - static final int breakAction = 3; - static final int fullSpeedRun = 6; - static final int singleStepRun = 7; - - } - - Boolean reDo = false; - Boolean doNext = false; - Boolean breakAction = false; - Boolean fullSpeedRun = true; - String curStep; - - - DoWhatNext breakpoint() throws AppException { - while (true) { - if (reDo) { - reDo = false; - return DoWhatNext.ReDoAction; - } - if (doNext) { - doNext = false; - return DoWhatNext.DoNextAction; - } - - if (breakAction) { - breakAction = false; - throw new AppException(A8kEcode.ActionBreakByUsr.index); - } - - if (fullSpeedRun) { - return DoWhatNext.DoNextAction; - } - - try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw new AppException(A8kEcode.ActionBreakByUsr.index); - } - } - } - - - public void dosome(String mark, ZFunction action) throws AppException, InterruptedException { - while (true) { - logger.info("do {}", mark); - curStep = mark; - action.fn(); - DoWhatNext next = breakpoint(); - if (next == DoWhatNext.DoNextAction) { - break; - } - } - - curStep = ""; - } - - @ExtApiFn(name = "下一步", order = ORDER.doNextStep) - public void doNextStep() { - doNext = true; - } - - @ExtApiFn(name = "重新执行当前步骤", order = ORDER.reDoStep) - public void reDoStep() { - reDo = true; - } - - @ExtApiFn(name = "中断动作", order = ORDER.breakAction) - public void breakAction() { - breakAction = true; - } - - - @ExtApiFn(name = "全速模式", order = ORDER.fullSpeedRun) - public void fullSpeedRun() { - fullSpeedRun = true; - } - - @ExtApiFn(name = "单步模式", order = ORDER.singleStepRun) - public void singleStepRun() { - fullSpeedRun = false; - } - - @ExtApiStatu(name = "全速运行") - public Boolean getFullSpeedRun() { - return fullSpeedRun; - } - - @ExtApiStatu(name = "当前步骤") - public String getCurStep() { - return curStep; - } - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/calibration/PositionCalibration.java b/src/main/java/a8k/service/bak_devicectrl/calibration/PositionCalibration.java deleted file mode 100644 index 9e997b9..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/calibration/PositionCalibration.java +++ /dev/null @@ -1,119 +0,0 @@ -package a8k.service.bak_devicectrl.calibration; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.type.exception.AppException; -import a8k.type.appret.AppRet; -import a8k.type.cfg.Pos2d; -import a8k.controler.extapi.utils.*; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.service.bak_devicectrl.param.DebugParam; -import a8k.service.bak_devicectrl.param.PosParam; -import a8k.service.bak_devicectrl.param.TimeParam; -import jakarta.annotation.Resource; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.PositionCalibration) -public class PositionCalibration { - - @Resource - A8kCanBusService canBus; - @Resource - TimeParam timep; - @Resource - PosParam pp; - @Resource - DebugParam dp; - - @ExtApiFn(name = "试管夹平移电机-使能", group = "电机使能") - public void FeedingModXMEnable(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); - } - - @ExtApiFn(name = "板夹仓Y轴-使能", group = "电机使能") - public void platesBoxYMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); - } - - @ExtApiFn(name = "板夹仓推杆-使能", group = "电机使能") - public void platesBoxPusherMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); - } - - @ExtApiFn(name = "拉杆-使能", group = "电机使能") - public void optModPullMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); - } - - @ExtApiFn(name = "光学模组扫描器-使能", group = "电机使能") - public void optModScannerMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); - } - - @ExtApiFn(name = "转盘-使能", group = "电机使能") - public void incubatorRotateCtrlMEndble(Boolean enable) throws AppException { - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); - - } - - - @ExtApiFn(name = "试管夹平移电机-读取位置", group = "通过归零测量位置") - public AppRet readXPosByMoveZero() throws AppException, InterruptedException { - return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.FeedingModXM, timep.getActionOvertime())); - } - - - @ExtApiFn(name = "通过归零读取<板夹仓>位置", group = "通过归零测量位置") - public AppRet readPlatesBoxYMPosByMoveToZero() throws AppException, InterruptedException { - return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxYM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<推杆>位置", group = "通过归零测量位置") - public AppRet readPlatesBoxPusherMPosByMoveToZero() throws AppException, InterruptedException { - return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxPusherM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<拉杆>位置", group = "通过归零测量位置") - public AppRet readOptModPullMPosByMoveToZero() throws AppException, InterruptedException { - return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModPullM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<光学模组扫描器>位置", group = "通过归零测量位置") - public AppRet readOptModScannerMPosByMoveToZero() throws AppException, InterruptedException { - return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModScannerM, timep.getActionOvertime())); - } - - @ExtApiFn(name = "通过归零读取<摇匀模组Z轴>位置", group = "通过归零测量位置") - public AppRet readShakeModGripperZMPosByMoveToZero() throws AppException, InterruptedException { - return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime())); - } - - - @ExtApiStatu(name = "HbotPos", group = "Hbot") - public String getHbotPos() throws AppException { - Pos2d pos = canBus.hbotReadPos(MId.HbotM); - return pos.toString(); - } - - - @ExtApiStatu(name = "转盘位置") - public String getIncubatorRotateCtrlMPos() throws AppException { - Integer pos = canBus.stepMotorReadPos(MId.IncubatorRotateCtrlM); - return pos.toString(); - } - - @ExtApiStatu(name = "抓手Y轴位置", group = "摇匀模组") - public String getShakeModGripperYPos() throws AppException { - Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperYSV); - return pos.toString(); - } - - @ExtApiStatu(name = "抓手位置", group = "摇匀模组") - public String getGripperPos() throws AppException { - Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperSV); - return pos.toString(); - } - - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/commonctrl/HardwareCommonCtrl.java b/src/main/java/a8k/service/bak_devicectrl/commonctrl/HardwareCommonCtrl.java deleted file mode 100644 index e6c5558..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/commonctrl/HardwareCommonCtrl.java +++ /dev/null @@ -1,395 +0,0 @@ -package a8k.service.bak_devicectrl.commonctrl; - - -import a8k.type.exception.AppException; -import a8k.type.appret.AppRet; -import a8k.controler.extapi.utils.ExtApiTab; -import a8k.controler.extapi.utils.ExtApiFn; -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.hardware.type.a8kcanprotocol.IOId; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.service.bak_devicectrl.param.PosParam; -import a8k.service.bak_devicectrl.param.TimeParam; -import jakarta.annotation.Resource; -import org.slf4j.Logger; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.HardwareCommonCtrl) -public class HardwareCommonCtrl { - static Logger logger = org.slf4j.LoggerFactory.getLogger(HardwareCommonCtrl.class); - - static class ORDER { - static final int initializeDevice = 1; - static final int deviceClear = 2; - static final int deviceForceStop = 3; - static final int forceDisableAllMOtor = 4; - static final int deviceEnable = 5; - } - - @Resource - A8kCanBusService canBus; - - @Resource - TimeParam timep; - - @Resource - PosParam posp; - - Boolean workState = false; - - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // CHECK - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - private AppRet checkDeviceStateBeforeRunToZero() throws AppException { - logger.info("checkDeviceStateBeforeRunToZero"); - //试管平移通道是否有障碍 - if (canBus.getIOState(IOId.THChInterPPS) || canBus.getIOState(IOId.THChOuterPPS)) { - logger.warn("THChInterPPS or THChOuterPPS is trigger"); - return AppRet.fail(A8kEcode.TubeXChannelIsNotEmpty.index); - } - - //板夹仓盖子是否盖上 - if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { - return AppRet.fail(A8kEcode.PlateBoxNotCover.index); - } - - //板夹仓卡板检测 - if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS)) { - return AppRet.fail(A8kEcode.PlateStuckDetectorSensorTrigger.index); - } - - //检查钩板电机是否处于终点位置 - if (!canBus.getIOState(IOId.PullerMZeroPPS)) { - return AppRet.fail(A8kEcode.PullerMInitPosError.index); - } - - //检查板夹仓光电是否处于起点位置 - if (!canBus.getIOState(IOId.PusherMZeroPPS)) { - return AppRet.fail(A8kEcode.PusherMInitPosError.index); - } - //板夹仓光电 - if (canBus.getIOState(IOId.RecycleBinOverflowPPS)) { - return AppRet.fail(A8kEcode.RecycleBinOverflow.index); - } - - return AppRet.success(); - } - - private void checkStopFlag() throws AppException { - if (!workState) { - throw new AppException(A8kEcode.StopByUser.index); - } - } - - - private AppRet moveMotorToZero() throws AppException, InterruptedException { - - //进出料初始化 - canBus.stepMotorEasyMoveToZeroBlock(MId.FeedingModXM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - - canBus.miniServoMoveToBlock(MId.ShakeModTubeScanerClampingSV, 20, timep.getActionOvertime()); - checkStopFlag(); - - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, 300, timep.getActionOvertime()); - checkStopFlag(); - - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, 300, timep.getActionOvertime()); - checkStopFlag(); - - - canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModClampingM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModGripperZM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModShakeM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - - canBus.stepMotorEasyMoveTo(MId.ShakeModShakeM, 90); - checkStopFlag(); - - //板夹仓初始化 - canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxYM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxPusherM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - //光学模组初始化 - canBus.stepMotorEasyMoveToZeroBlock(MId.OptModPullM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - canBus.stepMotorEasyMoveToZeroBlock(MId.OptModScannerM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - //HBot初始化 - canBus.hbotMoveToZero(MId.HbotM); - checkStopFlag(); - - // TODO canBus.stepMotorEasyMoveToZeroBlock(MId.PipetteModZM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - //转盘归零 - canBus.stepMotorEasyMoveToZeroBlock(MId.IncubatorRotateCtrlM, timep.getRuntoZeroActionOvertime()); - checkStopFlag(); - - - return AppRet.success(); - } - - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // Expose API - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - @ExtApiFn(name = "设备初始化", order = ORDER.initializeDevice) - public AppRet initializeDevice() throws AppException, InterruptedException { - logger.info("Initializing device ..."); - boolean initSuc = false; - workState = true; - AppRet ecode; - try { - //打开必要的电源 - canBus.setIOState(IOId.RecycleBinOverflowPPSPowerCtrl, true); - - //检查设备状态 - ecode = checkDeviceStateBeforeRunToZero(); - if (!ecode.isSuccess()) { - return AppRet.fail(ecode); - } - // 复位设备 - logger.info("moveMotorToZero"); - ecode = moveMotorToZero(); - if (!ecode.isSuccess()) { - return AppRet.fail(ecode); - } - initSuc = true; - logger.info("Device initialization completed"); - - } finally { - if (!initSuc) { - try { - canBus.stepMotorEnable(MId.ShakeModClampingM, 1); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEasyMoveBy(MId.ShakeModClampingM, 2); - } catch (AppException ignored) { - } - } - } - return AppRet.success("初始化完成"); - - } - - // @EnginnerPageAction(name = "清空板夹仓板夹", order = ORDER.deviceClear) - // public void clearDevice() { - // //TODO - // } - - - @ExtApiFn(name = "设备强制停止", order = ORDER.deviceForceStop) - public void deviceForceStop() throws AppException { - //StopAllMotor - //进出料初始化 - try { - canBus.moduleStop(MId.FeedingModInfeedM); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.FeedingModXM); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.FeedingModOutfeedM); - } catch (AppException ignored) { - } - //摇匀模组初始化 - try { - canBus.moduleStop(MId.ShakeModClampingM); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.ShakeModGripperZM); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.ShakeModShakeM); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.ShakeModGripperYSV); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.ShakeModGripperSV); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.ShakeModTubeScanerClampingSV); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.ShakeModTubeScanerRotateSV); - } catch (AppException ignored) { - } - //板夹仓初始化 - try { - canBus.moduleStop(MId.PlatesBoxYM); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.PlatesBoxPusherM); - } catch (AppException ignored) { - } - //光学模组初始化 - try { - canBus.moduleStop(MId.OptModPullM); - } catch (AppException ignored) { - } - try { - canBus.moduleStop(MId.OptModScannerM); - } catch (AppException ignored) { - } - //HBot初始化 - try { - canBus.moduleStop(MId.HbotM); - } catch (AppException ignored) { - } - // try { - // TODO canBus.moduleStop(MId.PipetteModZM); - // } catch (HardwareException ignored) { - // } - //转盘归零 - try { - canBus.moduleStop(MId.IncubatorRotateCtrlM); - } catch (AppException ignored) { - } - - } - - @ExtApiFn(name = "设备强制使能所有电机", order = ORDER.forceDisableAllMOtor) - public void forceDisableAllMOtor() { - //Disable all motor - //进出料初始化 - try { - canBus.stepMotorEnable(MId.FeedingModInfeedM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.FeedingModXM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0); - } catch (AppException ignored) { - } - - //摇匀模组初始化 - try { - canBus.stepMotorEnable(MId.ShakeModClampingM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.ShakeModGripperZM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.ShakeModShakeM, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModGripperYSV, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModGripperSV, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0); - } catch (AppException ignored) { - } - try { - canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0); - } catch (AppException ignored) { - } - - //板夹仓初始化 - try { - canBus.stepMotorEnable(MId.PlatesBoxYM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0); - } catch (AppException ignored) { - } - - //光学模组初始化 - try { - canBus.stepMotorEnable(MId.OptModPullM, 0); - } catch (AppException ignored) { - } - try { - canBus.stepMotorEnable(MId.OptModScannerM, 0); - } catch (AppException ignored) { - } - - //HBot初始化 - try { - canBus.hbotEnable(MId.HbotM, 0); - } catch (AppException ignored) { - } - // try { - //TODO canBus.stepMotorEnable(MId.PipetteModZM, 0); - // } catch (HardwareException ignored) { - // } - - //转盘归零 - try { - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0); - } catch (AppException ignored) { - } - } - - @ExtApiFn(name = "设备使能", order = ORDER.deviceEnable) - public void deviceEnable(Boolean enable) throws AppException { - //进出料初始化 - canBus.stepMotorEnable(MId.FeedingModInfeedM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.FeedingModOutfeedM, enable ? 1 : 0); - - //摇匀模组初始化 - canBus.stepMotorEnable(MId.ShakeModClampingM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.ShakeModGripperZM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.ShakeModShakeM, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModGripperYSV, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModGripperSV, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, enable ? 1 : 0); - canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, enable ? 1 : 0); - - //板夹仓初始化 - canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); - - //光学模组初始化 - canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); - canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); - - //HBot初始化 - canBus.hbotEnable(MId.HbotM, enable ? 1 : 0); - // TODO canBus.stepMotorEnable(MId.PipetteModZM, enable ? 1 : 0); - - //转盘归零 - canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); - } - - public void checkBeforeMove(MId mId) throws AppException { - //板夹仓盖子是否盖上 - if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { - throw new AppException(A8kEcode.PlateBoxNotCover.index); - } - } - - public void stop() { - workState = false; - } - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/ctrl/HbotControlService.java b/src/main/java/a8k/service/bak_devicectrl/ctrl/HbotControlService.java deleted file mode 100644 index fd42431..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/ctrl/HbotControlService.java +++ /dev/null @@ -1,400 +0,0 @@ -package a8k.service.bak_devicectrl.ctrl; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.hardware.A8kPipetteCtrlModule; -import a8k.hardware.type.regindex.PipetteRegIndex; -import a8k.type.ConsumableGroup; -import a8k.type.exception.AppException; -import a8k.type.appret.AppRet; -import a8k.type.cfg.*; -import a8k.controler.extapi.utils.*; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.hardware.type.a8kcanprotocol.IOId; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.hardware.type.regindex.RegIndex; -import a8k.service.bak_devicectrl.commonctrl.HardwareCommonCtrl; -import a8k.service.bak_devicectrl.param.DebugParam; -import a8k.service.bak_devicectrl.param.PosParam; -import a8k.service.bak_devicectrl.param.TimeParam; -import jakarta.annotation.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -/** - * Hbot控制服务 - */ -@Component -@ExtApiTab(cfg = ExtApiTabConfig.HbotControlService) -public class HbotControlService { - static Logger logger = LoggerFactory.getLogger(HbotControlService.class); - - @Resource - A8kCanBusService canBus; - - @Resource - A8kPipetteCtrlModule pipetteCtrlModule; - - Integer ao = 20000; - - - public void hbotMoveTo(Pos3d targetPos) throws AppException, InterruptedException { - logger.info("hbotCheckAndMoveTo:{}", targetPos); - - // 检查盖板是否关闭 - if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { - throw new AppException(A8kEcode.PlateBoxNotCover.index); - } - - boolean zEnable = true; - boolean hbotEnable = canBus.moduleGetReg(MId.HbotM, RegIndex.kreg_xyrobot_is_enable) == 1; - - //检查Z轴是否使能,如果没有使能,使能并移动到零点 - if (pipetteCtrlModule.getReg(PipetteRegIndex.kreg_pipette_zm_is_enable) == 0) { - pipetteCtrlModule.zMotorEnable(1); - pipetteCtrlModule.zMotorMoveZeroBlock(); - zEnable = false; - } - - //检查Z轴是否在零点 - if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { - pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); - } - if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { - throw new AppException(A8kEcode.ZMNotAtZPosWhenHbotTryMove.index); - } - - // HBot移动 - canBus.hbotEnable(MId.HbotM, 1); - canBus.hbotMoveToBlock(MId.HbotM, targetPos.x - 20, targetPos.y - 20, ao); - canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, ao); - canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, ao); - - // Z轴移动 - if (targetPos.z != 0) { - pipetteCtrlModule.zMotorEnable(1); - pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); - pipetteCtrlModule.zMotorMoveToBlock(targetPos.z); - } - pipetteCtrlModule.zMotorEnable(zEnable ? 1 : 0); - canBus.hbotEnable(MId.HbotM, hbotEnable ? 1 : 0); - } - - public void hbotMoveTo(Pos2d tpos) throws AppException, InterruptedException { - hbotMoveTo(new Pos3d(tpos.x, tpos.y, 0)); - } - - public String scan2dCode(Integer waittime) throws AppException, InterruptedException { - try { - canBus.codeScanerStartScan(MId.PipetteModCodeScanner); - String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, waittime); - canBus.codeScanerStopScan(MId.PipetteModCodeScanner); - return result; - } catch (AppException e) { - return ""; - } - } - - - // - // public Integer getGripperZeroYPos() { - // 之所以这样写,是因为是为了放置两个类之间的循环依赖 - // assert appCxt != null; - // TODO - // return - // appCxt.getBean(SamplesPreProcessModuleCtrlService.class).getGripperZeroYPos(); - // return 0; - // } - - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // 基础控制 - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // private void checkPublicArea() throws AppException { - // if (canBus.miniServoReadPos(MId.ShakeModGripperYSV) > getGripperZeroYPos() + 20) { - // logger.error("ShakeModGripperYSV Pos:{} > {}", canBus.miniServoReadPos(MId.ShakeModGripperYSV), - // getGripperZeroYPos() + 20); - // throw new AppException(A8kEcode.ShakeModGripperYSVInXYPublicArea.index); - // } - // } - - // /** - // * Hboot 移动 - // * - // * @param targetPos 目标位置 - // * @throws AppException e - // * @throws InterruptedException e - // */ - // public void hbotCheckAndMoveTo(Pos3d targetPos) throws AppException, InterruptedException { - // logger.info("hbotCheckAndMoveTo:{}", targetPos); - // if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { - // throw new AppException(A8kEcode.PlateBoxNotCover.index); - // } - // - // - // boolean zEnable = true; - // boolean hbotEnable = canBus.moduleGetReg(MId.HbotM, RegIndex.kreg_xyrobot_is_enable) == 1; - // - // if (pipetteCtrlModule.getReg(PipetteRegIndex.kreg_pipette_zm_is_enable) == 0) { - // pipetteCtrlModule.zMotorEnable(1); - // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); - // zEnable = false; - // } - // - // if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { - // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); - // } - // - // if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { - // throw new AppException(A8kEcode.ZMNotAtZPosWhenHbotTryMove.index); - // } - // Pos2d nowHbotPos = canBus.hbotReadPos(MId.HbotM); - // HbotLimitArea sampleArea = pp.getSampleCollectionArea(); - // - // // 检查采样区域是否有障碍 - // // if (sampleArea.checkIsInArea(nowHbotPos) || sampleArea.checkIsInArea(targetPos.getXYPos())) { - // // checkPublicArea(); - // // } - // - // // HBot移动 - // canBus.hbotEnable(MId.HbotM, 1); - // canBus.hbotMoveToBlock(MId.HbotM, targetPos.x - 20, targetPos.y - 20, timep.getActionOvertime()); - // canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, timep.getActionOvertime()); - // canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, timep.getActionOvertime()); - // - // // Z轴移动 - // if (targetPos.z != 0) { - // pipetteCtrlModule.zMotorEnable(1); - // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); - // pipetteCtrlModule.zMotorMoveToBlock(targetPos.z); - // } - // pipetteCtrlModule.zMotorEnable(zEnable ? 1 : 0); - // canBus.hbotEnable(MId.HbotM, hbotEnable ? 1 : 0); - // } - // - // public void zMoveTo(Integer z) throws AppException, InterruptedException { - // if (z == 0) { - // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); - // } else { - // pipetteCtrlModule.zMotorMoveToBlock(z); - // } - // } - // - // private void hbotCheckAndMoveTo(Pos2d targetPos) throws AppException, InterruptedException { - // hbotCheckAndMoveTo(new Pos3d(targetPos.x, targetPos.y, 0)); - // } - // - // private void modGroupMoveToZero() throws AppException, InterruptedException { - // if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { - // throw new AppException(A8kEcode.PlateBoxNotCover.index); - // } - // - // pipetteCtrlModule.zMotorEnable(1); - // canBus.hbotEnable(MId.HbotM, 1); - // - // canBus.hbotMoveToZeroBlock(MId.HbotM, timep.getHbotRuntoZeroActionOvertime()); - // - // // 丢弃tip - // Pos3d dropPos = pp.getTipDropPos(); - // hbotCheckAndMoveTo(dropPos); - // // TODO: canBus.pipetteCtrlInitDeviceBlock(MId.PipetteMod, timep.getActionOvertime()); - // - // // 快速归零 - // modGroupMoveToZeroQuick(); - // } - // - // private void modGroupMoveToZeroQuick() throws AppException, InterruptedException { - // hbotCheckAndMoveTo(new Pos2d(0, 0)); - // } - - - // // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // // 单步测试 - // // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // - // @ExtApiFn(name = "丢Tip", group = "单步测试") - // public void dropTip() throws AppException, InterruptedException { - // Pos3d pos = pp.getTipDropPos(); - // hbotMoveTo(pos.x, pos.y); - // zMoveTo(pos.z); - // pipetteCtrlModule.putTipBlock(); - // zMoveTo(0); - // } - // - // @ExtApiFn(name = "取Tip", group = "单步测试") - // public AppRet takeTip(Integer groupId, Integer index) throws AppException, InterruptedException { - // logger.info("takeTip groupId:{} index:{}", groupId, index); - // if (groupId > 2 || groupId < 0) { - // throw new AppException(A8kEcode.ParamOutOfRange.index); - // } - // - // if (index > TipPickUpPosInfo.cgetTipNum() || index < 0) { - // throw new AppException(A8kEcode.ParamOutOfRange.index); - // } - // - // TipPickUpPosInfo tipPos = pp.getTipPickUpPosInfo(); - // Pos2d pos = tipPos.getTipPos(groupId, index); - // hbotMoveTo(pos.x, pos.y); - // - // //TODO: 补偿,group大于1时,z轴需要补偿0.2mm - // Integer zCompensate = 0; - // if (groupId > 1) { - // zCompensate = 2; - // } - // - // pipetteCtrlModule.zMotorMoveToBlock(tipPos.getPickUpZPos(groupId) + zCompensate); - // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); - // - // Boolean isGetTip = canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; - // if (!isGetTip) { - // logger.error("takeTip fail"); - // } - // return AppRet.success(isGetTip); - // } - // - // @ExtApiFn(name = "HBot移动到", group = "单步测试") - // public void hbotMoveTo(Integer x, Integer y) throws AppException, InterruptedException { - // hbotCheckAndMoveTo(new Pos2d(x, y)); - // } - // - // @ExtApiFn(name = "HBot移动到小瓶缓冲液X孔", group = "单步测试") - // public void hbotMoveToSmallBottleGroup(ConsumableGroup group, Integer Xhole) - // throws AppException, InterruptedException { - // BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); - // if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) { - // throw new AppException(A8kEcode.ParamOutOfRange.index); - // } - // Pos2d pos = posInfo.cgetSmallBottleBufferPos(group.off, Xhole); - // hbotCheckAndMoveTo(pos); - // } - // - // @ExtApiFn(name = "HBot移动到探测物质X孔", group = "单步测试") - // public void hbotMoveToDetectMaterialPos(ConsumableGroup group, Integer Xhole) - // throws AppException, InterruptedException { - // BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); - // if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) { - // throw new AppException(A8kEcode.ParamOutOfRange.index); - // } - // Pos2d pos = posInfo.cgetDetectMaterialPos(group.off, Xhole); - // hbotCheckAndMoveTo(pos); - // } - // - // @ExtApiFn(name = "HBot移动到大瓶缓冲液X孔", group = "单步测试") - // public void hbotMoveToLargeBottleGroup(ConsumableGroup ch) throws AppException, InterruptedException { - // LargeBottleBufferPos posInfo = pp.getLargeBottleBufferPosInfo(); - // Pos2d pos = posInfo.cgetBottlePos(ch.off); - // hbotCheckAndMoveTo(pos); - // } - // - // @ExtApiFn(name = "HBot移动到急诊位", group = "单步测试") - // public void hbotMoveToEmergencyPos() throws AppException, InterruptedException { - // hbotCheckAndMoveTo(pp.getEmergencyPos()); - // } - - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // 坐标获取工具 - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // - // @ExtApiFn(name = "Hbot使能", group = "坐标获取工具") - // public void hBotEnable() throws AppException, InterruptedException { - // canBus.hbotEnable(MId.HbotM, 1); - // } - // - // @ExtApiFn(name = "Hbot失能", group = "坐标获取工具") - // public void hBotDisable() throws AppException, InterruptedException { - // canBus.hbotEnable(MId.HbotM, 0); - // } - // - // @ExtApiFn(name = "Z轴使能", group = "坐标获取工具") - // public void zAxisEnable() throws AppException, InterruptedException { - // pipetteCtrlModule.zMotorEnable(1); - // } - // - // @ExtApiFn(name = "Z轴失能", group = "坐标获取工具") - // public void zAxisDisable() throws AppException, InterruptedException { - // pipetteCtrlModule.zMotorEnable(0); - // } - - // @ExtApiFn(name = "归零读取Z轴坐标", group = "坐标获取工具") - // public AppRet readZAxisPosByMoveToZero() throws HardwareException, InterruptedException { - // return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PipetteModZM, timep.getActionOvertime())); - // } - // - // @ExtApiFn(name = "打开扫码器", group = "坐标获取工具") - // public void openCodeScaner(Boolean power) throws AppException, InterruptedException { - // if (power) { - // canBus.codeScanerStartScan(MId.PipetteModCodeScanner); - // } else { - // canBus.codeScanerStopScan(MId.PipetteModCodeScanner); - // } - // } - // - // Pos2d hbotRefPos = new Pos2d(0, 0); - // - // @ExtApiFn(name = "设置HBOT参考坐标", group = "坐标获取工具") - // public void setHbotRefPos(Integer x, Integer y) throws AppException, InterruptedException { - // hbotRefPos.x = x; - // hbotRefPos.y = y; - // } - - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // hbot移动到并扫码 - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - // private AppRet hBotMoveToAndScan(Pos2d pos) throws AppException, InterruptedException { - // hbotCheckAndMoveTo(pos); - // canBus.codeScanerStartScan(MId.PipetteModCodeScanner); - // String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, timep.getScancodeOvertime()); - // return AppRet.success(result); - // } - // - // // 扫描板夹仓二维码 - // @ExtApiFn(name = "扫描板夹仓二维码", group = "扫码") - // public AppRet scanPlatesCode(ConsumableGroup ch) throws AppException, InterruptedException { - // var posInfo = pp.getPlates2dCodeScanPosInfo(); - // return hBotMoveToAndScan(posInfo.cgetScanPos(ch.off)); - // } - // -// // 扫描缓冲液二维码 -// @ExtApiFn(name = "扫描缓冲液区二维码", group = "扫码") -// public AppRet scanBottleBuffersCode(ConsumableGroup group) throws AppException, InterruptedException { -// BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); -// return hBotMoveToAndScan(posInfo.cgetScanPos(group.ordinal())); -// } - // - // // 扫描大缓冲液二维码 - // @ExtApiFn(name = "扫描大缓冲液二维码", group = "扫码") - // public AppRet scanBigBottleBufferCode(ConsumableGroup group) - // throws AppException, InterruptedException { - // LargeBottleBufferPos posInfo = pp.getLargeBottleBufferPosInfo(); - // return hBotMoveToAndScan(posInfo.cgetScanPos(group.off)); - // } - - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // hbot取样品 - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - public Boolean getXPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 0); - } - - public Boolean getYPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 1); - } - - public Boolean getTipPPS() throws AppException { - return canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; - } - - public String getPos() throws AppException { - Pos2d pos = canBus.hbotReadPos(MId.HbotM); - return pos.toString(); - } - - // public String getHbotRelaPos() throws AppException { - // Pos2d pos = canBus.hbotReadPos(MId.HbotM); - // pos.x -= hbotRefPos.x; - // pos.y -= hbotRefPos.y; - // return pos.toString(); - // } -} diff --git a/src/main/java/a8k/service/bak_devicectrl/ctrl/PipetteGunCtrlService.java b/src/main/java/a8k/service/bak_devicectrl/ctrl/PipetteGunCtrlService.java deleted file mode 100644 index 4a7ded9..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/ctrl/PipetteGunCtrlService.java +++ /dev/null @@ -1,32 +0,0 @@ -package a8k.service.bak_devicectrl.ctrl; - - -import jakarta.annotation.PostConstruct; -import org.slf4j.Logger; -import org.springframework.stereotype.Component; - -/** - * - * 移液枪功能 - * 1. - * - * - * - */ - -@Component -public class PipetteGunCtrlService { - static Logger logger = org.slf4j.LoggerFactory.getLogger(PipetteGunCtrlService.class); - - public Integer a; - - @PostConstruct - void init() throws NoSuchMethodException { - System.out.println("PipetteGunCtrlService init"); - } - - //取样 - - // - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/ctrl/ReactionPlatesTransmitCtrl.java b/src/main/java/a8k/service/bak_devicectrl/ctrl/ReactionPlatesTransmitCtrl.java deleted file mode 100644 index fe6c2a4..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/ctrl/ReactionPlatesTransmitCtrl.java +++ /dev/null @@ -1,211 +0,0 @@ -package a8k.service.bak_devicectrl.ctrl; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.type.exception.AppException; -import a8k.utils.opt_algo.A8kOptAlgo; -import a8k.type.*; -import a8k.type.appret.AppRet; -import a8k.controler.extapi.utils.*; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.hardware.type.a8kcanprotocol.IOId; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.hardware.type.regindex.RegIndex; -import a8k.service.bak_devicectrl.param.DebugParam; -import a8k.service.bak_devicectrl.param.PosParam; -import a8k.service.bak_devicectrl.param.TimeParam; -import jakarta.annotation.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.ReactionPlatesTransmitCtrl) -public class ReactionPlatesTransmitCtrl { - static Logger logger = LoggerFactory.getLogger(ReactionPlatesTransmitCtrl.class); - EnginnerParamReader hpReader = new EnginnerParamReader(ReactionPlatesTransmitCtrl.class); - - - @Resource - A8kCanBusService canBus; - @Resource - TimeParam timep; - @Resource - PosParam pp; - @Resource - DebugParam dp; - - - public void checkBeforeMoveTrunable() throws AppException { - //板夹仓卡板检测 - if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS)) { - logger.error("PlateBoxPlateStuckPPS is trigger"); - throw new AppException(A8kEcode.PlateStuckDetectorSensorTrigger.index); - } - - //检查钩板电机是否处于终点位置 - if (!canBus.getIOState(IOId.PullerMZeroPPS)) { - logger.error("PullerM is not in zero pos"); - throw new AppException(A8kEcode.PullerMInitPosError.index); - } - - //检查板夹仓光电是否处于起点位置 - if (!canBus.getIOState(IOId.PusherMZeroPPS)) { - logger.error("PusherM is not in zero pos"); - throw new AppException(A8kEcode.PusherMInitPosError.index); - } - } - - public void checkBeforeMovePlateBox() throws AppException { - if (!canBus.getIOState(IOId.PusherMZeroPPS)) { - logger.error("PusherM is not in zero pos "); - throw new AppException(A8kEcode.PusherMInitPosError.index); - } - } - - public void modGroupMoveToZeroQuick() throws AppException, InterruptedException { - //光学模组初始化 - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, timep.getActionOvertime()); - - //板夹仓初始化 - checkBeforeMovePlateBox(); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, timep.getActionOvertime()); - - //转盘归零 - checkBeforeMoveTrunable(); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.IncubatorRotateCtrlM, timep.getActionOvertime()); - } - - private void trunableMoveTo(Integer pos) throws AppException, InterruptedException { - checkBeforeMoveTrunable(); - //限制pos在 0--> 36000之间 - pos = pos % 36000; - if (pos < 0) { - pos += 36000; - } - - //先移动半个间距,用来检测是否发生卡板 - Integer nowPos = canBus.stepMotorReadPos(MId.IncubatorRotateCtrlM); - if (nowPos < pos) { - canBus.stepMotorEasyMoveByBlock(MId.IncubatorRotateCtrlM, pp.getTurntablePosSpacing(), timep.getActionOvertime()); - } else if (nowPos > pos) { - canBus.stepMotorEasyMoveByBlock(MId.IncubatorRotateCtrlM, -pp.getTurntablePosSpacing(), timep.getActionOvertime()); - } - - //解决齿轮间隙的问题 - if (nowPos < pos) { - canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM, pos, timep.getActionOvertime()); - } else { - canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM, pos - 300/**/, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM, pos, timep.getActionOvertime()); - } - } - - /* ======================================================================================= - 基础操作 - =======================================================================================*/ - - @ExtApiFn(name = "转盘移动到推板位", group = "单步") - public void trunableMoveToPushPos(IncubatorPos index) throws AppException, InterruptedException { - trunableMoveTo(pp.getTurntablePushPos0() + index.off * pp.getTurntablePosSpacing()); - } - - @ExtApiFn(name = "转盘移动到出板位", group = "单步") - public void trunableMoveToPullPos(IncubatorPos index) throws AppException, InterruptedException { - trunableMoveTo(pp.getTurntablePullPos0() + index.off * pp.getTurntablePosSpacing()); - - } - - @ExtApiFn(name = "转盘移动到滴定位", group = "单步") - public void trunableMoveToDropLiquidPos(IncubatorPos index) throws AppException, InterruptedException { - trunableMoveTo(pp.getTurntableDropLiquidPos0() + index.off * pp.getTurntablePosSpacing()); - } - - - @ExtApiFn(name = "推板", group = "单步") - public AppRet pushPlate(ConsumableGroup PBCh, IncubatorPos turntablePosIndex) throws AppException, InterruptedException { - trunableMoveToPushPos(turntablePosIndex); - canBus.stepMotorEasyMoveToBlock(MId.PlatesBoxYM, pp.getPBCh0Pos() + PBCh.off * pp.getPBChSpacing(), timep.getActionOvertime()); - canBus.plateCodeScanerPushCardAndScanBlock(MId.PlatesBoxScanner, pp.getPusherEndPos(), 10000); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, timep.getActionOvertime()); - return AppRet.success(canBus.plateCodeScannerReadCode(MId.PlatesBoxScanner)); - } - - public void pushPlateQuick(ConsumableGroup PBCh, IncubatorPos turntablePosIndex) throws AppException, InterruptedException { - trunableMoveToPushPos(turntablePosIndex); - canBus.stepMotorEasyMoveToBlock(MId.PlatesBoxYM, pp.getPBCh0Pos() + PBCh.off * pp.getPBChSpacing(), timep.getActionOvertime()); - canBus.stepMotorEasyMoveToBlock(MId.PlatesBoxPusherM, pp.getPusherEndPos(), timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, timep.getActionOvertime()); - } - - - @ExtApiFn(name = "拉板", group = "单步操作") - public void pullPlate(IncubatorPos turntablePosIndex) throws AppException, InterruptedException { - trunableMoveToPullPos(turntablePosIndex); - canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, pp.getOptScanScandbyPos(), timep.getActionOvertime()); - canBus.stepMotorEasyMoveToBlock(MId.OptModPullM, pp.getPullerTargetPos(), timep.getActionOvertime()); - if (!canBus.getIOState(IOId.PullerMEndPPS)) { - logger.error("pull plate fail"); - throw new AppException(A8kEcode.PullPlateFail.index); - } - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, timep.getActionOvertime()); - } - - @ExtApiFn(name = "丢板", group = "单步操作") - public void dropPlate() throws AppException, InterruptedException { - canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, pp.getPlateDropPos(), timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, pp.getOptScanScandbyPos(), timep.getActionOvertime()); - } - - // @EnginnerPageAction(name = "显示板夹扫码原始曲线", group = "辅助调试") - // public AppRet readPlateScanCurve() throws HardwareException, InterruptedException { - // List scanDataCurve = canBus.plateCodeScanerReadRawResult(MId.PlatesBoxScanner); - // List refLine = new ArrayList<>(); - // for (int i = 0; i < 15; i++) { - // refLine.add(i * 12 + 6); - // } - // return AppRet.success(new A8kScanCurve(scanDataCurve, refLine)); - // } - - private AppRet packetOptDisplayScanCurve(List scanDataCurve) { - A8kScanCurve scanCurve = new A8kScanCurve(); - logger.info("pointNum: " + scanDataCurve.size()); - scanCurve.scanDataCurve = A8kOptAlgo.preProcessOptData(scanDataCurve); - logger.info("pointNum: " + scanCurve.scanDataCurve.size()); - scanCurve.refCurve = A8kOptAlgo.preProcessOptData(scanDataCurve); - scanCurve.refLine = new ArrayList<>(); - for (int i = 1; i < 6; i++) { - scanCurve.refLine.add(40 * i); - } - return AppRet.success(scanCurve); - } - - @ExtApiFn(name = "T光学扫码", group = "光学调试") - public AppRet optTScan(OptScanDirection direction, Integer scanerGain) throws AppException, InterruptedException { - // canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_t_pos_offset, getTOptPosOffset()); - // canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_t_reverse_scan_pos_offset,getTOptPosOffset()-1200); - // canBus.optTStartScanBlock(MId.OptMod, direction, getOptTLasterGain(), scanerGain, getOptScanOvertime()); - // return packetOptDisplayScanCurve(canBus.optReadRaw(MId.OptMod)); - return AppRet.fail(A8kEcode.CmdNotSupport.index); - } - - @ExtApiFn(name = "F光学扫码", group = "光学调试") - public AppRet optFScan(OptScanDirection direction, Integer scanerGain) throws AppException, InterruptedException { - //getFOptPosOffset - canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_f_pos_offset, pp.getFOptPosOffset()); - canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_f_reverse_scan_pos_offset, pp.getFOptPosOffset() - 1200); - - canBus.optFStartScanBlock(MId.OptMod, direction, pp.getOptFLasterGain(), scanerGain, timep.getOptScanOvertime()); - return packetOptDisplayScanCurve(canBus.optReadRaw(MId.OptMod)); - } - - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/ctrl/SamplesPreProcesCtrl.java b/src/main/java/a8k/service/bak_devicectrl/ctrl/SamplesPreProcesCtrl.java deleted file mode 100644 index ca9f7b6..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/ctrl/SamplesPreProcesCtrl.java +++ /dev/null @@ -1,268 +0,0 @@ -package a8k.service.bak_devicectrl.ctrl; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.type.exception.AppException; -import a8k.type.appret.AppRet; -import a8k.controler.extapi.utils.*; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.service.bak_devicectrl.param.DebugParam; -import a8k.service.bak_devicectrl.param.TimeParam; -import a8k.service.bak_devicectrl.param.PosParam; -import a8k.utils.ZEQ; -import jakarta.annotation.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.SamplesPreProcesCtrl) -public class SamplesPreProcesCtrl { - static Logger logger = LoggerFactory.getLogger(SamplesPreProcesCtrl.class); - - static class ORDER { - - static final int moduleReset = 1; - static final int moduleEnable = 2; - static final int moduleDisable = 3; - static final int takeTubeAndJudgeTubeExist = 4; - static final int shakeTube = 5; - static final int takeTubeCap = 6; - static final int pushBackTubeCapAndTakeBakTube = 7; - static final int setAeroslFanPower = 8; - } - - @Resource - A8kCanBusService canBus; - @Resource - TimeParam timep; - @Resource - PosParam pp; - @Resource - DebugParam dp; - - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // PRIVATE - // ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - private void modGroupMoveToZero() throws AppException, InterruptedException { - - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperClosePos(), timep.getActionOvertime()); - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperZeroYPos(), timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModClampingM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModShakeM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToBlock(MId.ShakeModShakeM, 90, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, -2, timep.getActionOvertime()); - } - - - private void modGroupMoveToZeroQuick() throws AppException, InterruptedException { - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModClampingM, timep.getActionOvertime()); - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModShakeM, timep.getActionOvertime()); - modGroupMoveToZero(); - } - - @ExtApiFn(name = "模块复位", group = "辅助调试", order = ORDER.moduleReset) - public void moduleReset() throws AppException, InterruptedException { - modGroupMoveToZero(); - } - - @ExtApiFn(name = "模块使能", group = "辅助调试", order = ORDER.moduleEnable) - public void moduleEnable() throws AppException, InterruptedException { - canBus.miniServoEnable(MId.ShakeModGripperSV, 1); - canBus.miniServoEnable(MId.ShakeModGripperYSV, 1); - canBus.stepMotorEnable(MId.ShakeModClampingM, 1); - canBus.stepMotorEnable(MId.ShakeModGripperZM, 1); - canBus.stepMotorEnable(MId.ShakeModShakeM, 1); - canBus.stepMotorEnable(MId.ShakeModShakeM, 1); - } - - @ExtApiFn(name = "模块失能", group = "辅助调试", order = ORDER.moduleDisable) - public void moduleDisable() throws AppException, InterruptedException { - canBus.stepMotorEnable(MId.ShakeModClampingM, 1); - canBus.stepMotorEasyMoveByBlock(MId.ShakeModClampingM, 10, timep.getActionOvertime()); - - - canBus.miniServoEnable(MId.ShakeModGripperSV, 0); - canBus.miniServoEnable(MId.ShakeModGripperYSV, 0); - canBus.stepMotorEnable(MId.ShakeModClampingM, 0); - canBus.stepMotorEnable(MId.ShakeModGripperZM, 0); - canBus.stepMotorEnable(MId.ShakeModShakeM, 0); - canBus.stepMotorEnable(MId.ShakeModShakeM, 0); - } - - @ExtApiFn(name = "夹紧试管", group = "辅助调试", order = ORDER.moduleDisable) - public void clampTube() throws AppException, InterruptedException { - canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, pp.getShakeClampingPos(), timep.getActionOvertime()); - } - - - void tryClampTube() throws AppException, InterruptedException { - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos() - 20, timep.getActionOvertime()); - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos(), timep.getActionOvertime()); - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos() - 20, timep.getActionOvertime()); - } - - /** - * 取试管帽,如果试管帽存在, - * @param highTube true/false - */ - @ExtApiFn(name = "取试管", group = "单步", order = ORDER.takeTubeAndJudgeTubeExist) - public AppRet takeTubeAndJudgeTubeExist(Boolean highTube) throws AppException, InterruptedException { - /* - * 校验: - * 1.当前摇匀模组设计到的电机是否都处于待机位 - */ - - //Z轴在原点 - if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { - throw new AppException(MId.ShakeModGripperZM, A8kEcode.MNotInZeroPos.index); - } - - //Y轴在零点附近 - if (!ZEQ.IntEq(canBus.miniServoReadPos(MId.ShakeModGripperYSV), pp.getGripperZeroYPos(), 30)) { - throw new AppException(MId.ShakeModGripperYSV, A8kEcode.MNotInZeroPos.index); - } - - //夹爪没有零位置 - if (!ZEQ.IntEq(canBus.miniServoReadPos(MId.ShakeModGripperSV), pp.getGripperClosePos(), 30)) { - throw new AppException(MId.ShakeModGripperSV, A8kEcode.MNotInZeroPos.index); - } - - //检查摇匀夹紧是否在零位 - if (!canBus.stepMotorReadIoState(MId.ShakeModClampingM, 0)) { - throw new AppException(MId.ShakeModClampingM, A8kEcode.MNotInZeroPos.index); - } - - boolean isHighBlood = highTube; - boolean tubeCapExist = true; - Integer gripperJudgeCapZPos = isHighBlood ? pp.getGripperJudgeHTubeCapZPos() : pp.getGripperJudgeSTubeCapZPos(); - Integer gripperTakeTubeZPos = isHighBlood ? pp.getGripperTakeHTubeZPos() : pp.getGripperTakeSTubeZPos(); - Integer gripperShakeZPos = pp.getGripperShakeTubeZPos(); - - //固定试管架 - canBus.miniServoMoveToBlock(MId.ShakeModTubeScanerClampingSV, 900, timep.getActionOvertime()); - //试管夹紧移动到终点位置 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, 70, timep.getActionOvertime()); - //试管摇匀移动到90度 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModShakeM, pp.getShakeModShakeMStandbyPos(), timep.getActionOvertime()); - //Y轴向前移动 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperTakeTubeYPos(), timep.getActionOvertime()); - //打开夹爪 - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); - // //Z轴下移动到试管帽有无检测位 - // canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperJudgeCapZPos, timep.getActionOvertime()); - //闭合夹爪检测试管帽是否存在 - // canBus.miniServoRotateWithTorque(MId.ShakeModGripperSV, -400); - // Thread.sleep(timep.getTubeCapJudgeDelayTime()); - // if (ZEQ.IntEq(canBus.miniServoReadPos(MId.ShakeModGripperSV), pp.getGripperClosePos(), 30)) { - // logger.info("试管帽不存在"); - // tubeCapExist = false; - // } - if (dp.getDebugMode() || tubeCapExist) { - //打开夹爪 - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); - //Z轴下移动到取试管位置 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperTakeTubeZPos, timep.getActionOvertime()); - //夹爪夹紧 - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos(), timep.getActionOvertime()); - canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperTakeTubeZPos - 100, timep.getActionOvertime()); - tryClampTube(); - - //Z轴上移动到零位 - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - //夹爪夹紧 - //Y轴移动到摇匀位 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos() - 50, timep.getActionOvertime()); //该动作是为了消除齿轮间隙 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos(), timep.getActionOvertime()); - //Z轴下移动到摇匀位放试管的位置 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperShakeZPos, timep.getActionOvertime()); - //夹紧试管 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, pp.getShakeClampingPos(), timep.getActionOvertime()); - //松开夹爪,放置试管 - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); - //Z轴上移动到零位 - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - //Z轴归零,校准一次位置 - canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - //Y轴移动到零位 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperZeroYPos(), timep.getActionOvertime()); - } else { - modGroupMoveToZeroQuick(); - } - return AppRet.success(tubeCapExist); - } - - @ExtApiFn(name = "摇匀", group = "单步", order = ORDER.shakeTube) - public void shakeTube(Integer shakeDegree, Integer times) throws AppException, InterruptedException { - var standByPos = pp.getShakeModShakeMStandbyPos(); - var startPos = standByPos - shakeDegree; - var endPos = standByPos + shakeDegree; - canBus.stepMotorEasyReciprocatingMotion(MId.ShakeModShakeM, startPos, endPos, times); - canBus.waitForMod(MId.ShakeModShakeM, timep.getActionOvertime()); - } - - @ExtApiFn(name = "取试管帽", group = "单步", order = ORDER.takeTubeCap) - public void takeTubeCap() throws AppException, InterruptedException { - //Y移动到取试管帽位置 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos(), timep.getActionOvertime()); - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); - //Z下移动到取试管帽位置 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, pp.getGripperTakeCapZPos() + 3, timep.getActionOvertime()); - //闭合夹爪 - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos(), timep.getActionOvertime()); - //Z上移动到零位 - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - // tryClampTube(); - // canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos()-30, timep.getActionOvertime()); - - - //Y移动到待机位 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperZeroYPos(), timep.getActionOvertime()); - } - - /** - * 盖试管帽,并将试管移动回试管架中 - */ - @ExtApiFn(name = "盖试管帽并放回试管架", group = "单步", order = ORDER.pushBackTubeCapAndTakeBakTube) - public void pushBackTubeCapAndTakeBakTube() throws AppException, InterruptedException { - //移动Y轴到取试管帽位置 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos(), timep.getActionOvertime()); - //移动Z轴盖帽 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, pp.getGripperTakeCapZPos() + 20, timep.getActionOvertime()); - //打开试管夹 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, 70, timep.getActionOvertime()); - //移动Z轴到零位 - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - - tryClampTube(); - - - //移动Y轴到方式管的位置 - canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperTakeTubeYPos(), timep.getActionOvertime()); - //移动Z轴到取试管位置 - canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, pp.getGripperTakeHTubeZPos() - 20, timep.getActionOvertime()); - //打开夹爪 - canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); - //Z轴上移动到零位 - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); - //设备快速归零 - modGroupMoveToZeroQuick(); - } - - /** - * 气溶胶风扇控制 - */ - @ExtApiFn(name = "气溶胶风扇控制", group = "其他", order = ORDER.setAeroslFanPower) - public void setAeroslFanPower(Boolean enable) throws Exception { - if (enable) { - canBus.fanControlerSetSpeed(MId.WbTubeFanMod, 99); - } else { - canBus.fanControlerSetSpeed(MId.WbTubeFanMod, 0); - } - } -} diff --git a/src/main/java/a8k/service/bak_devicectrl/ctrl/TubeRackMoveCtrl.java b/src/main/java/a8k/service/bak_devicectrl/ctrl/TubeRackMoveCtrl.java deleted file mode 100644 index 78e92c8..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/ctrl/TubeRackMoveCtrl.java +++ /dev/null @@ -1,298 +0,0 @@ -package a8k.service.bak_devicectrl.ctrl; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.type.exception.AppException; -import a8k.type.TargetPosMeasureDirection; -import a8k.type.appret.AppRet; -import a8k.controler.extapi.utils.*; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.hardware.type.a8kcanprotocol.IOId; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.service.bak_devicectrl.param.DebugParam; -import a8k.service.bak_devicectrl.param.PosParam; -import a8k.service.bak_devicectrl.param.TimeParam; -import jakarta.annotation.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.TubeRackMoveCtrl) -public class TubeRackMoveCtrl { - static Logger logger = LoggerFactory.getLogger(TubeRackMoveCtrl.class); - - static class ORDER { - static final int moveTubeRackTo = 1; - static final int scanClampModClamp = 2; - static final int scanClampModRelease = 3; - static final int tryEnterTubeRack = 4; - static final int tryEjectTubeRack = 5; - static final int tubeRackMoveToEnterPos = 6; - static final int moveTubeRackToExitPos = 7; - static final int moveTubeRackToScanPos = 8; - static final int moveTubeToScanPosAndScan = 9; - static final int moveTubeToPreProcessPos = 10; - static final int moveTubeToAltitJudgXPos = 11; - static final int judgeTubeExist = 12; - - } - - @Resource - private A8kCanBusService canBus; - @Resource - TimeParam timep; - @Resource - PosParam pp; - @Resource - DebugParam dp; - - - private Boolean isTubeExist() throws AppException { - return canBus.getIOState(IOId.TubeExistPPS); - } - - private Boolean isTubeRackInEnterPos() throws AppException { - return canBus.getIOState(IOId.InfeedPPS); - } - - private Boolean isTubeRackInExitPos() throws AppException { - return canBus.getIOState(IOId.OutfeedPPS); - } - - private Boolean isHighTube() throws AppException { - return canBus.getIOState(IOId.TubeHeightPPS); - } - - - /** - * 移动试管到扫码位置 - * @param tubeIndex 试管索引 - */ - private void moveTubeToScanPos(Integer tubeIndex) throws AppException, InterruptedException { - var scanPos = pp.getTScanXPos() + tubeIndex * pp.getTubeSpacing(); - scanClampModClamp(); - moveTubeRackTo(scanPos, TargetPosMeasureDirection.NEGATIVE, false); - } - - /** - * 移动<试管架>到试管架扫码位置 - */ - private void moveTubeRackToScanPos() throws AppException, InterruptedException { - moveTubeRackTo(pp.getTRScanXPos(), TargetPosMeasureDirection.POSITIVE, false); - } - - /*========================================================================================= - * 基础方法 - *========================================================================================*/ - - /** - * 移动试管架到指定位置 - * @param pos 指定位置 - * @throws AppException 硬件异常 - * @throws InterruptedException 打断异常 - */ - @ExtApiFn(name = "移动到坐标", group = "基础方法", order = ORDER.moveTubeRackTo) - public void moveTubeRackTo(Integer pos, TargetPosMeasureDirection moveDiretion, Boolean moveToZero) throws AppException, InterruptedException { - if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { - throw new AppException(A8kEcode.ShakeModGripperZMNotInZeroPos.index); - } - //打开扫码夹具 - scanClampModRelease(); - - //使能电机 - canBus.stepMotorEnable(MId.FeedingModXM, 1); - if (moveToZero) { - canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.FeedingModXM, timep.getActionOvertime()); - } - - // 处理试管架和试管架之间的间隙导致的运行位置误差 - Integer nowPos = canBus.stepMotorReadPos(MId.FeedingModXM); - if (TargetPosMeasureDirection.POSITIVE.equals(moveDiretion)) { - if (nowPos > (pos + 1)) { - canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos + 30, timep.getActionOvertime()); - } - } else if (TargetPosMeasureDirection.NEGATIVE.equals(moveDiretion)) { - if (nowPos < (pos - 1)) { - canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos - 30, timep.getActionOvertime()); - } - } - canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos, timep.getActionOvertime()); - - } - - /** - * 扫描夹紧机构夹紧 - */ - @ExtApiFn(name = "扫描夹紧机构夹紧", group = "基础方法", order = ORDER.scanClampModClamp) - public void scanClampModClamp() throws AppException, InterruptedException { - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 1); - canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, 900); - canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, timep.getActionOvertime()); - } - - /** - * 扫描夹紧机构复位 - */ - @ExtApiFn(name = "扫描夹紧机构复位", group = "基础方法", order = ORDER.scanClampModRelease) - public void scanClampModRelease() throws AppException, InterruptedException { - canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 1); - canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, 0); - canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, timep.getActionOvertime()); - } - - - public Boolean getTHchOuterPPS() throws AppException { - return canBus.getIOState(IOId.THChOuterPPS); - } - - public Boolean getTHchInterPPS() throws AppException { - return canBus.getIOState(IOId.THChInterPPS); - } - - - /*========================================================================================= - * 片段 - *========================================================================================*/ - - /** - * 移动试管架到入口位置 - */ - private void tubeRackMoveToEnterPos() throws AppException, InterruptedException { - moveTubeRackTo(pp.getTREnterXPos(), TargetPosMeasureDirection.NOTCARE, true); - } - - /** - * 移动<试管架>到出口位置 - */ - private void moveTubeRackToExitPos() throws AppException, InterruptedException { - moveTubeRackTo(pp.getTRExitXPos(), TargetPosMeasureDirection.NOTCARE, false); - moveTubeRackTo(pp.getTRExitXPos() - 10, TargetPosMeasureDirection.NOTCARE, false); - } - - /** - * 移动<试管架>到出口位置 - */ - @ExtApiFn(name = "入料", group = "单步", order = ORDER.moveTubeRackToExitPos) - public void enterTubeHolder() throws AppException, InterruptedException { - if (getTHchInterPPS() || getTHchOuterPPS()) { - throw new AppException(A8kEcode.TubeXChannelIsNotEmpty.index); - } - tubeRackMoveToEnterPos(); - try { - canBus.stepMotorEasyRotate(MId.FeedingModInfeedM, -1); - for (int i = 0; i < timep.getInfeedOvertime() / 100; i++) { - Thread.sleep(100); - if (getTHchInterPPS()) { - break; - } - } - Thread.sleep(1000); - canBus.stepMotorStop(MId.FeedingModInfeedM); - if (!getTHchInterPPS()) { - throw new AppException(A8kEcode.InfeedOvertimeFail.index); - } - } finally { - canBus.moduleStop(MId.FeedingModInfeedM); - } - } - - @ExtApiFn(name = "出料", group = "单步", order = ORDER.moveTubeRackToExitPos) - public void ejectTubeHolder() throws AppException, InterruptedException { - moveTubeRackToExitPos(); - try { - canBus.stepMotorEasyRotate(MId.FeedingModOutfeedM, 1); - for (int i = 0; i < timep.getOutfeedOvertime() / 100; i++) { - Thread.sleep(100); - logger.info("getTHchInterPPS:{} getTHchOuterPPS:{}", getTHchInterPPS(), getTHchOuterPPS()); - if (!getTHchInterPPS() && !getTHchOuterPPS()) { - break; - } - } - Thread.sleep(1000); - canBus.stepMotorStop(MId.FeedingModOutfeedM); - if (getTHchInterPPS() || getTHchOuterPPS()) { - throw new AppException(A8kEcode.OutfeedOvertimeFail.index); - } - } finally { - canBus.moduleStop(MId.FeedingModOutfeedM); - } - } - - /** - * 移动试管架到扫码并扫码 - */ - @ExtApiFn(name = "扫描<试管架>编码", group = "单步扫码", order = ORDER.moveTubeRackToScanPos) - public AppRet moveTubeRackToScanPosAndScan() throws AppException, InterruptedException { - String result; - moveTubeRackToScanPos(); - - scanClampModClamp(); - canBus.codeScanerStartScan(MId.FeedingModScannerMod); - result = canBus.codeScanerWaittingForResult(MId.FeedingModScannerMod, 1000); - scanClampModRelease(); - if (result == null || result.isEmpty()) { - return AppRet.fail(A8kEcode.ScanTimeout.index); - } - return AppRet.success(result); - } - // - // 试管移动 - // - - /** - * 移动试管到扫码位置,并扫码 - * @param tubeIndex 试管索引 - */ - @ExtApiFn(name = "扫描<试管X>编码", group = "单步扫码", order = ORDER.moveTubeToScanPosAndScan) - public AppRet moveTubeToScanPosAndScan(Integer tubeIndex) throws AppException, InterruptedException { - moveTubeToScanPos(tubeIndex); - try { - scanClampModClamp(); - - canBus.codeScanerStartScan(MId.FeedingModScannerMod); - canBus.miniServoRotateWithTorque(MId.ShakeModTubeScanerClampingSV, pp.getTubeScanServoTorque()); - String result = canBus.codeScanerWaittingForResult(MId.FeedingModScannerMod, pp.getTubeScanOvertime()); - if (result == null || result.isEmpty()) { - return AppRet.fail(A8kEcode.ScanTimeout.index); - } - return AppRet.success(result); - } finally { - canBus.moduleStop(MId.ShakeModTubeScanerClampingSV); - canBus.moduleStop(MId.FeedingModScannerMod); - scanClampModRelease(); - } - } - - /** - * 移动试管到试管预处理的位置 - * @param tubeIndex 试管索引 - */ - @ExtApiFn(name = "移动<试管N>摇匀位", group = "单步-处理", order = ORDER.moveTubeToPreProcessPos) - public void moveTubeToPreProcessPos(Integer tubeIndex) throws AppException, InterruptedException { - moveTubeRackTo(pp.getTPreProcessXPos() + tubeIndex * pp.getTubeSpacing(), TargetPosMeasureDirection.POSITIVE, false); - } - - /** - * 移动试管到试管高低判断位置 - * @param tubeIndex 试管索引 - */ - @ExtApiFn(name = "判断<试管N>高低", group = "单步-其他", order = ORDER.moveTubeToAltitJudgXPos) - public AppRet moveTubeToAltitJudgXPos(Integer tubeIndex) throws AppException, InterruptedException { - moveTubeRackTo(pp.getTAltitJudgXPos() + tubeIndex * pp.getTubeSpacing(), TargetPosMeasureDirection.NEGATIVE, false); - return AppRet.success(isHighTube()); - } - - - /** - * 移动试管到试管有无判断位置 - * @param tubeIndex 试管索引 - */ - @ExtApiFn(name = "判断<试管N>是否存在", group = "单步-其他", order = ORDER.judgeTubeExist) - public AppRet judgeTubeExist(Integer tubeIndex) throws AppException, InterruptedException { - moveTubeRackTo(pp.getTExistJudgXPos() + tubeIndex * pp.getTubeSpacing(), TargetPosMeasureDirection.NEGATIVE, false); - return AppRet.success(isTubeExist()); - } - - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/param/DebugParam.java b/src/main/java/a8k/service/bak_devicectrl/param/DebugParam.java deleted file mode 100644 index af152dc..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/param/DebugParam.java +++ /dev/null @@ -1,29 +0,0 @@ -package a8k.service.bak_devicectrl.param; - -import a8k.controler.extapi.utils.ExtApiTab; -import a8k.controler.extapi.utils.ExtApiFn; -import a8k.controler.extapi.utils.ExtApiStatu; -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.DebugParam) -public class DebugParam { - - Boolean debugMode = false; - - @ExtApiFn(name = "使能调试模式", order = 1) - public void enableDebugMode() { - debugMode = true; - } - - @ExtApiFn(name = "禁用调试模式", order = 2) - public void disableDebugMode() { - debugMode = false; - } - - @ExtApiStatu(name = "调试模式") - public Boolean getDebugMode() { - return debugMode; - } -} diff --git a/src/main/java/a8k/service/bak_devicectrl/param/PosParam.java b/src/main/java/a8k/service/bak_devicectrl/param/PosParam.java deleted file mode 100644 index bae0b67..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/param/PosParam.java +++ /dev/null @@ -1,393 +0,0 @@ -package a8k.service.bak_devicectrl.param; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.type.cfg.*; -import a8k.controler.extapi.utils.*; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.PosParam) -@ExtApiParamsTab(service = PosParam.class) -public class PosParam { - EnginnerParamReader hpReader = new EnginnerParamReader(PosParam.class); - - class ORDER { - static final int getGripperOpenPos = 1; - static final int getGripperClosePos = 2; - static final int getGripperTakeCapPos = 3; - static final int getGripperTakeTubeYPos = 4; - static final int getGripperShakeYPos = 5; - static final int getGripperZeroYPos = 6; - static final int getGripperTakeHTubeZPos = 7; - static final int getGripperTakeSTubeZPos = 8; - static final int getGripperJudgeHTubeCapZPos = 9; - static final int getGripperJudgeSTubeCapZPos = 10; - static final int getGripperShakeTubeZPos = 11; - static final int getGripperTakeCapZPos = 12; - static final int getShakeClampingPos = 13; - static final int getShakeModShakeMStandbyPos = 14; - static final int getTREnterXPos = 15; - static final int getTRExitXPos = 16; - static final int getTRScanXPos = 17; - static final int getTScanXPos = 18; - static final int getTAltitJudgXPos = 19; - static final int getTExistJudgXPos = 20; - static final int getTPreProcessXPos = 21; - static final int getTubeSpacing = 22; - static final int getTubeScanServoTorque = 23; - static final int getTubeScanOvertime = 24; - static final int getPBCh0Pos = 25; - static final int getPBChSpacing = 26; - static final int getPusherEndPos = 27; - static final int getPusherScanStartPos = 28; - static final int getTurntablePushPos0 = 29; - static final int getTurntablePullPos0 = 30; - static final int getTurntableDropLiquidPos0 = 31; - static final int getTurntablePosSpacing = 32; - static final int getPullerTargetPos = 33; - static final int getPlateDropPos = 34; - static final int getOptScanScandbyPos = 35; - static final int getTOptPosOffset = 36; - static final int getFOptPosOffset = 37; - static final int getOptTLasterGain = 38; - static final int getOptFLasterGain = 39; - static final int getEmergencyPos = 40; - static final int getTipPickUpPosInfo = 41; - static final int getTipDropPos = 42; - static final int getReactionPos = 43; - static final int getBottleBufferPosInfo = 44; - static final int getPlates2dCodeScanPosInfo = 45; - static final int getLargeBottleBufferPosInfo = 46; - static final int getSampleCollectionArea = 47; - } - - - // - // SamplesPreProcessModuleCtrlService - // - - @ExtApiParam(name = "抓手张开位置", group = "抓手", order = ORDER.getGripperOpenPos) - public Integer getGripperOpenPos() { - return hpReader.getInteger("GripperOpenPos", 450); - } - - @ExtApiParam(name = "抓手闭合位置", group = "抓手", order = ORDER.getGripperClosePos) - public Integer getGripperClosePos() { - return hpReader.getInteger("GripperClosePos", 310); - } - - @ExtApiParam(name = "抓手取试管位置", group = "抓手", order = ORDER.getGripperTakeCapPos) - public Integer getGripperTakeCapPos() { - return hpReader.getInteger("GripperTakeCapPos", 355); - } - - @ExtApiParam(name = "取试管位置", group = "抓手Y轴位置", order = ORDER.getGripperTakeTubeYPos) - public Integer getGripperTakeTubeYPos() { - return hpReader.getInteger("GripperTakeTubeYPos", 3080); - } - - @ExtApiParam(name = "摇匀位置", group = "抓手Y轴位置", order = ORDER.getGripperShakeYPos) - public Integer getGripperShakeYPos() { - return hpReader.getInteger("GripperShakeYPos", 2130); - } - - @ExtApiParam(name = "待机位", group = "抓手Y轴位置", order = ORDER.getGripperZeroYPos) - public Integer getGripperZeroYPos() { - return hpReader.getInteger("GripperZeroYPos", 300); - } - - - @ExtApiParam(name = "取高试管位置", group = "抓手Z轴位置", order = ORDER.getGripperTakeHTubeZPos) - public Integer getGripperTakeHTubeZPos() { - return hpReader.getInteger("GripperTakeHTubeZPos", 739); - } - - @ExtApiParam(name = "取低试管位置", group = "抓手Z轴位置", order = ORDER.getGripperTakeSTubeZPos) - public Integer getGripperTakeSTubeZPos() { - return hpReader.getInteger("GripperTakeSTubeZPos", 983); - } - - //JudgeTubeCapZ - @ExtApiParam(name = "高试管帽有无判断位", group = "抓手Z轴位置", order = ORDER.getGripperJudgeHTubeCapZPos) - public Integer getGripperJudgeHTubeCapZPos() { - return hpReader.getInteger("GripperJudgeHTubeCapZPos", 591); - } - - @ExtApiParam(name = "低试管帽有无判断位", group = "抓手Z轴位置", order = ORDER.getGripperJudgeSTubeCapZPos) - public Integer getGripperJudgeSTubeCapZPos() { - return hpReader.getInteger("GripperJudgeSTubeCapZPos", 867); - } - - //ShakeTubeZ - @ExtApiParam(name = "摇匀放置位置", group = "抓手Z轴位置", order = ORDER.getGripperShakeTubeZPos) - public Integer getGripperShakeTubeZPos() { - return hpReader.getInteger("GripperShakeTubeZPos", 835); - } - - //TakeCapZ - @ExtApiParam(name = "取试管帽位", group = "抓手Z轴位置", order = ORDER.getGripperTakeCapZPos) - public Integer getGripperTakeCapZPos() { - return hpReader.getInteger("GripperTakeCapZPos", 835); - } - - - @ExtApiParam(name = "试管夹紧位", group = "试管夹紧模块", order = ORDER.getShakeClampingPos) - public Integer getShakeClampingPos() { - return hpReader.getInteger("ShakeClampingPos", 10); - } - - @ExtApiParam(name = "摇匀臂", group = "试管摇匀待机位", order = ORDER.getShakeModShakeMStandbyPos) - public Integer getShakeModShakeMStandbyPos() { - return hpReader.getInteger("ShakeModShakeMStandbyPos", 90); - } - - - // - // MotorTubeRackMoveCtrlService - // - - @ExtApiParam(name = "入料X位置", group = "进出料<试管架>坐标", order = ORDER.getTREnterXPos) - public Integer getTREnterXPos() { - return hpReader.getInteger("TREnterXPos", -46); - } - - @ExtApiParam(name = "出料X位置", group = "进出料<试管架>坐标", order = ORDER.getTRExitXPos) - public Integer getTRExitXPos() { - return hpReader.getInteger("TRExitXPos", 3975); - } - - @ExtApiParam(name = "试管架扫码X位置", group = "进出料<试管架>坐标", order = ORDER.getTRScanXPos) - public Integer getTRScanXPos() { - return hpReader.getInteger("TRScanXPos", 2202); - } - - @ExtApiParam(name = "试管扫码位置", group = "进出料<试管位置>信息", order = ORDER.getTScanXPos) - public Integer getTScanXPos() { - //运动方向: -> - return hpReader.getInteger("TScanXPos", 505); - - } - - @ExtApiParam(name = "试管高度判断位置", group = "进出料<试管位置>信息", order = ORDER.getTAltitJudgXPos) - public Integer getTAltitJudgXPos() { - //运动方向: -> - return hpReader.getInteger("TAltitJudgXPos", 505); - } - - @ExtApiParam(name = "试管是否存在判断位置", group = "进出料<试管位置>信息", order = ORDER.getTExistJudgXPos) - public Integer getTExistJudgXPos() { - //运动方向: <- - return hpReader.getInteger("TExistJudgXPos", 300); - } - - @ExtApiParam(name = "试管预处理位置", group = "进出料<试管位置>信息", order = ORDER.getTPreProcessXPos) - public Integer getTPreProcessXPos() { - //运动方向: <- - return hpReader.getInteger("TPreProcessXPos", 1225); - } - - @ExtApiParam(name = "试管架孔间距", group = "其他", order = ORDER.getTubeSpacing) - public Integer getTubeSpacing() { - return hpReader.getInteger("TubeSpacing", 200); - } - - @ExtApiParam(name = "扫码舵机转速(0..900)", group = "其他", order = ORDER.getTubeScanServoTorque) - public Integer getTubeScanServoTorque() { - return hpReader.getInteger("TubeScanServoTorque", 500); - } - - @ExtApiParam(name = "试管扫码超时时间", group = "其他", order = ORDER.getTubeScanOvertime) - public Integer getTubeScanOvertime() { - return hpReader.getInteger("TubeScanOvertime", 1000); - } - - - // - // - // - - - @ExtApiParam(name = "板夹仓通道0位置", group = "板夹仓参数", order = ORDER.getPBCh0Pos) - public Integer getPBCh0Pos() { - return hpReader.getInteger("PBCh0Pos", -17); - } - - @ExtApiParam(name = "板夹仓通道间距", group = "板夹仓参数", order = ORDER.getPBChSpacing) - public Integer getPBChSpacing() { - return hpReader.getInteger("PBChSpacing", 265); - } - - @ExtApiParam(name = "推杆到位坐标", group = "板夹仓参数", order = ORDER.getPusherEndPos) - public Integer getPusherEndPos() { - return hpReader.getInteger("PusherEndPos", 1160); - } - - @ExtApiParam(name = "推杆扫码开始坐标", group = "板夹仓参数", order = ORDER.getPusherScanStartPos) - public Integer getPusherScanStartPos() { - return hpReader.getInteger("PusherScanStartPos", 960); - } - - /* - * 转盘相关位置 - */ - - @ExtApiParam(name = "仓位0入板位置", group = "转盘坐标参数", order = ORDER.getTurntablePushPos0) - public Integer getTurntablePushPos0() { - return hpReader.getInteger("TurntablePushPos0", 1650); - } - - @ExtApiParam(name = "仓位0出板位置", group = "转盘坐标参数", order = ORDER.getTurntablePullPos0) - public Integer getTurntablePullPos0() { - return hpReader.getInteger("TurntablePullPos0", 19700); - } - - @ExtApiParam(name = "仓位0点滴位", group = "转盘坐标参数", order = ORDER.getTurntableDropLiquidPos0) - public Integer getTurntableDropLiquidPos0() { - return hpReader.getInteger("TurntableDropLiquidPos0", 1650 + 8950); - } - - public Integer getTurntablePosSpacing() { - return 1800; - } - - /* - * 光学模组相关 - */ - @ExtApiParam(name = "拉板目标位置", group = "光学模组坐标参数", order = ORDER.getPullerTargetPos) - public Integer getPullerTargetPos() { - return hpReader.getInteger("PullerTargetPos", 1147); - } - - @ExtApiParam(name = "丢板坐标", group = "光学模组坐标参数", order = ORDER.getPlateDropPos) - public Integer getPlateDropPos() { - return hpReader.getInteger("PlateDropPos", -349); - } - - @ExtApiParam(name = "扫描待机位", group = "光学模组坐标参数", order = ORDER.getOptScanScandbyPos) - public Integer getOptScanScandbyPos() { - return hpReader.getInteger("OptScanScandbyPos", 305); - } - - @ExtApiParam(name = "T光学扫描起始坐标", group = "光学模组坐标参数", order = ORDER.getTOptPosOffset) - public Integer getTOptPosOffset() { - //3509 - return hpReader.getInteger("TOptPosOffset", 3723); - } - - @ExtApiParam(name = "F光学扫描起始坐标", group = "光学模组坐标参数", order = ORDER.getFOptPosOffset) - public Integer getFOptPosOffset() { - return hpReader.getInteger("FOptPosOffset", 2559); - } - - @ExtApiParam(name = "T光学发光增益", group = "光学模组坐标参数", order = ORDER.getOptTLasterGain) - public Integer getOptTLasterGain() { - return hpReader.getInteger("OptTLasterGain", 0); - } - - @ExtApiParam(name = "F光学发光增益", group = "光学模组坐标参数", order = ORDER.getOptFLasterGain) - public Integer getOptFLasterGain() { - return hpReader.getInteger("OptFLasterGain", 0); - } - - - @ExtApiParam(name = "急诊位", group = "简单位置坐标", order = ORDER.getEmergencyPos) - public Pos3d getEmergencyPos() { - return new Pos3d( - 4858, - 3196, - 246 - ); - } - - @ExtApiParam(name = "TIP组位置信息", group = "HBOT位置坐标集合", order = ORDER.getTipPickUpPosInfo) - public TipPickUpPosInfo getTipPickUpPosInfo() { - return hpReader.getObject("TipPickUpPosInfo", TipPickUpPosInfo.class, - new TipPickUpPosInfo( - new Pos2d(887, -15), - new Pos2d(2413, -15), - new Pos2d(3947, -15), - 92.3, - 92.15, - 578, - 580, - 585 - )); - } - - - @ExtApiParam(name = "Tip丢弃位置", group = "简单位置坐标", order = ORDER.getTipDropPos) - public Pos3d getTipDropPos() { - return new Pos3d( - 4873, - 2563, - 661 - ); - } - - @ExtApiParam(name = "滴液反应位", group = "简单位置坐标", order = ORDER.getReactionPos) - public Pos3d getReactionPos() { - return hpReader.getObject("ReactionPos", Pos3d.class, - new Pos3d( - 0, - 0, - 0 - )); - } - - @ExtApiParam(name = "缓冲液位置", group = "HBOT位置坐标集合", order = ORDER.getBottleBufferPosInfo) - public BottleGroupsPosInfo getBottleBufferPosInfo() { - return hpReader.getObject("BottleBufferPosInfo", BottleGroupsPosInfo.class, - new BottleGroupsPosInfo( - new Pos2d(741, 937), - 1230, - 1250, - new Pos2d(579, 1097), - 320, - new BottlesPosInfo - ( - new Pos2d(160, 160), - 210, - 210, - 0 - ), - new BottlesPosInfo - ( - new Pos2d(215, 205), - 187, - 187, - 0 - ) - )); - } - - @ExtApiParam(name = "板夹仓扫码位置", group = "HBOT位置坐标集合", order = ORDER.getPlates2dCodeScanPosInfo) - public Plates2dCodeScanPos getPlates2dCodeScanPosInfo() { - return hpReader.getObject("Plates2dCodeScanPosInfo", Plates2dCodeScanPos.class,// - new Plates2dCodeScanPos( - new Pos2d(-20, 1504), - 265 - ) - ); - } - - @ExtApiParam(name = "大瓶缓冲液位置", group = "HBOT位置坐标集合", order = ORDER.getLargeBottleBufferPosInfo) - public LargeBottleBufferPos getLargeBottleBufferPosInfo() { - return hpReader.getObject("LargeBottleBufferPosInfo", LargeBottleBufferPos.class, - new LargeBottleBufferPos( - new Pos2d(4474, 1172), - new Pos2d(109, 182), - 280, - 280, - new Pos2d(60, 30), - 280, - 580 - )); - } - - @ExtApiParam(name = "Hbot采样区", group = "限制值", order = ORDER.getSampleCollectionArea) - public HbotLimitArea getSampleCollectionArea() { - return hpReader.getObject("HbotPublicArea", HbotLimitArea.class, - new HbotLimitArea(0, 3643, 5060, 4074)); - } - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/param/TimeParam.java b/src/main/java/a8k/service/bak_devicectrl/param/TimeParam.java deleted file mode 100644 index 3a6e883..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/param/TimeParam.java +++ /dev/null @@ -1,52 +0,0 @@ -package a8k.service.bak_devicectrl.param; - - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.controler.extapi.utils.*; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.TimeParam) -public class TimeParam { - EnginnerParamReader hpReader = new EnginnerParamReader(ExtApiParamsTab.class); - - @ExtApiParam(name = "动作超时时间", group = "基础参数") - public Integer getActionOvertime() { - return hpReader.getInteger("ActionOvertime", 5000); - } - - @ExtApiParam(name = "归零超时时间", group = "基础参数") - public Integer getRuntoZeroActionOvertime() { - return hpReader.getInteger("RuntoZeroActionOvertime", 15000); - } - - @ExtApiParam(name = "入料超时时间", group = "基础参数") - public Integer getInfeedOvertime() { - return hpReader.getInteger("InfeedOvertime", 10000); - } - - @ExtApiParam(name = "出料超时时间", group = "基础参数") - public Integer getOutfeedOvertime() { - return hpReader.getInteger("OutfeedOvertime", 10000); - } - - @ExtApiParam(name = "试管帽有无判断时间", group = "基础参数") - public Integer getTubeCapJudgeDelayTime() { - return hpReader.getInteger("TubeCapJudgeDelayTime", 300); - } - - @ExtApiParam(name = "光学扫描超时时间", group = "光学") - public Integer getOptScanOvertime() { - return hpReader.getInteger("optScanOvertime", 12000); - } - - @ExtApiParam(name = "Hbot归零超时时间", group = "基础配置") - public Integer getHbotRuntoZeroActionOvertime() { - return hpReader.getInteger("HbotRuntoZeroActionOvertime", 20000); - } - - @ExtApiParam(name = "扫码超时时间", group = "基础配置") - public Integer getScancodeOvertime() { - return hpReader.getInteger("ScancodeOvertime", 1000); - } -} diff --git a/src/main/java/a8k/service/bak_devicectrl/status/DeviceStatus.java b/src/main/java/a8k/service/bak_devicectrl/status/DeviceStatus.java deleted file mode 100644 index 300d5ff..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/status/DeviceStatus.java +++ /dev/null @@ -1,87 +0,0 @@ -package a8k.service.bak_devicectrl.status; - -import a8k.type.exception.AppException; -import a8k.controler.extapi.utils.ExtApiTab; -import a8k.controler.extapi.utils.ExtApiStatu; -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.IOId; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.hardware.type.regindex.RegIndex; -import jakarta.annotation.Resource; -import org.springframework.stereotype.Component; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.DeviceStatus) -public class DeviceStatus { - @Resource - A8kCanBusService canBus; - - static class ORDER { - static final int isTubeExist = 1; - static final int isTubeRackInEnterPos = 2; - static final int isTubeRackInExitPos = 3; - static final int isHighTube = 4; - static final int getTHchOuterPPS = 5; - static final int getTHchInterPPS = 6; - static final int getXPPS = 7; - static final int getYPPS = 8; - static final int getZPPS = 9; - static final int getTipPPS = 10; - } - - // - // 状态 - // - @ExtApiStatu(name = "试管架存在", group = "进出料光电", order = ORDER.isTubeExist) - public Boolean isTubeExist() throws AppException { - return canBus.getIOState(IOId.TubeExistPPS); - } - - @ExtApiStatu(name = "入口光电", group = "进出料光电", order = ORDER.isTubeRackInEnterPos) - public Boolean isTubeRackInEnterPos() throws AppException { - return canBus.getIOState(IOId.InfeedPPS); - } - - @ExtApiStatu(name = "出口光电", group = "进出料光电", order = ORDER.isTubeRackInExitPos) - public Boolean isTubeRackInExitPos() throws AppException { - return canBus.getIOState(IOId.OutfeedPPS); - } - - @ExtApiStatu(name = "试管高低判读光电", group = "进出料光电", order = ORDER.isHighTube) - public Boolean isHighTube() throws AppException { - return canBus.getIOState(IOId.TubeHeightPPS); - } - - @ExtApiStatu(name = "通道外光电", group = "进出料光电", order = ORDER.getTHchOuterPPS) - public Boolean getTHchOuterPPS() throws AppException { - return canBus.getIOState(IOId.THChOuterPPS); - } - - @ExtApiStatu(name = "通道内光电", group = "进出料光电", order = ORDER.getTHchInterPPS) - public Boolean getTHchInterPPS() throws AppException { - return canBus.getIOState(IOId.THChInterPPS); - } - - @ExtApiStatu(name = "X轴光电➡", group = "HBOT", order = ORDER.getXPPS) - public Boolean getXPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 0); - } - - @ExtApiStatu(name = "Y轴光电⬇", group = "HBOT", order = ORDER.getYPPS) - public Boolean getYPPS() throws AppException { - return canBus.hbotReadInio(MId.HbotM, 1); - } - -// @EnginnerPageStatu(name = "Z轴光电⬆", group = "HBOT", order = ORDER.getZPPS) -// public Boolean getZPPS() throws HardwareException { -// return canBus.stepMotorReadIoState(MId.PipetteModZM, 0); -// } - - - // @HardwareServiceStatus(name = "TipState") - public Boolean getTipPPS() throws AppException { - return canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; - } - -} diff --git a/src/main/java/a8k/service/bak_devicectrl/testscript/TestScript.java b/src/main/java/a8k/service/bak_devicectrl/testscript/TestScript.java deleted file mode 100644 index bb5014b..0000000 --- a/src/main/java/a8k/service/bak_devicectrl/testscript/TestScript.java +++ /dev/null @@ -1,250 +0,0 @@ -package a8k.service.bak_devicectrl.testscript; - -import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; -import a8k.type.ConsumableGroup; -import a8k.type.exception.AppException; -import a8k.type.IncubatorPos; -import a8k.type.appret.AppRet; -import a8k.type.cfg.BottleGroupsPosInfo; -import a8k.type.cfg.BottlesPosInfo; -import a8k.type.cfg.TipPickUpPosInfo; -import a8k.controler.extapi.utils.*; -import a8k.service.bak_devicectrl.ctrl.SamplesPreProcesCtrl; -import a8k.service.bak_devicectrl.ctrl.TubeRackMoveCtrl; -import a8k.hardware.A8kCanBusService; -import a8k.hardware.type.a8kcanprotocol.A8kEcode; -import a8k.hardware.type.a8kcanprotocol.MId; -import a8k.hardware.type.regindex.RegIndex; -import a8k.service.bak_devicectrl.ctrl.HbotControlService; -import a8k.service.bak_devicectrl.ctrl.ReactionPlatesTransmitCtrl; -import a8k.service.bak_devicectrl.param.DebugParam; -import a8k.service.bak_devicectrl.param.PosParam; -import a8k.service.bak_devicectrl.param.TimeParam; -import jakarta.annotation.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -@Component -@ExtApiTab(cfg = ExtApiTabConfig.TestScript) -public class TestScript { - static Logger logger = LoggerFactory.getLogger(TestScript.class); - - static class ORDER { - static final int testTakeAllTipStop = 0; - static final int takeTipTestStep = 1; - static final int testTakeAllTip = 2; - static final int testAllLittleBottleBufferPos = 3; - static final int testAllDetectMaterialPos = 4; - static final int testAllBigBottleBufferPos = 5; - static final int pushAllPlateAndDrop = 6; - static final int testSamplePreProcessModule = 7; - } - - @Resource - A8kCanBusService canBus; - - @Resource - ApplicationContext appCxt; - - @Resource - HbotControlService hbotcs; - - @Resource - TimeParam timep; - @Resource - PosParam pp; - @Resource - DebugParam dp; - - @Resource - ReactionPlatesTransmitCtrl reactionPlatesTransmitCtrl; - - @Resource - SamplesPreProcesCtrl samplesPreProcesCtrl; - - @Resource - TubeRackMoveCtrl tubeRackMoveCtrl; - - EnginnerParamReader settingReader = new EnginnerParamReader(HbotControlService.class); - - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // 测试 - // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - Boolean testScriptWorkFlag = false; - - void checkTestScriptWorkFlag() throws AppException { - if (testScriptWorkFlag) { - testScriptWorkFlag = false; - throw new AppException(A8kEcode.TestScripIsRunning.index); - } - } - - @ExtApiFn(name = "停止测试脚本", group = "控制", order = ORDER.testTakeAllTipStop) - public void testTakeAllTipStop() { - testScriptWorkFlag = false; - } - -// @ExtApiFn(name = "取放Tip-单步", group = "Hbot测试脚本", order = ORDER.takeTipTestStep) - // public AppRet takeTipTestStep(Integer tipgroup, Integer index) throws AppException, InterruptedException { - // checkTestScriptWorkFlag(); - // testScriptWorkFlag = true; - // var ret = hbotcs.takeTip(tipgroup, index); - // TipPickUpPosInfo tipPos = pp.getTipPickUpPosInfo(); - // - // //TODO canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, tipPos.getPickUpZPos(tipgroup) - 100, timep.getActionOvertime()); - // // TODO canBus.pipetteCtrlPutTipBlock(MId.PipetteMod); - // - // if (canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1) { - // throw new AppException(A8kEcode.PutTipFail.index); - // } - // - // // TODO canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); - // testScriptWorkFlag = false; - // return ret; - // } - -// @ExtApiFn(name = "取放Tip-全部", group = "Hbot测试脚本", order = ORDER.testTakeAllTip) -// public AppRet> testTakeAllTip(Integer groupId, Integer startFrom) throws AppException, InterruptedException { -// checkTestScriptWorkFlag(); -// -// testScriptWorkFlag = true; -// Map result = new HashMap<>(); -// for (int i = startFrom; i < TipPickUpPosInfo.cgetTipNum(); i++) { -// var ret = takeTipTestStep(groupId, i); -// if (!ret.getData()) { -// throw new AppException(A8kEcode.TakeTipFail.index); -// } -// -// result.put("Tip" + i, ret.getData() ? "suc" : "fail"); -// logger.info("Take Tip {}-{} => {}", groupId, i, ret.getData()); -// if (!testScriptWorkFlag) { -// break; -// } -// } -// testScriptWorkFlag = false; -// return AppRet.success(result); -// } -// -// @ExtApiFn(name = "测试所有小瓶缓冲液位置", group = "Hbot测试脚本", order = ORDER.testAllLittleBottleBufferPos) -// public void testAllLittleBottleBufferPos(ConsumableGroup group) throws AppException, InterruptedException { -// checkTestScriptWorkFlag(); -// -// testScriptWorkFlag = true; -// BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); -// for (int i = 0; i < BottlesPosInfo.cgetMAX(); i++) { -// BottleGroupsPosInfo pos = pp.getBottleBufferPosInfo(); -// hbotcs.hbotMoveToSmallBottleGroup(group, i); -// //TODO: canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, pos.posTestZ, timep.getActionOvertime()); -// //TODO: canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); -// if (!testScriptWorkFlag) { -// break; -// } -// } -// testScriptWorkFlag = false; -// } -// -// @ExtApiFn(name = "测试所有探测物质位置", group = "Hbot测试脚本", order = ORDER.testAllDetectMaterialPos) -// public void testAllDetectMaterialPos(ConsumableGroup group) throws AppException, InterruptedException { -// checkTestScriptWorkFlag(); -// -// testScriptWorkFlag = true; -// for (int i = 0; i < BottlesPosInfo.cgetMAX(); i++) { -// BottleGroupsPosInfo pos = pp.getBottleBufferPosInfo(); -// hbotcs.hbotMoveToDetectMaterialPos(group, i); -// //TODO: canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, pos.posTestZ, timep.getActionOvertime()); -// //TODO: canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); -// if (!testScriptWorkFlag) { -// break; -// } -// } -// testScriptWorkFlag = false; -// } - -// @ExtApiFn(name = "测试所有大瓶缓冲液位置", group = "Hbot测试脚本", order = ORDER.testAllBigBottleBufferPos) -// public void testAllBigBottleBufferPos() throws AppException, InterruptedException { -// checkTestScriptWorkFlag(); -// -// testScriptWorkFlag = true; -// // 遍历枚举 ConsumableGroup -// for (ConsumableGroup group : ConsumableGroup.values()) { -// hbotcs.hbotMoveToLargeBottleGroup(group); -// //TODO: canBus.stepMotorEasyMoveByBlock(MId.PipetteModZM, 100, timep.getActionOvertime()); -// //TODO: canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); -// if (!testScriptWorkFlag) { -// break; -// } -// } -// testScriptWorkFlag = false; -// } - - @ExtApiFn(name = "推全部板同时丢弃", group = "板夹移动测试脚本", order = ORDER.pushAllPlateAndDrop) - public void pushAllPlateAndDrop(ConsumableGroup PBCh, IncubatorPos startPos) throws AppException, InterruptedException { - checkTestScriptWorkFlag(); - testScriptWorkFlag = true; - reactionPlatesTransmitCtrl.checkBeforeMoveTrunable(); - reactionPlatesTransmitCtrl.checkBeforeMovePlateBox(); - reactionPlatesTransmitCtrl.modGroupMoveToZeroQuick(); - reactionPlatesTransmitCtrl.dropPlate(); - for (IncubatorPos index : IncubatorPos.values()) { - if (index.compareTo(startPos) < 0) { - continue; - } - reactionPlatesTransmitCtrl.pushPlateQuick(PBCh, index); - reactionPlatesTransmitCtrl.pullPlate(index); - reactionPlatesTransmitCtrl.dropPlate(); - if (!testScriptWorkFlag) { - break; - } - } - testScriptWorkFlag = false; - } - - @ExtApiFn(name = "测试摇匀模组", group = "摇匀模组测试", order = ORDER.testSamplePreProcessModule) - public AppRet testSamplePreProcessModule() throws AppException, InterruptedException { - checkTestScriptWorkFlag(); - testScriptWorkFlag = true; - - try { - tubeRackMoveCtrl.enterTubeHolder(); - AppRet scanResult = tubeRackMoveCtrl.moveTubeRackToScanPosAndScan(); - if (!scanResult.isSuccess()) { - tubeRackMoveCtrl.ejectTubeHolder(); - logger.info("没有扫到试管架的码"); - return AppRet.message("没有扫到试管架的码", null); - } - if (!scanResult.getData().equals("1111\r")) { - tubeRackMoveCtrl.ejectTubeHolder(); - logger.info("不是全血试管架 {}", scanResult.getData()); - return AppRet.message("不是全血试管架", null); - } - - AppRet isExistTube = tubeRackMoveCtrl.judgeTubeExist(0); - AppRet isHighTube = tubeRackMoveCtrl.moveTubeToAltitJudgXPos(0); - tubeRackMoveCtrl.moveTubeToPreProcessPos(0); - - if (!isExistTube.getData()) { - tubeRackMoveCtrl.ejectTubeHolder(); - logger.info("试管架上没有试管"); - return AppRet.message("试管架上没有试管", null); - } - - - samplesPreProcesCtrl.takeTubeAndJudgeTubeExist(isHighTube.getData()); - samplesPreProcesCtrl.shakeTube(50, 5); - samplesPreProcesCtrl.takeTubeCap(); - samplesPreProcesCtrl.pushBackTubeCapAndTakeBakTube(); - tubeRackMoveCtrl.ejectTubeHolder(); - } finally { - testScriptWorkFlag = false; - } - - return AppRet.message("测试完成", null); - - } - -} diff --git a/src/main/java/a8k/service/devicectrl/calibration/PositionCalibration.java b/src/main/java/a8k/service/devicectrl/calibration/PositionCalibration.java new file mode 100644 index 0000000..4cf6b79 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/calibration/PositionCalibration.java @@ -0,0 +1,119 @@ +package a8k.service.devicectrl.calibration; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.type.exception.AppException; +import a8k.type.appret.AppRet; +import a8k.type.cfg.Pos2d; +import a8k.controler.extapi.utils.*; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.service.devicectrl.param.DebugParam; +import a8k.service.devicectrl.param.PosParam; +import a8k.service.devicectrl.param.TimeParam; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.PositionCalibration) +public class PositionCalibration { + + @Resource + A8kCanBusService canBus; + @Resource + TimeParam timep; + @Resource + PosParam pp; + @Resource + DebugParam dp; + + @ExtApiFn(name = "试管夹平移电机-使能", group = "电机使能") + public void FeedingModXMEnable(Boolean enable) throws AppException { + canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); + } + + @ExtApiFn(name = "板夹仓Y轴-使能", group = "电机使能") + public void platesBoxYMEndble(Boolean enable) throws AppException { + canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); + } + + @ExtApiFn(name = "板夹仓推杆-使能", group = "电机使能") + public void platesBoxPusherMEndble(Boolean enable) throws AppException { + canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); + } + + @ExtApiFn(name = "拉杆-使能", group = "电机使能") + public void optModPullMEndble(Boolean enable) throws AppException { + canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); + } + + @ExtApiFn(name = "光学模组扫描器-使能", group = "电机使能") + public void optModScannerMEndble(Boolean enable) throws AppException { + canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); + } + + @ExtApiFn(name = "转盘-使能", group = "电机使能") + public void incubatorRotateCtrlMEndble(Boolean enable) throws AppException { + canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); + + } + + + @ExtApiFn(name = "试管夹平移电机-读取位置", group = "通过归零测量位置") + public AppRet readXPosByMoveZero() throws AppException, InterruptedException { + return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.FeedingModXM, timep.getActionOvertime())); + } + + + @ExtApiFn(name = "通过归零读取<板夹仓>位置", group = "通过归零测量位置") + public AppRet readPlatesBoxYMPosByMoveToZero() throws AppException, InterruptedException { + return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxYM, timep.getActionOvertime())); + } + + @ExtApiFn(name = "通过归零读取<推杆>位置", group = "通过归零测量位置") + public AppRet readPlatesBoxPusherMPosByMoveToZero() throws AppException, InterruptedException { + return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxPusherM, timep.getActionOvertime())); + } + + @ExtApiFn(name = "通过归零读取<拉杆>位置", group = "通过归零测量位置") + public AppRet readOptModPullMPosByMoveToZero() throws AppException, InterruptedException { + return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModPullM, timep.getActionOvertime())); + } + + @ExtApiFn(name = "通过归零读取<光学模组扫描器>位置", group = "通过归零测量位置") + public AppRet readOptModScannerMPosByMoveToZero() throws AppException, InterruptedException { + return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModScannerM, timep.getActionOvertime())); + } + + @ExtApiFn(name = "通过归零读取<摇匀模组Z轴>位置", group = "通过归零测量位置") + public AppRet readShakeModGripperZMPosByMoveToZero() throws AppException, InterruptedException { + return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime())); + } + + + @ExtApiStatu(name = "HbotPos", group = "Hbot") + public String getHbotPos() throws AppException { + Pos2d pos = canBus.hbotReadPos(MId.HbotM); + return pos.toString(); + } + + + @ExtApiStatu(name = "转盘位置") + public String getIncubatorRotateCtrlMPos() throws AppException { + Integer pos = canBus.stepMotorReadPos(MId.IncubatorRotateCtrlM); + return pos.toString(); + } + + @ExtApiStatu(name = "抓手Y轴位置", group = "摇匀模组") + public String getShakeModGripperYPos() throws AppException { + Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperYSV); + return pos.toString(); + } + + @ExtApiStatu(name = "抓手位置", group = "摇匀模组") + public String getGripperPos() throws AppException { + Integer pos = canBus.miniServoReadPos(MId.ShakeModGripperSV); + return pos.toString(); + } + + +} diff --git a/src/main/java/a8k/service/devicectrl/commonctrl/HardwareCommonCtrl.java b/src/main/java/a8k/service/devicectrl/commonctrl/HardwareCommonCtrl.java new file mode 100644 index 0000000..9e9e9c2 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/commonctrl/HardwareCommonCtrl.java @@ -0,0 +1,395 @@ +package a8k.service.devicectrl.commonctrl; + + +import a8k.type.exception.AppException; +import a8k.type.appret.AppRet; +import a8k.controler.extapi.utils.ExtApiTab; +import a8k.controler.extapi.utils.ExtApiFn; +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.hardware.type.a8kcanprotocol.IOId; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.service.devicectrl.param.PosParam; +import a8k.service.devicectrl.param.TimeParam; +import jakarta.annotation.Resource; +import org.slf4j.Logger; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.HardwareCommonCtrl) +public class HardwareCommonCtrl { + static Logger logger = org.slf4j.LoggerFactory.getLogger(HardwareCommonCtrl.class); + + static class ORDER { + static final int initializeDevice = 1; + static final int deviceClear = 2; + static final int deviceForceStop = 3; + static final int forceDisableAllMOtor = 4; + static final int deviceEnable = 5; + } + + @Resource + A8kCanBusService canBus; + + @Resource + TimeParam timep; + + @Resource + PosParam posp; + + Boolean workState = false; + + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // CHECK + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + private AppRet checkDeviceStateBeforeRunToZero() throws AppException { + logger.info("checkDeviceStateBeforeRunToZero"); + //试管平移通道是否有障碍 + if (canBus.getIOState(IOId.THChInterPPS) || canBus.getIOState(IOId.THChOuterPPS)) { + logger.warn("THChInterPPS or THChOuterPPS is trigger"); + return AppRet.fail(A8kEcode.TubeXChannelIsNotEmpty.index); + } + + //板夹仓盖子是否盖上 + if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { + return AppRet.fail(A8kEcode.PlateBoxNotCover.index); + } + + //板夹仓卡板检测 + if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS)) { + return AppRet.fail(A8kEcode.PlateStuckDetectorSensorTrigger.index); + } + + //检查钩板电机是否处于终点位置 + if (!canBus.getIOState(IOId.PullerMZeroPPS)) { + return AppRet.fail(A8kEcode.PullerMInitPosError.index); + } + + //检查板夹仓光电是否处于起点位置 + if (!canBus.getIOState(IOId.PusherMZeroPPS)) { + return AppRet.fail(A8kEcode.PusherMInitPosError.index); + } + //板夹仓光电 + if (canBus.getIOState(IOId.RecycleBinOverflowPPS)) { + return AppRet.fail(A8kEcode.RecycleBinOverflow.index); + } + + return AppRet.success(); + } + + private void checkStopFlag() throws AppException { + if (!workState) { + throw new AppException(A8kEcode.StopByUser.index); + } + } + + + private AppRet moveMotorToZero() throws AppException, InterruptedException { + + //进出料初始化 + canBus.stepMotorEasyMoveToZeroBlock(MId.FeedingModXM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + + canBus.miniServoMoveToBlock(MId.ShakeModTubeScanerClampingSV, 20, timep.getActionOvertime()); + checkStopFlag(); + + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, 300, timep.getActionOvertime()); + checkStopFlag(); + + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, 300, timep.getActionOvertime()); + checkStopFlag(); + + + canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModClampingM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModGripperZM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModShakeM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + + canBus.stepMotorEasyMoveTo(MId.ShakeModShakeM, 90); + checkStopFlag(); + + //板夹仓初始化 + canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxYM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxPusherM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + //光学模组初始化 + canBus.stepMotorEasyMoveToZeroBlock(MId.OptModPullM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + canBus.stepMotorEasyMoveToZeroBlock(MId.OptModScannerM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + //HBot初始化 + canBus.hbotMoveToZero(MId.HbotM); + checkStopFlag(); + + // TODO canBus.stepMotorEasyMoveToZeroBlock(MId.PipetteModZM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + //转盘归零 + canBus.stepMotorEasyMoveToZeroBlock(MId.IncubatorRotateCtrlM, timep.getRuntoZeroActionOvertime()); + checkStopFlag(); + + + return AppRet.success(); + } + + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Expose API + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + @ExtApiFn(name = "设备初始化", order = ORDER.initializeDevice) + public AppRet initializeDevice() throws AppException, InterruptedException { + logger.info("Initializing device ..."); + boolean initSuc = false; + workState = true; + AppRet ecode; + try { + //打开必要的电源 + canBus.setIOState(IOId.RecycleBinOverflowPPSPowerCtrl, true); + + //检查设备状态 + ecode = checkDeviceStateBeforeRunToZero(); + if (!ecode.isSuccess()) { + return AppRet.fail(ecode); + } + // 复位设备 + logger.info("moveMotorToZero"); + ecode = moveMotorToZero(); + if (!ecode.isSuccess()) { + return AppRet.fail(ecode); + } + initSuc = true; + logger.info("Device initialization completed"); + + } finally { + if (!initSuc) { + try { + canBus.stepMotorEnable(MId.ShakeModClampingM, 1); + } catch (AppException ignored) { + } + try { + canBus.stepMotorEasyMoveBy(MId.ShakeModClampingM, 2); + } catch (AppException ignored) { + } + } + } + return AppRet.success("初始化完成"); + + } + + // @EnginnerPageAction(name = "清空板夹仓板夹", order = ORDER.deviceClear) + // public void clearDevice() { + // //TODO + // } + + + @ExtApiFn(name = "设备强制停止", order = ORDER.deviceForceStop) + public void deviceForceStop() throws AppException { + //StopAllMotor + //进出料初始化 + try { + canBus.moduleStop(MId.FeedingModInfeedM); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.FeedingModXM); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.FeedingModOutfeedM); + } catch (AppException ignored) { + } + //摇匀模组初始化 + try { + canBus.moduleStop(MId.ShakeModClampingM); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.ShakeModGripperZM); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.ShakeModShakeM); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.ShakeModGripperYSV); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.ShakeModGripperSV); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.ShakeModTubeScanerClampingSV); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.ShakeModTubeScanerRotateSV); + } catch (AppException ignored) { + } + //板夹仓初始化 + try { + canBus.moduleStop(MId.PlatesBoxYM); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.PlatesBoxPusherM); + } catch (AppException ignored) { + } + //光学模组初始化 + try { + canBus.moduleStop(MId.OptModPullM); + } catch (AppException ignored) { + } + try { + canBus.moduleStop(MId.OptModScannerM); + } catch (AppException ignored) { + } + //HBot初始化 + try { + canBus.moduleStop(MId.HbotM); + } catch (AppException ignored) { + } + // try { + // TODO canBus.moduleStop(MId.PipetteModZM); + // } catch (HardwareException ignored) { + // } + //转盘归零 + try { + canBus.moduleStop(MId.IncubatorRotateCtrlM); + } catch (AppException ignored) { + } + + } + + @ExtApiFn(name = "设备强制使能所有电机", order = ORDER.forceDisableAllMOtor) + public void forceDisableAllMOtor() { + //Disable all motor + //进出料初始化 + try { + canBus.stepMotorEnable(MId.FeedingModInfeedM, 0); + } catch (AppException ignored) { + } + try { + canBus.stepMotorEnable(MId.FeedingModXM, 0); + } catch (AppException ignored) { + } + try { + canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0); + } catch (AppException ignored) { + } + + //摇匀模组初始化 + try { + canBus.stepMotorEnable(MId.ShakeModClampingM, 0); + } catch (AppException ignored) { + } + try { + canBus.stepMotorEnable(MId.ShakeModGripperZM, 0); + } catch (AppException ignored) { + } + try { + canBus.stepMotorEnable(MId.ShakeModShakeM, 0); + } catch (AppException ignored) { + } + try { + canBus.miniServoEnable(MId.ShakeModGripperYSV, 0); + } catch (AppException ignored) { + } + try { + canBus.miniServoEnable(MId.ShakeModGripperSV, 0); + } catch (AppException ignored) { + } + try { + canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 0); + } catch (AppException ignored) { + } + try { + canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, 0); + } catch (AppException ignored) { + } + + //板夹仓初始化 + try { + canBus.stepMotorEnable(MId.PlatesBoxYM, 0); + } catch (AppException ignored) { + } + try { + canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0); + } catch (AppException ignored) { + } + + //光学模组初始化 + try { + canBus.stepMotorEnable(MId.OptModPullM, 0); + } catch (AppException ignored) { + } + try { + canBus.stepMotorEnable(MId.OptModScannerM, 0); + } catch (AppException ignored) { + } + + //HBot初始化 + try { + canBus.hbotEnable(MId.HbotM, 0); + } catch (AppException ignored) { + } + // try { + //TODO canBus.stepMotorEnable(MId.PipetteModZM, 0); + // } catch (HardwareException ignored) { + // } + + //转盘归零 + try { + canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0); + } catch (AppException ignored) { + } + } + + @ExtApiFn(name = "设备使能", order = ORDER.deviceEnable) + public void deviceEnable(Boolean enable) throws AppException { + //进出料初始化 + canBus.stepMotorEnable(MId.FeedingModInfeedM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.FeedingModXM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.FeedingModOutfeedM, enable ? 1 : 0); + + //摇匀模组初始化 + canBus.stepMotorEnable(MId.ShakeModClampingM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.ShakeModGripperZM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.ShakeModShakeM, enable ? 1 : 0); + canBus.miniServoEnable(MId.ShakeModGripperYSV, enable ? 1 : 0); + canBus.miniServoEnable(MId.ShakeModGripperSV, enable ? 1 : 0); + canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, enable ? 1 : 0); + canBus.miniServoEnable(MId.ShakeModTubeScanerRotateSV, enable ? 1 : 0); + + //板夹仓初始化 + canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); + + //光学模组初始化 + canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); + canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); + + //HBot初始化 + canBus.hbotEnable(MId.HbotM, enable ? 1 : 0); + // TODO canBus.stepMotorEnable(MId.PipetteModZM, enable ? 1 : 0); + + //转盘归零 + canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); + } + + public void checkBeforeMove(MId mId) throws AppException { + //板夹仓盖子是否盖上 + if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { + throw new AppException(A8kEcode.PlateBoxNotCover.index); + } + } + + public void stop() { + workState = false; + } + +} diff --git a/src/main/java/a8k/service/devicectrl/ctrl/HbotControlService.java b/src/main/java/a8k/service/devicectrl/ctrl/HbotControlService.java new file mode 100644 index 0000000..550f283 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/ctrl/HbotControlService.java @@ -0,0 +1,394 @@ +package a8k.service.devicectrl.ctrl; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.hardware.A8kPipetteCtrlModule; +import a8k.hardware.type.regindex.PipetteRegIndex; +import a8k.type.exception.AppException; +import a8k.type.cfg.*; +import a8k.controler.extapi.utils.*; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.hardware.type.a8kcanprotocol.IOId; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.hardware.type.regindex.RegIndex; +import jakarta.annotation.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Hbot控制服务 + */ +@Component +@ExtApiTab(cfg = ExtApiTabConfig.HbotControlService) +public class HbotControlService { + static Logger logger = LoggerFactory.getLogger(HbotControlService.class); + + @Resource + A8kCanBusService canBus; + + @Resource + A8kPipetteCtrlModule pipetteCtrlModule; + + Integer ao = 20000; + + + public void hbotMoveTo(Pos3d targetPos) throws AppException, InterruptedException { + logger.info("hbotCheckAndMoveTo:{}", targetPos); + + // 检查盖板是否关闭 + if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { + throw new AppException(A8kEcode.PlateBoxNotCover.index); + } + + boolean zEnable = true; + boolean hbotEnable = canBus.moduleGetReg(MId.HbotM, RegIndex.kreg_xyrobot_is_enable) == 1; + + //检查Z轴是否使能,如果没有使能,使能并移动到零点 + if (pipetteCtrlModule.getReg(PipetteRegIndex.kreg_pipette_zm_is_enable) == 0) { + pipetteCtrlModule.zMotorEnable(1); + pipetteCtrlModule.zMotorMoveZeroBlock(); + zEnable = false; + } + + //检查Z轴是否在零点 + if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { + pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); + } + if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { + throw new AppException(A8kEcode.ZMNotAtZPosWhenHbotTryMove.index); + } + + // HBot移动 + canBus.hbotEnable(MId.HbotM, 1); + canBus.hbotMoveToBlock(MId.HbotM, targetPos.x - 20, targetPos.y - 20, ao); + canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, ao); + canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, ao); + + // Z轴移动 + if (targetPos.z != 0) { + pipetteCtrlModule.zMotorEnable(1); + pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); + pipetteCtrlModule.zMotorMoveToBlock(targetPos.z); + } + pipetteCtrlModule.zMotorEnable(zEnable ? 1 : 0); + canBus.hbotEnable(MId.HbotM, hbotEnable ? 1 : 0); + } + + public void hbotMoveTo(Pos2d tpos) throws AppException, InterruptedException { + hbotMoveTo(new Pos3d(tpos.x, tpos.y, 0)); + } + + public String scan2dCode(Integer waittime) throws AppException, InterruptedException { + try { + canBus.codeScanerStartScan(MId.PipetteModCodeScanner); + String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, waittime); + canBus.codeScanerStopScan(MId.PipetteModCodeScanner); + return result; + } catch (AppException e) { + return ""; + } + } + + + // + // public Integer getGripperZeroYPos() { + // 之所以这样写,是因为是为了放置两个类之间的循环依赖 + // assert appCxt != null; + // TODO + // return + // appCxt.getBean(SamplesPreProcessModuleCtrlService.class).getGripperZeroYPos(); + // return 0; + // } + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // 基础控制 + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // private void checkPublicArea() throws AppException { + // if (canBus.miniServoReadPos(MId.ShakeModGripperYSV) > getGripperZeroYPos() + 20) { + // logger.error("ShakeModGripperYSV Pos:{} > {}", canBus.miniServoReadPos(MId.ShakeModGripperYSV), + // getGripperZeroYPos() + 20); + // throw new AppException(A8kEcode.ShakeModGripperYSVInXYPublicArea.index); + // } + // } + + // /** + // * Hboot 移动 + // * + // * @param targetPos 目标位置 + // * @throws AppException e + // * @throws InterruptedException e + // */ + // public void hbotCheckAndMoveTo(Pos3d targetPos) throws AppException, InterruptedException { + // logger.info("hbotCheckAndMoveTo:{}", targetPos); + // if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { + // throw new AppException(A8kEcode.PlateBoxNotCover.index); + // } + // + // + // boolean zEnable = true; + // boolean hbotEnable = canBus.moduleGetReg(MId.HbotM, RegIndex.kreg_xyrobot_is_enable) == 1; + // + // if (pipetteCtrlModule.getReg(PipetteRegIndex.kreg_pipette_zm_is_enable) == 0) { + // pipetteCtrlModule.zMotorEnable(1); + // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); + // zEnable = false; + // } + // + // if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { + // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); + // } + // + // if (!pipetteCtrlModule.zAixsZeroPointIsTrigger()) { + // throw new AppException(A8kEcode.ZMNotAtZPosWhenHbotTryMove.index); + // } + // Pos2d nowHbotPos = canBus.hbotReadPos(MId.HbotM); + // HbotLimitArea sampleArea = pp.getSampleCollectionArea(); + // + // // 检查采样区域是否有障碍 + // // if (sampleArea.checkIsInArea(nowHbotPos) || sampleArea.checkIsInArea(targetPos.getXYPos())) { + // // checkPublicArea(); + // // } + // + // // HBot移动 + // canBus.hbotEnable(MId.HbotM, 1); + // canBus.hbotMoveToBlock(MId.HbotM, targetPos.x - 20, targetPos.y - 20, timep.getActionOvertime()); + // canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, timep.getActionOvertime()); + // canBus.hbotMoveToBlock(MId.HbotM, targetPos.x, targetPos.y, timep.getActionOvertime()); + // + // // Z轴移动 + // if (targetPos.z != 0) { + // pipetteCtrlModule.zMotorEnable(1); + // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); + // pipetteCtrlModule.zMotorMoveToBlock(targetPos.z); + // } + // pipetteCtrlModule.zMotorEnable(zEnable ? 1 : 0); + // canBus.hbotEnable(MId.HbotM, hbotEnable ? 1 : 0); + // } + // + // public void zMoveTo(Integer z) throws AppException, InterruptedException { + // if (z == 0) { + // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); + // } else { + // pipetteCtrlModule.zMotorMoveToBlock(z); + // } + // } + // + // private void hbotCheckAndMoveTo(Pos2d targetPos) throws AppException, InterruptedException { + // hbotCheckAndMoveTo(new Pos3d(targetPos.x, targetPos.y, 0)); + // } + // + // private void modGroupMoveToZero() throws AppException, InterruptedException { + // if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) { + // throw new AppException(A8kEcode.PlateBoxNotCover.index); + // } + // + // pipetteCtrlModule.zMotorEnable(1); + // canBus.hbotEnable(MId.HbotM, 1); + // + // canBus.hbotMoveToZeroBlock(MId.HbotM, timep.getHbotRuntoZeroActionOvertime()); + // + // // 丢弃tip + // Pos3d dropPos = pp.getTipDropPos(); + // hbotCheckAndMoveTo(dropPos); + // // TODO: canBus.pipetteCtrlInitDeviceBlock(MId.PipetteMod, timep.getActionOvertime()); + // + // // 快速归零 + // modGroupMoveToZeroQuick(); + // } + // + // private void modGroupMoveToZeroQuick() throws AppException, InterruptedException { + // hbotCheckAndMoveTo(new Pos2d(0, 0)); + // } + + + // // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // // 单步测试 + // // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // + // @ExtApiFn(name = "丢Tip", group = "单步测试") + // public void dropTip() throws AppException, InterruptedException { + // Pos3d pos = pp.getTipDropPos(); + // hbotMoveTo(pos.x, pos.y); + // zMoveTo(pos.z); + // pipetteCtrlModule.putTipBlock(); + // zMoveTo(0); + // } + // + // @ExtApiFn(name = "取Tip", group = "单步测试") + // public AppRet takeTip(Integer groupId, Integer index) throws AppException, InterruptedException { + // logger.info("takeTip groupId:{} index:{}", groupId, index); + // if (groupId > 2 || groupId < 0) { + // throw new AppException(A8kEcode.ParamOutOfRange.index); + // } + // + // if (index > TipPickUpPosInfo.cgetTipNum() || index < 0) { + // throw new AppException(A8kEcode.ParamOutOfRange.index); + // } + // + // TipPickUpPosInfo tipPos = pp.getTipPickUpPosInfo(); + // Pos2d pos = tipPos.getTipPos(groupId, index); + // hbotMoveTo(pos.x, pos.y); + // + // //TODO: 补偿,group大于1时,z轴需要补偿0.2mm + // Integer zCompensate = 0; + // if (groupId > 1) { + // zCompensate = 2; + // } + // + // pipetteCtrlModule.zMotorMoveToBlock(tipPos.getPickUpZPos(groupId) + zCompensate); + // pipetteCtrlModule.zMotorMoveToZeroPointQuickBlock(); + // + // Boolean isGetTip = canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; + // if (!isGetTip) { + // logger.error("takeTip fail"); + // } + // return AppRet.success(isGetTip); + // } + // + // @ExtApiFn(name = "HBot移动到", group = "单步测试") + // public void hbotMoveTo(Integer x, Integer y) throws AppException, InterruptedException { + // hbotCheckAndMoveTo(new Pos2d(x, y)); + // } + // + // @ExtApiFn(name = "HBot移动到小瓶缓冲液X孔", group = "单步测试") + // public void hbotMoveToSmallBottleGroup(ConsumableGroup group, Integer Xhole) + // throws AppException, InterruptedException { + // BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); + // if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) { + // throw new AppException(A8kEcode.ParamOutOfRange.index); + // } + // Pos2d pos = posInfo.cgetSmallBottleBufferPos(group.off, Xhole); + // hbotCheckAndMoveTo(pos); + // } + // + // @ExtApiFn(name = "HBot移动到探测物质X孔", group = "单步测试") + // public void hbotMoveToDetectMaterialPos(ConsumableGroup group, Integer Xhole) + // throws AppException, InterruptedException { + // BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); + // if (Xhole < 0 || Xhole > BottlesPosInfo.cgetMAX()) { + // throw new AppException(A8kEcode.ParamOutOfRange.index); + // } + // Pos2d pos = posInfo.cgetDetectMaterialPos(group.off, Xhole); + // hbotCheckAndMoveTo(pos); + // } + // + // @ExtApiFn(name = "HBot移动到大瓶缓冲液X孔", group = "单步测试") + // public void hbotMoveToLargeBottleGroup(ConsumableGroup ch) throws AppException, InterruptedException { + // LargeBottleBufferPos posInfo = pp.getLargeBottleBufferPosInfo(); + // Pos2d pos = posInfo.cgetBottlePos(ch.off); + // hbotCheckAndMoveTo(pos); + // } + // + // @ExtApiFn(name = "HBot移动到急诊位", group = "单步测试") + // public void hbotMoveToEmergencyPos() throws AppException, InterruptedException { + // hbotCheckAndMoveTo(pp.getEmergencyPos()); + // } + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // 坐标获取工具 + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // + // @ExtApiFn(name = "Hbot使能", group = "坐标获取工具") + // public void hBotEnable() throws AppException, InterruptedException { + // canBus.hbotEnable(MId.HbotM, 1); + // } + // + // @ExtApiFn(name = "Hbot失能", group = "坐标获取工具") + // public void hBotDisable() throws AppException, InterruptedException { + // canBus.hbotEnable(MId.HbotM, 0); + // } + // + // @ExtApiFn(name = "Z轴使能", group = "坐标获取工具") + // public void zAxisEnable() throws AppException, InterruptedException { + // pipetteCtrlModule.zMotorEnable(1); + // } + // + // @ExtApiFn(name = "Z轴失能", group = "坐标获取工具") + // public void zAxisDisable() throws AppException, InterruptedException { + // pipetteCtrlModule.zMotorEnable(0); + // } + + // @ExtApiFn(name = "归零读取Z轴坐标", group = "坐标获取工具") + // public AppRet readZAxisPosByMoveToZero() throws HardwareException, InterruptedException { + // return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PipetteModZM, timep.getActionOvertime())); + // } + // + // @ExtApiFn(name = "打开扫码器", group = "坐标获取工具") + // public void openCodeScaner(Boolean power) throws AppException, InterruptedException { + // if (power) { + // canBus.codeScanerStartScan(MId.PipetteModCodeScanner); + // } else { + // canBus.codeScanerStopScan(MId.PipetteModCodeScanner); + // } + // } + // + // Pos2d hbotRefPos = new Pos2d(0, 0); + // + // @ExtApiFn(name = "设置HBOT参考坐标", group = "坐标获取工具") + // public void setHbotRefPos(Integer x, Integer y) throws AppException, InterruptedException { + // hbotRefPos.x = x; + // hbotRefPos.y = y; + // } + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // hbot移动到并扫码 + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + // private AppRet hBotMoveToAndScan(Pos2d pos) throws AppException, InterruptedException { + // hbotCheckAndMoveTo(pos); + // canBus.codeScanerStartScan(MId.PipetteModCodeScanner); + // String result = canBus.codeScanerWaittingForResult(MId.PipetteModCodeScanner, timep.getScancodeOvertime()); + // return AppRet.success(result); + // } + // + // // 扫描板夹仓二维码 + // @ExtApiFn(name = "扫描板夹仓二维码", group = "扫码") + // public AppRet scanPlatesCode(ConsumableGroup ch) throws AppException, InterruptedException { + // var posInfo = pp.getPlates2dCodeScanPosInfo(); + // return hBotMoveToAndScan(posInfo.cgetScanPos(ch.off)); + // } + // +// // 扫描缓冲液二维码 +// @ExtApiFn(name = "扫描缓冲液区二维码", group = "扫码") +// public AppRet scanBottleBuffersCode(ConsumableGroup group) throws AppException, InterruptedException { +// BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); +// return hBotMoveToAndScan(posInfo.cgetScanPos(group.ordinal())); +// } + // + // // 扫描大缓冲液二维码 + // @ExtApiFn(name = "扫描大缓冲液二维码", group = "扫码") + // public AppRet scanBigBottleBufferCode(ConsumableGroup group) + // throws AppException, InterruptedException { + // LargeBottleBufferPos posInfo = pp.getLargeBottleBufferPosInfo(); + // return hBotMoveToAndScan(posInfo.cgetScanPos(group.off)); + // } + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // hbot取样品 + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + public Boolean getXPPS() throws AppException { + return canBus.hbotReadInio(MId.HbotM, 0); + } + + public Boolean getYPPS() throws AppException { + return canBus.hbotReadInio(MId.HbotM, 1); + } + + public Boolean getTipPPS() throws AppException { + return canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; + } + + public String getPos() throws AppException { + Pos2d pos = canBus.hbotReadPos(MId.HbotM); + return pos.toString(); + } + + // public String getHbotRelaPos() throws AppException { + // Pos2d pos = canBus.hbotReadPos(MId.HbotM); + // pos.x -= hbotRefPos.x; + // pos.y -= hbotRefPos.y; + // return pos.toString(); + // } +} diff --git a/src/main/java/a8k/service/devicectrl/ctrl/PipetteGunCtrlService.java b/src/main/java/a8k/service/devicectrl/ctrl/PipetteGunCtrlService.java new file mode 100644 index 0000000..a917dd5 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/ctrl/PipetteGunCtrlService.java @@ -0,0 +1,32 @@ +package a8k.service.devicectrl.ctrl; + + +import jakarta.annotation.PostConstruct; +import org.slf4j.Logger; +import org.springframework.stereotype.Component; + +/** + * + * 移液枪功能 + * 1. + * + * + * + */ + +@Component +public class PipetteGunCtrlService { + static Logger logger = org.slf4j.LoggerFactory.getLogger(PipetteGunCtrlService.class); + + public Integer a; + + @PostConstruct + void init() throws NoSuchMethodException { + System.out.println("PipetteGunCtrlService init"); + } + + //取样 + + // + +} diff --git a/src/main/java/a8k/service/devicectrl/ctrl/ReactionPlatesTransmitCtrl.java b/src/main/java/a8k/service/devicectrl/ctrl/ReactionPlatesTransmitCtrl.java new file mode 100644 index 0000000..d50d9fe --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/ctrl/ReactionPlatesTransmitCtrl.java @@ -0,0 +1,211 @@ +package a8k.service.devicectrl.ctrl; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.type.exception.AppException; +import a8k.utils.opt_algo.A8kOptAlgo; +import a8k.type.*; +import a8k.type.appret.AppRet; +import a8k.controler.extapi.utils.*; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.hardware.type.a8kcanprotocol.IOId; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.hardware.type.regindex.RegIndex; +import a8k.service.devicectrl.param.DebugParam; +import a8k.service.devicectrl.param.PosParam; +import a8k.service.devicectrl.param.TimeParam; +import jakarta.annotation.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.ReactionPlatesTransmitCtrl) +public class ReactionPlatesTransmitCtrl { + static Logger logger = LoggerFactory.getLogger(ReactionPlatesTransmitCtrl.class); + EnginnerParamReader hpReader = new EnginnerParamReader(ReactionPlatesTransmitCtrl.class); + + + @Resource + A8kCanBusService canBus; + @Resource + TimeParam timep; + @Resource + PosParam pp; + @Resource + DebugParam dp; + + + public void checkBeforeMoveTrunable() throws AppException { + //板夹仓卡板检测 + if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS)) { + logger.error("PlateBoxPlateStuckPPS is trigger"); + throw new AppException(A8kEcode.PlateStuckDetectorSensorTrigger.index); + } + + //检查钩板电机是否处于终点位置 + if (!canBus.getIOState(IOId.PullerMZeroPPS)) { + logger.error("PullerM is not in zero pos"); + throw new AppException(A8kEcode.PullerMInitPosError.index); + } + + //检查板夹仓光电是否处于起点位置 + if (!canBus.getIOState(IOId.PusherMZeroPPS)) { + logger.error("PusherM is not in zero pos"); + throw new AppException(A8kEcode.PusherMInitPosError.index); + } + } + + public void checkBeforeMovePlateBox() throws AppException { + if (!canBus.getIOState(IOId.PusherMZeroPPS)) { + logger.error("PusherM is not in zero pos "); + throw new AppException(A8kEcode.PusherMInitPosError.index); + } + } + + public void modGroupMoveToZeroQuick() throws AppException, InterruptedException { + //光学模组初始化 + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, timep.getActionOvertime()); + + //板夹仓初始化 + checkBeforeMovePlateBox(); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, timep.getActionOvertime()); + + //转盘归零 + checkBeforeMoveTrunable(); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.IncubatorRotateCtrlM, timep.getActionOvertime()); + } + + private void trunableMoveTo(Integer pos) throws AppException, InterruptedException { + checkBeforeMoveTrunable(); + //限制pos在 0--> 36000之间 + pos = pos % 36000; + if (pos < 0) { + pos += 36000; + } + + //先移动半个间距,用来检测是否发生卡板 + Integer nowPos = canBus.stepMotorReadPos(MId.IncubatorRotateCtrlM); + if (nowPos < pos) { + canBus.stepMotorEasyMoveByBlock(MId.IncubatorRotateCtrlM, pp.getTurntablePosSpacing(), timep.getActionOvertime()); + } else if (nowPos > pos) { + canBus.stepMotorEasyMoveByBlock(MId.IncubatorRotateCtrlM, -pp.getTurntablePosSpacing(), timep.getActionOvertime()); + } + + //解决齿轮间隙的问题 + if (nowPos < pos) { + canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM, pos, timep.getActionOvertime()); + } else { + canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM, pos - 300/**/, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM, pos, timep.getActionOvertime()); + } + } + + /* ======================================================================================= + 基础操作 + =======================================================================================*/ + + @ExtApiFn(name = "转盘移动到推板位", group = "单步") + public void trunableMoveToPushPos(IncubatorPos index) throws AppException, InterruptedException { + trunableMoveTo(pp.getTurntablePushPos0() + index.off * pp.getTurntablePosSpacing()); + } + + @ExtApiFn(name = "转盘移动到出板位", group = "单步") + public void trunableMoveToPullPos(IncubatorPos index) throws AppException, InterruptedException { + trunableMoveTo(pp.getTurntablePullPos0() + index.off * pp.getTurntablePosSpacing()); + + } + + @ExtApiFn(name = "转盘移动到滴定位", group = "单步") + public void trunableMoveToDropLiquidPos(IncubatorPos index) throws AppException, InterruptedException { + trunableMoveTo(pp.getTurntableDropLiquidPos0() + index.off * pp.getTurntablePosSpacing()); + } + + + @ExtApiFn(name = "推板", group = "单步") + public AppRet pushPlate(ConsumableGroup PBCh, IncubatorPos turntablePosIndex) throws AppException, InterruptedException { + trunableMoveToPushPos(turntablePosIndex); + canBus.stepMotorEasyMoveToBlock(MId.PlatesBoxYM, pp.getPBCh0Pos() + PBCh.off * pp.getPBChSpacing(), timep.getActionOvertime()); + canBus.plateCodeScanerPushCardAndScanBlock(MId.PlatesBoxScanner, pp.getPusherEndPos(), 10000); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, timep.getActionOvertime()); + return AppRet.success(canBus.plateCodeScannerReadCode(MId.PlatesBoxScanner)); + } + + public void pushPlateQuick(ConsumableGroup PBCh, IncubatorPos turntablePosIndex) throws AppException, InterruptedException { + trunableMoveToPushPos(turntablePosIndex); + canBus.stepMotorEasyMoveToBlock(MId.PlatesBoxYM, pp.getPBCh0Pos() + PBCh.off * pp.getPBChSpacing(), timep.getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.PlatesBoxPusherM, pp.getPusherEndPos(), timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, timep.getActionOvertime()); + } + + + @ExtApiFn(name = "拉板", group = "单步操作") + public void pullPlate(IncubatorPos turntablePosIndex) throws AppException, InterruptedException { + trunableMoveToPullPos(turntablePosIndex); + canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, pp.getOptScanScandbyPos(), timep.getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.OptModPullM, pp.getPullerTargetPos(), timep.getActionOvertime()); + if (!canBus.getIOState(IOId.PullerMEndPPS)) { + logger.error("pull plate fail"); + throw new AppException(A8kEcode.PullPlateFail.index); + } + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, timep.getActionOvertime()); + } + + @ExtApiFn(name = "丢板", group = "单步操作") + public void dropPlate() throws AppException, InterruptedException { + canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, pp.getPlateDropPos(), timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, pp.getOptScanScandbyPos(), timep.getActionOvertime()); + } + + // @EnginnerPageAction(name = "显示板夹扫码原始曲线", group = "辅助调试") + // public AppRet readPlateScanCurve() throws HardwareException, InterruptedException { + // List scanDataCurve = canBus.plateCodeScanerReadRawResult(MId.PlatesBoxScanner); + // List refLine = new ArrayList<>(); + // for (int i = 0; i < 15; i++) { + // refLine.add(i * 12 + 6); + // } + // return AppRet.success(new A8kScanCurve(scanDataCurve, refLine)); + // } + + private AppRet packetOptDisplayScanCurve(List scanDataCurve) { + A8kScanCurve scanCurve = new A8kScanCurve(); + logger.info("pointNum: " + scanDataCurve.size()); + scanCurve.scanDataCurve = A8kOptAlgo.preProcessOptData(scanDataCurve); + logger.info("pointNum: " + scanCurve.scanDataCurve.size()); + scanCurve.refCurve = A8kOptAlgo.preProcessOptData(scanDataCurve); + scanCurve.refLine = new ArrayList<>(); + for (int i = 1; i < 6; i++) { + scanCurve.refLine.add(40 * i); + } + return AppRet.success(scanCurve); + } + + @ExtApiFn(name = "T光学扫码", group = "光学调试") + public AppRet optTScan(OptScanDirection direction, Integer scanerGain) throws AppException, InterruptedException { + // canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_t_pos_offset, getTOptPosOffset()); + // canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_t_reverse_scan_pos_offset,getTOptPosOffset()-1200); + // canBus.optTStartScanBlock(MId.OptMod, direction, getOptTLasterGain(), scanerGain, getOptScanOvertime()); + // return packetOptDisplayScanCurve(canBus.optReadRaw(MId.OptMod)); + return AppRet.fail(A8kEcode.CmdNotSupport.index); + } + + @ExtApiFn(name = "F光学扫码", group = "光学调试") + public AppRet optFScan(OptScanDirection direction, Integer scanerGain) throws AppException, InterruptedException { + //getFOptPosOffset + canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_f_pos_offset, pp.getFOptPosOffset()); + canBus.moduleSetReg(MId.OptMod, RegIndex.kreg_a8k_opt_f_reverse_scan_pos_offset, pp.getFOptPosOffset() - 1200); + + canBus.optFStartScanBlock(MId.OptMod, direction, pp.getOptFLasterGain(), scanerGain, timep.getOptScanOvertime()); + return packetOptDisplayScanCurve(canBus.optReadRaw(MId.OptMod)); + } + + +} diff --git a/src/main/java/a8k/service/devicectrl/ctrl/SamplesPreProcesCtrl.java b/src/main/java/a8k/service/devicectrl/ctrl/SamplesPreProcesCtrl.java new file mode 100644 index 0000000..8ba44aa --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/ctrl/SamplesPreProcesCtrl.java @@ -0,0 +1,268 @@ +package a8k.service.devicectrl.ctrl; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.type.exception.AppException; +import a8k.type.appret.AppRet; +import a8k.controler.extapi.utils.*; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.service.devicectrl.param.DebugParam; +import a8k.service.devicectrl.param.TimeParam; +import a8k.service.devicectrl.param.PosParam; +import a8k.utils.ZEQ; +import jakarta.annotation.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.SamplesPreProcesCtrl) +public class SamplesPreProcesCtrl { + static Logger logger = LoggerFactory.getLogger(SamplesPreProcesCtrl.class); + + static class ORDER { + + static final int moduleReset = 1; + static final int moduleEnable = 2; + static final int moduleDisable = 3; + static final int takeTubeAndJudgeTubeExist = 4; + static final int shakeTube = 5; + static final int takeTubeCap = 6; + static final int pushBackTubeCapAndTakeBakTube = 7; + static final int setAeroslFanPower = 8; + } + + @Resource + A8kCanBusService canBus; + @Resource + TimeParam timep; + @Resource + PosParam pp; + @Resource + DebugParam dp; + + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // PRIVATE + // ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + private void modGroupMoveToZero() throws AppException, InterruptedException { + + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperClosePos(), timep.getActionOvertime()); + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperZeroYPos(), timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModClampingM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModShakeM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.ShakeModShakeM, 90, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, -2, timep.getActionOvertime()); + } + + + private void modGroupMoveToZeroQuick() throws AppException, InterruptedException { + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModClampingM, timep.getActionOvertime()); + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModShakeM, timep.getActionOvertime()); + modGroupMoveToZero(); + } + + @ExtApiFn(name = "模块复位", group = "辅助调试", order = ORDER.moduleReset) + public void moduleReset() throws AppException, InterruptedException { + modGroupMoveToZero(); + } + + @ExtApiFn(name = "模块使能", group = "辅助调试", order = ORDER.moduleEnable) + public void moduleEnable() throws AppException, InterruptedException { + canBus.miniServoEnable(MId.ShakeModGripperSV, 1); + canBus.miniServoEnable(MId.ShakeModGripperYSV, 1); + canBus.stepMotorEnable(MId.ShakeModClampingM, 1); + canBus.stepMotorEnable(MId.ShakeModGripperZM, 1); + canBus.stepMotorEnable(MId.ShakeModShakeM, 1); + canBus.stepMotorEnable(MId.ShakeModShakeM, 1); + } + + @ExtApiFn(name = "模块失能", group = "辅助调试", order = ORDER.moduleDisable) + public void moduleDisable() throws AppException, InterruptedException { + canBus.stepMotorEnable(MId.ShakeModClampingM, 1); + canBus.stepMotorEasyMoveByBlock(MId.ShakeModClampingM, 10, timep.getActionOvertime()); + + + canBus.miniServoEnable(MId.ShakeModGripperSV, 0); + canBus.miniServoEnable(MId.ShakeModGripperYSV, 0); + canBus.stepMotorEnable(MId.ShakeModClampingM, 0); + canBus.stepMotorEnable(MId.ShakeModGripperZM, 0); + canBus.stepMotorEnable(MId.ShakeModShakeM, 0); + canBus.stepMotorEnable(MId.ShakeModShakeM, 0); + } + + @ExtApiFn(name = "夹紧试管", group = "辅助调试", order = ORDER.moduleDisable) + public void clampTube() throws AppException, InterruptedException { + canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, pp.getShakeClampingPos(), timep.getActionOvertime()); + } + + + void tryClampTube() throws AppException, InterruptedException { + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos() - 20, timep.getActionOvertime()); + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos(), timep.getActionOvertime()); + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos() - 20, timep.getActionOvertime()); + } + + /** + * 取试管帽,如果试管帽存在, + * @param highTube true/false + */ + @ExtApiFn(name = "取试管", group = "单步", order = ORDER.takeTubeAndJudgeTubeExist) + public AppRet takeTubeAndJudgeTubeExist(Boolean highTube) throws AppException, InterruptedException { + /* + * 校验: + * 1.当前摇匀模组设计到的电机是否都处于待机位 + */ + + //Z轴在原点 + if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { + throw new AppException(MId.ShakeModGripperZM, A8kEcode.MNotInZeroPos.index); + } + + //Y轴在零点附近 + if (!ZEQ.IntEq(canBus.miniServoReadPos(MId.ShakeModGripperYSV), pp.getGripperZeroYPos(), 30)) { + throw new AppException(MId.ShakeModGripperYSV, A8kEcode.MNotInZeroPos.index); + } + + //夹爪没有零位置 + if (!ZEQ.IntEq(canBus.miniServoReadPos(MId.ShakeModGripperSV), pp.getGripperClosePos(), 30)) { + throw new AppException(MId.ShakeModGripperSV, A8kEcode.MNotInZeroPos.index); + } + + //检查摇匀夹紧是否在零位 + if (!canBus.stepMotorReadIoState(MId.ShakeModClampingM, 0)) { + throw new AppException(MId.ShakeModClampingM, A8kEcode.MNotInZeroPos.index); + } + + boolean isHighBlood = highTube; + boolean tubeCapExist = true; + Integer gripperJudgeCapZPos = isHighBlood ? pp.getGripperJudgeHTubeCapZPos() : pp.getGripperJudgeSTubeCapZPos(); + Integer gripperTakeTubeZPos = isHighBlood ? pp.getGripperTakeHTubeZPos() : pp.getGripperTakeSTubeZPos(); + Integer gripperShakeZPos = pp.getGripperShakeTubeZPos(); + + //固定试管架 + canBus.miniServoMoveToBlock(MId.ShakeModTubeScanerClampingSV, 900, timep.getActionOvertime()); + //试管夹紧移动到终点位置 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, 70, timep.getActionOvertime()); + //试管摇匀移动到90度 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModShakeM, pp.getShakeModShakeMStandbyPos(), timep.getActionOvertime()); + //Y轴向前移动 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperTakeTubeYPos(), timep.getActionOvertime()); + //打开夹爪 + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); + // //Z轴下移动到试管帽有无检测位 + // canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperJudgeCapZPos, timep.getActionOvertime()); + //闭合夹爪检测试管帽是否存在 + // canBus.miniServoRotateWithTorque(MId.ShakeModGripperSV, -400); + // Thread.sleep(timep.getTubeCapJudgeDelayTime()); + // if (ZEQ.IntEq(canBus.miniServoReadPos(MId.ShakeModGripperSV), pp.getGripperClosePos(), 30)) { + // logger.info("试管帽不存在"); + // tubeCapExist = false; + // } + if (dp.getDebugMode() || tubeCapExist) { + //打开夹爪 + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); + //Z轴下移动到取试管位置 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperTakeTubeZPos, timep.getActionOvertime()); + //夹爪夹紧 + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos(), timep.getActionOvertime()); + canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperTakeTubeZPos - 100, timep.getActionOvertime()); + tryClampTube(); + + //Z轴上移动到零位 + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + //夹爪夹紧 + //Y轴移动到摇匀位 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos() - 50, timep.getActionOvertime()); //该动作是为了消除齿轮间隙 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos(), timep.getActionOvertime()); + //Z轴下移动到摇匀位放试管的位置 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, gripperShakeZPos, timep.getActionOvertime()); + //夹紧试管 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, pp.getShakeClampingPos(), timep.getActionOvertime()); + //松开夹爪,放置试管 + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); + //Z轴上移动到零位 + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + //Z轴归零,校准一次位置 + canBus.stepMotorEasyMoveToZeroBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + //Y轴移动到零位 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperZeroYPos(), timep.getActionOvertime()); + } else { + modGroupMoveToZeroQuick(); + } + return AppRet.success(tubeCapExist); + } + + @ExtApiFn(name = "摇匀", group = "单步", order = ORDER.shakeTube) + public void shakeTube(Integer shakeDegree, Integer times) throws AppException, InterruptedException { + var standByPos = pp.getShakeModShakeMStandbyPos(); + var startPos = standByPos - shakeDegree; + var endPos = standByPos + shakeDegree; + canBus.stepMotorEasyReciprocatingMotion(MId.ShakeModShakeM, startPos, endPos, times); + canBus.waitForMod(MId.ShakeModShakeM, timep.getActionOvertime()); + } + + @ExtApiFn(name = "取试管帽", group = "单步", order = ORDER.takeTubeCap) + public void takeTubeCap() throws AppException, InterruptedException { + //Y移动到取试管帽位置 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos(), timep.getActionOvertime()); + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); + //Z下移动到取试管帽位置 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, pp.getGripperTakeCapZPos() + 3, timep.getActionOvertime()); + //闭合夹爪 + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos(), timep.getActionOvertime()); + //Z上移动到零位 + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + // tryClampTube(); + // canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperTakeCapPos()-30, timep.getActionOvertime()); + + + //Y移动到待机位 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperZeroYPos(), timep.getActionOvertime()); + } + + /** + * 盖试管帽,并将试管移动回试管架中 + */ + @ExtApiFn(name = "盖试管帽并放回试管架", group = "单步", order = ORDER.pushBackTubeCapAndTakeBakTube) + public void pushBackTubeCapAndTakeBakTube() throws AppException, InterruptedException { + //移动Y轴到取试管帽位置 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperShakeYPos(), timep.getActionOvertime()); + //移动Z轴盖帽 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, pp.getGripperTakeCapZPos() + 20, timep.getActionOvertime()); + //打开试管夹 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModClampingM, 70, timep.getActionOvertime()); + //移动Z轴到零位 + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + + tryClampTube(); + + + //移动Y轴到方式管的位置 + canBus.miniServoMoveToBlock(MId.ShakeModGripperYSV, pp.getGripperTakeTubeYPos(), timep.getActionOvertime()); + //移动Z轴到取试管位置 + canBus.stepMotorEasyMoveToBlock(MId.ShakeModGripperZM, pp.getGripperTakeHTubeZPos() - 20, timep.getActionOvertime()); + //打开夹爪 + canBus.miniServoMoveToBlock(MId.ShakeModGripperSV, pp.getGripperOpenPos(), timep.getActionOvertime()); + //Z轴上移动到零位 + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.ShakeModGripperZM, timep.getActionOvertime()); + //设备快速归零 + modGroupMoveToZeroQuick(); + } + + /** + * 气溶胶风扇控制 + */ + @ExtApiFn(name = "气溶胶风扇控制", group = "其他", order = ORDER.setAeroslFanPower) + public void setAeroslFanPower(Boolean enable) throws Exception { + if (enable) { + canBus.fanControlerSetSpeed(MId.WbTubeFanMod, 99); + } else { + canBus.fanControlerSetSpeed(MId.WbTubeFanMod, 0); + } + } +} diff --git a/src/main/java/a8k/service/devicectrl/ctrl/TubeRackMoveCtrl.java b/src/main/java/a8k/service/devicectrl/ctrl/TubeRackMoveCtrl.java new file mode 100644 index 0000000..0e8b08a --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/ctrl/TubeRackMoveCtrl.java @@ -0,0 +1,298 @@ +package a8k.service.devicectrl.ctrl; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.type.exception.AppException; +import a8k.type.TargetPosMeasureDirection; +import a8k.type.appret.AppRet; +import a8k.controler.extapi.utils.*; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.hardware.type.a8kcanprotocol.IOId; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.service.devicectrl.param.DebugParam; +import a8k.service.devicectrl.param.PosParam; +import a8k.service.devicectrl.param.TimeParam; +import jakarta.annotation.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.TubeRackMoveCtrl) +public class TubeRackMoveCtrl { + static Logger logger = LoggerFactory.getLogger(TubeRackMoveCtrl.class); + + static class ORDER { + static final int moveTubeRackTo = 1; + static final int scanClampModClamp = 2; + static final int scanClampModRelease = 3; + static final int tryEnterTubeRack = 4; + static final int tryEjectTubeRack = 5; + static final int tubeRackMoveToEnterPos = 6; + static final int moveTubeRackToExitPos = 7; + static final int moveTubeRackToScanPos = 8; + static final int moveTubeToScanPosAndScan = 9; + static final int moveTubeToPreProcessPos = 10; + static final int moveTubeToAltitJudgXPos = 11; + static final int judgeTubeExist = 12; + + } + + @Resource + private A8kCanBusService canBus; + @Resource + TimeParam timep; + @Resource + PosParam pp; + @Resource + DebugParam dp; + + + private Boolean isTubeExist() throws AppException { + return canBus.getIOState(IOId.TubeExistPPS); + } + + private Boolean isTubeRackInEnterPos() throws AppException { + return canBus.getIOState(IOId.InfeedPPS); + } + + private Boolean isTubeRackInExitPos() throws AppException { + return canBus.getIOState(IOId.OutfeedPPS); + } + + private Boolean isHighTube() throws AppException { + return canBus.getIOState(IOId.TubeHeightPPS); + } + + + /** + * 移动试管到扫码位置 + * @param tubeIndex 试管索引 + */ + private void moveTubeToScanPos(Integer tubeIndex) throws AppException, InterruptedException { + var scanPos = pp.getTScanXPos() + tubeIndex * pp.getTubeSpacing(); + scanClampModClamp(); + moveTubeRackTo(scanPos, TargetPosMeasureDirection.NEGATIVE, false); + } + + /** + * 移动<试管架>到试管架扫码位置 + */ + private void moveTubeRackToScanPos() throws AppException, InterruptedException { + moveTubeRackTo(pp.getTRScanXPos(), TargetPosMeasureDirection.POSITIVE, false); + } + + /*========================================================================================= + * 基础方法 + *========================================================================================*/ + + /** + * 移动试管架到指定位置 + * @param pos 指定位置 + * @throws AppException 硬件异常 + * @throws InterruptedException 打断异常 + */ + @ExtApiFn(name = "移动到坐标", group = "基础方法", order = ORDER.moveTubeRackTo) + public void moveTubeRackTo(Integer pos, TargetPosMeasureDirection moveDiretion, Boolean moveToZero) throws AppException, InterruptedException { + if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { + throw new AppException(A8kEcode.ShakeModGripperZMNotInZeroPos.index); + } + //打开扫码夹具 + scanClampModRelease(); + + //使能电机 + canBus.stepMotorEnable(MId.FeedingModXM, 1); + if (moveToZero) { + canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.FeedingModXM, timep.getActionOvertime()); + } + + // 处理试管架和试管架之间的间隙导致的运行位置误差 + Integer nowPos = canBus.stepMotorReadPos(MId.FeedingModXM); + if (TargetPosMeasureDirection.POSITIVE.equals(moveDiretion)) { + if (nowPos > (pos + 1)) { + canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos + 30, timep.getActionOvertime()); + } + } else if (TargetPosMeasureDirection.NEGATIVE.equals(moveDiretion)) { + if (nowPos < (pos - 1)) { + canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos - 30, timep.getActionOvertime()); + } + } + canBus.stepMotorEasyMoveToBlock(MId.FeedingModXM, pos, timep.getActionOvertime()); + + } + + /** + * 扫描夹紧机构夹紧 + */ + @ExtApiFn(name = "扫描夹紧机构夹紧", group = "基础方法", order = ORDER.scanClampModClamp) + public void scanClampModClamp() throws AppException, InterruptedException { + canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 1); + canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, 900); + canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, timep.getActionOvertime()); + } + + /** + * 扫描夹紧机构复位 + */ + @ExtApiFn(name = "扫描夹紧机构复位", group = "基础方法", order = ORDER.scanClampModRelease) + public void scanClampModRelease() throws AppException, InterruptedException { + canBus.miniServoEnable(MId.ShakeModTubeScanerClampingSV, 1); + canBus.miniServoMoveTo(MId.ShakeModTubeScanerClampingSV, 0); + canBus.waitForMod(MId.ShakeModTubeScanerClampingSV, timep.getActionOvertime()); + } + + + public Boolean getTHchOuterPPS() throws AppException { + return canBus.getIOState(IOId.THChOuterPPS); + } + + public Boolean getTHchInterPPS() throws AppException { + return canBus.getIOState(IOId.THChInterPPS); + } + + + /*========================================================================================= + * 片段 + *========================================================================================*/ + + /** + * 移动试管架到入口位置 + */ + private void tubeRackMoveToEnterPos() throws AppException, InterruptedException { + moveTubeRackTo(pp.getTREnterXPos(), TargetPosMeasureDirection.NOTCARE, true); + } + + /** + * 移动<试管架>到出口位置 + */ + private void moveTubeRackToExitPos() throws AppException, InterruptedException { + moveTubeRackTo(pp.getTRExitXPos(), TargetPosMeasureDirection.NOTCARE, false); + moveTubeRackTo(pp.getTRExitXPos() - 10, TargetPosMeasureDirection.NOTCARE, false); + } + + /** + * 移动<试管架>到出口位置 + */ + @ExtApiFn(name = "入料", group = "单步", order = ORDER.moveTubeRackToExitPos) + public void enterTubeHolder() throws AppException, InterruptedException { + if (getTHchInterPPS() || getTHchOuterPPS()) { + throw new AppException(A8kEcode.TubeXChannelIsNotEmpty.index); + } + tubeRackMoveToEnterPos(); + try { + canBus.stepMotorEasyRotate(MId.FeedingModInfeedM, -1); + for (int i = 0; i < timep.getInfeedOvertime() / 100; i++) { + Thread.sleep(100); + if (getTHchInterPPS()) { + break; + } + } + Thread.sleep(1000); + canBus.stepMotorStop(MId.FeedingModInfeedM); + if (!getTHchInterPPS()) { + throw new AppException(A8kEcode.InfeedOvertimeFail.index); + } + } finally { + canBus.moduleStop(MId.FeedingModInfeedM); + } + } + + @ExtApiFn(name = "出料", group = "单步", order = ORDER.moveTubeRackToExitPos) + public void ejectTubeHolder() throws AppException, InterruptedException { + moveTubeRackToExitPos(); + try { + canBus.stepMotorEasyRotate(MId.FeedingModOutfeedM, 1); + for (int i = 0; i < timep.getOutfeedOvertime() / 100; i++) { + Thread.sleep(100); + logger.info("getTHchInterPPS:{} getTHchOuterPPS:{}", getTHchInterPPS(), getTHchOuterPPS()); + if (!getTHchInterPPS() && !getTHchOuterPPS()) { + break; + } + } + Thread.sleep(1000); + canBus.stepMotorStop(MId.FeedingModOutfeedM); + if (getTHchInterPPS() || getTHchOuterPPS()) { + throw new AppException(A8kEcode.OutfeedOvertimeFail.index); + } + } finally { + canBus.moduleStop(MId.FeedingModOutfeedM); + } + } + + /** + * 移动试管架到扫码并扫码 + */ + @ExtApiFn(name = "扫描<试管架>编码", group = "单步扫码", order = ORDER.moveTubeRackToScanPos) + public AppRet moveTubeRackToScanPosAndScan() throws AppException, InterruptedException { + String result; + moveTubeRackToScanPos(); + + scanClampModClamp(); + canBus.codeScanerStartScan(MId.FeedingModScannerMod); + result = canBus.codeScanerWaittingForResult(MId.FeedingModScannerMod, 1000); + scanClampModRelease(); + if (result == null || result.isEmpty()) { + return AppRet.fail(A8kEcode.ScanTimeout.index); + } + return AppRet.success(result); + } + // + // 试管移动 + // + + /** + * 移动试管到扫码位置,并扫码 + * @param tubeIndex 试管索引 + */ + @ExtApiFn(name = "扫描<试管X>编码", group = "单步扫码", order = ORDER.moveTubeToScanPosAndScan) + public AppRet moveTubeToScanPosAndScan(Integer tubeIndex) throws AppException, InterruptedException { + moveTubeToScanPos(tubeIndex); + try { + scanClampModClamp(); + + canBus.codeScanerStartScan(MId.FeedingModScannerMod); + canBus.miniServoRotateWithTorque(MId.ShakeModTubeScanerClampingSV, pp.getTubeScanServoTorque()); + String result = canBus.codeScanerWaittingForResult(MId.FeedingModScannerMod, pp.getTubeScanOvertime()); + if (result == null || result.isEmpty()) { + return AppRet.fail(A8kEcode.ScanTimeout.index); + } + return AppRet.success(result); + } finally { + canBus.moduleStop(MId.ShakeModTubeScanerClampingSV); + canBus.moduleStop(MId.FeedingModScannerMod); + scanClampModRelease(); + } + } + + /** + * 移动试管到试管预处理的位置 + * @param tubeIndex 试管索引 + */ + @ExtApiFn(name = "移动<试管N>摇匀位", group = "单步-处理", order = ORDER.moveTubeToPreProcessPos) + public void moveTubeToPreProcessPos(Integer tubeIndex) throws AppException, InterruptedException { + moveTubeRackTo(pp.getTPreProcessXPos() + tubeIndex * pp.getTubeSpacing(), TargetPosMeasureDirection.POSITIVE, false); + } + + /** + * 移动试管到试管高低判断位置 + * @param tubeIndex 试管索引 + */ + @ExtApiFn(name = "判断<试管N>高低", group = "单步-其他", order = ORDER.moveTubeToAltitJudgXPos) + public AppRet moveTubeToAltitJudgXPos(Integer tubeIndex) throws AppException, InterruptedException { + moveTubeRackTo(pp.getTAltitJudgXPos() + tubeIndex * pp.getTubeSpacing(), TargetPosMeasureDirection.NEGATIVE, false); + return AppRet.success(isHighTube()); + } + + + /** + * 移动试管到试管有无判断位置 + * @param tubeIndex 试管索引 + */ + @ExtApiFn(name = "判断<试管N>是否存在", group = "单步-其他", order = ORDER.judgeTubeExist) + public AppRet judgeTubeExist(Integer tubeIndex) throws AppException, InterruptedException { + moveTubeRackTo(pp.getTExistJudgXPos() + tubeIndex * pp.getTubeSpacing(), TargetPosMeasureDirection.NEGATIVE, false); + return AppRet.success(isTubeExist()); + } + + +} diff --git a/src/main/java/a8k/service/devicectrl/param/DebugParam.java b/src/main/java/a8k/service/devicectrl/param/DebugParam.java new file mode 100644 index 0000000..c4092c2 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/param/DebugParam.java @@ -0,0 +1,29 @@ +package a8k.service.devicectrl.param; + +import a8k.controler.extapi.utils.ExtApiTab; +import a8k.controler.extapi.utils.ExtApiFn; +import a8k.controler.extapi.utils.ExtApiStatu; +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.DebugParam) +public class DebugParam { + + Boolean debugMode = false; + + @ExtApiFn(name = "使能调试模式", order = 1) + public void enableDebugMode() { + debugMode = true; + } + + @ExtApiFn(name = "禁用调试模式", order = 2) + public void disableDebugMode() { + debugMode = false; + } + + @ExtApiStatu(name = "调试模式") + public Boolean getDebugMode() { + return debugMode; + } +} diff --git a/src/main/java/a8k/service/devicectrl/param/PosParam.java b/src/main/java/a8k/service/devicectrl/param/PosParam.java new file mode 100644 index 0000000..e5edb21 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/param/PosParam.java @@ -0,0 +1,393 @@ +package a8k.service.devicectrl.param; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.type.cfg.*; +import a8k.controler.extapi.utils.*; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.PosParam) +@ExtApiParamsTab(service = PosParam.class) +public class PosParam { + EnginnerParamReader hpReader = new EnginnerParamReader(PosParam.class); + + class ORDER { + static final int getGripperOpenPos = 1; + static final int getGripperClosePos = 2; + static final int getGripperTakeCapPos = 3; + static final int getGripperTakeTubeYPos = 4; + static final int getGripperShakeYPos = 5; + static final int getGripperZeroYPos = 6; + static final int getGripperTakeHTubeZPos = 7; + static final int getGripperTakeSTubeZPos = 8; + static final int getGripperJudgeHTubeCapZPos = 9; + static final int getGripperJudgeSTubeCapZPos = 10; + static final int getGripperShakeTubeZPos = 11; + static final int getGripperTakeCapZPos = 12; + static final int getShakeClampingPos = 13; + static final int getShakeModShakeMStandbyPos = 14; + static final int getTREnterXPos = 15; + static final int getTRExitXPos = 16; + static final int getTRScanXPos = 17; + static final int getTScanXPos = 18; + static final int getTAltitJudgXPos = 19; + static final int getTExistJudgXPos = 20; + static final int getTPreProcessXPos = 21; + static final int getTubeSpacing = 22; + static final int getTubeScanServoTorque = 23; + static final int getTubeScanOvertime = 24; + static final int getPBCh0Pos = 25; + static final int getPBChSpacing = 26; + static final int getPusherEndPos = 27; + static final int getPusherScanStartPos = 28; + static final int getTurntablePushPos0 = 29; + static final int getTurntablePullPos0 = 30; + static final int getTurntableDropLiquidPos0 = 31; + static final int getTurntablePosSpacing = 32; + static final int getPullerTargetPos = 33; + static final int getPlateDropPos = 34; + static final int getOptScanScandbyPos = 35; + static final int getTOptPosOffset = 36; + static final int getFOptPosOffset = 37; + static final int getOptTLasterGain = 38; + static final int getOptFLasterGain = 39; + static final int getEmergencyPos = 40; + static final int getTipPickUpPosInfo = 41; + static final int getTipDropPos = 42; + static final int getReactionPos = 43; + static final int getBottleBufferPosInfo = 44; + static final int getPlates2dCodeScanPosInfo = 45; + static final int getLargeBottleBufferPosInfo = 46; + static final int getSampleCollectionArea = 47; + } + + + // + // SamplesPreProcessModuleCtrlService + // + + @ExtApiParam(name = "抓手张开位置", group = "抓手", order = ORDER.getGripperOpenPos) + public Integer getGripperOpenPos() { + return hpReader.getInteger("GripperOpenPos", 450); + } + + @ExtApiParam(name = "抓手闭合位置", group = "抓手", order = ORDER.getGripperClosePos) + public Integer getGripperClosePos() { + return hpReader.getInteger("GripperClosePos", 310); + } + + @ExtApiParam(name = "抓手取试管位置", group = "抓手", order = ORDER.getGripperTakeCapPos) + public Integer getGripperTakeCapPos() { + return hpReader.getInteger("GripperTakeCapPos", 355); + } + + @ExtApiParam(name = "取试管位置", group = "抓手Y轴位置", order = ORDER.getGripperTakeTubeYPos) + public Integer getGripperTakeTubeYPos() { + return hpReader.getInteger("GripperTakeTubeYPos", 3080); + } + + @ExtApiParam(name = "摇匀位置", group = "抓手Y轴位置", order = ORDER.getGripperShakeYPos) + public Integer getGripperShakeYPos() { + return hpReader.getInteger("GripperShakeYPos", 2130); + } + + @ExtApiParam(name = "待机位", group = "抓手Y轴位置", order = ORDER.getGripperZeroYPos) + public Integer getGripperZeroYPos() { + return hpReader.getInteger("GripperZeroYPos", 300); + } + + + @ExtApiParam(name = "取高试管位置", group = "抓手Z轴位置", order = ORDER.getGripperTakeHTubeZPos) + public Integer getGripperTakeHTubeZPos() { + return hpReader.getInteger("GripperTakeHTubeZPos", 739); + } + + @ExtApiParam(name = "取低试管位置", group = "抓手Z轴位置", order = ORDER.getGripperTakeSTubeZPos) + public Integer getGripperTakeSTubeZPos() { + return hpReader.getInteger("GripperTakeSTubeZPos", 983); + } + + //JudgeTubeCapZ + @ExtApiParam(name = "高试管帽有无判断位", group = "抓手Z轴位置", order = ORDER.getGripperJudgeHTubeCapZPos) + public Integer getGripperJudgeHTubeCapZPos() { + return hpReader.getInteger("GripperJudgeHTubeCapZPos", 591); + } + + @ExtApiParam(name = "低试管帽有无判断位", group = "抓手Z轴位置", order = ORDER.getGripperJudgeSTubeCapZPos) + public Integer getGripperJudgeSTubeCapZPos() { + return hpReader.getInteger("GripperJudgeSTubeCapZPos", 867); + } + + //ShakeTubeZ + @ExtApiParam(name = "摇匀放置位置", group = "抓手Z轴位置", order = ORDER.getGripperShakeTubeZPos) + public Integer getGripperShakeTubeZPos() { + return hpReader.getInteger("GripperShakeTubeZPos", 835); + } + + //TakeCapZ + @ExtApiParam(name = "取试管帽位", group = "抓手Z轴位置", order = ORDER.getGripperTakeCapZPos) + public Integer getGripperTakeCapZPos() { + return hpReader.getInteger("GripperTakeCapZPos", 835); + } + + + @ExtApiParam(name = "试管夹紧位", group = "试管夹紧模块", order = ORDER.getShakeClampingPos) + public Integer getShakeClampingPos() { + return hpReader.getInteger("ShakeClampingPos", 10); + } + + @ExtApiParam(name = "摇匀臂", group = "试管摇匀待机位", order = ORDER.getShakeModShakeMStandbyPos) + public Integer getShakeModShakeMStandbyPos() { + return hpReader.getInteger("ShakeModShakeMStandbyPos", 90); + } + + + // + // MotorTubeRackMoveCtrlService + // + + @ExtApiParam(name = "入料X位置", group = "进出料<试管架>坐标", order = ORDER.getTREnterXPos) + public Integer getTREnterXPos() { + return hpReader.getInteger("TREnterXPos", -46); + } + + @ExtApiParam(name = "出料X位置", group = "进出料<试管架>坐标", order = ORDER.getTRExitXPos) + public Integer getTRExitXPos() { + return hpReader.getInteger("TRExitXPos", 3975); + } + + @ExtApiParam(name = "试管架扫码X位置", group = "进出料<试管架>坐标", order = ORDER.getTRScanXPos) + public Integer getTRScanXPos() { + return hpReader.getInteger("TRScanXPos", 2202); + } + + @ExtApiParam(name = "试管扫码位置", group = "进出料<试管位置>信息", order = ORDER.getTScanXPos) + public Integer getTScanXPos() { + //运动方向: -> + return hpReader.getInteger("TScanXPos", 505); + + } + + @ExtApiParam(name = "试管高度判断位置", group = "进出料<试管位置>信息", order = ORDER.getTAltitJudgXPos) + public Integer getTAltitJudgXPos() { + //运动方向: -> + return hpReader.getInteger("TAltitJudgXPos", 505); + } + + @ExtApiParam(name = "试管是否存在判断位置", group = "进出料<试管位置>信息", order = ORDER.getTExistJudgXPos) + public Integer getTExistJudgXPos() { + //运动方向: <- + return hpReader.getInteger("TExistJudgXPos", 300); + } + + @ExtApiParam(name = "试管预处理位置", group = "进出料<试管位置>信息", order = ORDER.getTPreProcessXPos) + public Integer getTPreProcessXPos() { + //运动方向: <- + return hpReader.getInteger("TPreProcessXPos", 1225); + } + + @ExtApiParam(name = "试管架孔间距", group = "其他", order = ORDER.getTubeSpacing) + public Integer getTubeSpacing() { + return hpReader.getInteger("TubeSpacing", 200); + } + + @ExtApiParam(name = "扫码舵机转速(0..900)", group = "其他", order = ORDER.getTubeScanServoTorque) + public Integer getTubeScanServoTorque() { + return hpReader.getInteger("TubeScanServoTorque", 500); + } + + @ExtApiParam(name = "试管扫码超时时间", group = "其他", order = ORDER.getTubeScanOvertime) + public Integer getTubeScanOvertime() { + return hpReader.getInteger("TubeScanOvertime", 1000); + } + + + // + // + // + + + @ExtApiParam(name = "板夹仓通道0位置", group = "板夹仓参数", order = ORDER.getPBCh0Pos) + public Integer getPBCh0Pos() { + return hpReader.getInteger("PBCh0Pos", -17); + } + + @ExtApiParam(name = "板夹仓通道间距", group = "板夹仓参数", order = ORDER.getPBChSpacing) + public Integer getPBChSpacing() { + return hpReader.getInteger("PBChSpacing", 265); + } + + @ExtApiParam(name = "推杆到位坐标", group = "板夹仓参数", order = ORDER.getPusherEndPos) + public Integer getPusherEndPos() { + return hpReader.getInteger("PusherEndPos", 1160); + } + + @ExtApiParam(name = "推杆扫码开始坐标", group = "板夹仓参数", order = ORDER.getPusherScanStartPos) + public Integer getPusherScanStartPos() { + return hpReader.getInteger("PusherScanStartPos", 960); + } + + /* + * 转盘相关位置 + */ + + @ExtApiParam(name = "仓位0入板位置", group = "转盘坐标参数", order = ORDER.getTurntablePushPos0) + public Integer getTurntablePushPos0() { + return hpReader.getInteger("TurntablePushPos0", 1650); + } + + @ExtApiParam(name = "仓位0出板位置", group = "转盘坐标参数", order = ORDER.getTurntablePullPos0) + public Integer getTurntablePullPos0() { + return hpReader.getInteger("TurntablePullPos0", 19700); + } + + @ExtApiParam(name = "仓位0点滴位", group = "转盘坐标参数", order = ORDER.getTurntableDropLiquidPos0) + public Integer getTurntableDropLiquidPos0() { + return hpReader.getInteger("TurntableDropLiquidPos0", 1650 + 8950); + } + + public Integer getTurntablePosSpacing() { + return 1800; + } + + /* + * 光学模组相关 + */ + @ExtApiParam(name = "拉板目标位置", group = "光学模组坐标参数", order = ORDER.getPullerTargetPos) + public Integer getPullerTargetPos() { + return hpReader.getInteger("PullerTargetPos", 1147); + } + + @ExtApiParam(name = "丢板坐标", group = "光学模组坐标参数", order = ORDER.getPlateDropPos) + public Integer getPlateDropPos() { + return hpReader.getInteger("PlateDropPos", -349); + } + + @ExtApiParam(name = "扫描待机位", group = "光学模组坐标参数", order = ORDER.getOptScanScandbyPos) + public Integer getOptScanScandbyPos() { + return hpReader.getInteger("OptScanScandbyPos", 305); + } + + @ExtApiParam(name = "T光学扫描起始坐标", group = "光学模组坐标参数", order = ORDER.getTOptPosOffset) + public Integer getTOptPosOffset() { + //3509 + return hpReader.getInteger("TOptPosOffset", 3723); + } + + @ExtApiParam(name = "F光学扫描起始坐标", group = "光学模组坐标参数", order = ORDER.getFOptPosOffset) + public Integer getFOptPosOffset() { + return hpReader.getInteger("FOptPosOffset", 2559); + } + + @ExtApiParam(name = "T光学发光增益", group = "光学模组坐标参数", order = ORDER.getOptTLasterGain) + public Integer getOptTLasterGain() { + return hpReader.getInteger("OptTLasterGain", 0); + } + + @ExtApiParam(name = "F光学发光增益", group = "光学模组坐标参数", order = ORDER.getOptFLasterGain) + public Integer getOptFLasterGain() { + return hpReader.getInteger("OptFLasterGain", 0); + } + + + @ExtApiParam(name = "急诊位", group = "简单位置坐标", order = ORDER.getEmergencyPos) + public Pos3d getEmergencyPos() { + return new Pos3d( + 4858, + 3196, + 246 + ); + } + + @ExtApiParam(name = "TIP组位置信息", group = "HBOT位置坐标集合", order = ORDER.getTipPickUpPosInfo) + public TipPickUpPosInfo getTipPickUpPosInfo() { + return hpReader.getObject("TipPickUpPosInfo", TipPickUpPosInfo.class, + new TipPickUpPosInfo( + new Pos2d(887, -15), + new Pos2d(2413, -15), + new Pos2d(3947, -15), + 92.3, + 92.15, + 578, + 580, + 585 + )); + } + + + @ExtApiParam(name = "Tip丢弃位置", group = "简单位置坐标", order = ORDER.getTipDropPos) + public Pos3d getTipDropPos() { + return new Pos3d( + 4873, + 2563, + 661 + ); + } + + @ExtApiParam(name = "滴液反应位", group = "简单位置坐标", order = ORDER.getReactionPos) + public Pos3d getReactionPos() { + return hpReader.getObject("ReactionPos", Pos3d.class, + new Pos3d( + 0, + 0, + 0 + )); + } + + @ExtApiParam(name = "缓冲液位置", group = "HBOT位置坐标集合", order = ORDER.getBottleBufferPosInfo) + public BottleGroupsPosInfo getBottleBufferPosInfo() { + return hpReader.getObject("BottleBufferPosInfo", BottleGroupsPosInfo.class, + new BottleGroupsPosInfo( + new Pos2d(741, 937), + 1230, + 1250, + new Pos2d(579, 1097), + 320, + new BottlesPosInfo + ( + new Pos2d(160, 160), + 210, + 210, + 0 + ), + new BottlesPosInfo + ( + new Pos2d(215, 205), + 187, + 187, + 0 + ) + )); + } + + @ExtApiParam(name = "板夹仓扫码位置", group = "HBOT位置坐标集合", order = ORDER.getPlates2dCodeScanPosInfo) + public Plates2dCodeScanPos getPlates2dCodeScanPosInfo() { + return hpReader.getObject("Plates2dCodeScanPosInfo", Plates2dCodeScanPos.class,// + new Plates2dCodeScanPos( + new Pos2d(-20, 1504), + 265 + ) + ); + } + + @ExtApiParam(name = "大瓶缓冲液位置", group = "HBOT位置坐标集合", order = ORDER.getLargeBottleBufferPosInfo) + public LargeBottleBufferPos getLargeBottleBufferPosInfo() { + return hpReader.getObject("LargeBottleBufferPosInfo", LargeBottleBufferPos.class, + new LargeBottleBufferPos( + new Pos2d(4474, 1172), + new Pos2d(109, 182), + 280, + 280, + new Pos2d(60, 30), + 280, + 580 + )); + } + + @ExtApiParam(name = "Hbot采样区", group = "限制值", order = ORDER.getSampleCollectionArea) + public HbotLimitArea getSampleCollectionArea() { + return hpReader.getObject("HbotPublicArea", HbotLimitArea.class, + new HbotLimitArea(0, 3643, 5060, 4074)); + } + +} diff --git a/src/main/java/a8k/service/devicectrl/param/TimeParam.java b/src/main/java/a8k/service/devicectrl/param/TimeParam.java new file mode 100644 index 0000000..9c8f00b --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/param/TimeParam.java @@ -0,0 +1,52 @@ +package a8k.service.devicectrl.param; + + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.controler.extapi.utils.*; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.TimeParam) +public class TimeParam { + EnginnerParamReader hpReader = new EnginnerParamReader(ExtApiParamsTab.class); + + @ExtApiParam(name = "动作超时时间", group = "基础参数") + public Integer getActionOvertime() { + return hpReader.getInteger("ActionOvertime", 5000); + } + + @ExtApiParam(name = "归零超时时间", group = "基础参数") + public Integer getRuntoZeroActionOvertime() { + return hpReader.getInteger("RuntoZeroActionOvertime", 15000); + } + + @ExtApiParam(name = "入料超时时间", group = "基础参数") + public Integer getInfeedOvertime() { + return hpReader.getInteger("InfeedOvertime", 10000); + } + + @ExtApiParam(name = "出料超时时间", group = "基础参数") + public Integer getOutfeedOvertime() { + return hpReader.getInteger("OutfeedOvertime", 10000); + } + + @ExtApiParam(name = "试管帽有无判断时间", group = "基础参数") + public Integer getTubeCapJudgeDelayTime() { + return hpReader.getInteger("TubeCapJudgeDelayTime", 300); + } + + @ExtApiParam(name = "光学扫描超时时间", group = "光学") + public Integer getOptScanOvertime() { + return hpReader.getInteger("optScanOvertime", 12000); + } + + @ExtApiParam(name = "Hbot归零超时时间", group = "基础配置") + public Integer getHbotRuntoZeroActionOvertime() { + return hpReader.getInteger("HbotRuntoZeroActionOvertime", 20000); + } + + @ExtApiParam(name = "扫码超时时间", group = "基础配置") + public Integer getScancodeOvertime() { + return hpReader.getInteger("ScancodeOvertime", 1000); + } +} diff --git a/src/main/java/a8k/service/devicectrl/status/DeviceStatus.java b/src/main/java/a8k/service/devicectrl/status/DeviceStatus.java new file mode 100644 index 0000000..61e5270 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/status/DeviceStatus.java @@ -0,0 +1,87 @@ +package a8k.service.devicectrl.status; + +import a8k.type.exception.AppException; +import a8k.controler.extapi.utils.ExtApiTab; +import a8k.controler.extapi.utils.ExtApiStatu; +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.IOId; +import a8k.hardware.type.a8kcanprotocol.MId; +import a8k.hardware.type.regindex.RegIndex; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.DeviceStatus) +public class DeviceStatus { + @Resource + A8kCanBusService canBus; + + static class ORDER { + static final int isTubeExist = 1; + static final int isTubeRackInEnterPos = 2; + static final int isTubeRackInExitPos = 3; + static final int isHighTube = 4; + static final int getTHchOuterPPS = 5; + static final int getTHchInterPPS = 6; + static final int getXPPS = 7; + static final int getYPPS = 8; + static final int getZPPS = 9; + static final int getTipPPS = 10; + } + + // + // 状态 + // + @ExtApiStatu(name = "试管架存在", group = "进出料光电", order = ORDER.isTubeExist) + public Boolean isTubeExist() throws AppException { + return canBus.getIOState(IOId.TubeExistPPS); + } + + @ExtApiStatu(name = "入口光电", group = "进出料光电", order = ORDER.isTubeRackInEnterPos) + public Boolean isTubeRackInEnterPos() throws AppException { + return canBus.getIOState(IOId.InfeedPPS); + } + + @ExtApiStatu(name = "出口光电", group = "进出料光电", order = ORDER.isTubeRackInExitPos) + public Boolean isTubeRackInExitPos() throws AppException { + return canBus.getIOState(IOId.OutfeedPPS); + } + + @ExtApiStatu(name = "试管高低判读光电", group = "进出料光电", order = ORDER.isHighTube) + public Boolean isHighTube() throws AppException { + return canBus.getIOState(IOId.TubeHeightPPS); + } + + @ExtApiStatu(name = "通道外光电", group = "进出料光电", order = ORDER.getTHchOuterPPS) + public Boolean getTHchOuterPPS() throws AppException { + return canBus.getIOState(IOId.THChOuterPPS); + } + + @ExtApiStatu(name = "通道内光电", group = "进出料光电", order = ORDER.getTHchInterPPS) + public Boolean getTHchInterPPS() throws AppException { + return canBus.getIOState(IOId.THChInterPPS); + } + + @ExtApiStatu(name = "X轴光电➡", group = "HBOT", order = ORDER.getXPPS) + public Boolean getXPPS() throws AppException { + return canBus.hbotReadInio(MId.HbotM, 0); + } + + @ExtApiStatu(name = "Y轴光电⬇", group = "HBOT", order = ORDER.getYPPS) + public Boolean getYPPS() throws AppException { + return canBus.hbotReadInio(MId.HbotM, 1); + } + +// @EnginnerPageStatu(name = "Z轴光电⬆", group = "HBOT", order = ORDER.getZPPS) +// public Boolean getZPPS() throws HardwareException { +// return canBus.stepMotorReadIoState(MId.PipetteModZM, 0); +// } + + + // @HardwareServiceStatus(name = "TipState") + public Boolean getTipPPS() throws AppException { + return canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1; + } + +} diff --git a/src/main/java/a8k/service/devicectrl/testscript/TestScript.java b/src/main/java/a8k/service/devicectrl/testscript/TestScript.java new file mode 100644 index 0000000..71d2e88 --- /dev/null +++ b/src/main/java/a8k/service/devicectrl/testscript/TestScript.java @@ -0,0 +1,242 @@ +package a8k.service.devicectrl.testscript; + +import a8k.controler.extapi.pagecontrol.ExtApiTabConfig; +import a8k.type.ConsumableGroup; +import a8k.type.exception.AppException; +import a8k.type.IncubatorPos; +import a8k.type.appret.AppRet; +import a8k.controler.extapi.utils.*; +import a8k.service.devicectrl.ctrl.SamplesPreProcesCtrl; +import a8k.service.devicectrl.ctrl.TubeRackMoveCtrl; +import a8k.hardware.A8kCanBusService; +import a8k.hardware.type.a8kcanprotocol.A8kEcode; +import a8k.service.devicectrl.ctrl.HbotControlService; +import a8k.service.devicectrl.ctrl.ReactionPlatesTransmitCtrl; +import a8k.service.devicectrl.param.DebugParam; +import a8k.service.devicectrl.param.PosParam; +import a8k.service.devicectrl.param.TimeParam; +import jakarta.annotation.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +@Component +@ExtApiTab(cfg = ExtApiTabConfig.TestScript) +public class TestScript { + static Logger logger = LoggerFactory.getLogger(TestScript.class); + + static class ORDER { + static final int testTakeAllTipStop = 0; + static final int takeTipTestStep = 1; + static final int testTakeAllTip = 2; + static final int testAllLittleBottleBufferPos = 3; + static final int testAllDetectMaterialPos = 4; + static final int testAllBigBottleBufferPos = 5; + static final int pushAllPlateAndDrop = 6; + static final int testSamplePreProcessModule = 7; + } + + @Resource + A8kCanBusService canBus; + + @Resource + ApplicationContext appCxt; + + @Resource + HbotControlService hbotcs; + + @Resource + TimeParam timep; + @Resource + PosParam pp; + @Resource + DebugParam dp; + + @Resource + ReactionPlatesTransmitCtrl reactionPlatesTransmitCtrl; + + @Resource + SamplesPreProcesCtrl samplesPreProcesCtrl; + + @Resource + TubeRackMoveCtrl tubeRackMoveCtrl; + + EnginnerParamReader settingReader = new EnginnerParamReader(HbotControlService.class); + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // 测试 + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Boolean testScriptWorkFlag = false; + + void checkTestScriptWorkFlag() throws AppException { + if (testScriptWorkFlag) { + testScriptWorkFlag = false; + throw new AppException(A8kEcode.TestScripIsRunning.index); + } + } + + @ExtApiFn(name = "停止测试脚本", group = "控制", order = ORDER.testTakeAllTipStop) + public void testTakeAllTipStop() { + testScriptWorkFlag = false; + } + +// @ExtApiFn(name = "取放Tip-单步", group = "Hbot测试脚本", order = ORDER.takeTipTestStep) + // public AppRet takeTipTestStep(Integer tipgroup, Integer index) throws AppException, InterruptedException { + // checkTestScriptWorkFlag(); + // testScriptWorkFlag = true; + // var ret = hbotcs.takeTip(tipgroup, index); + // TipPickUpPosInfo tipPos = pp.getTipPickUpPosInfo(); + // + // //TODO canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, tipPos.getPickUpZPos(tipgroup) - 100, timep.getActionOvertime()); + // // TODO canBus.pipetteCtrlPutTipBlock(MId.PipetteMod); + // + // if (canBus.moduleGetReg(MId.PipetteMod, RegIndex.kreg_pipette_tip_state) == 1) { + // throw new AppException(A8kEcode.PutTipFail.index); + // } + // + // // TODO canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); + // testScriptWorkFlag = false; + // return ret; + // } + +// @ExtApiFn(name = "取放Tip-全部", group = "Hbot测试脚本", order = ORDER.testTakeAllTip) +// public AppRet> testTakeAllTip(Integer groupId, Integer startFrom) throws AppException, InterruptedException { +// checkTestScriptWorkFlag(); +// +// testScriptWorkFlag = true; +// Map result = new HashMap<>(); +// for (int i = startFrom; i < TipPickUpPosInfo.cgetTipNum(); i++) { +// var ret = takeTipTestStep(groupId, i); +// if (!ret.getData()) { +// throw new AppException(A8kEcode.TakeTipFail.index); +// } +// +// result.put("Tip" + i, ret.getData() ? "suc" : "fail"); +// logger.info("Take Tip {}-{} => {}", groupId, i, ret.getData()); +// if (!testScriptWorkFlag) { +// break; +// } +// } +// testScriptWorkFlag = false; +// return AppRet.success(result); +// } +// +// @ExtApiFn(name = "测试所有小瓶缓冲液位置", group = "Hbot测试脚本", order = ORDER.testAllLittleBottleBufferPos) +// public void testAllLittleBottleBufferPos(ConsumableGroup group) throws AppException, InterruptedException { +// checkTestScriptWorkFlag(); +// +// testScriptWorkFlag = true; +// BottleGroupsPosInfo posInfo = pp.getBottleBufferPosInfo(); +// for (int i = 0; i < BottlesPosInfo.cgetMAX(); i++) { +// BottleGroupsPosInfo pos = pp.getBottleBufferPosInfo(); +// hbotcs.hbotMoveToSmallBottleGroup(group, i); +// //TODO: canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, pos.posTestZ, timep.getActionOvertime()); +// //TODO: canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); +// if (!testScriptWorkFlag) { +// break; +// } +// } +// testScriptWorkFlag = false; +// } +// +// @ExtApiFn(name = "测试所有探测物质位置", group = "Hbot测试脚本", order = ORDER.testAllDetectMaterialPos) +// public void testAllDetectMaterialPos(ConsumableGroup group) throws AppException, InterruptedException { +// checkTestScriptWorkFlag(); +// +// testScriptWorkFlag = true; +// for (int i = 0; i < BottlesPosInfo.cgetMAX(); i++) { +// BottleGroupsPosInfo pos = pp.getBottleBufferPosInfo(); +// hbotcs.hbotMoveToDetectMaterialPos(group, i); +// //TODO: canBus.stepMotorEasyMoveToBlock(MId.PipetteModZM, pos.posTestZ, timep.getActionOvertime()); +// //TODO: canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); +// if (!testScriptWorkFlag) { +// break; +// } +// } +// testScriptWorkFlag = false; +// } + +// @ExtApiFn(name = "测试所有大瓶缓冲液位置", group = "Hbot测试脚本", order = ORDER.testAllBigBottleBufferPos) +// public void testAllBigBottleBufferPos() throws AppException, InterruptedException { +// checkTestScriptWorkFlag(); +// +// testScriptWorkFlag = true; +// // 遍历枚举 ConsumableGroup +// for (ConsumableGroup group : ConsumableGroup.values()) { +// hbotcs.hbotMoveToLargeBottleGroup(group); +// //TODO: canBus.stepMotorEasyMoveByBlock(MId.PipetteModZM, 100, timep.getActionOvertime()); +// //TODO: canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PipetteModZM, timep.getActionOvertime()); +// if (!testScriptWorkFlag) { +// break; +// } +// } +// testScriptWorkFlag = false; +// } + + @ExtApiFn(name = "推全部板同时丢弃", group = "板夹移动测试脚本", order = ORDER.pushAllPlateAndDrop) + public void pushAllPlateAndDrop(ConsumableGroup PBCh, IncubatorPos startPos) throws AppException, InterruptedException { + checkTestScriptWorkFlag(); + testScriptWorkFlag = true; + reactionPlatesTransmitCtrl.checkBeforeMoveTrunable(); + reactionPlatesTransmitCtrl.checkBeforeMovePlateBox(); + reactionPlatesTransmitCtrl.modGroupMoveToZeroQuick(); + reactionPlatesTransmitCtrl.dropPlate(); + for (IncubatorPos index : IncubatorPos.values()) { + if (index.compareTo(startPos) < 0) { + continue; + } + reactionPlatesTransmitCtrl.pushPlateQuick(PBCh, index); + reactionPlatesTransmitCtrl.pullPlate(index); + reactionPlatesTransmitCtrl.dropPlate(); + if (!testScriptWorkFlag) { + break; + } + } + testScriptWorkFlag = false; + } + + @ExtApiFn(name = "测试摇匀模组", group = "摇匀模组测试", order = ORDER.testSamplePreProcessModule) + public AppRet testSamplePreProcessModule() throws AppException, InterruptedException { + checkTestScriptWorkFlag(); + testScriptWorkFlag = true; + + try { + tubeRackMoveCtrl.enterTubeHolder(); + AppRet scanResult = tubeRackMoveCtrl.moveTubeRackToScanPosAndScan(); + if (!scanResult.isSuccess()) { + tubeRackMoveCtrl.ejectTubeHolder(); + logger.info("没有扫到试管架的码"); + return AppRet.message("没有扫到试管架的码", null); + } + if (!scanResult.getData().equals("1111\r")) { + tubeRackMoveCtrl.ejectTubeHolder(); + logger.info("不是全血试管架 {}", scanResult.getData()); + return AppRet.message("不是全血试管架", null); + } + + AppRet isExistTube = tubeRackMoveCtrl.judgeTubeExist(0); + AppRet isHighTube = tubeRackMoveCtrl.moveTubeToAltitJudgXPos(0); + tubeRackMoveCtrl.moveTubeToPreProcessPos(0); + + if (!isExistTube.getData()) { + tubeRackMoveCtrl.ejectTubeHolder(); + logger.info("试管架上没有试管"); + return AppRet.message("试管架上没有试管", null); + } + + + samplesPreProcesCtrl.takeTubeAndJudgeTubeExist(isHighTube.getData()); + samplesPreProcesCtrl.shakeTube(50, 5); + samplesPreProcesCtrl.takeTubeCap(); + samplesPreProcesCtrl.pushBackTubeCapAndTakeBakTube(); + tubeRackMoveCtrl.ejectTubeHolder(); + } finally { + testScriptWorkFlag = false; + } + + return AppRet.message("测试完成", null); + + } + +} diff --git a/src/main/java/a8k/utils/ZSqliteJdbcHelper.java b/src/main/java/a8k/utils/ZSqliteJdbcHelper.java index f3560fa..24b7dba 100644 --- a/src/main/java/a8k/utils/ZSqliteJdbcHelper.java +++ b/src/main/java/a8k/utils/ZSqliteJdbcHelper.java @@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Date; import java.util.List; public class ZSqliteJdbcHelper { @@ -30,6 +31,10 @@ public class ZSqliteJdbcHelper { sql.append("integer,"); } else if (field.getType().equals(String.class)) { sql.append("text,"); + } else if (field.getType().equals(Date.class)) { + sql.append("text,"); + } else if (field.getType().isEnum()) { + sql.append("text,"); } else { sql.append("text,"); } @@ -49,6 +54,8 @@ public class ZSqliteJdbcHelper { field.set(obj, rs.getBoolean(field.getName())); } else if (field.getType().equals(String.class)) { field.set(obj, rs.getString(field.getName())); + } else if (field.getType().equals(Date.class)) { + field.set(obj, rs.getDate(field.getName())); } else if (field.getType().isEnum()) { Method methodValueOf = null; try {