From 73940a764b9ceff2bfe6a625372eaead903b1f94 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 17 Jul 2025 17:19:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B0=83=E6=95=B4iflytophald=20=E5=92=8C=20blisclient=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=B1=BB=E7=9A=84=E4=BD=8D=E7=BD=AE,=202.=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0BiLis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../channel/iflytophald/A8kChannelStateMgr.java | 19 - .../iflytophald/channel/A8kCanBusConnection.java | 361 ----------- .../iflytophald/channel/A8kCanBusService.java | 142 ----- .../iflytophald/channel/LisUartChannel.java | 237 -------- .../iflytophald/channel/PrinterUartChannel.java | 164 ----- .../channelctrl/IflytophaldChannelCtrl.java | 105 ---- .../iflytophald/driver/CodeScanerDriver.java | 97 --- .../app/channel/iflytophald/driver/HbotDriver.java | 96 --- .../iflytophald/driver/InputDetectDriver.java | 51 -- .../iflytophald/driver/MiniServoDriver.java | 218 ------- .../iflytophald/driver/ModuleEnableCtrlDriver.java | 170 ------ .../iflytophald/driver/OptModuleDriver.java | 127 ---- .../iflytophald/driver/OutputIOCtrlDriver.java | 25 - .../iflytophald/driver/PipetteCtrlDriverV2.java | 666 --------------------- .../iflytophald/driver/StepMotorCtrlDriver.java | 231 ------- .../driver/WaterTemperatureControllerDriver.java | 104 ---- .../type/channelctrl/IflytophaldResponse.java | 8 - .../iflytophald/type/protocol/A8kEcode.java | 271 --------- .../iflytophald/type/protocol/A8kPacket.java | 236 -------- .../channel/iflytophald/type/protocol/CmdId.java | 277 --------- .../iflytophald/type/protocol/HbotRegIndex.java | 48 -- .../iflytophald/type/protocol/InputIOId.java | 45 -- .../channel/iflytophald/type/protocol/LldType.java | 25 - .../app/channel/iflytophald/type/protocol/MId.java | 89 --- .../iflytophald/type/protocol/MiniServoMId.java | 20 - .../type/protocol/MiniServoRegIndex.java | 69 --- .../iflytophald/type/protocol/ModuleStatus.java | 26 - .../iflytophald/type/protocol/ModuleType.java | 34 -- .../type/protocol/OptModuleRegIndex.java | 51 -- .../iflytophald/type/protocol/OutputIOId.java | 23 - .../iflytophald/type/protocol/PipetteRegIndex.java | 78 --- .../iflytophald/type/protocol/RegIndex.java | 330 ---------- .../iflytophald/type/protocol/StepMotorMId.java | 24 - .../type/protocol/StepMotorRegIndex.java | 55 -- .../type/protocol/StepMotorSpeedLevel.java | 9 - .../type/protocol/TemperatureControlerMid.java | 15 - .../protocol/TemperatureControlerRegIndex.java | 40 -- .../protocol/pipette_module/AspirationParamId.java | 42 -- .../pipette_module/DistribuAllParamId.java | 35 -- .../type/protocol/pipette_module/DistribuType.java | 11 - .../protocol/pipette_module/PipetteConfig.java | 19 - .../protocol/pipette_module/PipetteStateIndex.java | 32 - .../type/protocol/pipette_module/TipType.java | 34 -- .../pipette_module/cfg/ContainerInfoIndex.java | 23 - .../pipette_module/cfg/LiquidInfoIndex.java | 76 --- .../pipette_module/cfg/PMBasicConfigIndex.java | 11 - .../pipette_module/cfg/PMVConfigIndex.java | 16 - .../cfg/PipetteCommonConfigIndex.java | 14 - .../pipette_module/cfg/PlatformInfoIndex.java | 34 -- .../pipette_module/cfg/ZMBasicConfigIndex.java | 30 - .../pipette_module/cfg/ZMVConfigIndex.java | 18 - .../cfgbean/PipetteCommonConfig.java | 83 --- .../cfgbean/PipetteContainerInfo.java | 70 --- .../pipette_module/cfgbean/PipetteLiquidInfo.java | 149 ----- .../pipette_module/cfgbean/PipettePMVCfg.java | 62 -- .../pipette_module/cfgbean/PipettePlatInfo.java | 84 --- .../pipette_module/cfgbean/PipetteZMBCfg.java | 74 --- .../pipette_module/cfgbean/PipetteZMVCfg.java | 67 --- .../pipette_module/cpyidx/ContainerCpyId.java | 41 -- .../pipette_module/cpyidx/LiquidConfigCpyIdx.java | 44 -- .../protocol/pipette_module/cpyidx/PMVCpyIdx.java | 42 -- .../pipette_module/cpyidx/PlatInfoCpyIdx.java | 26 - .../protocol/pipette_module/cpyidx/ZMVCpyIdx.java | 40 -- .../pipette_module/param/AspirationParam.java | 117 ---- .../pipette_module/param/DistribuAllParam.java | 81 --- .../channel/iflytophald/utils/OptGainConvert.java | 79 --- .../app/channel/net/BiLisDoubleTrackTcpClient.java | 249 -------- .../app/channel/net/BiLisSingleTrackTcpClient.java | 127 ---- .../a8k/app/client/BiLisDoubleTrackTcpClient.java | 246 ++++++++ .../a8k/app/client/BiLisSingleTrackTcpClient.java | 127 ++++ .../a8k/app/config/A8kSubModuleInitRegConfig.java | 4 +- .../app/config/IflytophaldConnectionConfig.java | 6 +- .../a8k/app/constant/ActionOvertimeConstant.java | 6 +- .../java/a8k/app/constant/MiniServoConstant.java | 2 +- .../api/v1/app/assistant/ApiRetTestControler.java | 6 +- .../controler/api/v1/app/ctrl/OsCtrlControler.java | 2 +- .../api/v1/app/data/A8kProjectCardControler.java | 2 +- .../controler/api/v1/app/data/UsrControler.java | 2 +- .../api/v1/app/ws/AppStateWebsocketEndpoint.java | 1 - .../api/v1/app/ws/AppWebSocketEndpointMgr.java | 32 +- ...quidAbsorptionAndDistributionTestControler.java | 2 +- .../java/a8k/app/dao/A8kProjExtInfoCardDao.java | 2 +- src/main/java/a8k/app/dao/SubModuleConfigDao.java | 3 +- .../a8k/app/dao/SubModuleRegInitialValueDao.java | 4 +- .../a8k/app/dao/type/db/SubModuleConfigValue.java | 5 +- .../app/dao/type/db/SubModuleRegInitialValue.java | 4 +- .../java/a8k/app/factory/A8kPacketFactory.java | 4 +- .../app/factory/BiLisDoubleTrackFrameFactory.java | 14 +- .../java/a8k/app/factory/FakeAppErrorFactory.java | 6 +- .../java/a8k/app/i18n/Internationalization.java | 8 +- .../a8k/app/iflytophald/A8kChannelStateMgr.java | 19 + .../channel/A8kCanBusCommunicationChannel.java | 362 +++++++++++ .../channel/LisUartCommunicationChannel.java | 237 ++++++++ .../channel/PrinterUartCommunicationChannel.java | 164 +++++ .../iflytophald/driver/A8kCanBusBaseDriver.java | 144 +++++ .../app/iflytophald/driver/CodeScanerDriver.java | 96 +++ .../a8k/app/iflytophald/driver/HbotDriver.java | 95 +++ .../app/iflytophald/driver/InputDetectDriver.java | 50 ++ .../app/iflytophald/driver/MiniServoDriver.java | 218 +++++++ .../iflytophald/driver/ModuleEnableCtrlDriver.java | 169 ++++++ .../app/iflytophald/driver/OptModuleDriver.java | 126 ++++ .../app/iflytophald/driver/OutputIOCtrlDriver.java | 24 + .../iflytophald/driver/PipetteCtrlDriverV2.java | 666 +++++++++++++++++++++ .../iflytophald/driver/StepMotorCtrlDriver.java | 230 +++++++ .../driver/WaterTemperatureControllerDriver.java | 103 ++++ .../type/channelctrl/IflytophaldResponse.java | 8 + .../app/iflytophald/type/protocol/A8kEcode.java | 277 +++++++++ .../app/iflytophald/type/protocol/A8kPacket.java | 236 ++++++++ .../a8k/app/iflytophald/type/protocol/CmdId.java | 277 +++++++++ .../iflytophald/type/protocol/HbotRegIndex.java | 48 ++ .../app/iflytophald/type/protocol/InputIOId.java | 45 ++ .../a8k/app/iflytophald/type/protocol/LldType.java | 25 + .../a8k/app/iflytophald/type/protocol/MId.java | 89 +++ .../iflytophald/type/protocol/MiniServoMId.java | 20 + .../type/protocol/MiniServoRegIndex.java | 69 +++ .../iflytophald/type/protocol/ModuleStatus.java | 26 + .../app/iflytophald/type/protocol/ModuleType.java | 34 ++ .../type/protocol/OptModuleRegIndex.java | 51 ++ .../app/iflytophald/type/protocol/OutputIOId.java | 23 + .../iflytophald/type/protocol/PipetteRegIndex.java | 78 +++ .../app/iflytophald/type/protocol/RegIndex.java | 330 ++++++++++ .../iflytophald/type/protocol/StepMotorMId.java | 24 + .../type/protocol/StepMotorRegIndex.java | 55 ++ .../type/protocol/StepMotorSpeedLevel.java | 9 + .../type/protocol/TemperatureControlerMid.java | 15 + .../protocol/TemperatureControlerRegIndex.java | 40 ++ .../protocol/pipette_module/AspirationParamId.java | 42 ++ .../pipette_module/DistribuAllParamId.java | 35 ++ .../type/protocol/pipette_module/DistribuType.java | 11 + .../protocol/pipette_module/PipetteConfig.java | 19 + .../protocol/pipette_module/PipetteStateIndex.java | 32 + .../type/protocol/pipette_module/TipType.java | 34 ++ .../pipette_module/cfg/ContainerInfoIndex.java | 23 + .../pipette_module/cfg/LiquidInfoIndex.java | 76 +++ .../pipette_module/cfg/PMBasicConfigIndex.java | 11 + .../pipette_module/cfg/PMVConfigIndex.java | 16 + .../cfg/PipetteCommonConfigIndex.java | 14 + .../pipette_module/cfg/PlatformInfoIndex.java | 34 ++ .../pipette_module/cfg/ZMBasicConfigIndex.java | 30 + .../pipette_module/cfg/ZMVConfigIndex.java | 18 + .../cfgbean/PipetteCommonConfig.java | 83 +++ .../cfgbean/PipetteContainerInfo.java | 70 +++ .../pipette_module/cfgbean/PipetteLiquidInfo.java | 149 +++++ .../pipette_module/cfgbean/PipettePMVCfg.java | 62 ++ .../pipette_module/cfgbean/PipettePlatInfo.java | 84 +++ .../pipette_module/cfgbean/PipetteZMBCfg.java | 74 +++ .../pipette_module/cfgbean/PipetteZMVCfg.java | 67 +++ .../pipette_module/cpyidx/ContainerCpyId.java | 41 ++ .../pipette_module/cpyidx/LiquidConfigCpyIdx.java | 44 ++ .../protocol/pipette_module/cpyidx/PMVCpyIdx.java | 42 ++ .../pipette_module/cpyidx/PlatInfoCpyIdx.java | 26 + .../protocol/pipette_module/cpyidx/ZMVCpyIdx.java | 40 ++ .../pipette_module/param/AspirationParam.java | 117 ++++ .../pipette_module/param/DistribuAllParam.java | 81 +++ .../utils/IflytophaldChannelCtrlRequester.java | 105 ++++ .../a8k/app/iflytophald/utils/OptGainConvert.java | 79 +++ .../a8k/app/service/analyzer/A8kEcodeAnalyzer.java | 2 +- .../analyzer/A8kIdCardDataParseService.java | 2 +- .../appsetup/A8kSubModuleRegInitService.java | 12 +- .../ProjIDCardCtrlAndMonitorService.java | 14 +- .../background/SensorDataUpdateService.java | 16 +- .../service/background/TemperatureCtrlService.java | 4 +- .../service/ctrlmodule/TipOperationCtrlModule.java | 4 +- .../a8k/app/service/data/AppUserMgrService.java | 5 +- .../app/service/data/ProjIdCardInfoMgrService.java | 2 +- .../a8k/app/service/data/ProjInfoMgrService.java | 2 +- .../app/service/data/SubModuleConfigService.java | 8 +- .../data/SubModuleRegInitialValueMgrService.java | 12 +- ...LiquidAbsorptionAndDistributionTestService.java | 12 +- .../utils/BeforeDoEngineerActionChecker.java | 2 +- .../app/service/lis/BiLisDoubleTrackChannel.java | 136 +++-- .../app/service/lis/BiLisSingleTrackChannel.java | 82 ++- src/main/java/a8k/app/service/lis/LisChannel.java | 21 + .../app/service/lis/LisCommunicationService.java | 86 ++- .../java/a8k/app/service/lis/LisSampleInfo.java | 12 + .../lowerctrl/ConsumablesScanCtrlService.java | 2 +- .../app/service/lowerctrl/HbotMoveCtrlService.java | 18 +- .../service/lowerctrl/HbotMoveExCtrlService.java | 4 +- .../lowerctrl/LiquidOperationCtrService.java | 14 +- .../lowerctrl/OptScanModuleLowerCtrlService.java | 10 +- .../app/service/lowerctrl/PlateBoxCtrlService.java | 4 +- .../service/lowerctrl/TubeFeedingCtrlService.java | 22 +- .../lowerctrl/TubeFeedingExCtrlService.java | 14 +- .../lowerctrl/TubePreProcessModuleCtrlService.java | 10 +- .../TubePreProcessModuleExCtrlService.java | 6 +- .../service/lowerctrl/TurnableMoveCtrlService.java | 16 +- .../mainctrl/AppConsumablesScanService.java | 2 +- .../service/mainctrl/AppDeviceInitCtrlService.java | 4 +- .../mainctrl/AppDeviceMainFlowCtrlService.java | 2 +- .../service/mainctrl/MainFlowCtrlScheduler.java | 2 +- .../mainctrl/TubeHolderSettingMgrService.java | 2 +- .../app/service/module/InFeedingCtrlModule.java | 6 +- .../java/a8k/app/service/os/OSBeepCtrlService.java | 10 +- .../a8k/app/service/os/OSDeviceInfoMgrService.java | 5 +- .../a8k/app/service/os/OSNetworkMgrService.java | 2 +- .../service/peripheral_ctrl/PrinterService.java | 6 +- .../app/service/setting/AppSettingsMgrService.java | 2 +- .../service/statemgr/ConsumablesMgrService.java | 2 +- .../a8k/app/service/statemgr/GStateMgrService.java | 2 +- .../a8k/app/service/statemgr/TubeStateMgr.java | 2 +- .../statemgr/consumables_mgr/TipStateMgr.java | 2 +- src/main/java/a8k/app/service/utils/UISender.java | 8 +- .../java/a8k/app/service/utils/ZAppChecker.java | 2 +- .../virtualstate/DeviceVirtualStateMgrService.java | 2 +- src/main/java/a8k/app/type/BoardVersions.java | 2 +- .../a8k/app/type/a8k/state/DeviceWorkState.java | 2 +- .../a8k/app/type/appevent/A8kHardwareReport.java | 2 +- .../app/type/appevent/AppWarningNotifyEvent.java | 2 +- src/main/java/a8k/app/type/error/AECodeError.java | 2 +- .../app/type/error/AEConsumeNotEnoughError.java | 2 +- .../java/a8k/app/type/error/AEHardwareError.java | 6 +- .../a8k/app/type/error/AESimpleErrorPrompt.java | 2 +- src/main/java/a8k/app/type/error/AETubeError.java | 2 +- src/main/java/a8k/app/type/error/AppError.java | 2 +- .../java/a8k/app/type/exception/AppException.java | 6 +- .../app/type/exception/ZAppInterruptException.java | 2 +- .../BiLisDoubleTrackFrameBuildContext.java | 2 - .../a8k/app/type/lisprotocol/subframe/OFrame.java | 17 +- src/main/java/a8k/app/type/ui/ApiRet.java | 2 +- src/main/java/a8k/app/utils/ActionTaskPool.java | 2 +- .../pos_calibration/HbotTipPosCalibration.java | 4 +- .../java/a8k/extui/page/apptest/LisTestPage.java | 4 +- .../a8k/extui/page/apptest/PrinterDebugPage.java | 22 +- .../codetest/BiLisDoubleTrackChannelTestPage.java | 28 +- .../page/debug/P02ConsumablesMgrDebugPage.java | 2 +- .../page/driver/CodeScannerDriverCtrlPage.java | 2 +- .../java/a8k/extui/page/driver/HbotCtrlPage.java | 6 +- .../a8k/extui/page/driver/MiniServoCtrlPage.java | 6 +- .../java/a8k/extui/page/driver/MotorCtrlPage.java | 8 +- .../a8k/extui/page/driver/OptScannerCtrlPage.java | 6 +- .../driver/pipette_module/PipetteGunCfgSync.java | 4 +- .../pipette_module/PipetteGunCommonConfigPage.java | 6 +- .../PipetteGunContainerConfigSettingPage.java | 6 +- .../PipetteGunLiquidConfigSettingPage.java | 8 +- .../PipetteGunOperationCtrlPage.java | 10 +- .../PipetteGunPMVelConfigSettingPage.java | 6 +- .../PipetteGunPlatformSettingPage.java | 4 +- .../pipette_module/PipetteGunTestCtrlPage.java | 8 +- .../PipetteGunZMVelConfigSettingPage.java | 6 +- .../pipette_module/PipetteGunZMotorCtrlPage.java | 6 +- .../page/extapp/OptModuleParamCalibration.java | 2 +- .../a8k/extui/page/extapp/TemporaryTestPage.java | 4 +- .../P02A8kTemperaturaVerfication.java | 2 +- .../page/extapp/tools/MoterMoveUtilsPage.java | 6 +- .../db/A8kSubModuleRegAndConfigSyncPage.java | 8 +- .../page/hardwaretest/HBotHardwareTestPage.java | 4 +- .../hardwaretest/InputIOStateHardwareTestPage.java | 4 +- .../extui/page/hardwaretest/LISUartTestPage.java | 16 +- .../hardwaretest/MiniServoHardwareTestPage.java | 4 +- .../hardwaretest/MiniServoPosCalibratePage.java | 4 +- .../page/hardwaretest/MiscHardwareTestPage.java | 2 +- .../page/hardwaretest/MotorHardwareTestPage.java | 7 +- .../hardwaretest/MotorPPSHardwareTestPage.java | 7 +- .../page/hardwaretest/OutputIOCtrlTestPage.java | 4 +- .../hardwaretest/PipetteGunHardwareTestPage.java | 3 +- .../page/hardwaretest/SubBoardProberPage.java | 6 +- .../hardwaretest/SubModuleVersionPreviewPage.java | 6 +- .../hardwaretest/WaterTempControllerTestPage.java | 6 +- .../page/measurement/FeedingModMeasurePage.java | 6 +- .../measurement/HbotFreedomPosMeasurePage.java | 4 +- .../extui/page/measurement/HbotPosMeasurePage.java | 6 +- .../page/measurement/IncubatorMeasurePage.java | 4 +- .../extui/page/measurement/OptModMeasurePage.java | 6 +- .../page/measurement/PlatesBoxMeasurePage.java | 4 +- .../measurement/ShakeModStepMotorMeasurePage.java | 8 +- .../extui/page/miniservo/MiniServoScanerPage.java | 4 +- .../extui/page/optalgotest/OptAlgoTestPage.java | 2 +- .../page/test/codetest/OptFormulaTestPage.java | 2 +- .../page/test/codetest/OptFormulaTestPageV2.java | 2 +- .../HbotCodeScanPosVerificationPage.java | 2 +- .../test/verification/P10ProjejIDCardTestPage.java | 2 +- ...1ReactionPlatesTransmitPosVerificationPage.java | 4 +- .../verification/P50VerificationScriptPage.java | 2 +- src/main/java/a8k/extui/type/ret/AppRetV1.java | 2 +- 274 files changed, 7037 insertions(+), 6887 deletions(-) delete mode 100644 src/main/java/a8k/app/channel/iflytophald/A8kChannelStateMgr.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusConnection.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusService.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/channel/LisUartChannel.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/channel/PrinterUartChannel.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/channelctrl/IflytophaldChannelCtrl.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/CodeScanerDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/HbotDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/InputDetectDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/MiniServoDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/ModuleEnableCtrlDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/OptModuleDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/OutputIOCtrlDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/PipetteCtrlDriverV2.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/StepMotorCtrlDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/driver/WaterTemperatureControllerDriver.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/channelctrl/IflytophaldResponse.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kEcode.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kPacket.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/CmdId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/HbotRegIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/InputIOId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/LldType.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/MId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoMId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoRegIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleStatus.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleType.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/OptModuleRegIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/OutputIOId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/PipetteRegIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/RegIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorMId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorRegIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorSpeedLevel.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerMid.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerRegIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/AspirationParamId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuType.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteConfig.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/TipType.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/AspirationParam.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java delete mode 100644 src/main/java/a8k/app/channel/iflytophald/utils/OptGainConvert.java delete mode 100644 src/main/java/a8k/app/channel/net/BiLisDoubleTrackTcpClient.java delete mode 100644 src/main/java/a8k/app/channel/net/BiLisSingleTrackTcpClient.java create mode 100644 src/main/java/a8k/app/client/BiLisDoubleTrackTcpClient.java create mode 100644 src/main/java/a8k/app/client/BiLisSingleTrackTcpClient.java create mode 100644 src/main/java/a8k/app/iflytophald/A8kChannelStateMgr.java create mode 100644 src/main/java/a8k/app/iflytophald/channel/A8kCanBusCommunicationChannel.java create mode 100644 src/main/java/a8k/app/iflytophald/channel/LisUartCommunicationChannel.java create mode 100644 src/main/java/a8k/app/iflytophald/channel/PrinterUartCommunicationChannel.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/A8kCanBusBaseDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/CodeScanerDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/HbotDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/InputDetectDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/MiniServoDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/ModuleEnableCtrlDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/OptModuleDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/OutputIOCtrlDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/PipetteCtrlDriverV2.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/StepMotorCtrlDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/driver/WaterTemperatureControllerDriver.java create mode 100644 src/main/java/a8k/app/iflytophald/type/channelctrl/IflytophaldResponse.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/A8kEcode.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/A8kPacket.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/CmdId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/HbotRegIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/InputIOId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/LldType.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/MId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/MiniServoMId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/MiniServoRegIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/ModuleStatus.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/ModuleType.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/OptModuleRegIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/OutputIOId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/PipetteRegIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/RegIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/StepMotorMId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/StepMotorRegIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/StepMotorSpeedLevel.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerMid.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerRegIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/AspirationParamId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuType.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteConfig.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/TipType.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/AspirationParam.java create mode 100644 src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java create mode 100644 src/main/java/a8k/app/iflytophald/utils/IflytophaldChannelCtrlRequester.java create mode 100644 src/main/java/a8k/app/iflytophald/utils/OptGainConvert.java create mode 100644 src/main/java/a8k/app/service/lis/LisChannel.java create mode 100644 src/main/java/a8k/app/service/lis/LisSampleInfo.java diff --git a/src/main/java/a8k/app/channel/iflytophald/A8kChannelStateMgr.java b/src/main/java/a8k/app/channel/iflytophald/A8kChannelStateMgr.java deleted file mode 100644 index fe506a0..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/A8kChannelStateMgr.java +++ /dev/null @@ -1,19 +0,0 @@ -package a8k.app.channel.iflytophald; - -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -@Component -@Slf4j -@RequiredArgsConstructor -public class A8kChannelStateMgr { - private final A8kCanBusService canBus; - - - public Boolean isCanBusConnected() { - return canBus.isConnect(); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusConnection.java b/src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusConnection.java deleted file mode 100644 index 64ffc94..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusConnection.java +++ /dev/null @@ -1,361 +0,0 @@ -package a8k.app.channel.iflytophald.channel; - -import a8k.OS; -import a8k.app.channel.iflytophald.type.protocol.*; -import a8k.app.type.appevent.A8kCanBusOnConnectEvent; -import a8k.app.type.appevent.A8kHardwareReport; -import a8k.app.type.error.AEHardwareError; -import a8k.app.type.exception.AppException; -import a8k.app.factory.A8kPacketFactory; -import a8k.app.service.background.AppEventBusService; -import a8k.app.utils.ByteArrayUtils; -import a8k.app.utils.ZList; -import jakarta.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.enums.ReadyState; -import org.java_websocket.handshake.ServerHandshake; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; - -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - - -@Slf4j -public class A8kCanBusConnection extends WebSocketClient { - @Resource - AppEventBusService eventBus; - - String datachurl = null; - String cmdchurl = null; - Boolean firstCall = true; - - @Value("${iflytophald.enable}") - Boolean iflytophaldEnable; - - - static class ProcessContext { - BlockingQueue receiptQueue = new LinkedBlockingQueue<>(); // - A8kPacket cmdPacket; - Map txcmdcache = new HashMap<>(); - - - public A8kPacket getReceipt(long overtime) { - long end = OS.getMonotonicClockTimestamp() + overtime; - A8kPacket packet = null; - while (OS.getMonotonicClockTimestamp() < end) { - try { - packet = receiptQueue.poll(2, TimeUnit.MILLISECONDS); - } catch (InterruptedException ignored) { - } - if (packet != null) { - this.cmdPacket = null; - return packet; - } - } - - synchronized (this) { - try { - packet = receiptQueue.poll(1, TimeUnit.MILLISECONDS); - } catch (InterruptedException ignored) { - } - receiptQueue.clear(); - this.cmdPacket = null; - return packet; - } - } - - synchronized void pushReceipt(A8kPacket receipt) { - if (this.cmdPacket != null && this.cmdPacket.getPacketIndex() == receipt.getPacketIndex()) { - if (this.cmdPacket.getModuleId() == receipt.getModuleId() && this.cmdPacket.getCmdId() == receipt.getCmdId()) { - receiptQueue.add(receipt); - this.cmdPacket = null; - } else { - log.warn("RX index equal, but cmdId not equal, {} {}", this.cmdPacket, receipt); - } - } else { - log.warn("RX unmatched index receipt, {} {}", this.cmdPacket, receipt); - log.warn("."); - } - } - - synchronized void setWaitingReceiptIndex(A8kPacket cmdPacket) { - if (!receiptQueue.isEmpty()) { - log.warn("some packets in receiptQueue, clear it"); - for (A8kPacket p : receiptQueue) { - log.warn("unprocess receipt: {}", p); - } - } - receiptQueue.clear(); - this.cmdPacket = cmdPacket; - } - - - synchronized void storageTxLastCmd(A8kPacket pack) { - MId mid = MId.valueOf(pack.getModuleId()); - CmdId cmdId = CmdId.valueOf(pack.getCmdId()); - if (cmdId != null && cmdId.isActionCmd()) - txcmdcache.put(mid, cmdId); - } - - synchronized CmdId getLastTxCmd(MId mid) { - return txcmdcache.get(mid); - } - } - - - ProcessContext context = new ProcessContext(); - int packetIndex = 0;//发送包的packetIndex - - - public A8kCanBusConnection(String cmdchurl, String datachurl) { - super(URI.create(datachurl)); - log.info("new A8kCanBusConnection: {} {}", cmdchurl, datachurl); - - this.datachurl = datachurl; - this.cmdchurl = cmdchurl; - packetIndex = 0; - - - } - - @Override public void onOpen(ServerHandshake serverHandshake) { - log.info("a8k canbus connect sucess"); - eventBus.pushEvent(new A8kCanBusOnConnectEvent()); - } - - @Override public void onMessage(String s) { - log.debug("RX-RAW: {}", s); - processCanRxMessage(s); - } - - @Override public void onClose(int i, String s, boolean b) { - log.warn("a8k canbus lost connection..."); - } - - @Override public void onError(Exception e) { - log.info("a8k can-websocket-channel on error"); - } - - - synchronized public A8kPacket callcmd(MId moduleId, CmdId cmdId, Integer... param) throws AppException { - var packet = packParamsToPacket(moduleId.toInt(), cmdId.toInt(), ZList.of(param)); - return autoReSend(packet, A8kPacket.CMD_OVERTIME); - } - - synchronized public A8kPacket callcmd(MId moduleId, CmdId cmdId, Long overtime, Integer... params) throws AppException { - var packet = packParamsToPacket(moduleId.toInt(), cmdId.toInt(), ZList.of(params)); - return autoReSend(packet, overtime); - } - - synchronized public A8kPacket send(A8kPacket pack, int overtime) throws AppException { - return priSend(pack, overtime); - } - - synchronized public ModuleStatus moduleGetStatus(MId id) throws AppException { - var getStatusPacket = packParamsToPacket(id.toInt(), CmdId.module_get_status.toInt(), ZList.of()); - for (int i = 0; i < 10; i++) { - try { - return ModuleStatus.valueOf(priSend(getStatusPacket, 30).getContentI32(0)); - } catch (AppException ignored) { - } - restartCanif(); - OS.hsleep(10); - } - throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, - MId.valueOf(getStatusPacket.getModuleId()), CmdId.valueOf(getStatusPacket.getCmdId()))); - - } - - // - // PRIVATE - // - @Scheduled(fixedRate = 10000) - private void autoConnect() { - if (!iflytophaldEnable) - return; - - if (!isOpen()) { - if (getReadyState().equals(ReadyState.NOT_YET_CONNECTED)) { - try { - connect(); - } catch (IllegalStateException ignored) { - } - } else if (getReadyState().equals(ReadyState.CLOSED)) { - reconnect(); - } - } - } - - /** - * 强制关闭websocket连接,让其与canbus服务重连 - */ - private A8kPacket packParamsToPacket(Integer moduleId, Integer cmdId, List params) { - return A8kPacketFactory.buildCMDPacket(moduleId, cmdId, params); - } - - - private A8kPacket autoReSend(A8kPacket pack, long overtime) throws AppException { - if (firstCall) { - firstCall = false; - restartCanif(); - } - - for (int j = 0; j < 2; j++) { - for (int i = 0; i < 5; i++) { - try { - return this.priSend(pack, overtime); - } catch (AppException e) { - if (!e.error.code.equals(A8kEcode.LOW_ERROR_OVERTIME)) { - throw e; - } - } - log.error("send cmd {} {} fail", pack, pack.toByteString()); - OS.hsleep(100); - log.error("retry {}", i); - } - restartCanif(); - } - - throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()))); - } - - - private A8kPacket priSend(A8kPacket pack, long overtime) throws AppException { - try { - return _priSend(pack, overtime); - } catch (AppException e) { - throw e; - } catch (Exception e) { - log.error("priSend error", e); - throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()))); - } - } - - - AppException buildOvertimeError(A8kPacket pack) { - return AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()))); - } - - private A8kPacket _priSend(A8kPacket pack, long overtime) throws AppException { - // alloc new packetIndex - packetIndex = packetIndex + 1; - if (packetIndex > 30000) { - packetIndex = 1; - } - - //set waiting receipt index - pack.setPacketIndex(packetIndex); - context.storageTxLastCmd(pack); - context.setWaitingReceiptIndex(pack); - - // TX packet - String txpacket = pack.toByteString(); - log.debug("TX-RAW: {} | {}", txpacket, pack); - send(txpacket); - - - A8kPacket receipt; - receipt = context.getReceipt(overtime); - if (receipt == null) { - throw buildOvertimeError(pack); - } - - if (receipt.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) { - throw AppException.of(new AEHardwareError(A8kEcode.fromInt(receipt.getContentI32(0)), - MId.valueOf(pack.getModuleId()), - CmdId.valueOf(pack.getCmdId()), - txpacket, - receipt.toByteString() - ) - ); - } - return receipt; - } - - /** - * 处理接收到的消息 - */ - private void processCanRxMessage(String s) { - byte[] rx = ByteArrayUtils.hexStringToBytes(s); - if (rx == null || rx.length == 0) { - log.warn("rx is empty"); - return; - } - - if (rx.length < A8kPacket.PACKET_MIN_LEN) { - log.warn("rx is too short,{}", s); - return; - } - - A8kPacket packet = new A8kPacket(rx); - - if (packet.getCheckcode() != packet.computeCheckcode()) { - log.warn("Rx packet checkcode error: {}, expect: {} but got: {}", packet, packet.computeCheckcode(), packet.getCheckcode()); - return; - } - - if (!packet.isSupportPacket()) { - log.warn("Rx packet not support: {}", packet); - return; - } - - - if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK || packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) { - log.debug("RX-ACK |RAW:{}| {}", s, packet); - context.pushReceipt(packet); - } else if (packet.getPacketType() == A8kPacket.PACKET_TYPE_EVENT) { - log.debug("RX-REPORT |RAW:{}| {}", s, packet); - eventBus.pushEvent(new A8kHardwareReport(packet)); - } else { - log.warn("RX-UNPROCESSABLE: |RAW:{}| {}", s, packet); - } - } - - public synchronized CmdId getLastTxCmd(MId mid) { - return context.getLastTxCmd(mid); - } - - public void restartCanif() { - callLocalCmd("restart"); - } - - - public HttpResponse callLocalCmd(String path) { - // 创建一个HttpClient实例 - HttpClient httpClient = HttpClient.newHttpClient(); - HttpRequest httpRequest = HttpRequest.newBuilder().uri(URI.create(String.format("%s/%s", cmdchurl, path))).build(); - HttpResponse ret = null; - try { - ret = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); - } catch (Exception e) { - log.error("callcmd error", e); - return null; - } - return ret; - } - - public static void main(String[] args) { - HttpClient httpClient = HttpClient.newHttpClient(); - HttpRequest httpRequest = HttpRequest.newBuilder().uri(URI.create("http://192.168.8.10:19004/zexcan/restart")).build(); - HttpResponse ret = null; - try { - ret = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); - log.info("ret: \t{}", ret.body()); - } catch (Exception e) { - log.error("callcmd error", e); - } - } - -} - - diff --git a/src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusService.java b/src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusService.java deleted file mode 100644 index 9d5cb35..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/channel/A8kCanBusService.java +++ /dev/null @@ -1,142 +0,0 @@ -package a8k.app.channel.iflytophald.channel; - -import a8k.app.channel.iflytophald.type.protocol.*; -import a8k.app.type.error.AEHardwareError; -import a8k.app.type.exception.AppException; -import a8k.OS; -import a8k.app.utils.ByteArrayUtils; -import jakarta.annotation.PostConstruct; -import jakarta.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import java.net.URISyntaxException; - -@Component -@Slf4j -public class A8kCanBusService { - @Resource - A8kCanBusConnection connection; - - - @Value("${iflytophald.enable}") - Boolean iflytophaldEnable; - - @PostConstruct - public void init() throws URISyntaxException { - if (iflytophaldEnable) { - connection.connect(); - } else { - log.warn("canBus is disabled"); - } - } - - /** - * 强制关闭websocket连接,让其与canbus服务重连 - */ - public void forceShutdown() { - connection.close(); - } - - // - // BASE_OPERATION - // - - public A8kPacket callcmd(MId moduleId, CmdId cmdId, Integer... param) throws AppException { - return connection.callcmd(moduleId, cmdId, param); - } - - public A8kPacket callcmd(MId moduleId, CmdId cmdId, Long overtime, Integer... params) throws AppException { - return connection.callcmd(moduleId, cmdId, overtime, params); - } - - synchronized public A8kPacket send(A8kPacket pack, int overtime) throws AppException { - return connection.send(pack, overtime); - } - - // - // MODULE FUNCTION - // - - public void moduleStop(MId id) throws AppException { - connection.callcmd(id, CmdId.module_stop); - } - - public void moduleStopNoException(MId id) { - try { - moduleStop(id); - } catch (AppException ignored) { - } - } - - public ModuleStatus moduleGetStatus(MId id) throws AppException { - return connection.moduleGetStatus(id); - } - - public void moduleSetReg(MId id, RegIndex regindex, Integer reg) throws AppException { - connection.callcmd(id, CmdId.module_set_reg, 100L, regindex.index, reg); - } - - public Integer moduleGetReg(MId id, RegIndex regindex) throws AppException { - var packet = connection.callcmd(id, CmdId.module_get_reg, 100L, regindex.index); - return packet.getContentI32(0); - } - - public A8kEcode moduleGetError(MId id) throws AppException { - var packet = connection.callcmd(id, CmdId.module_get_error); - return A8kEcode.fromInt(packet.getContentI32(0)); - } - - public Integer moduleGetDetailError(MId id) throws AppException { - return connection.callcmd(id, CmdId.module_get_detail_error).getContentI32(0); - } - - public Integer moduleReadVersion(MId id) throws AppException { - return connection.callcmd(id, CmdId.module_get_version).getContentI32(0); - } - - public ModuleType moduleReadType(MId id) throws AppException { - var packet = connection.callcmd(id, CmdId.module_get_type); - return ModuleType.of(packet.getContentI32(0)); - } - - public byte[] a8kIdcardReaderReadRaw() throws AppException { - int i = 0; - byte[] result = new byte[0]; - while (true) { - var rxPacket = connection.callcmd(MId.A8kIdCardReader, CmdId.a8000_idcard_reader_read_raw, i++); - if (rxPacket.getCmdContent().length == 0) { - break; - } - result = ByteArrayUtils.concat(result, rxPacket.getCmdContent()); - } - return result; - } - - public void waitForMod(MId mid, Integer acitionOvertime) throws AppException { - long startedAt = OS.getMonotonicClockTimestamp(); - CmdId action = connection.getLastTxCmd(mid); - do { - ModuleStatus statu = moduleGetStatus(mid); - if (statu == ModuleStatus.IDLE) { - break; - } else if (statu == ModuleStatus.ERROR) { - log.error("{} waitting for action {} , catch error {}, defail ecode {}", mid, action, moduleGetError(mid), moduleGetDetailError(mid)); - throw AppException.of(new AEHardwareError(moduleGetError(mid), mid, action)); - } - long now = OS.getMonotonicClockTimestamp(); - if (now - startedAt > acitionOvertime) { - log.error("{} waitting for action {} overtime({})", mid, action, acitionOvertime); - moduleStopNoException(mid); - throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_ACTION_OVERTIME, mid, action)); - } - OS.hsleep(30); - } while (true); - } - - public boolean isConnect() { - return connection.isOpen(); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/channel/LisUartChannel.java b/src/main/java/a8k/app/channel/iflytophald/channel/LisUartChannel.java deleted file mode 100644 index 0013d3c..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/channel/LisUartChannel.java +++ /dev/null @@ -1,237 +0,0 @@ -package a8k.app.channel.iflytophald.channel; - -import a8k.app.config.IflytophaldConnectionConfig; -import a8k.app.channel.iflytophald.channelctrl.IflytophaldChannelCtrl; -import a8k.app.utils.ByteArrayUtils; -import jakarta.annotation.PostConstruct; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.enums.ReadyState; -import org.java_websocket.handshake.ServerHandshake; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.nio.ByteBuffer; - - -@Slf4j -@Component -@RequiredArgsConstructor -public class LisUartChannel { - - @Value("${iflytophald.enable}") - Boolean iflytophaldEnable; - - - private final String channelName = "lis"; - private final String charsetName = "UTF-8"; - - private final IflytophaldConnectionConfig config; - private final IflytophaldChannelCtrl cmdSender; - - private OnMessageListener onMessageListener; - private WebSocketClient conn; - - private Integer baudRate = 115200; - private Boolean syncBaudRateSuc = false; - private final Object baudRateLock = new Object(); - private Boolean loopbackMode = false; - - - synchronized public void tx(byte[] toSend) { - if (toSend == null || toSend.length == 0) { - return; - } - conn.send(toSend); - } - - synchronized public void tx(String toSend) { - try { - conn.send(toSend.getBytes(charsetName)); - } catch (UnsupportedEncodingException e) { - log.error("tx error", e); - } - } - - synchronized public void regRxMessageListener(OnMessageListener listener) { - this.onMessageListener = listener; - } - synchronized public void unRegRxMessageListener() { - this.onMessageListener = null; - } - - synchronized public boolean isConnected() { - return conn != null && conn.isOpen(); - } - - public synchronized Boolean setBaudRate(Integer baudRate) { - if (baudRate == null) { - log.warn("setBaudRate: baudRate is null or empty"); - return false; - } - syncBaudRateSuc = false; - syncSetBaudRate(baudRate); - return true; - } - - public synchronized void setInLoopbackMode(boolean inLoopback) { - synchronized (this.baudRateLock) { - loopbackMode = inLoopback; - } - } - - public Boolean isInLoopbackMode() { - synchronized (this.baudRateLock) { - return loopbackMode; - } - } - - public Integer getBaudRateDirect() { - synchronized (this.baudRateLock) { - if (!isConnected()) { - return this.baudRate; - } - - if (syncBaudRateSuc) { - return this.baudRate; - } - - var receipt = cmdSender.callCmd(channelName, "getBaudrate", GetBaudrateResponse.class); - if (receipt == null || receipt.status != 0 || receipt.data == null) { - log.error("getBaudRateDirect: callCmd returned null or error"); - return null; - } - syncBaudRateSuc = receipt.data.baudrate != null && receipt.data.baudrate.equals(this.baudRate); - return receipt.data.baudrate; - } - } - - - // - // PRIVATE - // - - @FunctionalInterface - public interface OnMessageListener { - void onMessage(byte[] bytes); - } - - static public class GetBaudrateResponse { - public Integer baudrate; - } - - - private void onMessage(ByteBuffer bytes) { - byte[] byteArray = new byte[bytes.remaining()]; - bytes.get(byteArray); - log.debug("onMessage: {}", ByteArrayUtils.toByteString(byteArray)); - if (onMessageListener != null) { - onMessageListener.onMessage(byteArray); - } - if (loopbackMode) { - // 如果是环回模式,则直接发送回去 - tx(byteArray); - } - } - - @PostConstruct - void init() { - // 初始化连接 - String url = config.getDatachUrl(channelName); - log.info("LisUartChannel url: {}", url); - conn = new WebSocketClient(URI.create(url)) { - @Override - public void onOpen(ServerHandshake serverHandshake) { - LisUartChannel.this.onOpen(serverHandshake); - } - - @Override - public void onMessage(String s) { - log.error("onMessage: received string message {}, this should not happen in LisUartChannel", s); - } - - @Override - public void onClose(int i, String s, boolean b) { - LisUartChannel.this.onClose(i, s, b); - } - - @Override - public void onError(Exception e) { - LisUartChannel.this.onError(e); - } - - @Override - public void onMessage(ByteBuffer bytes) { - LisUartChannel.this.onMessage(bytes); - } - }; - conn.connect(); - } - - private void onOpen(ServerHandshake serverHandshake) { - log.info("connect success"); - syncBaudRateSuc = false; - syncSetBaudRate(null); - } - - private void onClose(int i, String s, boolean b) { - log.warn("lost connection..."); - } - - private void onError(Exception e) { - log.info("on error"); - } - - private void syncSetBaudRate(Integer baudRate) { - synchronized (this.baudRateLock) { - if (baudRate != null) { - this.baudRate = baudRate; - } - if (!isConnected()) { - log.warn("lis channel is not connected, sync later"); - return; - } - - if (syncBaudRateSuc) { - return; - } - - var receipt = cmdSender.callCmd(channelName, "setBaudrate", Void.class, String.format("baudrate=%s", this.baudRate)); - if (receipt == null || receipt.status != 0) { - log.error("syncSetBaudRate: callCmd returned null"); - syncBaudRateSuc = false; - return; - } - log.info("syncSetBaudRate: set baudrate to {}", this.baudRate); - syncBaudRateSuc = true; - } - } - - @Scheduled(fixedRate = 1000) - private void autoConnect() { - if (!iflytophaldEnable) { - return; - } - - if (!conn.isOpen()) { - if (conn.getReadyState().equals(ReadyState.NOT_YET_CONNECTED)) { - try { - conn.connect(); - } catch (IllegalStateException ignored) { - } - } else if (conn.getReadyState().equals(ReadyState.CLOSED)) { - conn.reconnect(); - } - } else { - if (!syncBaudRateSuc) { - syncSetBaudRate(null); - } - } - } -} - - diff --git a/src/main/java/a8k/app/channel/iflytophald/channel/PrinterUartChannel.java b/src/main/java/a8k/app/channel/iflytophald/channel/PrinterUartChannel.java deleted file mode 100644 index 439c6a8..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/channel/PrinterUartChannel.java +++ /dev/null @@ -1,164 +0,0 @@ -package a8k.app.channel.iflytophald.channel; - -import a8k.app.config.IflytophaldConnectionConfig; -import jakarta.annotation.PostConstruct; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.java_websocket.client.WebSocketClient; -import org.java_websocket.enums.ReadyState; -import org.java_websocket.handshake.ServerHandshake; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.LinkedList; -import java.util.Queue; - - -@Slf4j -@Component -@RequiredArgsConstructor -public class PrinterUartChannel { - @Value("${iflytophald.enable}") - Boolean iflytophaldEnable; - - WebSocketClient conn; - - private final IflytophaldConnectionConfig config; - private Queue sendQueue = new LinkedList<>(); - - @PostConstruct - void init() { - String url = config.getDatachUrl("printer"); - log.info("PrinterUartChannel url: {}", url); - conn = new WebSocketClient(URI.create(url)) { - @Override - public void onOpen(ServerHandshake serverHandshake) { - PrinterUartChannel.this.onOpen(serverHandshake); - } - - @Override - public void onMessage(String s) { - PrinterUartChannel.this.onMessage(s); - } - - @Override - public void onClose(int i, String s, boolean b) { - PrinterUartChannel.this.onClose(i, s, b); - } - - @Override - public void onError(Exception e) { - PrinterUartChannel.this.onError(e); - } - }; - conn.connect(); - } - - /** - * 打印字符串 - * @param fmt 格式化字符串 - * @param args 参数 - * 1. 打印%时候,需要使用%%,否则会报错 - * - */ - public void printf(String fmt, Object... args) { - if (conn.isOpen()) { - String s = String.format(fmt, args); - try { - byte[] toSend = s.getBytes("GBK"); - pushToSend(toSend); - } catch (UnsupportedEncodingException e) { - log.error("charset error", e); - } - } else { - log.warn("PrinterUartChannel is not open"); - } - } - - public void printfEnd() { - if (conn.isOpen()) { - printf("\r\n"); - printf("\r\n"); - printf("\r\n"); - } - } - - - // - // PRIVATE - // - - - private void onOpen(ServerHandshake serverHandshake) { - log.info("a8k canbus connect sucess"); - } - - private void onMessage(String s) { - } - - private void onClose(int i, String s, boolean b) { - log.warn("a8k canbus lost connection..."); - } - - private void onError(Exception e) { - log.info("a8k can-websocket-channel on error"); - } - - - synchronized private void pushToSend(byte[] toSend) { - sendQueue.add(toSend); - } - - synchronized private byte[] popToSend() { - if (!sendQueue.isEmpty()) { - return sendQueue.poll(); - } - return null; - } - - // conn.send(toSend); - // if (toSend.length > 10) { - // OS.forceSleep(150); - // } - @Scheduled(fixedRate = 400) - private void autoSend() { - while (true) { - var tosend = popToSend(); - if (tosend != null) { - if (conn.isOpen()) { - conn.send(tosend); - } - if (tosend.length > 2) { - break; - } - } else { - break; - } - - } - - } - - - @Scheduled(fixedRate = 10000) - private void autoConnect() { - if (!iflytophaldEnable) { - return; - } - if (!conn.isOpen()) { - if (conn.getReadyState().equals(ReadyState.NOT_YET_CONNECTED)) { - try { - conn.connect(); - } catch (IllegalStateException ignored) { - } - } else if (conn.getReadyState().equals(ReadyState.CLOSED)) { - conn.reconnect(); - } - } - } -} - - diff --git a/src/main/java/a8k/app/channel/iflytophald/channelctrl/IflytophaldChannelCtrl.java b/src/main/java/a8k/app/channel/iflytophald/channelctrl/IflytophaldChannelCtrl.java deleted file mode 100644 index fcc9f35..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/channelctrl/IflytophaldChannelCtrl.java +++ /dev/null @@ -1,105 +0,0 @@ -package a8k.app.channel.iflytophald.channelctrl; - -import a8k.app.config.IflytophaldConnectionConfig; -import a8k.app.channel.iflytophald.type.channelctrl.IflytophaldResponse; -import a8k.app.utils.ZJsonHelper; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; - -@Component -@Slf4j -@RequiredArgsConstructor -public class IflytophaldChannelCtrl { - - private final IflytophaldConnectionConfig config; - - //http://192.168.8.10:19004/$chname/setBaudrate?baudrate=9600 - public HttpResponse callCmd(String channel, String cmd, String... params) { - return callCmd(config, channel, cmd, params); - } - - public IflytophaldResponse callCmd(String channel, String cmd, Class retType, String... params) { - return callCmdStatic(config.getCmdChBaseUrl(channel), cmd, retType, params); - } - - - static public HttpResponse callCmd(IflytophaldConnectionConfig connectConfig, String channel, String cmd, String... params) { - String baseurl = connectConfig.getCmdChBaseUrl(channel); - return callCmdStatic(baseurl, cmd, params); - } - - static public IflytophaldResponse callCmdStatic(String baseurl, String cmd, Class retType, String... params) { - HttpResponse response = callCmdStatic(baseurl, cmd, params); - if (response == null || response.body() == null) { - return null; - } - try { - ObjectMapper mapper = new ObjectMapper(); - JavaType javaType = mapper.getTypeFactory().constructParametricType(IflytophaldResponse.class, retType); - return mapper.readValue(response.body(), javaType); - } catch (Exception e) { - log.error("callCmd error", e); - return null; - } - } - - static public HttpResponse callCmdStatic(String baseurl, String cmd, String... params) { - // 创建一个HttpClient实例 - HttpClient httpClient = HttpClient.newHttpClient(); - - String paramStr = ""; - if (params != null && params.length > 0) { - StringBuilder sb = new StringBuilder(); - for (String param : params) { - if (!sb.isEmpty()) { - sb.append("&"); - } - sb.append(param); - } - paramStr = "?" + sb.toString(); - } - var url = URI.create(String.format("%s/%s%s", baseurl, cmd, paramStr)); - log.info("callCmd url: {}", url); - HttpRequest httpRequest = HttpRequest.newBuilder().uri(url).build(); - HttpResponse ret = null; - try { - ret = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); - } catch (Exception e) { - log.error("callcmd error", e); - return null; - } - return ret; - } - - static public class GetBaudrateResponse { - public Integer baudrate; - } - - public static void main(String[] args) { - - { - IflytophaldResponse response = - IflytophaldChannelCtrl.callCmdStatic("http://192.168.8.10:19004/lis", "setBaudrate", Void.class, "baudrate=9600"); - log.info("1Response: {}", ZJsonHelper.objToPrettyJson(response)); - } - { - IflytophaldResponse response = - IflytophaldChannelCtrl.callCmdStatic("http://192.168.8.10:19004/lis", "getBaudrate", GetBaudrateResponse.class); - log.info("2Response: {}", ZJsonHelper.objToPrettyJson(response)); - - - } - - - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/CodeScanerDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/CodeScanerDriver.java deleted file mode 100644 index e06e7ce..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/CodeScanerDriver.java +++ /dev/null @@ -1,97 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.OS; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.A8kPacket; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.type.exception.AppException; -import jakarta.annotation.Resource; -import org.springframework.stereotype.Component; - -@Component -public class CodeScanerDriver { - - @Resource - A8kCanBusService canBus; - - public String pipetteModCodeScannerScanCode(Integer overtime) throws AppException { - try { - codeScanerStartScan(MId.PipetteModCodeScanner); - String result = codeScanerWaittingForResult(MId.PipetteModCodeScanner, overtime); - codeScanerStopScan(MId.PipetteModCodeScanner); - return result; - } catch (AppException e) { - return ""; - } - } - - public String pipetteModCodeScannerScanCode() throws AppException { - return pipetteModCodeScannerScanCode(1000); - } - - public void pipetteModCodeScannerStartScan() throws AppException { - codeScanerStartScan(MId.PipetteModCodeScanner); - } - - public void pipetteModCodeScannerStopScan() throws AppException { - codeScanerStopScan(MId.PipetteModCodeScanner); - } - - - public String feedingModScannerModCodeScannerScanCode(Integer waittime) { - try { - codeScanerStartScan(MId.FeedingModScannerMod); - String result = codeScanerWaittingForResult(MId.FeedingModScannerMod, waittime); - codeScanerStopScan(MId.FeedingModScannerMod); - return result; - } catch (AppException e) { - return ""; - } - } - - public void feedingModScannerModCodeScannerStartScan() throws AppException { - codeScanerStartScan(MId.FeedingModScannerMod); - } - - public void feedingModScannerModCodeScannerStopScan() throws AppException { - codeScanerStopScan(MId.FeedingModScannerMod); - } - - private String codeScanerReadScanerResult(MId id) throws AppException { - A8kPacket ack = canBus.callcmd(id, CmdId.code_scaner_read_scaner_result); - var contentBytes = ack.getCmdContent(); - return new String(contentBytes); - } - - private Boolean codeScanerResultIsReady(MId id) throws AppException { - var packet = canBus.callcmd(id, CmdId.code_scaner_result_is_ready); - return packet.getContentI32(0) != 0; - } - - private String codeScanerWaittingForResult(MId mid, Integer acitionOvertime) throws AppException { - long startedAt = OS.getMonotonicClockTimestamp(); - do { - if (codeScanerResultIsReady(mid)) - break; - long now = OS.getMonotonicClockTimestamp(); - if (now - startedAt > acitionOvertime) { - codeScanerStopScan(mid); - return null; - } - OS.hsleep(100); - } while (true); - codeScanerStopScan(mid); - return codeScanerReadScanerResult(mid); - } - - - private void codeScanerStartScan(MId id) throws AppException { - canBus.callcmd(id, CmdId.code_scaner_start_scan); - } - - private void codeScanerStopScan(MId id) throws AppException { - canBus.callcmd(id, CmdId.code_scaner_stop_scan); - } -} - diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/HbotDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/HbotDriver.java deleted file mode 100644 index 4f8152b..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/HbotDriver.java +++ /dev/null @@ -1,96 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.HbotRegIndex; -import a8k.app.type.a8k.Pos2d; -import a8k.app.type.exception.AppException; -import jakarta.annotation.Resource; -import org.springframework.stereotype.Component; - -@Component -public class HbotDriver { - - @Resource - A8kCanBusService canBus; - - Integer actionOvertime = 10000; - Integer moveToZeroActionOvertime = 20000; - - public void enable(Integer enable) throws AppException { - canBus.callcmd(MId.HbotM, CmdId.xymotor_enable, enable); - } - - private void moveBy(Integer x, Integer y) throws AppException { - canBus.callcmd(MId.HbotM, CmdId.xymotor_move_by, x, y); - } - - public void moveByBlock(Integer x, Integer y) throws AppException { - moveBy(x, y); - canBus.waitForMod(MId.HbotM, actionOvertime); - } - - private void moveTo(Integer x, Integer y) throws AppException { - canBus.callcmd(MId.HbotM, CmdId.xymotor_move_to, x, y); - } - - public void moveToBlock(Integer x, Integer y) throws AppException { - moveTo(x, y); - canBus.waitForMod(MId.HbotM, actionOvertime); - } - - private void moveToZero() throws AppException { - canBus.callcmd(MId.HbotM, CmdId.xymotor_move_to_zero); - } - - public void moveToZeroBlock() throws AppException { - moveToZero(); - canBus.waitForMod(MId.HbotM, moveToZeroActionOvertime); - } - - public Pos2d readPos() throws AppException { - Pos2d pos = new Pos2d(0, 0); - var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_pos); - pos.x = packet.getContentI32(0); - pos.y = packet.getContentI32(1); - return pos; - } - - public Boolean readInIO(Integer ioIndex) throws AppException { - var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_inio, ioIndex); - return packet.getContentI32(0) != 0; - } - - public void setPos(Integer x, Integer y) throws AppException { - canBus.callcmd(MId.HbotM, CmdId.xymotor_set_pos, x, y); - } - - public void moveByDirectBlock(Integer motor1_dpos, Integer motor2_dpos) throws AppException { - canBus.callcmd(MId.HbotM, CmdId.xymotor_motor_move_by_direct, motor1_dpos, motor2_dpos); - canBus.waitForMod(MId.HbotM, actionOvertime); - } - - public Integer[] readEncDirect() throws AppException { - var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_enc_direct); - Integer[] enc = new Integer[2]; - enc[0] = packet.getContentI32(0); - enc[1] = packet.getContentI32(1); - return enc; - } - - public Integer hbotReadInioIndexInStm32(Integer ioIndex) throws AppException { - var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_inio_index_in_stm32, ioIndex); - return packet.getContentI32(0); - } - - public void setReg(HbotRegIndex regIndex, Integer value) throws AppException { - canBus.moduleSetReg(MId.HbotM, regIndex.regIndex, value); - } - - public Integer getReg(HbotRegIndex regIndex) throws AppException { - return canBus.moduleGetReg(MId.HbotM, regIndex.regIndex); - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/InputDetectDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/InputDetectDriver.java deleted file mode 100644 index 2829711..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/InputDetectDriver.java +++ /dev/null @@ -1,51 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.app.type.error.AECodeError; -import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.InputIOId; -import a8k.app.channel.iflytophald.type.protocol.ModuleType; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -@Slf4j -public class InputDetectDriver { - - private final A8kCanBusService a8kCanBusService; - - public Boolean getIOState(InputIOId ioid) throws AppException { - while (true) { - Boolean firstReadIO = priGetIOState(ioid, 100); - Boolean secondReadIO = priGetIOState(ioid, 100); - if (firstReadIO == secondReadIO) { - if (ioid.mirror) { - return !firstReadIO; - } - return firstReadIO; - } else { - log.warn("getIOState {} not match, retry", ioid); - } - } - } - - public Boolean getIOQuickState(InputIOId ioid) throws AppException { - return priGetIOState(ioid, 50); - } - - - private Boolean priGetIOState(InputIOId ioid, long overtime) throws AppException { - if (ioid.mtype == ModuleType.Board) { - return a8kCanBusService.callcmd(ioid.mid, CmdId.extboard_read_inio, overtime, ioid.ioIndex).getContentI32(0) != 0; - } else if (ioid.mtype == ModuleType.TMCStepMotor) { - return a8kCanBusService.callcmd(ioid.mid, CmdId.step_motor_read_io_state, overtime, ioid.ioIndex).getContentI32(0) != 0; - } else if (ioid.mtype == ModuleType.MiniServo) { - return a8kCanBusService.callcmd(ioid.mid, CmdId.mini_servo_read_io_state, overtime, ioid.ioIndex).getContentI32(0) != 0; - } else { - throw new AppException(new AECodeError(String.format("IOID MODULE TYPE %s NOT SUPPORT", ioid.mtype))); - } - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/MiniServoDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/MiniServoDriver.java deleted file mode 100644 index 8a5ad34..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/MiniServoDriver.java +++ /dev/null @@ -1,218 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.OS; -import a8k.app.constant.MiniServoConstant; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.*; -import a8k.app.type.error.AEHardwareError; -import a8k.app.type.exception.AppException; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - - -@Component -@Slf4j -@RequiredArgsConstructor -public class MiniServoDriver { - final private A8kCanBusService canBus; - - public void moduleStop(MiniServoMId id) throws AppException { - canBus.moduleStop(id.mid); - } - - public void miniServoEnable(MiniServoMId id, int enable) throws AppException { - log.debug("{} miniServoEnable {}", id.mid, enable); - callcmd(id.mid, CmdId.mini_servo_enable, enable); - } - - public void miniServoForceEnable(MiniServoMId id, int enable) { - try { - miniServoEnable(id, enable); - } catch (AppException e) { - log.error("miniServoForceEnable error", e); - } - } - - public Boolean miniServoPing(MiniServoMId id) { - try { - miniServoReadPos(id); - } catch (AppException e) { - return false; - } - return true; - } - - public int miniServoReadPos(MiniServoMId id) throws AppException { - var packet = callcmd(id.mid, CmdId.mini_servo_read_pos); - return packet.getContentI32(0); - } - - public void miniServoMoveToZeroBlock(MiniServoMId id) throws AppException { - log.debug("{} miniServoMoveToZeroBlock", id.mid); - miniServoMoveToBlock(id, MiniServoConstant.getZeroPos(id)); - } - - public void miniServoMoveToRefBlock(MiniServoMId id) throws AppException { - log.debug("{} miniServoMoveToRefBlock", id.mid); - miniServoMoveToBlock(id, MiniServoConstant.getRefPos(id)); - } - - - private void miniServoMoveTo(MiniServoMId id, int pos) throws AppException { - callcmd(id.mid, CmdId.mini_servo_move_to, pos); - } - - public void miniServoMoveToBlock(MiniServoMId id, int pos) throws AppException { - log.debug("{} miniServoMoveTo {}", id.mid, pos); - int retry = 0; - do { - try { - miniServoMoveTo(id, pos); - canBus.waitForMod(id.mid, MiniServoConstant.actionOvertime); - return; - } catch (AppException e) { - if (e.getError().code.equals(A8kEcode.LOW_ERROR_SUBDEVICE_OVERTIME)) { - log.warn("CALL miniServoMoveToBlock {} FAIL, SUB DEVICE OVERTIME", id); - if (retry > 3) { - throw e; - } - } else { - throw e; - } - } - OS.hsleep(1000); - retry++; - } while (true); - } - - - public void miniServoRotate(MiniServoMId id, int direction) throws AppException { - log.debug("{} miniServoRotate {}", id.mid, direction); - callcmd(id.mid, CmdId.mini_servo_rotate, direction); - } - - public void miniServoActiveCfg(MiniServoMId id) throws AppException { - callcmd(id.mid, CmdId.mini_servo_active_cfg); - } - - public void miniServoStop(MiniServoMId id) throws AppException { - callcmd(id.mid, CmdId.mini_servo_stop); - } - - public void miniServoSetMidPoint(MiniServoMId id) throws AppException { - callcmd(id.mid, CmdId.mini_servo_set_mid_point); - } - - public int miniServoReadIoState(MiniServoMId id) throws AppException { - var packet = callcmd(id.mid, CmdId.mini_servo_read_io_state); - return packet.getContentI32(0); - } - - public void miniServoRotateBlock(MiniServoMId id, int direction) throws AppException { - miniServoRotate(id, direction); - canBus.waitForMod(id.mid, MiniServoConstant.actionOvertime); - } - - public void miniServoRotateWithTorque(MiniServoMId id, int torque) throws AppException { - log.debug("{} miniServoRotateWithTorque {}", id.mid, torque); - callcmd(id.mid, CmdId.mini_servo_rotate_with_torque, torque); - } - - public void waitForMod(MiniServoMId mid) throws AppException { - canBus.waitForMod(mid.mid, MiniServoConstant.actionOvertime); - } - - public void waitForMod(MiniServoMId... mid) throws AppException { - for (MiniServoMId m : mid) { - waitForMod(m); - } - } - - - // kmini_servo_set_cur_pos - private void miniServoSetCurPos(MiniServoMId id, Integer pos) throws AppException { - log.debug("{} miniServoSetCurPos {}", id.mid, pos); - callcmd2(id.mid, CmdId.mini_servo_set_cur_pos, 5000L, pos); - } - - public Integer miniServoSetRefPos(MiniServoMId id) throws AppException { - miniServoSetCurPos(id, MiniServoConstant.getRefPos(id)); - return MiniServoConstant.getRefPos(id); - } - - public void setReg(MiniServoMId id, MiniServoRegIndex regindex, int val) throws AppException { - log.debug("{} setReg {} {}", id.mid, regindex, val); - canBus.moduleSetReg(id.mid, regindex.regIndex, val); - } - - public Integer getReg(MiniServoMId id, MiniServoRegIndex regindex) throws AppException { - return canBus.moduleGetReg(id.mid, regindex.regIndex); - } - - public Integer getRegNoEx(MiniServoMId id, MiniServoRegIndex regindex) { - try { - return canBus.moduleGetReg(id.mid, regindex.regIndex); - } catch (AppException e) { - log.error("readRegNoEx error", e); - return null; - } - } - - public void miniServoWaitIsNotMove(MiniServoMId id, int acitionOvertime) throws AppException { - long startedAt = OS.getMonotonicClockTimestamp(); - do { - var isMove = canBus.moduleGetReg(id.mid, RegIndex.kreg_mini_servo_is_move); - if (isMove != 0) { - break; - } - long now = OS.getMonotonicClockTimestamp(); - if (now - startedAt > acitionOvertime) { - throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, id.mid, null)); - } - - } while (true); - } - - private A8kPacket callcmd(MId id, CmdId cmdId, Integer... args) throws AppException { - int retry = 0; - do { - try { - return canBus.callcmd(id, cmdId, args); - } catch (AppException e) { - if (e.getError().code.equals(A8kEcode.LOW_ERROR_SUBDEVICE_OVERTIME)) { - log.warn("CALL CMD {} FAIL, SUB DEVICE OVERTIME", cmdId); - if (retry > 3) { - throw e; - } - } else { - throw e; - } - } - OS.hsleep(1000); - retry++; - } while (true); - } - - private A8kPacket callcmd2(MId id, CmdId cmdId, Long timeout, Integer... args) throws AppException { - int retry = 0; - do { - try { - return canBus.callcmd(id, cmdId, timeout, args); - } catch (AppException e) { - if (e.getError().code.equals(A8kEcode.LOW_ERROR_SUBDEVICE_OVERTIME)) { - log.warn("CALL CMD2 {} FAIL, SUB DEVICE OVERTIME", cmdId); - if (retry > 3) { - throw e; - } - } else { - throw e; - } - } - OS.hsleep(1000); - retry++; - } while (true); - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/ModuleEnableCtrlDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/ModuleEnableCtrlDriver.java deleted file mode 100644 index 9dc09b1..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/ModuleEnableCtrlDriver.java +++ /dev/null @@ -1,170 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; -import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.type.protocol.MId; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -@Component -@Slf4j -@RequiredArgsConstructor -public class ModuleEnableCtrlDriver { - - private final HbotDriver hbotDriver; - private final PipetteCtrlDriverV2 pipetteCtrlDriver; - private final StepMotorCtrlDriver stepMotorCtrlDriver; - private final MiniServoDriver miniServoDriver; - private final A8kCanBusService canBus; - - public void forceDisableAllMotor() { - // StepMotorMId.values() - for (StepMotorMId stepMotorMId : StepMotorMId.values()) { - try { - stepMotorCtrlDriver.stepMotorEnable(stepMotorMId, 0); - } catch (AppException e) { - log.info("disableStepMotor: {} failed, {}", stepMotorMId, e.getMessage()); - } - } - - for (MiniServoMId miniServoMId : MiniServoMId.values()) { - try { - miniServoDriver.miniServoEnable(miniServoMId, 0); - } catch (AppException e) { - log.info("disableMiniServo: {} failed, {}", miniServoMId, e.getMessage()); - } - } - - try { - hbotDriver.enable(0); - } catch (AppException e) { - log.info("hbotDriver disable failed, {}", e.getMessage()); - } - - try { - pipetteCtrlDriver.zMotorEnable(0); - } catch (AppException e) { - log.info("pipetteCtrlDriver: zMotorEnable failed, {}", e.getMessage()); - } - } - - public void stopAllMotor() 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 { - canBus.moduleStop(MId.IncubatorRotateCtrlM); - } catch (AppException ignored) { - } - - for (var motorId : StepMotorMId.values()) { - try { - stepMotorCtrlDriver.stepMotorEnable(motorId, 0); - } catch (AppException ignored) { - } - } - - for (var miniServoId : MiniServoMId.values()) { - try { - miniServoDriver.miniServoEnable(miniServoId, 0); - } catch (AppException ignored) { - } - } - - hbotDriver.enable(0); - pipetteCtrlDriver.zMotorEnable(0); - } - - - public void stopHeating() throws AppException { - canBus.moduleStop(MId.IncubatorTCM); - canBus.moduleStop(MId.PlatesBoxTCM); - } - - public void enableAllMotor() throws AppException { - try { - for (StepMotorMId stepMotorMId : StepMotorMId.values()) - stepMotorCtrlDriver.stepMotorEnable(stepMotorMId, 1); - - - for (MiniServoMId miniServoMId : MiniServoMId.values()) - miniServoDriver.miniServoEnable(miniServoMId, 1); - - hbotDriver.enable(1); - pipetteCtrlDriver.zMotorEnable(1); - } catch (AppException e) { - forceDisableAllMotor(); - throw e; - } - - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/OptModuleDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/OptModuleDriver.java deleted file mode 100644 index 0800083..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/OptModuleDriver.java +++ /dev/null @@ -1,127 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.OS; -import a8k.app.factory.A8kPacketFactory; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.ModuleStatus; -import a8k.app.channel.iflytophald.type.protocol.OptModuleRegIndex; -import a8k.app.type.error.AEHardwareError; -import a8k.app.type.exception.AppException; -import a8k.app.utils.ByteArrayUtils; -import a8k.app.utils.ZJsonNode; -import a8k.app.utils.ZList; -import com.fasterxml.jackson.databind.JsonNode; -import jakarta.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -@Component -@Slf4j -public class OptModuleDriver { - public enum OptScanDirection { - FORWARD, //从左向右扫描 - BACKWARD; - - public Integer getInteger() { - return this == FORWARD ? 1 : -1; - } - } - - @Resource - A8kCanBusService canBus; - - - void waittingForOptFinish(Integer overtime) throws AppException { - long startedAt = OS.getMonotonicClockTimestamp(); - - do { - var packet = A8kPacketFactory.buildCMDPacket(MId.OptMod.toInt(), CmdId.module_get_status.toInt(), ZList.of()); - ModuleStatus statu = null; - try { - statu = ModuleStatus.valueOf(canBus.send(packet, 50).getContentI32(0)); - } catch (Exception ignored) { - } - - - if (statu == null || statu == ModuleStatus.BUSY) { - log.info("Waitting for Opt Finish"); - } else if (statu == ModuleStatus.IDLE) { - log.info("Opt Finish"); - break; - } else if (statu == ModuleStatus.ERROR) { - throw AppException.of(new AEHardwareError(canBus.moduleGetError(MId.OptMod), MId.OptMod, CmdId.a8k_opt_v2_t_start_scan)); - } - - if (OS.getMonotonicClockTimestamp() - startedAt > overtime) { - throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_ACTION_OVERTIME, MId.OptMod, CmdId.a8k_opt_v2_t_start_scan)); - } - OS.forceSleep(100); - } while (true); - - } - - - public void optTStartScan(OptScanDirection scanDirection, Integer lasterGain, Integer scanGain) throws AppException { - log.info("OptTStartScan scanDirection:{} lasterGain:{} scanGain:{}", scanDirection, lasterGain, scanGain); - canBus.callcmd(MId.OptMod, CmdId.a8k_opt_v2_t_start_scan, scanDirection.getInteger(), lasterGain, scanGain); - //TODO: 2024-10-26 zhaohe,修改底层,光学结束上报一条完成事件 - long startedAt = OS.getMonotonicClockTimestamp(); - OS.forceSleep(100); - waittingForOptFinish(10 * 1000); - log.info("opt t scan use {}s", (OS.getMonotonicClockTimestamp() - startedAt) / 1000.0); - } - - public void optFStartScan(OptScanDirection scanDirection, Integer lasterGain, Integer scanGain) throws AppException { - log.info("OptFStartScan scanDirection:{} lasterGain:{} scanGain:{}", scanDirection, lasterGain, scanGain); - canBus.callcmd(MId.OptMod, CmdId.a8k_opt_v2_f_start_scan, scanDirection.getInteger(), lasterGain, scanGain); - //TODO: 2024-10-26 zhaohe,修改底层,光学结束上报一条完成事件 - long startedAt = OS.getMonotonicClockTimestamp(); - OS.forceSleep(100); - waittingForOptFinish(10 * 1000); - log.info("opt f scan use {}s", (OS.getMonotonicClockTimestamp() - startedAt) / 1000.0); - } - - public Integer[] optReadRaw() throws AppException { - int i = 0; - List result = new ArrayList<>(); - while (true) { - var rxPacket = canBus.callcmd(MId.OptMod, CmdId.a8k_opt_v2_read_raw, i++); - if (rxPacket.getCmdContent().length == 0) { - break; - } - var rawdata = ByteArrayUtils.readU16bitArray(rxPacket.getCmdContent()); - result.addAll(Arrays.asList(rawdata)); - } - return result.toArray(new Integer[0]); - } - - public Integer getReg(OptModuleRegIndex regIndex) throws AppException { - return canBus.moduleGetReg(MId.OptMod, regIndex.regIndex); - } - - public void setReg(OptModuleRegIndex regIndex, Integer value) throws AppException { - canBus.moduleSetReg(MId.OptMod, regIndex.regIndex, value); - } - - public JsonNode readAllRegJson() throws AppException { - ZJsonNode node = new ZJsonNode(); - for (OptModuleRegIndex reg : OptModuleRegIndex.values()) { - try { - Integer val = getReg(reg); - node.get(reg.name()).set(val); - } catch (AppException e) { - node.get(reg.name()).set(e.getError().code); - } - } - return node.get(); - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/OutputIOCtrlDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/OutputIOCtrlDriver.java deleted file mode 100644 index 807f963..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/OutputIOCtrlDriver.java +++ /dev/null @@ -1,25 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.app.type.error.AECodeError; -import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.ModuleType; -import a8k.app.channel.iflytophald.type.protocol.OutputIOId; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class OutputIOCtrlDriver { - - private final A8kCanBusService canBus; - - public void setIOState(OutputIOId outputIOId, Boolean state) throws AppException { - if (outputIOId.mtype == ModuleType.Board) { - canBus.callcmd(outputIOId.mid, CmdId.extboard_write_outio, outputIOId.ioIndex, state ? 1 : 0); - } else { - throw new AppException(new AECodeError("IOID MODULE TYPE %s NOT SUPPORT", outputIOId.mtype)); - } - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/PipetteCtrlDriverV2.java b/src/main/java/a8k/app/channel/iflytophald/driver/PipetteCtrlDriverV2.java deleted file mode 100644 index 65548f8..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/PipetteCtrlDriverV2.java +++ /dev/null @@ -1,666 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.*; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.DistribuAllParamId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.PipetteConfig; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.PipetteStateIndex; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.*; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean.*; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.*; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.AspirationParam; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; -import a8k.app.constant.ActionOvertimeConstant; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.AspirationParamId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean.*; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.*; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.*; -import a8k.app.type.exception.AppException; -import a8k.app.utils.ZJsonHelper; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -@Component -@RequiredArgsConstructor -@Slf4j -public class PipetteCtrlDriverV2 { - private final A8kCanBusService canBus; - private final ActionOvertimeConstant actionOvertimeConstant; - - public void moduleStop() throws AppException { - canBus.moduleStop(MId.PipetteMod); - } - - public ModuleStatus moduleGetStatus() throws AppException { - return canBus.moduleGetStatus(MId.PipetteMod); - } - - public A8kEcode moduleGetErrors() throws AppException { - return canBus.moduleGetError(MId.PipetteMod); - } - - public String moduleGetDetailStatus() throws AppException { - Integer code = canBus.moduleGetDetailError(MId.PipetteMod); - return String.format("0x%08X", code); - } - - public void setZMBCfg(ZMBasicConfigIndex index, Integer val) throws AppException { - log.info("setZMBCfg: index={}, val={}", index, val); - callcmd(MId.PipetteMod, CmdId.pipette_set_zmbcfg, index.toInteger(), val); - } - - public Integer getZMBCfg(ZMBasicConfigIndex index) throws AppException { - Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_zmbcfg, index.toInteger()).getContentI32(0); - log.info("getZMBCfg: index={} --> {}", index, ret); - return ret; - } - - public void setPMBCfg(PMBasicConfigIndex index, Integer val) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_set_pmbcfg, index.toInteger(), val); - } - - public Integer getPMBCfg(PMBasicConfigIndex index) throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_get_pmbcfg, index.toInteger()).getContentI32(0); - } - - /** - * 设置平台信息 - * - * @param cpyid 第几份 - * @param index 平台信息索引 - * @param val 值 - * @throws AppException 异常 - */ - public void setPlatInfo(Integer cpyid, PlatformInfoIndex index, Integer val) throws AppException { - log.info("setPlatInfo: cpyid={}, index={} , {}", cpyid, index, val); - callcmd(MId.PipetteMod, CmdId.pipette_set_platinfo, cpyid, index.toInteger(), val); - } - - /** - * 获取平台信息 - * - * @param cpyid 第几份 - * @param index 索引 - * @return 值 - * @throws AppException 异常 - */ - public Integer getPlatInfo(Integer cpyid, PlatformInfoIndex index) throws AppException { - Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_platinfo, cpyid, index.toInteger()).getContentI32(0); - log.info("getPlatInfo: cpyid={}, index={} --> {}", cpyid, index, ret); - return ret; - } - - /** - * 设置容器信息 - * - * @param cpyid 第几份 - * @param index 容器信息索引 - * @param val 值 - * @throws AppException 异常 - */ - public void setZMVCfg(ZMVCpyIdx cpyid, ZMVConfigIndex index, Integer val) throws AppException { - log.info("setZMVCfg: cpyid={}, index={} , {}", cpyid, index, val); - callcmd(MId.PipetteMod, CmdId.pipette_set_zmvcfg, cpyid.toInteger(), index.toInteger(), val); - } - - /** - * 获取容器信息 - * - * @param cpyid 第几份 - * @param index 索引 - * @return 值 - * @throws AppException 异常 - */ - public Integer getZMVCfg(ZMVCpyIdx cpyid, ZMVConfigIndex index) throws AppException { - Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_zmvcfg, cpyid.toInteger(), index.toInteger()).getContentI32(0); - log.info("getZMVCfg: cpyid={}, index={} --> {}", cpyid, index, ret); - return ret; - } - - /** - * 设置泵机速度 - * - * @param cpyid 第几份 - * @param index 泵机信息索引 - * @param val 值 - * @throws AppException 异常 - */ - public void setPMVCfg(PMVCpyIdx cpyid, PMVConfigIndex index, Integer val) throws AppException { - log.info("setPMVCfg: cpyid={}, index={} , {}", cpyid, index, val); - callcmd(MId.PipetteMod, CmdId.pipette_set_pmvcfg, cpyid.toInteger(), index.toInteger(), val); - } - - /** - * 获取泵机速度 - * - * @param cpyid 第几份 - * @param index 索引 - * @return 值 - * @throws AppException 异常 - */ - public Integer getPMVCfg(PMVCpyIdx cpyid, PMVConfigIndex index) throws AppException { - Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_pmvcfg, cpyid.toInteger(), index.toInteger()).getContentI32(0); - log.info("getPMVCfg: cpyid={}, index={} --> {}", cpyid, index, ret); - return ret; - } - - /** - * 设置容器信息 - * - * @param cpyid 第几份 - * @param index 容器信息索引 - * @param val 值 - * @throws AppException 异常 - */ - public void setContainerInfo(Integer cpyid, ContainerInfoIndex index, Integer val) throws AppException { - log.info("setContainerInfo: cpyid={}, index={} , {}", cpyid, index, val); - callcmd(MId.PipetteMod, CmdId.pipette_set_container_info, cpyid, index.toInteger(), val); - } - - public void setContainerInfo(ContainerCpyId cpyid, ContainerInfoIndex index, Integer val) throws AppException { - setContainerInfo(cpyid.toInteger(), index, val); - } - - /** - * 获取容器信息 - * - * @param cpyid 第几份 - * @param index 索引 - * @return 值 - * @throws AppException 异常 - */ - public Integer getContainerInfo(Integer cpyid, ContainerInfoIndex index) throws AppException { - Integer val = callcmd(MId.PipetteMod, CmdId.pipette_get_container_info, cpyid, index.toInteger()).getContentI32(0); - log.info("getContainerInfo: cpyid={}, index={} --> {}", cpyid, index, val); - return val; - - } - - public Integer getContainerInfo(ContainerCpyId cpyid, ContainerInfoIndex index) throws AppException { - return getContainerInfo(cpyid.toInteger(), index); - } - - /** - * 设置液体信息 - * - * @param cpyid 第几份 - * @param index 液体信息索引 - * @param val 值 - * @throws AppException 异常 - */ - public void setLiquidInfo(Integer cpyid, LiquidInfoIndex index, Integer val) throws AppException { - log.info("setLiquidInfo: cpyid={}, index={} , {}", cpyid, index, val); - callcmd(MId.PipetteMod, CmdId.pipette_set_liquid_info, cpyid, index.toInteger(), val); - } - - public void setLiquidInfo(LiquidConfigCpyIdx cpyid, LiquidInfoIndex index, Integer val) throws AppException { - setLiquidInfo(cpyid.toInteger(), index, val); - } - - public void setCommonConfig(PipetteCommonConfigIndex index, Integer val) throws AppException { - log.info("setCommonConfig: index={}, val={}", index, val); - callcmd(MId.PipetteMod, CmdId.pipette_set_common_cfg, index.toInteger(), val); - } - - public Integer getCommonConfig(PipetteCommonConfigIndex index) throws AppException { - Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_common_cfg, index.toInteger()).getContentI32(0); - log.info("getCommonConfig: index={} --> {}", index, ret); - return ret; - } - - /** - * 获取液体信息 - * - * @param cpyid 第几份 - * @param index 索引 - * @return 值 - * @throws AppException 异常 - */ - public Integer getLiquidInfo(Integer cpyid, LiquidInfoIndex index) throws AppException { - Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_liquid_info, cpyid, index.toInteger()).getContentI32(0); - log.info("getLiquidInfo: cpyid={}, index={} --> {}", cpyid, index, ret); - return ret; - } - - public Integer getLiquidInfo(LiquidConfigCpyIdx cpyid, LiquidInfoIndex index) throws AppException { - return getLiquidInfo(cpyid.toInteger(), index); - } - - public Integer getPlatInfoMaxCpyId() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_get_platinfo_max_cpyid).getContentI32(0); - } - - public Integer getZMVCfgMaxCpyId() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_get_zmvcfg_max_cpyid).getContentI32(0); - } - - public Integer getPMVCfgMaxCpyId() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_get_pmvcfg_max_cpyid).getContentI32(0); - } - - public Integer getContainerInfoMaxCpyId() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_get_container_info_max_cpyid).getContentI32(0); - } - - // pipette_get_liquid_info_max_cpyid - public Integer getLiquidInfoMaxCpyId() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_get_liquid_info_max_cpyid).getContentI32(0); - } - - /*********************************************************************************************************************** - * Z轴控制 * - ***********************************************************************************************************************/ - - public void zMotorEnable(Integer enable) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_zmotor_enable, enable); - } - - public void zMotorMoveZeroBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_zero); - waitForMod(CmdId.pipette_zmotor_move_zero); - } - - public void zMotorMoveToZeroPointQuickBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_to_zero_point_quick); - waitForMod(CmdId.pipette_zmotor_move_to_zero_point_quick); - } - - public void zMotorMeasureDistance() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_zmotor_measure_distance); - waitForMod(CmdId.pipette_zmotor_measure_distance); - - } - - public Integer zMotorReadMeasureDistanceResult() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_measure_distance_result).getContentI32(0); - } - - public void zMotorMoveByBlock(Integer distance) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_by, distance); - waitForMod(CmdId.pipette_zmotor_move_by); - } - - public void zMotorMoveToBlock(Integer position) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_to, position); - waitForMod(CmdId.pipette_zmotor_move_to); - } - - public Boolean zMotorReadZeroPointState() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_zero_point_state).getContentI32(0) != 0; - } - - public Integer zMotorReadDevStatusCache() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_dev_status_cache).getContentI32(0); - } - - public Integer zMotorReadPos() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_pos).getContentI32(0); - } - - public Integer zMotorReadEncPos() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_enc_pos).getContentI32(0); - } - // pipette_zmotor_move_to_tip_deposit - - public void zMotorMoveToTipDepositBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_to_tip_deposit); - waitForMod(CmdId.pipette_zmotor_move_to_tip_deposit); - } - - // /*********************************************************************************************************************** - // * PUMP * - // ***********************************************************************************************************************/ - public void initPumpDeviceBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_init_device); - waitForMod(CmdId.pipette_pump_init_device); - } - - - public void takeTipBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_take_tip); - waitForMod(CmdId.pipette_pump_take_tip); - } - - public void depositTipBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_deposit_tip); - waitForMod(CmdId.pipette_pump_deposit_tip); - } - - public void putBakTipBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_putbak_tip); - waitForMod(CmdId.pipette_pump_putbak_tip); - } - - public void pierceThroughBlock(ContainerCpyId containerCpyId, Integer containerPos) throws AppException { - log.info("pierceThroughBlock: containerCpyId={}, containerPos={}", containerCpyId, containerPos); - callcmd(MId.PipetteMod, CmdId.pipette_pump_pierce_through, containerCpyId.toInteger(), containerPos); - waitForMod(CmdId.pipette_pump_pierce_through); - } - - public void aspirateSetParam(AspirationParamId param, Integer val) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_aspirate_set_param, param.toInteger(), val); - } - - public void aspirateSetParam(AspirationParam param) throws AppException { - log.info("aspirateSetParam :\n{}", ZJsonHelper.objToPrettyJson(param)); - param.serialization(this::aspirateSetParam); - } - - public void aspirateBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_aspirate); - waitForMod(CmdId.pipette_pump_aspirate); - } - - public void aspirateBlock(AspirationParam aspirationParam) throws AppException { - aspirateSetParam(aspirationParam); - aspirateBlock(); - } - - public void distributeAllSetParam(DistribuAllParamId param, Integer val) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_distribu_all_set_param, param.toInteger(), val); - } - - public void distributeAllSetParam(DistribuAllParam param) throws AppException { - log.info("distributeAllSetParam :\n{}", ZJsonHelper.objToPrettyJson(param)); - param.serialization(this::distributeAllSetParam); - } - - public void distributeAllBlock() throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_pump_distribu_all); - waitForMod(CmdId.pipette_pump_distribu_all); - } - - public void distributeAllBlock(DistribuAllParam distribuAllParam) throws AppException { - distributeAllSetParam(distribuAllParam); - distributeAllBlock(); - } - - public void pipetteTestPumpMoveToX100nl(Integer x100nl, Integer vcfgIndex) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_pump_move_to_x100nl, x100nl, vcfgIndex); - waitForMod(CmdId.pipette_test_pump_move_to_x100nl); - } - - public void pipetteTestLld(Integer containerPos, ContainerCpyId containerCpyId, LiquidConfigCpyIdx liquidCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_lld, containerPos, containerCpyId.toInteger(), liquidCpyId.toInteger()); - waitForMod(CmdId.pipette_test_lld); - } - - public void pipetteTestMoveToContainerBottom(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_container_bottom, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_container_bottom); - } - - public void pipetteTestMoveToContainerBottomSectionBegin(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_container_bottom_section_begin, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_container_bottom_section_begin); - } - - public void pipetteTestMoveToImmersionPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_immersion_pos, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_immersion_pos); - } - - public void pipetteTestMoveToLeavingHeightPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_leaving_height_pos, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_leaving_height_pos); - } - - public void pipetteTestMoveToJetPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_jet_pos, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_jet_pos); - } - - public void pipetteTestMoveToLldStartSearchPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_lld_start_search_pos, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_lld_start_search_pos); - } - - public void pipetteTestMoveToFixWaterLevelPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_fix_water_level_pos, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_fix_water_level_pos); - } - - public void pipetteTestMoveToPiercePos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_pierce_pos, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_pierce_pos); - } - - public void pipetteTestMoveToLldEndPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { - callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_lld_end_pos, containerPos, containerCpyId.toInteger()); - waitForMod(CmdId.pipette_test_move_to_lld_end_pos); - } - - /** - * 测试pipette模块的连接性 - * @throws AppException 连接异常 - * - * @Warning: 该指令超时时间过长, 除了在测试pipette模块连接性时, 请不要使用该指令 - */ - public void pipetteTestConnectivity() throws AppException { - canBus.callcmd(MId.PipetteMod, CmdId.pipette_test_connectivity, 2000L); - } - - public Integer readState(PipetteStateIndex index) throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_read_state, index.toInteger()).getContentI32(0); - } - - static public class PipetteGunConnectivityTestReport { - public Boolean io1Connected; - public Boolean uart232Connected; - public Boolean uart485Connected; - } - - public PipetteGunConnectivityTestReport readPipetteConnectedState() throws AppException { - Integer io1_connected = readState(PipetteStateIndex.testPipetteIo1Connected); - Integer uart232_connected = readState(PipetteStateIndex.testPipetteUart232Connected); - Integer uart485_connected = readState(PipetteStateIndex.testPipetteUart485Connected); - - PipetteGunConnectivityTestReport report = new PipetteGunConnectivityTestReport(); - report.io1Connected = io1_connected == 1; - report.uart232Connected = uart232_connected == 1; - report.uart485Connected = uart485_connected == 1; - return report; - } - - - public Boolean readTipState() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_read_tip_state).getContentI32(0) != 0; - } - - public Integer readPressure() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_read_pressure).getContentI32(0); - } - - public Integer readCapacitance() throws AppException { - return callcmd(MId.PipetteMod, CmdId.pipette_read_capacitance).getContentI32(0); - } - - - public List getAspPressureData() throws AppException { - List pressuredata = new ArrayList<>(); - for (int i = 0; ; i++) { - A8kPacket packet = callcmd(MId.PipetteMod, CmdId.pipette_get_asp_pressure_data, i); - if (packet.getDataLen() == 0) { - break; - } - var content = packet.getContentI16Array(); - for (Integer val : content) { - pressuredata.add(val); - } - } - return pressuredata; - } - - - // - // UTILS - // - private A8kPacket callcmd(MId moduleId, CmdId cmdId, Integer... param) throws AppException { - return canBus.callcmd(moduleId, cmdId, param); - } - - private void waitForMod(CmdId action) throws AppException { - canBus.waitForMod(MId.PipetteMod, actionOvertimeConstant.get(MId.PipetteMod, action)); - } - - - // - // Config - // - public void setLiquidInfo(LiquidConfigCpyIdx cpyIdx, PipetteLiquidInfo val) throws AppException { - if (val == null) { - log.error("setLiquidInfo val is null"); - return; - } - val.serialization((index, itermVal) -> setLiquidInfo(cpyIdx.toInteger(), index, itermVal)); - } - - public PipetteLiquidInfo getLiquidInfo(LiquidConfigCpyIdx cpyIdx) throws AppException { - return PipetteLiquidInfo.build((LiquidInfoIndex index) -> getLiquidInfo(cpyIdx.toInteger(), index)); - } - - public void applyPlatInfo(Integer cpyIdx, PipettePlatInfo val) throws AppException { - if (val == null) { - log.error("applyPlatInfo val is null"); - return; - } - val.serialization((index, itermVal) -> setPlatInfo(cpyIdx, index, itermVal)); - } - - public PipettePlatInfo getPlatInfo(Integer cpyIdx) throws AppException { - return PipettePlatInfo.build((PlatformInfoIndex index) -> getPlatInfo(cpyIdx, index)); - } - - public void setContainerInfo(ContainerCpyId cpyIdx, PipetteContainerInfo val) throws AppException { - if (val == null) { - log.error("setContainerInfo val is null"); - return; - } - val.serialization((index, itermVal) -> setContainerInfo(cpyIdx.toInteger(), index, itermVal)); - } - - public PipetteContainerInfo getContainerInfo(ContainerCpyId cpyIdx) throws AppException { - return PipetteContainerInfo.build((ContainerInfoIndex index) -> getContainerInfo(cpyIdx.toInteger(), index)); - } - - - public void setPMVCfg(PMVCpyIdx idx, PipettePMVCfg val) throws AppException { - if (val == null) { - log.error("setPMVCfg val is null"); - return; - } - val.serialization((index, itermVal) -> setPMVCfg(idx, index, itermVal)); - } - - public PipettePMVCfg getPMVCfg(PMVCpyIdx idx) throws AppException { - return PipettePMVCfg.build((PMVConfigIndex index) -> getPMVCfg(idx, index)); - } - - public void setZMBCfg(PipetteZMBCfg val) throws AppException { - if (val == null) { - log.error("setZMBCfg val is null"); - return; - } - val.serialization(this::setZMBCfg); - } - - public PipetteZMBCfg getZMBCfg() throws AppException { - return PipetteZMBCfg.build(this::getZMBCfg); - } - - - public void setZMVCfg(ZMVCpyIdx idx, PipetteZMVCfg val) throws AppException { - if (val == null) { - log.error("setZMVCfg val is null"); - return; - } - val.serialization((index, itermVal) -> setZMVCfg(idx, index, itermVal)); - } - - public PipetteZMVCfg getZMVCfg(ZMVCpyIdx idx) throws AppException { - return PipetteZMVCfg.build((ZMVConfigIndex index) -> getZMVCfg(idx, index)); - } - - public void setCommonConfig(PipetteCommonConfig val) throws AppException { - if (val == null) { - log.error("setCommonConfig val is null"); - return; - } - val.serialization(this::setCommonConfig); - } - - public PipetteCommonConfig getCommonConfig() throws AppException { - return PipetteCommonConfig.build(this::getCommonConfig); - } - - public PipetteConfig getConfig() throws AppException { - PipetteConfig cfg = new PipetteConfig(); - cfg.zmBCfgs = getZMBCfg(); - cfg.commonCfg = getCommonConfig(); - - for (int i = 0; i < PlatInfoCpyIdx.values().length; i++) { - cfg.platInfos.add(getPlatInfo(i)); - } - for (int i = 0; i < ContainerCpyId.values().length; i++) { - if (ContainerCpyId.values()[i].equals(ContainerCpyId.NotSet)) - continue; - cfg.containerInfos.add(getContainerInfo(ContainerCpyId.values()[i])); - } - for (int i = 0; i < LiquidConfigCpyIdx.values().length; i++) { - if (LiquidConfigCpyIdx.values()[i].equals(LiquidConfigCpyIdx.NotSet)) - continue; - cfg.liquidInfos.add(getLiquidInfo(LiquidConfigCpyIdx.values()[i])); - } - for (int i = 0; i < ZMVCpyIdx.values().length; i++) { - if (ZMVCpyIdx.values()[i].equals(ZMVCpyIdx.NotSet)) - continue; - cfg.zmVCfgs.add(getZMVCfg(ZMVCpyIdx.values()[i])); - } - for (int i = 0; i < PMVCpyIdx.values().length; i++) { - if (PMVCpyIdx.values()[i].equals(PMVCpyIdx.NotSet)) - continue; - cfg.pmVCfgs.add(getPMVCfg(PMVCpyIdx.values()[i])); - } - return cfg; - } - - public void setConfig(PipetteConfig cfg) throws AppException { - if (cfg == null) { - log.error("updateConfig cfg is null"); - return; - } - Long start = System.currentTimeMillis(); - setZMBCfg(cfg.zmBCfgs); - setCommonConfig(cfg.commonCfg); - for (int i = 0; i < cfg.platInfos.size(); i++) { - applyPlatInfo(i, cfg.platInfos.get(i)); - } - for (int i = 0; i < cfg.containerInfos.size(); i++) { - if (ContainerCpyId.values()[i].equals(ContainerCpyId.NotSet)) - break; - setContainerInfo(ContainerCpyId.values()[i], cfg.containerInfos.get(i)); - } - for (int i = 0; i < cfg.liquidInfos.size(); i++) { - if (LiquidConfigCpyIdx.values()[i].equals(LiquidConfigCpyIdx.NotSet)) - break; - setLiquidInfo(LiquidConfigCpyIdx.values()[i], cfg.liquidInfos.get(i)); - } - for (int i = 0; i < cfg.zmVCfgs.size(); i++) { - if (ZMVCpyIdx.values()[i].equals(ZMVCpyIdx.NotSet)) - break; - setZMVCfg(ZMVCpyIdx.values()[i], cfg.zmVCfgs.get(i)); - } - for (int i = 0; i < cfg.pmVCfgs.size(); i++) { - if (PMVCpyIdx.values()[i].equals(PMVCpyIdx.NotSet)) - break; - setPMVCfg(PMVCpyIdx.values()[i], cfg.pmVCfgs.get(i)); - } - - log.info("sync config to pipette module completed, cost {} ms", System.currentTimeMillis() - start); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/StepMotorCtrlDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/StepMotorCtrlDriver.java deleted file mode 100644 index 9b3ad0c..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/StepMotorCtrlDriver.java +++ /dev/null @@ -1,231 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.constant.ActionOvertimeConstant; -import a8k.app.channel.iflytophald.type.protocol.*; -import a8k.app.type.exception.AppException; -import a8k.app.utils.ZJsonHelper; -import a8k.iflyutils.BitUtils; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -@Slf4j -public class StepMotorCtrlDriver { - - final private A8kCanBusService canBus; - - private final ActionOvertimeConstant actionOvertimeConstant; - - public static class StepMotorErrorInfo { - public A8kEcode ecode; - - public Integer sgResult; - public Integer fsActive; - public Integer csActual; - public Integer stallGuard; - public Integer ot; - public Integer otpw; - public Integer s2ga; - public Integer s2gb; - public Integer ola; - public Integer olb; - public Integer stst; - - static StepMotorErrorInfo build(A8kEcode ecode, Integer detailEcode) throws AppException { - StepMotorErrorInfo errorInfo = new StepMotorErrorInfo(); - errorInfo.ecode = ecode; - int ioff = 0; - errorInfo.sgResult = BitUtils.getBitValueAsInt(detailEcode, ioff, 10); - ioff += 10; - ioff += 5; - errorInfo.fsActive = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.csActual = BitUtils.getBitValueAsInt(detailEcode, ioff, 5); - ioff += 5; - ioff += 3; - errorInfo.stallGuard = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.ot = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.otpw = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.s2ga = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.s2gb = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.ola = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.olb = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - ioff += 1; - errorInfo.stst = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); - return errorInfo; - } - - public static void main(String[] args) { - } - } - - public StepMotorErrorInfo readErrorInfo(StepMotorMId mid) throws AppException { - A8kEcode ecode = canBus.moduleGetError(mid.mid); - Integer detailEcode = canBus.moduleGetDetailError(mid.mid); - return StepMotorErrorInfo.build(ecode, detailEcode); - } - - public void stepMotorEasyMoveBy(StepMotorMId id, Integer dpos) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_move_by, dpos); - } - - public void stepMotorEasyMoveTo(StepMotorMId id, Integer pos) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to, pos); - } - - public void stepMotorEasyMoveToZero(StepMotorMId id) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to_zero); - } - - public void setCurrentPos(StepMotorMId id, Integer pos) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_set_current_pos, pos); - } - - void stepMotorEasyMoveToZeroPointQuick(StepMotorMId id) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to_zero_point_quick); - } - - void stepMotorEasyMoveToEndPoint(StepMotorMId id) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to_end_point); - } - - public void stepMotorEnable(StepMotorMId mid, Integer enable) throws AppException { - canBus.callcmd(mid.mid, CmdId.step_motor_enable, enable); - } - - public Integer stepMotorReadPos(StepMotorMId id) throws AppException { - A8kPacket packet = canBus.callcmd(id.mid, CmdId.step_motor_read_pos); - return packet.getContentI32(0); - } - - public Integer stepMotorReadEncPos(StepMotorMId id) throws AppException { - A8kPacket packet = canBus.callcmd(id.mid, CmdId.step_motor_read_enc_pos); - return packet.getContentI32(0); - } - - public void stepMotorEasyRotate(StepMotorMId id, Integer direction) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_rotate, direction); - } - - public void stepMotorEasyMoveByBlock(StepMotorMId id, Integer dpos) throws AppException { - log.debug("stepMotorEasyMoveByBlock {} {}", id, dpos); - stepMotorEasyMoveBy(id, dpos); - canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_by)); - } - - public void waitForMod(StepMotorMId id, Integer overtime) throws AppException { - canBus.waitForMod(id.mid, overtime); - } - - public void stepMotorEasyMoveToBlock(StepMotorMId id, Integer pos) throws AppException { - log.debug("stepMotorEasyMoveToBlock {} {}", id, pos); - stepMotorEasyMoveTo(id, pos); - canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to)); - } - - public void stepMotorEasyMoveToZeroBlock(StepMotorMId id) throws AppException { - log.debug("stepMotorEasyMoveToZeroBlock {}", id); - stepMotorEasyMoveToZero(id); - canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to_zero)); - } - - public Integer stepMotorReadPosByMoveToZeroBlock(StepMotorMId id) throws AppException { - stepMotorEnable(id, 1); - stepMotorEasyMoveToZeroBlock(id); - Integer nowpos = stepMotorReadPos(id); - Integer measurepos = -canBus.moduleGetReg(id.mid, RegIndex.kreg_step_motor_dpos) + nowpos; - stepMotorEnable(id, 0); - return measurepos; - } - - public void stepMotorEasyMoveToZeroPointQuickBlock(StepMotorMId id) throws AppException { - stepMotorEasyMoveToZeroPointQuick(id); - canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to_zero_point_quick)); - } - - public void stepMotorStop(StepMotorMId id) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_stop, 0); - } - - - // step_motor_move_by(0x021d, "STEP_MOTOR_MOVE_BY"), // (dpos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) - // step_motor_move_to(0x021e, "STEP_MOTOR_MOVE_TO"), // (pos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) - // step_motor_move_to_zero_point_quick(0x021f, "STEP_MOTOR_MOVE_TO_ZERO_POINT_QUICK"), // (speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) - // step_motor_rotate(0x0220, "STEP_MOTOR_ROTATE"), // - - public void moveByBlock(StepMotorMId id, Integer dpos, StepMotorSpeedLevel speedLevel) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_move_by, dpos, speedLevel.ordinal()); - waitForMod(id, actionOvertimeConstant.get(id, CmdId.step_motor_move_by)); - } - - public void moveToBlock(StepMotorMId id, Integer pos, StepMotorSpeedLevel speedLevel) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_move_to, pos, speedLevel.ordinal()); - waitForMod(id, actionOvertimeConstant.get(id, CmdId.step_motor_move_to)); - } - - public void moveToZeroQuickBlock(StepMotorMId id, StepMotorSpeedLevel speedLevel) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_move_to_zero_point_quick, speedLevel.ordinal()); - waitForMod(id, actionOvertimeConstant.get(id, CmdId.step_motor_move_to_zero_point_quick)); - } - - public void rotate(StepMotorMId id, Integer direction, StepMotorSpeedLevel speedLevel) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_rotate, direction, speedLevel.ordinal()); - - } - - public Boolean stepMotorReadIoState(StepMotorMId id, Integer ioindex) throws AppException { - var packet = canBus.callcmd(id.mid, CmdId.step_motor_read_io_state, ioindex); - return packet.getContentI32(0) != 0; - } - - public void stepMotorEasyMoveToEndPointBlock(StepMotorMId id) throws AppException { - stepMotorEasyMoveToEndPoint(id); - canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to_end_point)); - } - - void stepMotorEasyReciprocatingMotion(StepMotorMId id, Integer startpos, Integer endpos, Integer times) throws AppException { - canBus.callcmd(id.mid, CmdId.step_motor_easy_reciprocating_motion, startpos, endpos, times); - } - - public void stepMotorEasyReciprocatingMotionBlock(StepMotorMId id, Integer startpos, Integer endpos, Integer times) throws AppException { - stepMotorEasyReciprocatingMotion(id, startpos, endpos, times); - canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_reciprocating_motion)); - } - - public Boolean isHasMoveToZero(StepMotorMId id) throws AppException { - return getReg(id, StepMotorRegIndex.kreg_step_motor_has_move_zero) != 0; - } - - public void setReg(StepMotorMId id, StepMotorRegIndex regIndex, Integer val) throws AppException { - canBus.moduleSetReg(id.mid, regIndex.regIndex, val); - } - - public Integer getReg(StepMotorMId id, StepMotorRegIndex regIndex) throws AppException { - return canBus.moduleGetReg(id.mid, regIndex.regIndex); - } - - public void resetRegs(StepMotorMId id) throws AppException { - canBus.callcmd(id.mid, CmdId.module_reset_reg); - } - - public Object getAllReg(StepMotorMId id) throws AppException { - ObjectNode node = ZJsonHelper.createObjectNode(); - for (StepMotorRegIndex regIndex : StepMotorRegIndex.values()) { - Integer regVal = getReg(id, regIndex); - log.debug("read reg {} -> {}", regIndex, regVal); - node.put(regIndex.name(), getReg(id, regIndex)); - } - return node; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/driver/WaterTemperatureControllerDriver.java b/src/main/java/a8k/app/channel/iflytophald/driver/WaterTemperatureControllerDriver.java deleted file mode 100644 index 59219dd..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/driver/WaterTemperatureControllerDriver.java +++ /dev/null @@ -1,104 +0,0 @@ -package a8k.app.channel.iflytophald.driver; - -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.TemperatureControlerMid; -import a8k.app.channel.iflytophald.type.protocol.TemperatureControlerRegIndex; -import a8k.app.service.param.misc.TemperatureCtrlParamMgr; -import a8k.app.type.exception.AppException; -import a8k.app.type.param.TemperatureCtrlParam; -import jakarta.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -@Component -@Slf4j -public class WaterTemperatureControllerDriver { - @Resource - A8kCanBusService canBus; - - Double incubatorTCMTempOffset = 0.0; - Double platesBoxTCMTempOffset = 0.0; - - @Resource - TemperatureCtrlParamMgr temperatureCtrlParamMgr; - - public void startCtrlTemperature(Double incubatorTemperature, Double platesBoxTemperature) throws AppException { - - incubatorTCMTempOffset = temperatureCtrlParamMgr.getParam(TemperatureCtrlParam.IncubatorTCMTempOffset); - platesBoxTCMTempOffset = temperatureCtrlParamMgr.getParam(TemperatureCtrlParam.PlatesBoxTCMTempOffset); - - Integer incubatorTCMSetTemp = (int) ((incubatorTemperature + incubatorTCMTempOffset) * 10); - Integer platesBoxTCMSetTemp = (int) ((platesBoxTemperature + platesBoxTCMTempOffset) * 10); - - log.info("startCtrlTemperature incubatorTCMSetTemp {}", incubatorTCMSetTemp); - log.info("startCtrlTemperature platesBoxTCMSetTemp {}", platesBoxTCMSetTemp); - - canBus.callcmd(TemperatureControlerMid.IncubatorTCM.mid, CmdId.temp_controler_start_hearting, incubatorTCMSetTemp); - canBus.callcmd(TemperatureControlerMid.PlatesBoxTCM.mid, CmdId.temp_controler_start_hearting, platesBoxTCMSetTemp); - } - - public void stopCtrlTemperature() throws AppException { - canBus.callcmd(TemperatureControlerMid.IncubatorTCM.mid, CmdId.temp_controler_stop_hearting); - canBus.callcmd(TemperatureControlerMid.PlatesBoxTCM.mid, CmdId.temp_controler_stop_hearting); - } - - public Double readIncubateBoxTemperature() throws AppException { - Integer readval = readReg(TemperatureControlerMid.IncubatorTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval); - Double readvalDouble = readval * 0.1; - return readvalDouble - incubatorTCMTempOffset; - } - - public Double readPlateBoxTemperature() throws AppException { - Integer readval = readReg(TemperatureControlerMid.PlatesBoxTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval); - Double readvalDouble = readval * 0.1; - return readvalDouble - platesBoxTCMTempOffset; - } - - - public void startCtrlTemperature(TemperatureControlerMid mid, Double temperature) throws AppException { - Integer setTemp = (int) ((temperature) * 10); - canBus.callcmd(mid.mid, CmdId.temp_controler_start_hearting, setTemp); - } - - public void stopCtrlTemperature(TemperatureControlerMid mid) throws AppException { - canBus.callcmd(mid.mid, CmdId.temp_controler_stop_hearting); - } - - public void setPeltierPower(TemperatureControlerMid mid, Integer val0To100) throws AppException { - canBus.callcmd(mid.mid, CmdId.temp_controler_set_peltier_power_level, val0To100); - } - - public void setCtrlFanLevel(TemperatureControlerMid mid, Integer val0To100) throws AppException { - canBus.callcmd(mid.mid, CmdId.temp_controler_set_fan_level, val0To100); - } - - public void setWaterPumpSpeed(TemperatureControlerMid mid, Integer val0To100) throws AppException { - canBus.callcmd(mid.mid, CmdId.temp_controler_set_pump_level, val0To100); - } - - public Double readFeedbakTemperature(TemperatureControlerMid mid) throws AppException { - Integer readval = readReg(mid, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval); - return readval * 0.1; - } - - - public Integer readIncubateBoxPWMOutput() throws AppException { - return readReg(TemperatureControlerMid.IncubatorTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_nowoutput); - } - - public Integer readPlateBoxPWMOutput() throws AppException { - return readReg(TemperatureControlerMid.PlatesBoxTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_nowoutput); - } - - - public Integer readReg(TemperatureControlerMid mid, TemperatureControlerRegIndex regIndex) throws AppException { - return canBus.moduleGetReg(mid.mid, regIndex.regIndex); - } - - public void setReg(TemperatureControlerMid mid, TemperatureControlerRegIndex regIndex, Integer val) throws AppException { - canBus.moduleSetReg(mid.mid, regIndex.regIndex, val); - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/channelctrl/IflytophaldResponse.java b/src/main/java/a8k/app/channel/iflytophald/type/channelctrl/IflytophaldResponse.java deleted file mode 100644 index d5ae8c6..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/channelctrl/IflytophaldResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package a8k.app.channel.iflytophald.type.channelctrl; - -public class IflytophaldResponse { - public Integer status; - public String msg; - public T data; - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kEcode.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kEcode.java deleted file mode 100644 index d6414d7..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kEcode.java +++ /dev/null @@ -1,271 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import lombok.extern.slf4j.Slf4j; - -/** - * 错误分类 - * 10, - * 为代码错误,代码没有BUG的情况下,这个错误时不会出现的,前端打印出错误,和错误携带的栈信息,方便产品维护时,非程序员能够提供详细的错误的信息。 - * - * - * - * - * - */ -@Slf4j -public enum A8kEcode { - - SUC(0), - // - // 代码错误,代码没有BUG的情况下,前端直接打印错误信息和栈信息即可 - // - CODEERROR(10), //代码错误 - ERROR_WORK_MODE(11), //工作模式错误 - ZAPP_INTERRUPT_EXCEPTION(12), - ERROR_OPERATION(13), //操作错误 - IP_FORMAT_ERROR(14), //IP地址格式错误 - SHUTDOWN_ERROR_DEVICE_IS_WORKING(15), //设备正在工作中,不允许关机 - LOGIN_OUT_ERROR_DEVICE_IS_WORKING(16), //设备正在工作中,不允许退出登录 - DEVICE_IS_BUSY(17), //设备正在工作中,不允许操作 - SYS_EXCEPTION(18), //系统异常 - DEVICE_NOT_INIT(19), //设备未初始化 - APPE_PAUSE_OPERATION_NOT_SUPPORT_IN_ENGINEER_TASK(20), // - APPE_CONTINUE_OPERATION_NOT_SUPPORT_IN_ENGINEER_TASK(21), // - APPE_WAST_BIN_IS_FULL(22), //废料箱已满 - SYS_CMD_EXEC_OVERTIME(23), //Linux命令执行超时 - NETWORK_PARAMETER_ERROR(24), //网络参数错误 - - - // - // 参数错误 - // - PE_PARAM_OUT_OF_RANGE(100),//参数超出范围 - // - // 用户错误 - // - USR_ALREADY_EXIST(110),//用户已存在 - USR_NOT_EXIT(111), //用户不存在 - USR_PASSWORD_ERROR(112),//用户密码错误 - USR_PASSWORD_IS_EMPTY(113),//用户密码为空 - USR_OLD_PASSWORD_ERROR(114),//用户旧密码错误 - - // - // ID卡错误 - // - APPE_A8K_ID_CARD_NOT_MOUNTED(120), //ID卡未挂载 - // - // 试管配置管理服务相关错误码 - // - APPE_TUBE_HOLDER_SETTING_IS_LOCKED(130),//试管架设置被锁定,已锁定的,说明当前后台正在使用这个配置,是不允许修改 - APPE_TUBEHOLDER_SETTING_ERROR(131), //试管架配置错误 - - // - // 急诊错误 - // - APPE_EMERGENCY_SAMPLE_IS_PROCESSING(141), //添加急诊样本失败,急诊样本还没有处理完成 (这个错误发生在前端,没有做好状态检测) - APPE_ADD_EMERGENCY_ACTION_IS_NOT_ALLOWED_WHEN_WORKING(142),//添加急诊样本失败,设备正在运行中 (这个错误发生在前端,没有做好状态检测) - // - // 设备操作操作 - // - APPE_DEVICE_IS_IN_FATAL_ERROR(150),//设备处于严重错误,请关机后重启设备进行恢复 - APPE_DEVICE_INIT_CHECK_FAIL(151),//设备初始化检查失败 - - APPE_DO_ACTION_FAIL_DEVICE_IS_WORKING(152),//设备正在工作中,不允许执行操作 - APPE_CONSUMABLES_IS_IN_USE_NOT_ALLOW_UNSTALL(153),//耗材正在使用中,不允许卸载 - - DEVICE_STARTUP_IN_PROGRESS(154), // 设备启动中,请稍后 - // - // 业务流程中的错误 - // 1. 点击开始运行后,设备在运行过程中出现的错误 - // 2. 下面错误,中文情况下,直接显示注释信息即可 - // - //扫描耗材错误 - APPE_NO_UNINSTALLED_CONSUMABLE(160),//没有未安装的耗材 - - - APPE_TIP_G1_SETTING_NUM_MISMATCH_ERROR(161),//Tip设置数量错误 - APPE_TIP_G2_SETTING_NUM_MISMATCH_ERROR(162),//Tip设置数量错误 - APPE_TIP_G3_SETTING_NUM_MISMATCH_ERROR(163),//Tip设置数量错误 - - APPE_INACTIVE_TUBEHOLDER_SETTING_EXISTS(164),//有试管架配置未激活 - - - //入料阶段错误 - APPE_SCAN_TUBEHOLDER_TYPE_TIMEOUT(200),//扫描试管架类型超时 - APPE_TUBE_HOLDER_TYPE_IS_NOT_SUPPORT(201),//试管架类型不支持 - APPE_INFEED_OVERTIME_FAIL(202),//入料超时失败 - APPE_TUBEHOLDER_IS_EMPTY(203),//试管架中没有试管 - - //样本处理过程中的错误 - APPE_PUT_TIP_FAIL(210),//丢弃Tip失败 - APPE_TAKE_TIP_FAIL(211),//取Tip失败 - APPE_DETECT_SAMPLE_FAIL(212),// 检测样本失败 - APPE_TAKE_LARGE_BUFFER_LIQUID_FAIL(213),//取大瓶缓冲液失败 - APPE_TAKE_SAMPLE_FAIL(214),//取大瓶缓冲液失败 - - - //出料阶段错误 - APPE_EJECT_TUBEHOLDER_TIMEOUT(220),//弹出试管架超时 - APPE_NO_TUBE_IN_HOLDER(221),//试管架中没有试管 - APPE_CONSUME_NOT_ENOUGH(222),//耗材不足 - APPE_TIP_NOT_ENOUGH(223),//tip不足 - APPE_ROLLBACK_TUBEHOLDER_TIMEOUT(224),//回滚试管架超时 - - APPE_OUTFEED_AREA_IS_FULL(225),//出料区满 - - - //运行中的公用错误 - APPE_A8K_PROJ_CARD_PARSE_ERROR(300), //ID卡解析错误 - APPE_A8K_PROJ_CARD_EXPIRYED(301), //ID卡过期 - APPE_A8K_PROJ_ID_IS_EMPTY(302), //项目ID为空 - PROJ_CARD_ERROR_WRONG_UNSUPPORTED(303), //项目不支持 - APPE_PULLER_MOTOR_INIT_POS_ERROR(305), //初始化阶段,拉板电机没有处于零点位置 - APPE_PUSHER_MOTOR_INIT_POS_ERROR(306), //初始化阶段,推板电机没有处于零点位置 - APPE_PLATE_STUCK_DETECTOR_SENSOR_TRIGGER(307), //卡板检测传感器触发 - APPE_TUBE_X_CHANNEL_IS_NOT_EMPTY(308), //试管架通道有异物 - APPE_PLATE_BOX_NOT_COVER(309), //板夹仓未盖 - APPE_DEVICE_NOT_INITED(310), //设备未初始化 - APPE_SHAKE_MODULE_CLAMPM_NOT_IN_ZERO_POS(311), //摇匀模组夹紧模块没有在零点位置 - APPE_INCUBATION_PLATE_OUTLET_STUCK_DETECTOR_SENSOR_IS_TRIGGER(312), //孵育板出料口卡板检测传感器触发 - APPE_INCUBATION_PLATE_INLET_STUCK_DETECTOR_SENSOR_IS_TRIGGER(313), //孵育板入料口卡板检测传感器触发 - APPE_DEVICE_IS_WORKING(314), //设备正在工作中,不允许执行操作 - - - // - // ID卡检验错误 - // - PROJ_CARD_ERROR_EXPIRYED(500),//ID卡验证错误,过期 - PROJ_CARD_ERROR_WRONG_FUNCTION_NUM(500),//ID卡验证错误,函数数量错误 - PROJ_CARD_ERROR_WRONG_OPT_NUM(500),//ID卡验证错误,光学数量错误 - PROJ_CARD_ERROR_WRONG_FUNCTION_X_TYPE(500),//ID卡验证错误,公式X类型错误 - PROJ_CARD_ERROR_WRONG_FUNCTION_JUDGE_X_TYPE(500),//ID卡验证错误,公式X类型错误 - PROJ_CARD_ERROR_WRONG_FUNCTION_L_X_TYPE(500),//ID卡验证错误,公式X类型错误 - PROJ_CARD_ERROR_WRONG_FUNCTION_H_X_TYPE(500),//ID卡验证错误,公式X类型错误 - PROJ_CARD_ERROR_WRONG_FUNCTION_X_SCOPE(500),//ID卡验证错误,公式X的范围错误 - PROJ_CARD_ERROR_WRONG_FUNCTION_LIMIT_SCOPE(500),//ID卡验证错误,光学数量错误 - PROJ_CARD_ERROR_WRONG_FUNCTION_TYPE(500),//ID卡验证错误,公式类型错误 - - PROJ_CARD_ERROR_WRONG_RESULT_UNIT_TYPE(500),//ID卡验证错误,Unit类型错误 - PROJ_CARD_ERROR_WRONG_RESULT_UNIT2_COEFFICIENT(500),//ID卡验证错误,Unit2转换系数错误 - PROJ_CARD_ERROR_WRONG_RESULT_UNIT3_COEFFICIENT(500),//ID卡验证错误,Unit3转换系数错误 - - // PROJ_CARD_ERROR_WRONG_UNSUPPORTED(520),//ID卡验证错误,不支持的ID卡 - PROJ_CARD_ERROR_BUILD_IN_PROJ_INFO_ERROR(521),//ID卡验证错误,内置项目信息错误 - PROJ_CARD_ERROR_ID_CARD_VERSION_IS_LOWER_THAN_STORED(522),//ID卡验证错误,ID卡版本低于存储的版本 - - - // - // LowBoard 底层错误,直接打印错误英文 - // - LOW_ERROR_HARDWARE_ERROR_START(1000), - LOW_ERROR_BOARD_COMMON_ERROR(1001), - LOW_ERROR_PARAM_OUT_OF_RANGE(1102), - LOW_ERROR_CMD_NOT_SUPPORT(1103), - LOW_ERROR_DEVICE_IS_BUSY(1104), - LOW_ERROR_DEVICE_IS_OFFLINE(1105), - LOW_ERROR_OVERTIME(1106), - LOW_ERROR_NO_ACK(1107), - LOW_ERROR_ERROR_ACK(1108), - LOW_ERROR_DEVICE_OFFLINE(1109), - LOW_ERROR_SUBDEVICE_OVERTIME(1111), - LOW_ERROR_BUFFER_NOT_ENOUGH(1112), - LOW_ERROR_CMD_PARAM_NUM_ERROR(1114), - LOW_ERROR_CHECKCODE_IS_ERROR(1115), - LOW_ERROR_ILLEGAL_OPERATION(1116), - LOW_ERROR_ACTION_OVERTIME(1117), - LOW_ERROR_MODULE_OPERATION_BREAK_BY_USER(1202), - LOW_ERROR_MODULE_NOT_FIND_REG(1207), - LOW_ERROR_XYMOTOR_X_FIND_ZERO_EDGE_FAIL(1306), - LOW_ERROR_XYMOTOR_Y_FIND_ZERO_EDGE_FAIL(1307), - LOW_ERROR_XYMOTOR_NOT_ENABLE(1308), - LOW_ERROR_XYMOTOR_TARGET_POS_OUT_OF_RANGE(1309), - LOW_ERROR_XYMOTOR_NOT_MOVE_TO_ZERO(1310), - LOW_ERROR_PIPETTE_ERROR_NO_ERROR(1400), - LOW_ERROR_PIPETTE_ERROR_INIT_FAIL(1401), - LOW_ERROR_PIPETTE_ERROR_INVALID_CMD(1402), - LOW_ERROR_PIPETTE_ERROR_INVALID_ARG(1403), - LOW_ERROR_PIPETTE_ERROR_PRESSURE_SENSOR_ERROR(1404), - LOW_ERROR_PIPETTE_ERROR_OVER_PRESSURE(1405), - LOW_ERROR_PIPETTE_ERROR_LLD_ERROR(1406), //一般为lld时移液枪吸液过快,导致很快到达最大行程 - LOW_ERROR_PIPETTE_ERROR_DEVICE_NOT_INIT(1407), - LOW_ERROR_PIPETTE_ERROR_TIP_POP_ERROR(1408), - LOW_ERROR_PIPETTE_ERROR_PUMP_OVERLOAD(1409), - LOW_ERROR_PIPETTE_ERROR_TIP_DROP(1410), - LOW_ERROR_PIPETTE_ERROR_CAN_BUS_ERROR(1411), - LOW_ERROR_PIPETTE_ERROR_INVALID_CHECKSUM(1412), - LOW_ERROR_PIPETTE_ERROR_EEPROM_ERROR(1413), - LOW_ERROR_PIPETTE_ERROR_CMD_BUFFER_EMPTY(1414), - LOW_ERROR_PIPETTE_ERROR_CMD_BUFFER_OVERFLOW(1415), - LOW_ERROR_PIPETTE_ERROR_TIP_BLOCK(1416), - LOW_ERROR_PIPETTE_ERROR_AIR_SUCTION(1417), - LOW_ERROR_PIPETTE_ERROR_BUBBLE(1418), - LOW_ERROR_PIPETTE_ERROR_VOLUME_ERROR(1419), - LOW_ERROR_PIPETTE_ERROR_TIP_ALREADY_LOAD(1420), - LOW_ERROR_PIPETTE_ERROR_TIP_LOAD_FAIL(1421), - LOW_ERROR_PIPETTE_ERROR_NO_TIP_WHEN_LLD(1422), - - LOW_ERROR_PIPETTE_ERROR_TIPISLOAD_WHEN_LLD_PREPARE(1500), - LOW_ERROR_PIPETTE_ERROR_UNINITIALIZED(1501), - LOW_ERROR_PIPETTE_ERROR_NOT_LLD_PREPARE(1502), - LOW_ERROR_PIPETTE_ERROR_PUMP_LOAD_VAL_IS_NOT_EMPTY(1503), - LOW_ERROR_PIPETTE_LLD_ERROR_NO_LIQUID_DETECTED(1504), - LOW_ERROR_PIPETTE_LLD_ERROR_PUMP_REACH_MAX_POS(1505), - LOW_ERROR_PIPETTE_PM_POSITIONING_ABNORMALITY(1506), // 电机定位异常 - LOW_ERROR_PIPETTE_NO_LIQUID_IN_IT(1507), // 泵内无液体 - - - LOW_ERROR_STEP_MOTOR_NOT_FOUND_ZERO_POINT(1600), - LOW_ERROR_STEP_MOTOR_NOT_GO_ZERO(1601), - LOW_ERROR_STEP_MOTOR_OVER_TEMPERATURE(1602), - LOW_ERROR_STEP_MOTOR_OVER_VOLTAGE(1603), - LOW_ERROR_STEP_MOTOR_RUN_OVERTIME(1604), - LOW_ERROR_STEP_MOTOR_NOT_ENABLE(1605), - LOW_ERROR_STEP_MOTOR_IO_INDEX_OUT_OF_RANGE(1606), - LOW_ERROR_STEP_MOTOR_SUBIC_RESET(1607), - LOW_ERROR_STEP_MOTOR_DRV_ERR(1608), - LOW_ERROR_STEP_MOTOR_UV_CP(1609), - LOW_ERROR_STEP_MOTOR_NOT_FOUND_POINT_EDGE(1610), - LOW_ERROR_STEP_MOTOR_LOST_STEP(1611), - LOW_ERROR_STEP_MOTOR_NOT_MOVE_TO_ZERO(1612), - LOW_ERROR_STEP_MOTOR_OT(1613), - LOW_ERROR_STEP_MOTOR_OTPW(1614), - LOW_ERROR_STEP_MOTOR_S2GA(1615), - LOW_ERROR_STEP_MOTOR_S2GB(1616), - LOW_ERROR_STEP_MOTOR_OLA(1617), - LOW_ERROR_STEP_MOTOR_OLB(1618), - LOW_ERROR_MINI_SERVO_NOT_ENABLE(1700), - LOW_ERROR_MINI_SERVO_MODE_NOT_SUPPORT(1701), - LOW_ERROR_FAN_HARDWARE_FAULT(1800), - LOW_ERROR_WATER_COOLING_FAN_ERROR(1900), - LOW_ERROR_WATER_COOLING_TEMPERATURE_SENSOR_ERROR(1902), - LOW_ERROR_WATER_COOLING_PUMP_IS_ERROR(1903), - LOW_ERROR_WATER_COOLING_PELTER_IS_ERROR(1904), - // - // 底层扩展错误码,由java定义 - // - LOW_EXT_ERROR_UNKNOWN_INDEX_ERROR(5000), //代码错误,未知错误 - LOW_EXT_ERROR_CMD_NOT_SUPPORT(5001), //代码错误,未知错误 - LOW_EXT_ERROR_MOTOR_AT_WRONG_POS(5002),//电机在错误的位置 - ; - - public final int index; - public int rawindex = 0; - - A8kEcode(int index) { - this.index = index; - } - - - static public A8kEcode fromInt(int index) { - for (var e : A8kEcode.values()) { - if (e.index == index) { - return e; - } - } - log.error("未知错误码:{}", index); - A8kEcode.LOW_EXT_ERROR_UNKNOWN_INDEX_ERROR.rawindex = index; - return A8kEcode.LOW_EXT_ERROR_UNKNOWN_INDEX_ERROR; - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kPacket.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kPacket.java deleted file mode 100644 index 302d90e..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/A8kPacket.java +++ /dev/null @@ -1,236 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import a8k.app.utils.ByteArrayUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.Assert; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -public class A8kPacket { - - //#pragma pack(push, 1) - //typedef struct { - // uint8_t packetType; - // uint16_t cmdid; - // uint8_t moduleId; - // uint16_t index; - // uint8_t datalen; - // uint8_t data[]; - // /* int8_t checksum;*/ - //} zcr_cmd_header_t; - // - //#pragma pack(pop) - //typedef enum { - // kptv2_cmd = 0xA0, - // kptv2_ack = 0xA1, - // kptv2_error_ack = 0xA2, - // kptv2_event = 0xA3, - //} zcan_cmd_packet_type_t; - // - - /** - * - * @WARNING - * 1. 修改这里时,需要注意连同createPacket一起修改 - * 2. PACKET_MIN_LEN 比Header多一个字节,是因为还有一个字节的校验位 - */ - - public static final int PACKET_TYPE_OFFSET = 0; - public static final int CMDID_OFFSET = 1; - public static final int MODULE_ID_OFFSET = 3; - public static final int INDEX_OFFSET = 4; - public static final int DATA_LEN_OFFSET = 6; - public static final int DATA_OFFSET = 7; - - public static final int PACKET_MIN_LEN = 8;// - - public static final int CMD_OVERTIME = 1500; - - - public static final int PACKET_TYPE_CMD = 0xA0; - public static final int PACKET_TYPE_ACK = 0xA1; - public static final int PACKET_TYPE_ERROR_ACK = 0xA2; - public static final int PACKET_TYPE_EVENT = 0xA3; - - public static final Logger logger = LoggerFactory.getLogger(A8kPacket.class); - - byte[] raw; - - public A8kPacket(byte[] cmd) { - raw = new byte[cmd.length]; - System.arraycopy(cmd, 0, raw, 0, cmd.length); - } - - public void setPacketIndex(int packetIndex) { - ByteArrayUtils.setU16bit(raw, INDEX_OFFSET, packetIndex); - int checkcode = computeCheckcode(); - ByteArrayUtils.setU8(raw, raw.length - 1, checkcode); - } - - - public int getPacketIndex() { - return ByteArrayUtils.readU16bit(raw, INDEX_OFFSET); - } - - public int getCmdId() { - return ByteArrayUtils.readU16bit(raw, CMDID_OFFSET); - } - - public int getPacketType() { - return ByteArrayUtils.readU8bit(raw, PACKET_TYPE_OFFSET); - } - - public int getModuleId() { - return ByteArrayUtils.readU8bit(raw, MODULE_ID_OFFSET); - } - - public int getDataLen() { - return ByteArrayUtils.readU8bit(raw, DATA_LEN_OFFSET); - } - - public byte[] getCmdContent() { - if (raw.length < PACKET_MIN_LEN) { - return new byte[0]; - } - byte[] cmdcontent = new byte[getDataLen()]; - System.arraycopy(raw, DATA_OFFSET, cmdcontent, 0, getDataLen()); - return cmdcontent; - } - - public int[] getContentI16Array() { - int[] ret = new int[getDataLen() / 2]; - for (int i = 0; i < ret.length; i++) { - ret[i] = ByteArrayUtils.readS16bit(raw, DATA_OFFSET + i * 2); - } - return ret; - } - - - public int getContentI32(int index) { - return ByteArrayUtils.read32bit(raw, DATA_OFFSET + index * 4); - } - - public int getCheckcode() { - return ByteArrayUtils.readU8bit(raw, raw.length - 1); - } - - public int computeCheckcode() { - int checkcode = 0; - for (int i = 0; i < raw.length - 1; i++) { - checkcode += raw[i]; - } - return checkcode & 0xFF; - } - - public String toByteString() { - return ByteArrayUtils.toByteString(raw); - } - - public String toString() { - int packetType = getPacketType(); - String ret = ""; - - CmdId cmdId = CmdId.valueOf(getCmdId()); - Assert.isTrue(cmdId != null, "cmdId is null"); - if (packetType == PACKET_TYPE_CMD) { - - if (cmdId.equals(CmdId.module_get_reg) || cmdId.equals(CmdId.module_set_reg)) { - RegIndex regIndex = RegIndex.valueOf(getContentI32(0)); - if (regIndex != null) { - ret = String.format("[CMD ] index:[%d] %s %s %s(%d) %d", getPacketIndex(), cmdId, - MId.valueOf(getModuleId()), regIndex, regIndex.index, getContentI32(1)); - } else { - ret = String.format("[CMD ] index:[%d] %s unkown_index(%d) %d", getPacketIndex(), cmdId, - getContentI32(0), getContentI32(1)); - } - } else { - if (cmdId.getCmdAttachType() == CmdId.ATTACH_IS_INT32) { - ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, - MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); - } else { - ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, - MId.valueOf(getModuleId()), getModuleId(), ByteArrayUtils.toByteString(getCmdContent())); - } - } - - } else if (packetType == PACKET_TYPE_ACK) { - if (cmdId.getReceiptAttachType() == CmdId.ATTACH_IS_INT32) { - ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, - formatInt32ATTACH(getCmdContent())); - } else { - ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, - ByteArrayUtils.toByteString(getCmdContent())); - } - } else if (packetType == PACKET_TYPE_ERROR_ACK) { - ret = String.format("[EACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, (getContentI32(0))); - } else if (packetType == PACKET_TYPE_EVENT) { - if (cmdId.getCmdAttachType() == CmdId.ATTACH_IS_INT32) { - ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, - MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); - } else { - ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, - MId.valueOf(getModuleId()), getModuleId(), ByteArrayUtils.toByteString(getCmdContent())); - } - } else { - ret = String.format("Unknown packet type: %d", packetType); - } - return ret; - } - - private String formatInt32ATTACH(byte[] attach) { - StringBuilder ret = new StringBuilder(); - for (int i = 0; i < attach.length; i += 4) { - if (i + 3 >= attach.length) - break; - if (i != 0) - ret.append(","); - ret.append(String.format("%d", ByteArrayUtils.read32bit(attach, i))); - } - return ret.toString(); - } - - public Boolean isSupportPacket() { - CmdId cmdid = CmdId.valueOf(getCmdId()); - if (cmdid == null) { - return false; - } - if (CmdId.module_get_reg.equals(cmdid) || CmdId.module_set_reg.equals(cmdid)) { - if (getPacketType() == PACKET_TYPE_CMD) { - RegIndex regIndex = RegIndex.valueOf(getContentI32(0)); - return regIndex != null; - } - } - return true; - } - - - static public A8kPacket createPacket(Integer moduleId, int packetType, Integer cmdId, Integer[] params) { - int bufferSize = A8kPacket.PACKET_MIN_LEN + 4 * params.length; - ByteBuffer buffer = ByteBuffer.allocate(bufferSize); - buffer.order(ByteOrder.LITTLE_ENDIAN); - buffer.put((byte) (packetType & 0xff)); // packetType - buffer.putShort((short) (cmdId & 0xffff)); // cmdid - buffer.put((byte) (moduleId & 0xFF)); // moduleId - buffer.put((byte) 0x4C); // index - buffer.put((byte) 0x00); // index - buffer.put((byte) (params.length * 4)); // datalen - for (int value : params) { - buffer.putInt(value); - } - // int8_t checksum; - int checksum = 0; - for (int i = 0; i < bufferSize - 1; i++) { - checksum += buffer.get(i); - } - buffer.put((byte) checksum); - return new A8kPacket(buffer.array()); - } - - public static void main(String[] args) { - var packet = createPacket(41, A8kPacket.PACKET_TYPE_CMD, CmdId.module_stop.index, new Integer[]{}); - logger.info("{}", packet.toByteString()); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/CmdId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/CmdId.java deleted file mode 100644 index 47e4b42..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/CmdId.java +++ /dev/null @@ -1,277 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum CmdId { - NotSet(0xFFFF, "NOACTION"),// - - board_reset(0x0000, "复位板子"),// - event_bus_reg_change_report(0x0064, "寄存器修改事件"),// - // - - module_ping(0x0101, "MODULE_PING"), - module_stop(0x0102, "MODULE_STOP"), - - module_get_error(0x0110, "MODULE_GET_ERROR"), - module_get_detail_error(0x0111, "MODULE_GET_DETAIL_ERROR"), - module_clear_error(0x0112, "MODULE_CLEAR_ERROR"), - - module_set_reg(0x0120, "MODULE_SET_REG"), - module_get_reg(0x0121, "MODULE_GET_REG"), - module_reset_reg(0x0123, "MODULE_RESET_REG"), - - module_get_version(0x0130, "MODULE_GET_VERSION"), - module_get_type(0x0131, "MODULE_GET_TYPE"), - module_get_status(0x0132, "MODULE_GET_STATUS"), - - - // module_active_cfg(0x0110, "激活配置"),// - // - xymotor_enable(0x0301, "XYMOTOR_ENABLE"),// - xymotor_move_by(0x0302, "XYMOTOR_MOVE_BY"),// - xymotor_move_to(0x0303, "XYMOTOR_MOVE_TO"),// - xymotor_move_to_zero(0x0304, "XYMOTOR_MOVE_TO_ZERO"),// - xymotor_read_pos(0x0306, "XYMOTOR_READ_POS"),// - xymotor_read_inio_index_in_stm32(0x0307, "XYMOTOR_READ_INIO_INDEX_IN_STM32"),// - xymotor_read_inio(0x0308, "XYMOTOR_READ_INIO"),// - xymotor_set_pos(0x0309, "XYMOTOR_SET_POS"),// - xymotor_motor_move_by_direct(0x030a, "XYMOTOR_MOTOR_MOVE_BY_DIRECT"),// - xymotor_read_enc_direct(0x030b, "XYMOTOR_READ_ENC_DIRECT"),// - // - a8k_opt_v2_read_raw(0x0609, "A8K_OPT_V2_READ_RAW"),// - // - a8k_opt_v2_t_start_scan(0x0700, "A8K_OPT_V2_T_START_SCAN"),// - a8k_opt_v2_f_start_scan(0x0701, "A8K_OPT_V2_F_START_SCAN"),// - a8k_opt_v2_t_open_laster(0x070a, "A8K_OPT_V2_T_OPEN_LASTER"),// - a8k_opt_v2_t_close_laster(0x070b, "A8K_OPT_V2_T_CLOSE_LASTER"),// - a8k_opt_v2_t_readVal(0x070c, "A8K_OPT_V2_T_READVAL"),// - a8k_opt_v2_f_open_laster(0x070d, "A8K_OPT_V2_F_OPEN_LASTER"),// - a8k_opt_v2_f_close_laster(0x070e, "A8K_OPT_V2_F_CLOSE_LASTER"),// - a8k_opt_v2_f_readVal(0x070f, "A8K_OPT_V2_F_READVAL"),// - // - step_motor_enable(0x0201, "STEP_MOTOR_ENABLE"),// - step_motor_read_pos(0x020b, "STEP_MOTOR_READ_POS"),// - step_motor_read_enc_pos(0x020c, "STEP_MOTOR_READ_ENC_POS"),// - step_motor_easy_rotate(0x0211, "STEP_MOTOR_EASY_ROTATE"),// - step_motor_easy_move_by(0x0212, "STEP_MOTOR_EASY_MOVE_BY"),// - step_motor_easy_move_to(0x0213, "STEP_MOTOR_EASY_MOVE_TO"),// - step_motor_easy_move_to_zero(0x0214, "STEP_MOTOR_EASY_MOVE_TO_ZERO"),// - step_motor_easy_set_current_pos(0x0215, "STEP_MOTOR_EASY_SET_CURRENT_POS"),// - step_motor_easy_move_to_io(0x0216, "STEP_MOTOR_EASY_MOVE_TO_IO"),// - step_motor_stop(0x0228, "STEP_MOTOR_STOP"),// - step_motor_move_by(0x021d, "STEP_MOTOR_MOVE_BY"), // (dpos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) - step_motor_move_to(0x021e, "STEP_MOTOR_MOVE_TO"), // (pos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) - step_motor_move_to_zero_point_quick(0x021f, "STEP_MOTOR_MOVE_TO_ZERO_POINT_QUICK"), // (speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) - step_motor_rotate(0x0220, "STEP_MOTOR_ROTATE"), // - - step_motor_active_cfg(0x0229, "STEP_MOTOR_ACTIVE_CFG"),// - step_motor_read_io_state(0x022a, "STEP_MOTOR_READ_IO_STATE"),// - step_motor_easy_move_to_end_point(0x022c, "STEP_MOTOR_EASY_MOVE_TO_END_POINT"),// - step_motor_read_tmc5130_status(0x0232, "STEP_MOTOR_READ_TMC5130_STATUS"),// - step_motor_read_tmc5130_state(0x0233, "STEP_MOTOR_READ_TMC5130_STATE"),// - step_motor_read_io_index_in_stm32(0x0238, "STEP_MOTOR_READ_IO_INDEX_IN_STM32"),// - step_motor_set_subdevice_reg(0x0239, "STEP_MOTOR_SET_SUBDEVICE_REG"),// - step_motor_get_subdevice_reg(0x023a, "STEP_MOTOR_GET_SUBDEVICE_REG"),// - step_motor_easy_reciprocating_motion(0x022d, "STEP_MOTOR_EASY_RECIPROCATING_MOTION"),// - step_motor_easy_move_to_zero_point_quick(0x022e, "STEP_MOTOR_EASY_MOVE_TO_ZERO_POINT_QUICK"),// - // - mini_servo_enable(0x6601, "MINI_SERVO_ENABLE"),// - mini_servo_read_pos(0x6602, "MINI_SERVO_READ_POS"),// - mini_servo_active_cfg(0x6603, "MINI_SERVO_ACTIVE_CFG"),// - mini_servo_stop(0x6604, "MINI_SERVO_STOP"),// - mini_servo_set_mid_point(0x6607, "MINI_SERVO_SET_MID_POINT"),// - mini_servo_read_io_state(0x6608, "MINI_SERVO_READ_IO_STATE"),// - mini_servo_move_to(0x6609, "MINI_SERVO_MOVE_TO"),// - mini_servo_rotate(0x660a, "MINI_SERVO_ROTATE"),// - mini_servo_rotate_with_torque(0x660b, "MINI_SERVO_ROTATE_WITH_TORQUE"),// - mini_servo_set_cur_pos(0x660c, "MINI_SERVO_SET_CUR_POS"),// - // - extboard_read_inio(0x6701, "EXTBOARD_READ_INIO"),// - extboard_write_outio(0x6702, "EXTBOARD_WRITE_OUTIO"),// - extboard_read_muti_inio(0x6703, "EXTBOARD_READ_MUTI_INIO"),// - extboard_read_inio_index_in_stm32(0x6704, "EXTBOARD_READ_INIO_INDEX_IN_STM32"),// - extboard_read_outio_index_in_stm32(0x6705, "EXTBOARD_READ_OUTIO_INDEX_IN_STM32"),// - extboard_read_outio(0x6706, "EXTBOARD_READ_OUTIO"),// - code_scaner_start_scan(0x6801, "CODE_SCANER_START_SCAN"),// - code_scaner_stop_scan(0x6802, "CODE_SCANER_STOP_SCAN"),// - code_scaner_result_is_ready(0x6803, "CODE_SCANER_RESULT_IS_READY"),// - code_scaner_read_scaner_result(0x6804, "CODE_SCANER_READ_SCANER_RESULT"),// - code_scaner_get_result_length(0x6805, "CODE_SCANER_GET_RESULT_LENGTH"),// - // - fan_controler_set_speed(0x6900, "FAN_CONTROLER_SET_SPEED"),// - // - temp_controler_start_hearting(0x7000, "TEMP_CONTROLER_START_HEARTING"),// - temp_controler_stop_hearting(0x7001, "TEMP_CONTROLER_STOP_HEARTING"),// - temp_controler_set_peltier_power_level(0x7002, "TEMP_CONTROLER_SET_PELTIER_POWER_LEVEL"),// - temp_controler_set_pump_level(0x7003, "TEMP_CONTROLER_SET_PUMP_LEVEL"),// - temp_controler_set_fan_level(0x7004, "TEMP_CONTROLER_SET_FAN_LEVEL"),// - temp_controler_enable_log(0x7005, "TEMP_CONTROLER_ENABLE_LOG"),// - // - a8000_idcard_reader_read_raw(0x7100, "A8000_IDCARD_READER_READ_RAW"),// - a8000_idcard_write_raw(0x7101, "A8000_IDCARD_WRITE_RAW"),// - a8000_idcard_erase(0x7102, "A8000_IDCARD_ERASE"),// - a8000_idcard_earse_unlock(0x7103, "A8000_IDCARD_EARSE_UNLOCK"),// - // - event_a8000_idcard_online(0x71c8, "EVENT_A8000_IDCARD_ONLINE"),// - event_a8000_idcard_offline(0x71c9, "EVENT_A8000_IDCARD_OFFLINE"),// - // - // plate_code_scaner_push_card_and_scan(0x7301, "PLATE_CODE_SCANER_PUSH_CARD_AND_SCAN"),// - // plate_code_scaner_stop_scan(0x7302, "PLATE_CODE_SCANER_STOP_SCAN"),// - // plate_code_scaner_read_result(0x7303, "PLATE_CODE_SCANER_READ_RESULT"),// - // plate_code_scaner_read_result_point_num(0x7304, "PLATE_CODE_SCANER_READ_RESULT_POINT_NUM"),// - // plate_code_scaner_read_code(0x7305, "PLATE_CODE_SCANER_READ_CODE"),// - // plate_code_scaner_adc_readraw(0x7306, "PLATE_CODE_SCANER_ADC_READRAW"),// - // plate_code_scaner_open_laser(0x7307, "PLATE_CODE_SCANER_OPEN_LASER"),// - // plate_code_scaner_close_laser(0x7308, "PLATE_CODE_SCANER_CLOSE_LASER"),// - // - - - pipette_set_zmbcfg(0x7401, "pipette_set_zmbcfg"), - pipette_get_zmbcfg(0x7402, "pipette_get_zmbcfg"), - pipette_set_pmbcfg(0x7403, "pipette_set_pmbcfg"), - pipette_get_pmbcfg(0x7404, "pipette_get_pmbcfg"), - pipette_set_platinfo(0x7405, "pipette_set_platinfo"), - pipette_get_platinfo(0x7406, "pipette_get_platinfo"), - pipette_set_zmvcfg(0x7407, "pipette_set_zmvcfg"), - pipette_get_zmvcfg(0x7408, "pipette_get_zmvcfg"), - pipette_set_pmvcfg(0x7409, "pipette_set_pmvcfg"), - pipette_get_pmvcfg(0x740A, "pipette_get_pmvcfg"), - pipette_set_container_info(0x740B, "pipette_set_container_info"), - pipette_get_container_info(0x740C, "pipette_get_container_info"), - pipette_set_liquid_info(0x740D, "pipette_set_liquid_info"), - pipette_get_liquid_info(0x740E, "pipette_get_liquid_info"), - pipette_get_platinfo_max_cpyid(0x7410, "pipette_get_platinfo_max_cpyid"), - pipette_get_zmvcfg_max_cpyid(0x7411, "pipette_get_zmvcfg_max_cpyid"), - pipette_get_pmvcfg_max_cpyid(0x7412, "pipette_get_pmvcfg_max_cpyid"), - pipette_get_container_info_max_cpyid(0x7413, "pipette_get_container_info_max_cpyid"), - pipette_get_liquid_info_max_cpyid(0x7414, "pipette_get_liquid_info_max_cpyid"), - pipette_set_common_cfg(0x7415, "pipette_set_common_cfg"), - pipette_get_common_cfg(0x7416, "pipette_get_common_cfg"), - - pipette_zmotor_enable(0x7500, "pipette_zmotor_enable"), - pipette_zmotor_move_zero(0x7501, "pipette_zmotor_move_zero"), - pipette_zmotor_move_to_zero_point_quick(0x7502, "pipette_zmotor_move_to_zero_point_quick"), - pipette_zmotor_measure_distance(0x7503, "pipette_zmotor_measure_distance"), - pipette_zmotor_read_measure_distance_result(0x7504, "pipette_zmotor_read_measure_distance_result"), - pipette_zmotor_move_by(0x7505, "pipette_zmotor_move_by"), - pipette_zmotor_move_to(0x7506, "pipette_zmotor_move_to"), - pipette_zmotor_read_zero_point_state(0x7507, "pipette_zmotor_read_zero_point_state"), - pipette_zmotor_read_dev_status_cache(0x7508, "pipette_zmotor_read_dev_status_cache"), - pipette_zmotor_read_pos(0x7509, "pipette_zmotor_read_pos"), - pipette_zmotor_read_enc_pos(0x750A, "pipette_zmotor_read_enc_pos"), - pipette_zmotor_move_to_tip_deposit(0x750B, "pipette_zmotor_move_to_tip_deposit"), - - - pipette_pump_init_device(0x7580, "pipette_pump_init_device"), - pipette_pump_take_tip(0x7581, "pipette_pump_take_tip"), - pipette_pump_deposit_tip(0x7582, "pipette_pump_put_tip"), - pipette_pump_pierce_through(0x7583, "pipette_pump_aspirate_set_param"), - pipette_pump_aspirate_set_param(0x7584, "pipette_pump_aspirate_set_param"), - pipette_pump_aspirate(0x7585, "pipette_pump_aspirate"), - pipette_get_sensor_sample_data(0x7587, "pipette_get_sensor_sample_data"), - pipette_get_sensor_sample_data_num(0x7588, "pipette_get_sensor_sample_data_num"), - pipette_read_state(0x7589, "pipette_read_state"), - pipette_pump_putbak_tip(0x758A, "pipette_pump_cutback_tip"), - pipette_read_tip_state(0x758B, "pipette_read_tip_state"), - pipette_read_pressure(0x758C, "pipette_read_pressure"), - pipette_read_capacitance(0x758D, "pipette_read_capacitance"), - pipette_pump_distribu_all_set_param(0x758E, "pipette_pump_distribu_all_set_param"), // {paramid,val}, ack:{} - pipette_pump_distribu_all(0x758F, "pipette_pump_distribu_all"), // {}, ack:{} - pipette_get_asp_pressure_data(0x7590, "pipette_get_asp_pressure_data"), // {section_off}, ack:{int16_t data[]} - - - pipette_test_pump_move_to_x100nl(0x7600, "pipette_test_pump_move_to_x100nl"), // int32_t x100nl, int32_t vcfgindex - pipette_test_lld(0x7601, "pipette_test_lld"), // int32_t container_pos, int32_t container_cpyid, int32_t liquid_cpyid - pipette_test_move_to_container_bottom(0x7602, "pipette_test_move_to_container_bottom"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_container_bottom_section_begin(0x7603, "pipette_test_move_to_container_bottom_section_begin"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_immersion_pos(0x7604, "pipette_test_move_to_immersion_pos"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_leaving_height_pos(0x7605, "pipette_test_move_to_leaving_height_pos"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_jet_pos(0x7606, "pipette_test_move_to_jet_pos"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_lld_start_search_pos(0x7607, "pipette_test_move_to_lld_start_search_pos"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_fix_water_level_pos(0x7608, "pipette_test_move_to_fix_water_level_pos"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_pierce_pos(0x7609, "pipette_test_move_to_pierce_pos"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_move_to_lld_end_pos(0x760A, "pipette_test_move_to_lld_end_pos"), // int32_t container_pos, int32_t container_cpyid, - pipette_test_connectivity(0x760B, "pipette_test_connectivity"), // 测试电缆连接性 {}, ack:{} - - ; - public final static int ATTACH_IS_BYTES = 1; - public final static int ATTACH_IS_INT32 = 2; - public final int index; - public final String chName; - - - // public final int cmdAttachType = ATTACH_IS_INT32; - // public final int receiptAttachType = ATTACH_IS_INT32; - // public final boolean trace = true; - // public final boolean actionCmd = true; - - CmdId(int index, String chname) { - this.index = index; - this.chName = chname; - } - - public int toInt() { - return index; - } - - public static CmdId valueOf(int val) { - CmdId[] values = CmdId.values(); - for (CmdId e : values) { - if (e.toInt() == val) - return e; - } - return null; - } - - public static String toString(int val) { - CmdId[] values = CmdId.values(); - for (CmdId e : values) { - if (e.toInt() == val) { - return e.toString(); - } - } - return "unkown(" + val + ")"; - } - - public String getChname() { - return chName; - } - - public Boolean eq(Integer index) { - return this.index == index; - } - - - public int getCmdAttachType() { - return switch (this) { - case a8000_idcard_write_raw -> ATTACH_IS_BYTES; - default -> ATTACH_IS_INT32; - }; - } - - public int getReceiptAttachType() { - return switch (this) { - case a8k_opt_v2_read_raw, a8000_idcard_reader_read_raw -> ATTACH_IS_BYTES; - default -> ATTACH_IS_INT32; - }; - } - - public boolean isTrace() { - return true; - } - - public boolean isActionCmd() { - - return switch (this) { - case module_get_status, - module_get_error, - xymotor_read_pos, - xymotor_read_inio, - step_motor_read_io_state, - extboard_read_inio, - extboard_read_muti_inio, - module_get_reg, - module_set_reg, - code_scaner_result_is_ready -> false; - default -> true; - }; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/HbotRegIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/HbotRegIndex.java deleted file mode 100644 index 66635f5..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/HbotRegIndex.java +++ /dev/null @@ -1,48 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum HbotRegIndex { -// kreg_module_version(RegIndex.kreg_module_version), // 模块版本 -// kreg_module_type(RegIndex.kreg_module_type), // 模块类型 -// kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error -// kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag - - kreg_xyrobot_io_state(RegIndex.kreg_xyrobot_io_state), // - kreg_xyrobot_is_enable(RegIndex.kreg_xyrobot_is_enable), // - kreg_xyrobot_robot_type(RegIndex.kreg_xyrobot_robot_type), // - kreg_xyrobot_one_circle_pulse(RegIndex.kreg_xyrobot_one_circle_pulse), // - kreg_xyrobot_one_circle_pulse_denominator(RegIndex.kreg_xyrobot_one_circle_pulse_denominator), // - kreg_xyrobot_ihold(RegIndex.kreg_xyrobot_ihold), // - kreg_xyrobot_irun(RegIndex.kreg_xyrobot_irun), // - kreg_xyrobot_iholddelay(RegIndex.kreg_xyrobot_iholddelay), // - kreg_xyrobot_iglobalscaler(RegIndex.kreg_xyrobot_iglobalscaler), // - kreg_xyrobot_vstart(RegIndex.kreg_xyrobot_vstart), // - kreg_xyrobot_a1(RegIndex.kreg_xyrobot_a1), // - kreg_xyrobot_amax(RegIndex.kreg_xyrobot_amax), // - kreg_xyrobot_v1(RegIndex.kreg_xyrobot_v1), // - kreg_xyrobot_dmax(RegIndex.kreg_xyrobot_dmax), // - kreg_xyrobot_d1(RegIndex.kreg_xyrobot_d1), // - kreg_xyrobot_vstop(RegIndex.kreg_xyrobot_vstop), // - kreg_xyrobot_tzerowait(RegIndex.kreg_xyrobot_tzerowait), // - kreg_xyrobot_enc_resolution(RegIndex.kreg_xyrobot_enc_resolution), // - kreg_xyrobot_enable_enc(RegIndex.kreg_xyrobot_enable_enc), // - kreg_xyrobot_x_shaft(RegIndex.kreg_xyrobot_x_shaft), // - kreg_xyrobot_y_shaft(RegIndex.kreg_xyrobot_y_shaft), // - kreg_xyrobot_min_x(RegIndex.kreg_xyrobot_min_x), // - kreg_xyrobot_min_y(RegIndex.kreg_xyrobot_min_y), // - kreg_xyrobot_max_x(RegIndex.kreg_xyrobot_max_x), // - kreg_xyrobot_max_y(RegIndex.kreg_xyrobot_max_y), // - kreg_xyrobot_run_to_zero_speed(RegIndex.kreg_xyrobot_run_to_zero_speed), // - kreg_xyrobot_look_zero_edge_speed(RegIndex.kreg_xyrobot_look_zero_edge_speed), // - kreg_xyrobot_shift_x(RegIndex.kreg_xyrobot_shift_x), // - kreg_xyrobot_shift_y(RegIndex.kreg_xyrobot_shift_y), // - kreg_xyrobot_pos_devi_tolerance(RegIndex.kreg_xyrobot_pos_devi_tolerance), // - kreg_xyrobot_io_trigger_append_distance(RegIndex.kreg_xyrobot_io_trigger_append_distance), // - kreg_xyrobot_default_velocity(RegIndex.kreg_xyrobot_default_velocity), // - ; - - public final RegIndex regIndex; - HbotRegIndex(RegIndex regIndex) { - this.regIndex = regIndex; - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/InputIOId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/InputIOId.java deleted file mode 100644 index d79abe3..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/InputIOId.java +++ /dev/null @@ -1,45 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum InputIOId { - TubeHeightPPS("入料平移通道-试管高低检测IO", ModuleType.Board, MId.FeedingModBoard, 0, false), //高低试管检测IO - TubeExistPPS("入料平移通道-试管有无光电", ModuleType.Board, MId.FeedingModBoard, 4, false),//试管有无光电 - THChOuterPPS("入料平移通道-外光电", ModuleType.Board, MId.FeedingModBoard, 1, false),//试管架转移通道有无检测 外 - THChInterPPS("入料平移通道-内光电", ModuleType.Board, MId.FeedingModBoard, 2, false),//试管架转移通道有无检测 内 - InfeedPPS("入料区有无光电", ModuleType.Board, MId.FeedingModBoard, 5, false),//试管架入料位置 试管架有无检测 - OutfeedPPS("出料位有无检测", ModuleType.Board, MId.FeedingModBoard, 3, false),//试管出料位置 试管架有无检测 - - RecycleBinOverflowPPS("废料仓满溢检测", ModuleType.Board, MId.PlatesBoxTCMBoard, 2, false),//废料桶满溢检测 - RecycleBinInPlacePPS("废料仓到位检测", ModuleType.Board, MId.OptModBoard, 1, false),//废料桶到位检测 - IncubationPlateOutletStuckPPS("光学模组-入口-卡板-检测", ModuleType.Board, MId.OptModBoard, 4, false),//废料桶到位检测 - - PlateBoxCoverClosurePPS("板夹仓-仓门光电", ModuleType.Board, MId.PlatesBoxBoard, 0, true),//板夹仓舱盖闭合检测 - IncubationPlateInletStuckPPS("板夹仓-卡板光电", ModuleType.Board, MId.PlatesBoxBoard, 1, false),//板夹仓卡板检测 - - - - //转盘逻辑相关光电 - //钩板电机,零点光电,终点光电 - PullerMZeroPPS("光学模组-拉杆电机-零点光电", ModuleType.TMCStepMotor, MId.OptModPullM, 0, false),// - PullerMEndPPS("光学模组-拉杆电机-限位光电", ModuleType.TMCStepMotor, MId.OptModPullM, 1, false),// - //推板电机,零点光电,终点光电 - PusherMZeroPPS("推杆电机-零点光电", ModuleType.TMCStepMotor, MId.PlatesBoxPusherM, 0, false),// - PusherMEndPPS("推杆电机-终点光电", ModuleType.TMCStepMotor, MId.PlatesBoxPusherM, 1, false),// - ; - - final public String chname; - final public ModuleType mtype; - final public MId mid; - final public int ioIndex; - final public boolean mirror; - - InputIOId(String chname, ModuleType mtype, MId mid, int ioIndex, boolean mirror) { - this.chname = chname; - this.mtype = mtype; - this.mid = mid; - this.ioIndex = ioIndex; - this.mirror = mirror; - - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/LldType.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/LldType.java deleted file mode 100644 index 00e4f72..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/LldType.java +++ /dev/null @@ -1,25 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -/** - * 液位探测方式 - */ -public enum LldType { - // 电容式 - kclld(0), - - // 电压式 - kplld(1), - - // 混合式 - kmixlld(2); - - - private final int index; - - LldType(int index) { - this.index = index; - } - public int getIndex() { - return index; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/MId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/MId.java deleted file mode 100644 index 0b8a08a..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/MId.java +++ /dev/null @@ -1,89 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum MId { - NotSet(0, "未设置"),// - HbotBoard(10, "机械臂板模块"),// - HbotM(11, "机械臂XY"),// - // - PlatesBoxBoard(20, "板夹仓模块"),// - PlatesBoxYM(21, "板夹仓移动电机"),// - PlatesBoxPusherM(22, "板夹仓推杆电机"),// - // PlatesBoxScanner(23, "板夹仓扫码模组"),// - // - ShakeModBoard(30, "摇匀模组板"),// - ShakeModClampingM(31, "试管固定夹爪电机"),// - ShakeModGripperZM(32, "摇匀升降电机"),// - ShakeModShakeM(33, "试管摇匀电机"),// - ShakeModGripperYSV(34, "摇匀前后移动舵机"),// - ShakeModGripperSV(35, "摇匀试管帽夹爪舵机"),// - ShakeModTubeScanerClampingSV(36, "试管架扫码夹紧舵机"),// - ShakeModTubeScanerRotateSV(37, "试管架旋转舵机"),// - ShakeModLiftingSV(38, "试管顶升舵机"),// - // - PlatesBoxTCMBoard(40, "反应板夹温度控制板"),// - PlatesBoxTCM(41, "反应板夹温度控制模块"),// - WbTubeFanMod(42, "气溶胶风扇"),// - // - IncubatorTCMBoard(50, "温度控制"),// - IncubatorTCM(51, "温度控制"),// - // - FeedingModBoard(60, "出入料模块"),// - FeedingModInfeedM(61, "入料电机"),// - FeedingModXM(62, "试管架平移电机"),// - FeedingModOutfeedM(63, "出料电机"),// - FeedingModScannerMod(64, "试管架扫码器"),// - // - IncubatorRotateBoard(70, "孵育盘旋转板"),// - IncubatorRotateCtrlM(71, "孵育盘旋转"),// - // - PipetteModBoard(80, "机械臂Z轴板"),// - PipetteMod(82, "移液枪"),// - PipetteModCodeScanner(83, "物料扫码器"),// - // - OptModBoard(90, "光学模组板"),// - OptModScannerM(91, "板卡扫描电机"),// - OptModPullM(92, "板卡推杆电机"),// - OptMod(93, "扫描仪"),// - // - A8kIdCardReaderBoard(100, "A8K读卡器板"),// - A8kIdCardReader(101, "A8K读卡器"),// - ; - - - final public String chname; - final public int index; - - MId(int index, String chname) { - this.chname = chname; - this.index = index; - } - - public int toInt() { - return index; - } - - - public static MId valueOf(Integer val) { - return valueOf(val.intValue()); - } - - public static MId valueOf(int val) { - MId[] values = MId.values(); - for (MId e : values) { - if (e.toInt() == val) - return e; - } - return null; - } - - public static String toString(int val) { - MId[] values = MId.values(); - for (MId e : values) { - if (e.toInt() == val) { - return e.toString(); - } - } - return "unkown(" + val + ")"; - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoMId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoMId.java deleted file mode 100644 index d7575af..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoMId.java +++ /dev/null @@ -1,20 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import org.springframework.util.Assert; - -public enum MiniServoMId { - ShakeModGripperYSV(MId.ShakeModGripperYSV),// 夹爪Y轴 - ShakeModGripperSV(MId.ShakeModGripperSV),// 夹爪舵机 - ShakeModTubeScanerClampingSV(MId.ShakeModTubeScanerClampingSV),//扫码夹紧 - ShakeModTubeScanerRotateSV(MId.ShakeModTubeScanerRotateSV),//扫码旋转 - ShakeModLiftingSV(MId.ShakeModLiftingSV),//试管升降 - ; - - final public MId mid; - - MiniServoMId(MId mid) { - Assert.isTrue(this.name().equals(mid.name()), "MiniServoMid Init fail"); - this.mid = mid; - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoRegIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoRegIndex.java deleted file mode 100644 index e9e75bc..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/MiniServoRegIndex.java +++ /dev/null @@ -1,69 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum MiniServoRegIndex { - // kreg_module_version(RegIndex.kreg_module_version), // 模块版本 - // kreg_module_type(RegIndex.kreg_module_type), // 模块类型 - // kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error - // kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag - - kreg_mini_servo_pos(RegIndex.kreg_mini_servo_pos), // 位置 - kreg_mini_servo_limit_velocity(RegIndex.kreg_mini_servo_limit_velocity), // 限制速度 - kreg_mini_servo_limit_torque(RegIndex.kreg_mini_servo_limit_torque), // 限制扭矩 - kreg_mini_servo_protective_torque(RegIndex.kreg_mini_servo_protective_torque), // 保护扭矩 - kreg_mini_servo_is_move(RegIndex.kreg_mini_servo_is_move), // 是否在运动 - - - kreg_mini_servo_status(RegIndex.kreg_mini_servo_status), // 舵机状态 - kreg_mini_servo_voltage(RegIndex.kreg_mini_servo_voltage), // 电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V - kreg_mini_servo_current(RegIndex.kreg_mini_servo_current), // 电流 反馈当前工作电流值,单位为ma - kreg_mini_servo_temperature(RegIndex.kreg_mini_servo_temperature), // 温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 - kreg_mini_servo_loadvalue(RegIndex.kreg_mini_servo_loadvalue), // 负载值 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 - kreg_mini_servo_target_pos_tolerance(RegIndex.kreg_mini_servo_target_pos_tolerance), // 目标位置容忍度 - - - kreg_mini_servo_firmware_main_version(RegIndex.kreg_mini_servo_firmware_main_version), // 固件主版本号 - kreg_mini_servo_firmware_sub_version(RegIndex.kreg_mini_servo_firmware_sub_version), // 固件次版本号 - kreg_mini_servo_servo_main_version(RegIndex.kreg_mini_servo_servo_main_version), // 舵机主版本号 - kreg_mini_servo_servo_sub_version(RegIndex.kreg_mini_servo_servo_sub_version), // 舵机次版本号 - kreg_mini_servo_servo_min_angle(RegIndex.kreg_mini_servo_servo_min_angle), // 最小角度限制 - kreg_mini_servo_servo_max_angle(RegIndex.kreg_mini_servo_servo_max_angle), // 最大角度限制 - kreg_mini_servo_servo_max_temp(RegIndex.kreg_mini_servo_servo_max_temp), // 最高温度上限 - kreg_mini_servo_servo_max_voltage(RegIndex.kreg_mini_servo_servo_max_voltage), // 最高输入电压 - kreg_mini_servo_servo_min_voltage(RegIndex.kreg_mini_servo_servo_min_voltage), // 最低输入电压 - kreg_mini_servo_servo_max_torque(RegIndex.kreg_mini_servo_servo_max_torque), // 最大扭矩 - kreg_mini_servo_servo_unload_condition(RegIndex.kreg_mini_servo_servo_unload_condition), // 卸载条件 - kreg_mini_servo_servo_p(RegIndex.kreg_mini_servo_servo_p), // P 比例系 - kreg_mini_servo_servo_d(RegIndex.kreg_mini_servo_servo_d), // D 微分系 - kreg_mini_servo_servo_i(RegIndex.kreg_mini_servo_servo_i), // I - kreg_mini_servo_servo_min_start(RegIndex.kreg_mini_servo_servo_min_start), // 最小启动 - kreg_mini_servo_servo_cw_dead_zone(RegIndex.kreg_mini_servo_servo_cw_dead_zone), // 顺时针不灵敏区 - kreg_mini_servo_servo_ccw_dead_zone(RegIndex.kreg_mini_servo_servo_ccw_dead_zone), // 逆时针不灵敏 - kreg_mini_servo_servo_protect_current(RegIndex.kreg_mini_servo_servo_protect_current), // 保护电流 - kreg_mini_servo_servo_protect_torque(RegIndex.kreg_mini_servo_servo_protect_torque), // 保护扭矩 0->100 ,触发后,需要写入与组转方向相反的位置指令,进行解除 - kreg_mini_servo_servo_protect_time(RegIndex.kreg_mini_servo_servo_protect_time), // 保护时间 - kreg_mini_servo_servo_overload_torque(RegIndex.kreg_mini_servo_servo_overload_torque), // 过载扭矩 - kreg_mini_servo_servo_speed_p(RegIndex.kreg_mini_servo_servo_speed_p), // 速度闭环P比例参数 - kreg_mini_servo_servo_overload_time(RegIndex.kreg_mini_servo_servo_overload_time), // 过流保护时间 - kreg_mini_servo_servo_speed_i(RegIndex.kreg_mini_servo_servo_speed_i), // 速度闭环I积分参数 - kreg_mini_servo_servo_torque_switch(RegIndex.kreg_mini_servo_servo_torque_switch), // 扭矩开关 - kreg_mini_servo_servo_acc(RegIndex.kreg_mini_servo_servo_acc), // 加速度 - kreg_mini_servo_servo_target_pos(RegIndex.kreg_mini_servo_servo_target_pos), // 目标位置 - kreg_mini_servo_servo_run_time(RegIndex.kreg_mini_servo_servo_run_time), // 运行时间 - kreg_mini_servo_servo_run_speed(RegIndex.kreg_mini_servo_servo_run_speed), // 运行速度 - kreg_mini_servo_servo_torque_limit(RegIndex.kreg_mini_servo_servo_torque_limit), // 转矩限制 - kreg_mini_servo_servo_lock_flag(RegIndex.kreg_mini_servo_servo_lock_flag), // 锁标志 - kreg_mini_servo_servo_current_pos(RegIndex.kreg_mini_servo_servo_current_pos), // 当前位置 - kreg_mini_servo_servo_current_speed(RegIndex.kreg_mini_servo_servo_current_speed), // 当前速度 - kreg_mini_servo_servo_current_load(RegIndex.kreg_mini_servo_servo_current_load), // 当前负载 bit10为方向位 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 - kreg_mini_servo_servo_current_voltage(RegIndex.kreg_mini_servo_servo_current_voltage), // 当前电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V - kreg_mini_servo_servo_current_temp(RegIndex.kreg_mini_servo_servo_current_temp), // 当前温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 - kreg_mini_servo_servo_status(RegIndex.kreg_mini_servo_servo_status), // 舵机状态 - kreg_mini_servo_servo_move_flag(RegIndex.kreg_mini_servo_servo_move_flag), // 移动标志 - kreg_mini_servo_servo_current_current(RegIndex.kreg_mini_servo_servo_current_current), // 当前电流 反馈当前工作电流值,单位为6.26.5mA,最大可反馈电流为500*6.5mA=3250mA - ; - public final RegIndex regIndex; - - MiniServoRegIndex(RegIndex regIndex) { - this.regIndex = regIndex; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleStatus.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleStatus.java deleted file mode 100644 index 038008b..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleStatus.java +++ /dev/null @@ -1,26 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import org.springframework.util.Assert; - -public enum ModuleStatus { - IDLE(0), // - BUSY(1), // - ERROR(2),// - ; - - final public int index; - - ModuleStatus(int index) { - this.index = index; - } - - public int getIndex() { - return index; - } - - public static ModuleStatus valueOf(int value) { // 手写的从int到enum的转换函数 - Assert.isTrue((value >= 0 && value <= 2), String.format("(value=%s value >= 0 && value <= 2)", value)); - return values()[value]; - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleType.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleType.java deleted file mode 100644 index 5d34a4d..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/ModuleType.java +++ /dev/null @@ -1,34 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum ModuleType { - Board(0), // 板子 - HBOT(1), // hbot模块 - WaterCoolingTempCtrl(2), // 温度控制 - FanCtrl(3), // 风扇控制 - CodeScaner(4), // 扫码器 - TMCStepMotor(5), // 步进电机 - MiniServo(6), // 舵机 - PipetteGunCtrl(7), // 移液体枪控制 - - A8kOptical(100), // a8000光学模组 - A8KIdCardReader(101), // id卡读卡器 - A8KPlateCodeScaner(102), // 反应板条扫码器 - - UNKNOWN(999); // 未知类型 - public final int code; - - ModuleType(int val) { - this.code = val; - } - - static public ModuleType of(int val) { - for (ModuleType type : ModuleType.values()) { - if (type.code == val) { - return type; - } - } - return UNKNOWN; - } - - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/OptModuleRegIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/OptModuleRegIndex.java deleted file mode 100644 index dc7d9f4..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/OptModuleRegIndex.java +++ /dev/null @@ -1,51 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum OptModuleRegIndex { - kreg_a8k_opt_t_pos_offset(RegIndex.kreg_a8k_opt_t_pos_offset), - kreg_a8k_opt_f_pos_offset(RegIndex.kreg_a8k_opt_f_pos_offset), - kreg_a8k_opt_t_reverse_scan_pos_offset(RegIndex.kreg_a8k_opt_t_reverse_scan_pos_offset), - kreg_a8k_opt_f_reverse_scan_pos_offset(RegIndex.kreg_a8k_opt_f_reverse_scan_pos_offset), - kreg_a8k_opt_scan_step_interval(RegIndex.kreg_a8k_opt_scan_step_interval), - kreg_a8k_opt_scan_pointnum(RegIndex.kreg_a8k_opt_scan_pointnum), - - kreg_a8k_opt_f_scan_vdefault(RegIndex.kreg_a8k_opt_f_scan_vdefault), // - kreg_a8k_opt_f_scan_vstart(RegIndex.kreg_a8k_opt_f_scan_vstart), // - kreg_a8k_opt_f_scan_a1(RegIndex.kreg_a8k_opt_f_scan_a1), // - kreg_a8k_opt_f_scan_amax(RegIndex.kreg_a8k_opt_f_scan_amax), // - kreg_a8k_opt_f_scan_v1(RegIndex.kreg_a8k_opt_f_scan_v1), // - kreg_a8k_opt_f_scan_dmax(RegIndex.kreg_a8k_opt_f_scan_dmax), // - kreg_a8k_opt_f_scan_d1(RegIndex.kreg_a8k_opt_f_scan_d1), // - kreg_a8k_opt_f_scan_vstop(RegIndex.kreg_a8k_opt_f_scan_vstop), // - kreg_a8k_opt_f_scan_tzerowait(RegIndex.kreg_a8k_opt_f_scan_tzerowait), // - kreg_a8k_opt_f_scan_irun(RegIndex.kreg_a8k_opt_f_scan_irun), // - - kreg_a8k_opt_t_scan_vdefault(RegIndex.kreg_a8k_opt_t_scan_vdefault), // - kreg_a8k_opt_t_scan_vstart(RegIndex.kreg_a8k_opt_t_scan_vstart), // - kreg_a8k_opt_t_scan_a1(RegIndex.kreg_a8k_opt_t_scan_a1), // - kreg_a8k_opt_t_scan_amax(RegIndex.kreg_a8k_opt_t_scan_amax), // - kreg_a8k_opt_t_scan_v1(RegIndex.kreg_a8k_opt_t_scan_v1), // - kreg_a8k_opt_t_scan_dmax(RegIndex.kreg_a8k_opt_t_scan_dmax), // - kreg_a8k_opt_t_scan_d1(RegIndex.kreg_a8k_opt_t_scan_d1), // - kreg_a8k_opt_t_scan_vstop(RegIndex.kreg_a8k_opt_t_scan_vstop), // - kreg_a8k_opt_t_scan_tzerowait(RegIndex.kreg_a8k_opt_t_scan_tzerowait), // - kreg_a8k_opt_t_scan_irun(RegIndex.kreg_a8k_opt_t_scan_irun), // - - kreg_a8k_opt_barcode_scan_vdefault(RegIndex.kreg_a8k_opt_barcode_scan_vdefault), // - kreg_a8k_opt_barcode_scan_vstart(RegIndex.kreg_a8k_opt_barcode_scan_vstart), // - kreg_a8k_opt_barcode_scan_a1(RegIndex.kreg_a8k_opt_barcode_scan_a1), // - kreg_a8k_opt_barcode_scan_amax(RegIndex.kreg_a8k_opt_barcode_scan_amax), // - kreg_a8k_opt_barcode_scan_v1(RegIndex.kreg_a8k_opt_barcode_scan_v1), // - kreg_a8k_opt_barcode_scan_dmax(RegIndex.kreg_a8k_opt_barcode_scan_dmax), // - kreg_a8k_opt_barcode_scan_d1(RegIndex.kreg_a8k_opt_barcode_scan_d1), // - kreg_a8k_opt_barcode_scan_vstop(RegIndex.kreg_a8k_opt_barcode_scan_vstop), // - kreg_a8k_opt_barcode_scan_tzerowait(RegIndex.kreg_a8k_opt_barcode_scan_tzerowait), // - kreg_a8k_opt_barcode_scan_irun(RegIndex.kreg_a8k_opt_barcode_scan_irun), // - - - ; - public final RegIndex regIndex; - - OptModuleRegIndex(RegIndex regIndex) { - this.regIndex = regIndex; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/OutputIOId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/OutputIOId.java deleted file mode 100644 index e65756e..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/OutputIOId.java +++ /dev/null @@ -1,23 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum OutputIOId { - RecycleBinOverflowPPSPowerCtrl("废料仓-光栅电源", ModuleType.Board, MId.PlatesBoxTCMBoard, 0, false),//废料桶光栅电源 - BeepCtrl("蜂鸣器", ModuleType.Board, MId.IncubatorTCMBoard, 0, false),//蜂鸣器 - ; - - final public String chname; - final public ModuleType mtype; - final public MId mid; - final public int ioIndex; - final public boolean mirror; - - OutputIOId(String chname, ModuleType mtype, MId mid, int ioIndex, boolean mirror) { - this.chname = chname; - this.mtype = mtype; - this.mid = mid; - this.ioIndex = ioIndex; - this.mirror = mirror; - - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/PipetteRegIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/PipetteRegIndex.java deleted file mode 100644 index 58c57b3..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/PipetteRegIndex.java +++ /dev/null @@ -1,78 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import org.springframework.util.Assert; - -public enum PipetteRegIndex { -// kreg_module_version(RegIndex.kreg_module_version), // 模块版本 -// kreg_module_type(RegIndex.kreg_module_type), // 模块类型 -// kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error -// kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag - - kreg_pipette_pos_nl(RegIndex.kreg_pipette_pos_nl), // 移液枪位置 - kreg_pipette_capactitance_val(RegIndex.kreg_pipette_capactitance_val), // 移液枪电容值 - kreg_pipette_tip_state(RegIndex.kreg_pipette_tip_state), // 移动液枪tip状态 - - // kreg_pipette_limit_ul(RegIndex.kreg_pipette_limit_ul), // - // kreg_pipette_pump_acc(RegIndex.kreg_pipette_pump_acc), // - // kreg_pipette_pump_dec(RegIndex.kreg_pipette_pump_dec), // - // kreg_pipette_pump_vstart(RegIndex.kreg_pipette_pump_vstart), // - // kreg_pipette_pump_vstop(RegIndex.kreg_pipette_pump_vstop), // - // kreg_pipette_pump_vmax(RegIndex.kreg_pipette_pump_vmax), // - // kreg_pipette_aspirate_distribut_pump_vel(RegIndex.kreg_pipette_aspirate_distribut_pump_vel), // - // kreg_pipette_lld_pump_vel(RegIndex.kreg_pipette_lld_pump_vel), // - // kreg_pipette_lld_motor_vel_rpm(RegIndex.kreg_pipette_lld_motor_vel_rpm), // - // kreg_pipette_lld_detect_period_ms(RegIndex.kreg_pipette_lld_detect_period_ms), // - // kreg_pipette_lld_prepare_pos(RegIndex.kreg_pipette_lld_prepare_pos), // - // kreg_pipette_lld_prepare_distribut_pos(RegIndex.kreg_pipette_lld_prepare_distribut_pos), // - - kreg_pipette_zm_pos(RegIndex.kreg_pipette_zm_pos), - kreg_pipette_zm_is_enable(RegIndex.kreg_pipette_zm_is_enable), - kreg_pipette_zm_dpos(RegIndex.kreg_pipette_zm_dpos), - - kreg_pipette_zm_shaft(RegIndex.kreg_pipette_zm_shaft), - kreg_pipette_zm_one_circle_pulse(RegIndex.kreg_pipette_zm_one_circle_pulse), - kreg_pipette_zm_one_circle_pulse_denominator(RegIndex.kreg_pipette_zm_one_circle_pulse_denominator), - kreg_pipette_zm_default_velocity(RegIndex.kreg_pipette_zm_default_velocity), - kreg_pipette_zm_ihold(RegIndex.kreg_pipette_zm_ihold), - kreg_pipette_zm_irun(RegIndex.kreg_pipette_zm_irun), - kreg_pipette_zm_iholddelay(RegIndex.kreg_pipette_zm_iholddelay), - kreg_pipette_zm_iglobalscaler(RegIndex.kreg_pipette_zm_iglobalscaler), - kreg_pipette_zm_run_to_zero_speed(RegIndex.kreg_pipette_zm_run_to_zero_speed), - kreg_pipette_zm_look_zero_edge_speed(RegIndex.kreg_pipette_zm_look_zero_edge_speed), - kreg_pipette_zm_max_d(RegIndex.kreg_pipette_zm_max_d), - kreg_pipette_zm_min_d(RegIndex.kreg_pipette_zm_min_d), - - kreg_pipette_zm_vstart(RegIndex.kreg_pipette_zm_vstart), - kreg_pipette_zm_a1(RegIndex.kreg_pipette_zm_a1), - kreg_pipette_zm_amax(RegIndex.kreg_pipette_zm_amax), - kreg_pipette_zm_v1(RegIndex.kreg_pipette_zm_v1), - kreg_pipette_zm_dmax(RegIndex.kreg_pipette_zm_dmax), - kreg_pipette_zm_d1(RegIndex.kreg_pipette_zm_d1), - kreg_pipette_zm_vstop(RegIndex.kreg_pipette_zm_vstop), - kreg_pipette_zm_tzerowait(RegIndex.kreg_pipette_zm_tzerowait), - kreg_pipette_zm_enc_resolution(RegIndex.kreg_pipette_zm_enc_resolution), - kreg_pipette_zm_enable_enc(RegIndex.kreg_pipette_zm_enable_enc), - kreg_pipette_zm_dzero(RegIndex.kreg_pipette_zm_dzero), - kreg_pipette_zm_pos_devi_tolerance(RegIndex.kreg_pipette_zm_pos_devi_tolerance), - kreg_pipette_zm_io_trigger_append_distance(RegIndex.kreg_pipette_zm_io_trigger_append_distance), - kreg_pipette_zm_mres(RegIndex.kreg_pipette_zm_mres), - kreg_pipette_zm_encpos(RegIndex.kreg_pipette_zm_encpos), - ; - - public final RegIndex regIndex; - - PipetteRegIndex(RegIndex regIndex) { - Assert.isTrue(this.name().equals(regIndex.name()), "PipetteRegIndex name must be equal to RegIndex name"); - this.regIndex = regIndex; - } - - public static PipetteRegIndex valueOf(int val) { - PipetteRegIndex[] values = PipetteRegIndex.values(); - for (PipetteRegIndex regindex : values) { - if (regindex.regIndex.index == val) { - return regindex; - } - } - return null; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/RegIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/RegIndex.java deleted file mode 100644 index 3a04fc0..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/RegIndex.java +++ /dev/null @@ -1,330 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum RegIndex { - - /******************************************************************************* - * 模块通用配置和状态 * - *******************************************************************************/ - // kreg_module_version(0), // 模块版本 - // kreg_module_type(1), // 模块类型 - // kreg_module_status(2), // 0idle,1busy,2error - // kreg_module_errorcode(3), // inited_flag - // kreg_module_detail_errorcode(4), // 详细的错误信息,该位置的定义根据module_errorcode的不同,而不同 - // kreg_extboard_resetflag(100), - - - /*********************************************************************************************************************** - * 水冷温度控制器 * - ***********************************************************************************************************************/ - kreg_water_cooling_tmp_controler_pid_target(3000), // 目标数值 - kreg_water_cooling_tmp_controler_pid_nowoutput(3001), // 当前输出 - kreg_water_cooling_tmp_controler_pid_feedbackval(3002), // 当前输出 - kreg_water_cooling_tmp_controler_temp0(3003), // 温度1 - kreg_water_cooling_tmp_controler_temp1(3004), // 温度2 - kreg_water_cooling_tmp_controler_temp2(3005), // 温度3 - kreg_water_cooling_tmp_controler_temp3(3006), // 温度4 - - kreg_water_cooling_tmp_controler_pid_kp(3050), // kp - kreg_water_cooling_tmp_controler_pid_ki(3051), // ki - kreg_water_cooling_tmp_controler_pid_kd(3052), // kd - kreg_water_cooling_tmp_controler_pid_max_output(3053), // 最大输出 - kreg_water_cooling_tmp_controler_pid_min_output(3054), // 最小输出 - kreg_water_cooling_tmp_controler_pid_max_integral(3055), // 最大积分 - kreg_water_cooling_tmp_controler_pid_min_integral(3056), // 最小积分 - kreg_water_cooling_tmp_controler_pid_error_limit(3057), // 误差限制 - kreg_water_cooling_tmp_controler_pid_compute_interval(3058), // 计算间隔 - - /******************************************************************************* - * 移液枪状态 * - *******************************************************************************/ - kreg_pipette_pos_nl(4000), // 移液枪位置 - kreg_pipette_capactitance_val(4001), // 移液枪电容值 - kreg_pipette_tip_state(4002, false), // 移动液枪tip状态 - - kreg_pipette_zm_pos(4101), - kreg_pipette_zm_is_enable(4102), - kreg_pipette_zm_dpos(4103), - kreg_pipette_zm_shift(4105), - kreg_pipette_zm_shaft(4106), - kreg_pipette_zm_one_circle_pulse(4107), - kreg_pipette_zm_one_circle_pulse_denominator(4108), - kreg_pipette_zm_default_velocity(4109), - kreg_pipette_zm_ihold(4110), - kreg_pipette_zm_irun(4111), - kreg_pipette_zm_iholddelay(4112), - kreg_pipette_zm_iglobalscaler(4113), - kreg_pipette_zm_run_to_zero_speed(4114), - kreg_pipette_zm_look_zero_edge_speed(4115), - kreg_pipette_zm_max_d(4116), - kreg_pipette_zm_min_d(4117), - kreg_pipette_zm_in_debug_mode(4118), - kreg_pipette_zm_vstart(4119), - kreg_pipette_zm_a1(4120), - kreg_pipette_zm_amax(4121), - kreg_pipette_zm_v1(4122), - kreg_pipette_zm_dmax(4123), - kreg_pipette_zm_d1(4124), - kreg_pipette_zm_vstop(4125), - kreg_pipette_zm_tzerowait(4126), - kreg_pipette_zm_enc_resolution(4127), - kreg_pipette_zm_enable_enc(4128), - kreg_pipette_zm_dzero(4129), - kreg_pipette_zm_pos_devi_tolerance(4130), - kreg_pipette_zm_io_trigger_append_distance(4131), - kreg_pipette_zm_has_move_zero(4132), // 是否回零 - kreg_pipette_zm_mres(4133), // 电机细分 - kreg_pipette_zm_encpos(4134), // 编码器位置,readonly - /** - * 光学模组 - * - * 扫描零点偏移:(F光学向左扫描的起始位置) - * 扫描方向:1:板卡箭头方向,-1板卡箭头反方向 - * 扫描点数:固定为1200 - * 扫描步距:固定为1 - * 返回点数:(1200) - */ - kreg_a8k_opt_t_pos_offset(4501), // T光学正向扫描,扫描起始位距离零点的偏移 - kreg_a8k_opt_f_pos_offset(4502), // F光学正向扫描,扫描起始位距离零点的偏移 - kreg_a8k_opt_t_reverse_scan_pos_offset(4503), // T光学逆向扫描,扫描起始位距离零点的偏移 - kreg_a8k_opt_f_reverse_scan_pos_offset(4504), // F光学逆向扫描,扫描起始位距离零点的偏移 - kreg_a8k_opt_scan_step_interval(4505), // 参数固定:为1 - kreg_a8k_opt_scan_pointnum(4506), // 参数固定:为1200个点 - // kreg_a8k_opt_scan_vdefault(4520), - // kreg_a8k_opt_scan_vstart(4521), - // kreg_a8k_opt_scan_a1(4522), - // kreg_a8k_opt_scan_amax(4523), - // kreg_a8k_opt_scan_v1(4524), - // kreg_a8k_opt_scan_dmax(4525), - // kreg_a8k_opt_scan_d1(4526), - // kreg_a8k_opt_scan_vstop(4527), - // kreg_a8k_opt_scan_tzerowait(4528), - - kreg_a8k_opt_f_scan_vdefault(4600), // - kreg_a8k_opt_f_scan_vstart(4601), // - kreg_a8k_opt_f_scan_a1(4602), // - kreg_a8k_opt_f_scan_amax(4603), // - kreg_a8k_opt_f_scan_v1(4604), // - kreg_a8k_opt_f_scan_dmax(4605), // - kreg_a8k_opt_f_scan_d1(4606), // - kreg_a8k_opt_f_scan_vstop(4607), // - kreg_a8k_opt_f_scan_tzerowait(4608), // - kreg_a8k_opt_f_scan_irun(4609), // - - kreg_a8k_opt_t_scan_vdefault(4700), // - kreg_a8k_opt_t_scan_vstart(4701), // - kreg_a8k_opt_t_scan_a1(4702), // - kreg_a8k_opt_t_scan_amax(4703), // - kreg_a8k_opt_t_scan_v1(4704), // - kreg_a8k_opt_t_scan_dmax(4705), // - kreg_a8k_opt_t_scan_d1(4706), // - kreg_a8k_opt_t_scan_vstop(4707), // - kreg_a8k_opt_t_scan_tzerowait(4708), // - kreg_a8k_opt_t_scan_irun(4709), // - - kreg_a8k_opt_barcode_scan_vdefault(4800), // - kreg_a8k_opt_barcode_scan_vstart(4801), // - kreg_a8k_opt_barcode_scan_a1(4802), // - kreg_a8k_opt_barcode_scan_amax(4803), // - kreg_a8k_opt_barcode_scan_v1(4804), // - kreg_a8k_opt_barcode_scan_dmax(4805), // - kreg_a8k_opt_barcode_scan_d1(4806), // - kreg_a8k_opt_barcode_scan_vstop(4807), // - kreg_a8k_opt_barcode_scan_tzerowait(4808), // - kreg_a8k_opt_barcode_scan_irun(4809), // - - - /*********************************************************************************************************************** - * XYROBOT * - ***********************************************************************************************************************/ - - kreg_xyrobot_io_state(9900, false), // - kreg_xyrobot_is_enable(9901), // - kreg_xyrobot_robot_type(9950), // - kreg_xyrobot_one_circle_pulse(9951), // - kreg_xyrobot_one_circle_pulse_denominator(9952), // - kreg_xyrobot_ihold(9954), // - kreg_xyrobot_irun(9955), // - kreg_xyrobot_iholddelay(9956), // - kreg_xyrobot_iglobalscaler(9957), // - kreg_xyrobot_vstart(9958), // - kreg_xyrobot_a1(9959), // - kreg_xyrobot_amax(9960), // - kreg_xyrobot_v1(9961), // - kreg_xyrobot_dmax(9962), // - kreg_xyrobot_d1(9963), // - kreg_xyrobot_vstop(9964), // - kreg_xyrobot_tzerowait(9965), // - kreg_xyrobot_enc_resolution(9966), // - kreg_xyrobot_enable_enc(9967), // - kreg_xyrobot_x_shaft(9968), // - kreg_xyrobot_y_shaft(9969), // - kreg_xyrobot_min_x(9972), // - kreg_xyrobot_min_y(9973), // - kreg_xyrobot_max_x(9974), // - kreg_xyrobot_max_y(9975), // - kreg_xyrobot_run_to_zero_speed(9976), // - kreg_xyrobot_look_zero_edge_speed(9977), // - kreg_xyrobot_shift_x(9978), // - kreg_xyrobot_shift_y(9979), // - kreg_xyrobot_pos_devi_tolerance(9980), // - kreg_xyrobot_io_trigger_append_distance(9981), // - kreg_xyrobot_default_velocity(10000), // - - /*********************************************************************************************************************** - * step_motor * - ***********************************************************************************************************************/ - - kreg_step_motor_pos(10101), // 机器人x坐标 - kreg_step_motor_is_enable(10102), // 是否使能 - kreg_step_motor_dpos(10103), // 执行完上一条指令后的相对位移 - kreg_step_motor_has_move_zero(10104), // 是否回零 - // kreg_step_motor_shift(10150), // x偏移 - kreg_step_motor_shaft(10151), // x轴是否反转 - kreg_step_motor_one_circle_pulse(10152), // x轴一圈脉冲数 - kreg_step_motor_one_circle_pulse_denominator(10153), // 设置一圈脉冲数的分母 - kreg_step_motor_default_velocity(10154), // 默认速度 - kreg_step_motor_low_velocity(10155), // 低速 - kreg_step_motor_mid_velocity(10156), // 中速 - kreg_step_motor_high_velocity(10157), // 高速 - kreg_step_motor_ihold(10158), // 步进电机电流配置 - kreg_step_motor_irun(10159), // 步进电机电流配置 - kreg_step_motor_iholddelay(10160), // 步进电机电流配置 - kreg_step_motor_iglobalscaler(10161), // 步进电机电流配置 - kreg_step_motor_mres(10162), // 电机细分 - kreg_step_motor_run_to_zero_speed(10173), // 回零速度 - kreg_step_motor_look_zero_edge_speed(10175), // 找零边缘速度 - kreg_step_motor_max_d(10178), // 最大限制距离 - kreg_step_motor_min_d(10179), // 最小限制距离 - kreg_step_motor_in_debug_mode(10180), // 驱动器处于调试模式 - kreg_step_motor_vstart(10181), // a1起作用的速度 - kreg_step_motor_a1(10182), // - kreg_step_motor_amax(10183), // - kreg_step_motor_v1(10184), // - kreg_step_motor_dmax(10185), // - kreg_step_motor_d1(10186), // - kreg_step_motor_vstop(10187), // - kreg_step_motor_tzerowait(10188), // - kreg_step_motor_enc_resolution(10189), // 编码器分辨率 1000,1024,4000,4096,16384 - kreg_step_motor_enable_enc(10190), // - kreg_step_motor_dzero_pos(10191), // 驱动器处于调试模式 - kret_step_motor_pos_devi_tolerance(10192), // 位置偏差容忍度 - kret_step_motor_io_trigger_append_distance(10193), // 移动到io时,附加的距离 - kreg_step_motor_zero_io_mirror(10194), //零点IO有效位是否翻转 - kreg_step_motor_limit_io_mirror(10195), //限位IO有效位是否翻转 - - /*********************************************************************************************************************** - * step_motor * - ***********************************************************************************************************************/ - - kreg_mini_servo_pos(10201), // 位置 - kreg_mini_servo_limit_velocity(10251), // 限制速度 - kreg_mini_servo_limit_torque(10252), // 限制扭矩 - kreg_mini_servo_protective_torque(10253), // 保护扭矩 - kreg_mini_servo_is_move(10254), // 是否在运动 - kreg_mini_servo_status(10255), // 舵机状态 - kreg_mini_servo_voltage(10256), // 电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V - kreg_mini_servo_current(10257), // 电流 反馈当前工作电流值,单位为ma - kreg_mini_servo_temperature(10258), // 温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 - kreg_mini_servo_loadvalue(10259), // 负载值 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 - kreg_mini_servo_target_pos_tolerance(10260), // 目标位置容忍度 - - - kreg_mini_servo_firmware_main_version(10500), // 固件主版本号 - kreg_mini_servo_firmware_sub_version(10501), // 固件次版本号 - kreg_mini_servo_servo_main_version(10503), // 舵机主版本号 - kreg_mini_servo_servo_sub_version(10504), // 舵机次版本号 - kreg_mini_servo_servo_min_angle(10509), // 最小角度限制 - kreg_mini_servo_servo_max_angle(10511), // 最大角度限制 - kreg_mini_servo_servo_max_temp(10513), // 最高温度上限 - kreg_mini_servo_servo_max_voltage(10514), // 最高输入电压 - kreg_mini_servo_servo_min_voltage(10515), // 最低输入电压 - kreg_mini_servo_servo_max_torque(10516), // 最大扭矩 - kreg_mini_servo_servo_unload_condition(10519), // 卸载条件 - kreg_mini_servo_servo_p(10521), // P 比例系 - kreg_mini_servo_servo_d(10522), // D 微分系 - kreg_mini_servo_servo_i(10523), // I - kreg_mini_servo_servo_min_start(10524), // 最小启动 - kreg_mini_servo_servo_cw_dead_zone(10526), // 顺时针不灵敏区 - kreg_mini_servo_servo_ccw_dead_zone(10527), // 逆时针不灵敏 - kreg_mini_servo_servo_protect_current(10528), // 保护电流 - kreg_mini_servo_servo_protect_torque(10534), // 保护扭矩 0->100 ,触发后,需要写入与组转方向相反的位置指令,进行解除 - kreg_mini_servo_servo_protect_time(10535), // 保护时间 - kreg_mini_servo_servo_overload_torque(10536), // 过载扭矩 - kreg_mini_servo_servo_speed_p(10537), // 速度闭环P比例参数 - kreg_mini_servo_servo_overload_time(10538), // 过流保护时间 - kreg_mini_servo_servo_speed_i(10539), // 速度闭环I积分参数 - kreg_mini_servo_servo_torque_switch(10540), // 扭矩开关 - kreg_mini_servo_servo_acc(10541), // 加速度 - kreg_mini_servo_servo_target_pos(10542), // 目标位置 - kreg_mini_servo_servo_run_time(10544), // 运行时间 - kreg_mini_servo_servo_run_speed(10546), // 运行速度 - kreg_mini_servo_servo_torque_limit(10548), // 转矩限制 - kreg_mini_servo_servo_lock_flag(10555), // 锁标志 - kreg_mini_servo_servo_current_pos(10556), // 当前位置 - kreg_mini_servo_servo_current_speed(10558), // 当前速度 - kreg_mini_servo_servo_current_load(10560), // 当前负载 bit10为方向位 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 - kreg_mini_servo_servo_current_voltage(10562), // 当前电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V - kreg_mini_servo_servo_current_temp(10563), // 当前温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 - kreg_mini_servo_servo_status(10565), // 舵机状态 - kreg_mini_servo_servo_move_flag(10566), // 移动标志 - kreg_mini_servo_servo_current_current(10569), // 当前电流 反馈当前工作电流值,单位为6.26.5mA,最大可反馈电流为500*6.5mA=3250mA - - - /*********************************************************************************************************************** - * ID_CARD_READER * - ***********************************************************************************************************************/ - - kreg_id_card_reader_raw_sector_size(10301), // - - kreg_id_card_reader_raw_sector_num(10302), // - - kreg_id_card_reader_is_online(10303, false), // - - /*********************************************************************************************************************** - * 板夹仓扫码 * - ***********************************************************************************************************************/ - - kreg_plate_code_scaner_laster_intensity(10401), // - - kreg_plate_code_scaner_scan_gain(10402), // - - kreg_plate_code_scaner_scan_velocity(10403), // - - kreg_plate_code_scaner_scan_start_pos(10404), // - - kreg_plate_code_scaner_final_stop_pos(10405), // - - kreg_plate_code_scaner_code_judgment_threshold(10406), // - - kreg_plate_code_scaner_item(10407), // - - kreg_plate_code_scaner_lot(10408), // - - kreg_plate_code_scaner_rawcode(10409), // - - kreg_plate_code_scaner_code_legal(10410); // - - public final int index; - public final Boolean trace; - - RegIndex(int regIndex) { - this.index = regIndex; - this.trace = true; - } - - RegIndex(int regIndex, Boolean trace) { - this.index = regIndex; - this.trace = trace; - } - - public static RegIndex valueOf(int val) { - RegIndex[] values = RegIndex.values(); - for (RegIndex regindex : values) { - if (regindex.index == val) { - return regindex; - } - } - return null; - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorMId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorMId.java deleted file mode 100644 index 529445d..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorMId.java +++ /dev/null @@ -1,24 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import org.springframework.util.Assert; - -public enum StepMotorMId { - PlatesBoxYM(MId.PlatesBoxYM),// - PlatesBoxPusherM(MId.PlatesBoxPusherM),// - ShakeModClampingM(MId.ShakeModClampingM),// - ShakeModGripperZM(MId.ShakeModGripperZM),// - ShakeModShakeM(MId.ShakeModShakeM),// - FeedingModInfeedM(MId.FeedingModInfeedM),// - FeedingModXM(MId.FeedingModXM),// - FeedingModOutfeedM(MId.FeedingModOutfeedM),// - IncubatorRotateCtrlM(MId.IncubatorRotateCtrlM),// - OptModScannerM(MId.OptModScannerM),//),// - OptModPullM(MId.OptModPullM),// - ; - final public MId mid; - - StepMotorMId(MId mid) { - Assert.isTrue(this.name().equals(mid.name()),"StepMotorMId init fail"); - this.mid = mid; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorRegIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorRegIndex.java deleted file mode 100644 index da3caa3..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorRegIndex.java +++ /dev/null @@ -1,55 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum StepMotorRegIndex { - // kreg_module_version(RegIndex.kreg_module_version), // 模块版本 - // kreg_module_type(RegIndex.kreg_module_type), // 模块类型 - // kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error - // kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag - /*********************************************************************************************************************** - * step_motor * - ***********************************************************************************************************************/ - kreg_step_motor_pos(RegIndex.kreg_step_motor_pos), // 机器人x坐标 - kreg_step_motor_is_enable(RegIndex.kreg_step_motor_is_enable), // 是否使能 - kreg_step_motor_dpos(RegIndex.kreg_step_motor_dpos), // 执行完上一条指令后的相对位移 - kreg_step_motor_has_move_zero(RegIndex.kreg_step_motor_has_move_zero), // 是否已经移动到零点 - // kreg_step_motor_shift(RegIndex.kreg_step_motor_shift), // x偏移 - kreg_step_motor_shaft(RegIndex.kreg_step_motor_shaft), // x轴是否反转 - kreg_step_motor_one_circle_pulse(RegIndex.kreg_step_motor_one_circle_pulse), // x轴一圈脉冲数 - kreg_step_motor_one_circle_pulse_denominator(RegIndex.kreg_step_motor_one_circle_pulse_denominator), // 设置一圈脉冲数的分母 - kreg_step_motor_default_velocity(RegIndex.kreg_step_motor_default_velocity), // 默认速度 - kreg_step_motor_low_velocity(RegIndex.kreg_step_motor_low_velocity), - kreg_step_motor_mid_velocity(RegIndex.kreg_step_motor_mid_velocity), - kreg_step_motor_high_velocity(RegIndex.kreg_step_motor_high_velocity), - kreg_step_motor_ihold(RegIndex.kreg_step_motor_ihold), // 步进电机电流配置 - kreg_step_motor_irun(RegIndex.kreg_step_motor_irun), // 步进电机电流配置 - kreg_step_motor_iholddelay(RegIndex.kreg_step_motor_iholddelay), // 步进电机电流配置 - kreg_step_motor_iglobalscaler(RegIndex.kreg_step_motor_iglobalscaler), // 步进电机电流配置 - kreg_step_motor_mres(RegIndex.kreg_step_motor_mres), // 步进电机电流配置 - - kreg_step_motor_run_to_zero_speed(RegIndex.kreg_step_motor_run_to_zero_speed), // 回零速度 - kreg_step_motor_look_zero_edge_speed(RegIndex.kreg_step_motor_look_zero_edge_speed), // 找零边缘速度 - kreg_step_motor_max_d(RegIndex.kreg_step_motor_max_d), // 最大限制距离 - kreg_step_motor_min_d(RegIndex.kreg_step_motor_min_d), // 最小限制距离 - kreg_step_motor_in_debug_mode(RegIndex.kreg_step_motor_in_debug_mode), // 驱动器处于调试模式 - kreg_step_motor_vstart(RegIndex.kreg_step_motor_vstart), // a1起作用的速度 - kreg_step_motor_a1(RegIndex.kreg_step_motor_a1), // - kreg_step_motor_amax(RegIndex.kreg_step_motor_amax), // - kreg_step_motor_v1(RegIndex.kreg_step_motor_v1), // - kreg_step_motor_dmax(RegIndex.kreg_step_motor_dmax), // - kreg_step_motor_d1(RegIndex.kreg_step_motor_d1), // - kreg_step_motor_vstop(RegIndex.kreg_step_motor_vstop), // - kreg_step_motor_tzerowait(RegIndex.kreg_step_motor_tzerowait), // - kreg_step_motor_enc_resolution(RegIndex.kreg_step_motor_enc_resolution), // 编码器分辨率 1000,1024,4000,4096,16384 - kreg_step_motor_enable_enc(RegIndex.kreg_step_motor_enable_enc), // - kreg_step_motor_dzero_pos(RegIndex.kreg_step_motor_dzero_pos), // 驱动器处于调试模式 - kret_step_motor_pos_devi_tolerance(RegIndex.kret_step_motor_pos_devi_tolerance), // 位置偏差容忍度 - kret_step_motor_io_trigger_append_distance(RegIndex.kret_step_motor_io_trigger_append_distance), // 移动到io时,附加的距离 - kreg_step_motor_zero_io_mirror(RegIndex.kreg_step_motor_zero_io_mirror), // 零点io镜像 - kreg_step_motor_limit_io_mirror(RegIndex.kreg_step_motor_limit_io_mirror), // 限位io镜像 - ; - public final RegIndex regIndex; - - StepMotorRegIndex(RegIndex regIndex) { - this.regIndex = regIndex; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorSpeedLevel.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorSpeedLevel.java deleted file mode 100644 index dd81fe2..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/StepMotorSpeedLevel.java +++ /dev/null @@ -1,9 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -public enum StepMotorSpeedLevel { - DEFAULT, - LOW, - MID, - HIGH, - ; -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerMid.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerMid.java deleted file mode 100644 index 6ba7fa4..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerMid.java +++ /dev/null @@ -1,15 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import org.springframework.util.Assert; - -public enum TemperatureControlerMid { - PlatesBoxTCM(MId.PlatesBoxTCM), - IncubatorTCM(MId.IncubatorTCM), - ; - final public MId mid; - - TemperatureControlerMid(MId mid) { - Assert.isTrue(this.name().equals(mid.name()), "StepMotorMId init fail"); - this.mid = mid; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerRegIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerRegIndex.java deleted file mode 100644 index 96866cf..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/TemperatureControlerRegIndex.java +++ /dev/null @@ -1,40 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol; - -import org.springframework.util.Assert; - -public enum TemperatureControlerRegIndex { - kreg_water_cooling_tmp_controler_pid_target(RegIndex.kreg_water_cooling_tmp_controler_pid_target), - kreg_water_cooling_tmp_controler_pid_nowoutput(RegIndex.kreg_water_cooling_tmp_controler_pid_nowoutput), - kreg_water_cooling_tmp_controler_pid_feedbackval(RegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval), - kreg_water_cooling_tmp_controler_temp0(RegIndex.kreg_water_cooling_tmp_controler_temp0), - kreg_water_cooling_tmp_controler_temp1(RegIndex.kreg_water_cooling_tmp_controler_temp1), - kreg_water_cooling_tmp_controler_temp2(RegIndex.kreg_water_cooling_tmp_controler_temp2), - kreg_water_cooling_tmp_controler_temp3(RegIndex.kreg_water_cooling_tmp_controler_temp3), - kreg_water_cooling_tmp_controler_pid_kp(RegIndex.kreg_water_cooling_tmp_controler_pid_kp), - kreg_water_cooling_tmp_controler_pid_ki(RegIndex.kreg_water_cooling_tmp_controler_pid_ki), - kreg_water_cooling_tmp_controler_pid_kd(RegIndex.kreg_water_cooling_tmp_controler_pid_kd), - kreg_water_cooling_tmp_controler_pid_max_output(RegIndex.kreg_water_cooling_tmp_controler_pid_max_output), - kreg_water_cooling_tmp_controler_pid_min_output(RegIndex.kreg_water_cooling_tmp_controler_pid_min_output), - kreg_water_cooling_tmp_controler_pid_max_integral(RegIndex.kreg_water_cooling_tmp_controler_pid_max_integral), - kreg_water_cooling_tmp_controler_pid_min_integral(RegIndex.kreg_water_cooling_tmp_controler_pid_min_integral), - kreg_water_cooling_tmp_controler_pid_error_limit(RegIndex.kreg_water_cooling_tmp_controler_pid_error_limit), - kreg_water_cooling_tmp_controler_pid_compute_interval(RegIndex.kreg_water_cooling_tmp_controler_pid_compute_interval), - - ; - public final RegIndex regIndex; - - TemperatureControlerRegIndex(RegIndex regIndex) { - Assert.isTrue(this.name().equals(regIndex.name()), "PipetteRegIndex name must be equal to RegIndex name"); - this.regIndex = regIndex; - } - - public static TemperatureControlerRegIndex valueOf(int val) { - TemperatureControlerRegIndex[] values = TemperatureControlerRegIndex.values(); - for (TemperatureControlerRegIndex regindex : values) { - if (regindex.regIndex.index == val) { - return regindex; - } - } - return null; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/AspirationParamId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/AspirationParamId.java deleted file mode 100644 index b2b3445..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/AspirationParamId.java +++ /dev/null @@ -1,42 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module; - -public enum AspirationParamId { - // - // 吸取体积 - // - volume, - // - // 容器 - // - containerPos, - containerInfoCpyId, - // - // 液体类型 - // - liquidCfgIdx, - // - // 吸取模式 - // - aspirationMode, - // - // lld配置 - // - lldEnable, - lldType, - lldEnableProtect, - // - // llf配置 - // - mixLlfEnable, - llfEnable, - // - // 混匀配置 - // - mixVolume, - mixTimes, - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java deleted file mode 100644 index bdbd03f..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java +++ /dev/null @@ -1,35 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module; - -public enum DistribuAllParamId { - // - // 容器位置 - // - containerPos, // 容器位置 - - // - // 目标容器信息 - // - destContainerCpyid, // 目标容器配置索引 - destContainerIsEmpty, // 目标容器是否为空 - destLiquidCfgIndex, // 目标容器中的液体类型 - - // - // 分配方式 - // - distribuType, // 分配类型 0:液面上分配,1:液面下分配 - - // - // 混匀配置 - // - mixVolume, // 混匀体积 - mixTimes, // 混匀次数 - // - // 其他配置 - // - zmAutoMoveToZero, // zm自动归零 - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuType.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuType.java deleted file mode 100644 index 7ac72ec..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/DistribuType.java +++ /dev/null @@ -1,11 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module; - -public enum DistribuType { - JET_DIST, //液面上分配 - SURFACE_DIST, //液体表面分配 - ; - - public Integer toInteger() { - return this.ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteConfig.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteConfig.java deleted file mode 100644 index d63a0b6..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean.*; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean.*; - -import java.util.ArrayList; -import java.util.List; - -public class PipetteConfig { - public PipetteZMBCfg zmBCfgs; - public PipetteCommonConfig commonCfg; - - public List platInfos = new ArrayList<>(); - public List containerInfos = new ArrayList<>(); - public List liquidInfos = new ArrayList<>(); - public List zmVCfgs = new ArrayList<>(); - public List pmVCfgs = new ArrayList<>(); - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java deleted file mode 100644 index 06284b4..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java +++ /dev/null @@ -1,32 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module; - -public enum PipetteStateIndex { - enable, - dul, - dpos, - zmHasMoveZero, - - aspirationOk, - pumpLldReachLimit, - detectedLiquid, - waterLevel, - tipblock, - airsuction, - bubble, - - - asynchronousResult0, - asynchronousResult1, - - platinfoCpyid,//当前plateinfoCpyId - - testPipetteIo1Connected, - testPipetteIo1Reverse, - testPipetteUart485Connected, - testPipetteUart232Connected, - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/TipType.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/TipType.java deleted file mode 100644 index d800fa0..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/TipType.java +++ /dev/null @@ -1,34 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module; - -public enum TipType { - TS1000UL, // 0 1000ul max=1002.6ul - TS200UL, // 1 200ul max=250ul - TS50UL, // 2 50ul max=62ul - TS20UL, // 3 20ul max=40ul - NotSet, - ; - - public static TipType of(Integer val) { - if (val < 0) - return NotSet; - - for (TipType idx : TipType.values()) { - if (idx.ordinal() == val) { - return idx; - } - } - return NotSet; - } - - public static Integer of(TipType idx) { - if (idx == null) - return -1; - if (idx.equals(NotSet)) - return -1; - return idx.ordinal(); - } - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java deleted file mode 100644 index 9f5b589..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java +++ /dev/null @@ -1,23 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -public enum ContainerInfoIndex { - containerType, // 容器类型 0:平面 1:flat(平底) 2:conical(锥底) 3:round(圆底) - containerNeckPos, // 容器,瓶口位置(相对位置0.1mm) - containerDepth, // 容器,深度(0.1mm) - containerRound, // 容器,直径(0.1mm) - containerBottomSectionHeight, // 容器,瓶底高度(0.1mm) - immersionDepth, // 侵入液面高度,即液面以下的高度,精度0.1mm - leavingHeight, // 离开液面高度,此位置ZEUS开始缓慢进入液面或离开液面,精度0.1mm - jetHeight, // 喷射高度(0.1mm) - lldStartSearchDepth, // lld开始搜索时位置冗余,精度0.1mm,abspos = container_neck_pos + lld_start_search_pos_redundancy - fixAspirationDepth, // 固定吸液深度((0.1mm),当lld失能时,移液枪先移动到这个位置,然后开始吸液 - llfVConvertCoefficient, // 液面跟随转换系数 0.0001 llf_zm_vel = aspiration_pm_vel * llf_vconvert_coneff * 0.0001 - pierceDepth, // 穿刺深度(0.1mm),用于刺破容器防尘膜 - lldEndPosMargin, // 液面跟随结束位置冗余(0.1mm),用于液面跟随结束时,移液枪的冗余位置 - mark, - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java deleted file mode 100644 index 999e529..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java +++ /dev/null @@ -1,76 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -public enum LiquidInfoIndex { - // // - // // lld - // // - plldPmVCpyId, // 液面探测时泵机速率 - plldThreshold, // 液面探测阈值 - plldZmVel, // 液面探测时泵机速率 - plldInvasionDepth,//液面探测时,会多侵入液面一定深度,这个深度和plld阈值和zm_vel速度有关 (0.1mm) - - // // - // // 清空tip配置 - // // - emptyTipPmVCpyId, // 清空tip速度 - // // - // // 吸入空气 - // // - blowoutAirVolume, // 清空空气量,在吸液前吸入的空气量. 精度0.1ul (保证清空tip头) - blowoutAirPmVCpyId, // 吸入空气时泵机速率 - // // - // // 润湿tip头配置 - // // - overAspiratedVolume, // 过量吸液量,先吸入后迅速排出用来润湿tip头,这个用在移液量小于10微升的情况下。精度0.1ul - overAspiratedPmVCpyId, // 过量吸液速度 - // - // aspiration 吸液配置 - // - aspirationPmVCpyIdLow,// 小体积吸液速度 - aspirationPmVCpyIdHigh,// 大体积吸液速度 - aspirationVolumeBreakVal,// 小体积大体积分界点 - volumeCalibrationCoefficientB,// 0.0001 - volumeCalibrationCoefficientK,// 0.0001 - /** - * settling_time(ms) - * - * Settling Time in 1 ms - * This parameter sets how long the tip - * remains in liquid after aspiration or - * dispense before moving out of the - * liquid. The tip geometry and liquid - * viscosity are considered when setting - * this parameter. If settling time is too - * short the liquid has not enough time to fill - * the tip and unwanted air is aspirated - * as soon as the tip is lifted out of the liquid. - * - * 保持时间 - * - * 此参数用于吸液后在液面下保持的时间。这个参数的设定根据tip头的类型和液体的粘稠度有关。 - * 如果此值设定的时间太短则液体不能完全充满tip头。 - * - */ - settlingTime, // (ms) 设置 - // // - // // 转移时多吸入的量 - // // - transportVolume, // 转移过程中多吸入的量,精度0.1ul (放滴落) - transportVolumePmVCpyId, // 吸入过量空气时泵机速率 - // - // // - // // 混匀pm速率 - // // - mixPmVCpyId, // 混匀时泵机速率配置 - // - // 分配配置 - // - jetPmVCpyId, // 喷射时泵机速率配置 jet_pm_vcpyid - distributePmVCpyId, // 分配时泵机速率配置 distribu_pm_vpyid - mark, - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java deleted file mode 100644 index 2731903..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java +++ /dev/null @@ -1,11 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -public enum PMBasicConfigIndex { - Pad, - mark, - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java deleted file mode 100644 index 40ec6a6..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java +++ /dev/null @@ -1,16 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -public enum PMVConfigIndex { - acc, // 加速度 level 1…20 default:14 1:797.5 ul/s^2 ... 20:797*20 nl/s^2 - dec, // 减速度 level 1…20 default:14 - vStart, // 启动速度 ul/s (0...319) - vStop, // 停止速度 ul/s (0...319) - vMax, // 最大速度 ul/s (0...2552) -mark, - ; - - public Integer toInteger() { - return ordinal(); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java deleted file mode 100644 index f716110..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java +++ /dev/null @@ -1,14 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -public enum PipetteCommonConfigIndex { - pressureRecordEnable, - platformInfoCpyid, - eachActionDelayTime, - aspiratePressureReportExtendTime, // 吸液压力采集延长时间,吸液完成后,多采集压力的时间 - lldEnableProtect, // 是否启用LLD保护,如果启用,则在LLD过程中,最大探测范围为tip的长度范围 - mark; - - public Integer toInteger() { - return ordinal(); - } -} \ No newline at end of file diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java deleted file mode 100644 index 1f08342..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java +++ /dev/null @@ -1,34 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -public enum PlatformInfoIndex { - /** - * 工作参考平面 - * 代码中并不使用这个位置,这个参数只是为了后续 - * 如果平台高度发生变化时,可以通过调整dzero使得 - * work_ref_plane数值不变。 - */ - workRefPos, - - tipPickingPos, // 开始取tip位置(绝对位置0.1mm) - tipPickingSearchRange, // 取tip的范围 - tipPickingAppendDistance, // 取tip时z轴的附加距离 - tipPickingSettlingTime, // 取tip时的settling时间 - tipDepositPos, // 丢tip位置(绝对位置0.1mm) - transformPos, // 移液枪安全移动的高度(绝对位置0.1mm) - - /** - * tip类型 - * TS1000UL = 0 // 1000ul max=1002.6ul - * TS200UL = 1 // 200ul max=250ul - * TS50UL = 2 // 50ul max=62ul - * TS20UL = 3 // 20ul max=40ul - */ - tipType, - tipLength, // tip长度 - mark, - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java deleted file mode 100644 index a073ccf..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java +++ /dev/null @@ -1,30 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -/** - * Z轴电机基础配置 - */ -public enum ZMBasicConfigIndex { - shaft, - oneCirclePulse, - oneCirclePulseDenominator, - ihold, - irun, - iholddelay, - iglobalscaler, - mind, - maxd, - tzerowait, - encResolution, - enableEnc, - dzero, - ioTriggerAppendDistance, - posDeviTolerance, - mres, - mark, - ; - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java deleted file mode 100644 index 658e445..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java +++ /dev/null @@ -1,18 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg; - -public enum ZMVConfigIndex { - vstart, - a1, - amax, - v1, - dmax, - d1, - vstop, - vmax, - mark, - ; - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java deleted file mode 100644 index e950907..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java +++ /dev/null @@ -1,83 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.PipetteCommonConfigIndex; -import a8k.app.type.exception.AppException; - -public class PipetteCommonConfig { - - - /** - * @brief - * - * LLD - * 移动到液面之上--> - * 清空TIP - * 吸入空气 - * 移动到液面之下--> - * 吸入 - * 等待一定时间 - * 移动到液面之上(缓慢) - * 吸入一定量的空气 - */ - - // - // lld - // - public Integer pressureRecordEnable = 0; // 是否记录压力数据 - public Integer platformInfoCpyid = 0; // 平台信息配置索引,当调用initPumpDevice时,如果传入的参数为-1,则使用platformInfoMCpyid - public Integer eachActionDelayTime = 0; // 每个动作之间的延时,单位ms (动作调试使用,方便观察液体变化情况) - public Integer aspiratePressureReportExtendTime = 0; // 吸液压力采集延长时间,吸液完成后,多采集压力的时间 - public Integer lldEnableProtect = 0; // 是否启用LLD保护,如果启用,则在LLD过程中,最大探测范围为tip的长度范围 - public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 - - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(PipetteCommonConfigIndex index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(PipetteCommonConfigIndex index, Integer itermVal) throws AppException; - } - - - public static PipetteCommonConfig build(AssignObjectItemFn assignFn) throws AppException { - PipetteCommonConfig info = new PipetteCommonConfig(); - info.assignObject(assignFn); - return info; - } - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (PipetteCommonConfigIndex idx : PipetteCommonConfigIndex.values()) { - try { - PipetteCommonConfig.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (PipetteCommonConfigIndex idx : PipetteCommonConfigIndex.values()) { - try { - Integer val = (Integer) PipetteCommonConfig.class.getDeclaredField(idx.name()).get(this); - if (val == null) - continue; - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - PipetteCommonConfig info = new PipetteCommonConfig(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> { - System.out.println("Index: " + index + ", Value: " + val); - }); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java deleted file mode 100644 index a5eeffe..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java +++ /dev/null @@ -1,70 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.ContainerInfoIndex; -import a8k.app.type.exception.AppException; - -public class PipetteContainerInfo { - public Integer containerType = 0; // 容器类型 0:平面 1:flat(平底) 2:conical(锥底) 3:round(圆底) - public Integer containerNeckPos = 0; // 容器,瓶口位置(相对位置0.1mm) !discard 废弃不再使用 - public Integer containerDepth = 0; // 容器,深度(0.1mm) - public Integer containerRound = 0; // 容器,直径(0.1mm) - public Integer containerBottomSectionHeight = 0; // 容器,瓶底高度(0.1mm) - public Integer immersionDepth = 0; // 侵入液面高度,即液面以下的高度,精度0.1mm - public Integer leavingHeight = 0; // 离开液面高度,此位置ZEUS开始缓慢进入液面或离开液面,精度0.1mm - public Integer jetHeight = 0; // 喷射高度(0.1mm) - public Integer lldStartSearchDepth = 0; // lld开始搜索时位置冗余,精度0.1mm,abspos = container_neck_pos + lld_start_search_pos_redundancy - public Integer fixAspirationDepth = 0; // 固定吸液深度((0.1mm),当lld失能时,移液枪先移动到这个位置,然后开始吸液 - public Integer llfVConvertCoefficient = 0; // 液面跟随转换系数 0.0001 llf_zm_vel = aspiration_pm_vel * llf_vconvert_coneff * 0.0001 - public Integer pierceDepth = 0; // 穿刺深度(0.1mm),用于刺破容器防尘膜 - public Integer lldEndPosMargin = 0; // 液面跟随结束位置冗余(0.1mm),lld_max_pos = container_pos + container_depth - lld_end_pos_margin - public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 - - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(ContainerInfoIndex index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(ContainerInfoIndex index, Integer itermVal) throws AppException; - } - - public static PipetteContainerInfo build(AssignObjectItemFn assignFn) throws AppException { - PipetteContainerInfo info = new PipetteContainerInfo(); - info.assignObject(assignFn); - return info; - } - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (ContainerInfoIndex idx : ContainerInfoIndex.values()) { - try { - PipetteContainerInfo.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (ContainerInfoIndex idx : ContainerInfoIndex.values()) { - try { - Integer val = (Integer) PipetteContainerInfo.class.getDeclaredField(idx.name()).get(this); - if (val == null) - continue; - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - PipetteContainerInfo info = new PipetteContainerInfo(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> System.out.println("Index: " + index + ", Value: " + val)); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java deleted file mode 100644 index a2c8264..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java +++ /dev/null @@ -1,149 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.LiquidInfoIndex; -import a8k.app.type.exception.AppException; - -public class PipetteLiquidInfo { - - - /** - * @brief - * - * LLD - * 移动到液面之上--> - * 清空TIP - * 吸入空气 - * 移动到液面之下--> - * 吸入 - * 等待一定时间 - * 移动到液面之上(缓慢) - * 吸入一定量的空气 - */ - - // - // lld - // - public Integer plldPmVCpyId = 0; // 液面探测时泵机速率 - public Integer plldThreshold = 0; // 液面探测阈值 - public Integer plldZmVel = 0; // 液面探测时泵机速率 - public Integer plldInvasionDepth = 0; - // - // 清空tip配置 - // - public Integer emptyTipPmVCpyId = 0; // 清空tip速度 - - // - // 吸入空气 - // - public Integer blowoutAirVolume = 0; // 清空空气量,在吸液前吸入的空气量. 精度0.1ul (保证清空tip头) - public Integer blowoutAirPmVCpyId = 0; // 吸入空气时泵机速率 - - // - // 润湿tip头配置 - // - public Integer overAspiratedVolume = 0; // 过量吸液量,先吸入后迅速排出用来润湿tip头,这个用在移液量小于10微升的情况下。精度0.1ul - public Integer overAspiratedPmVCpyId = 0; // 过量吸液速度 - - // - // aspiration 吸液配置 - // - public Integer aspirationPmVCpyIdLow = 0; // 小体积吸液速度 - public Integer aspirationPmVCpyIdHigh = 0; // 大体积吸液速度 - public Integer aspirationVolumeBreakVal = 0; // 小体积大体积分界点 - public Integer volumeCalibrationCoefficientB = 0; // 0.0001 - public Integer volumeCalibrationCoefficientK = 0; // 0.0001 - - // - // 保持时间 - // - /** - * @brief settling_time(ms) - * - * Settling Time in 1 ms - * This parameter sets how long the tip - * remains in liquid after aspiration or - * dispense before moving out of the - * liquid. The tip geometry and liquid - * viscosity are considered when setting - * this parameter. If settling time is too - * short the liquid has not enough time to fill - * the tip and unwanted air is aspirated - * as soon as the tip is lifted out of the liquid. - * - * 保持时间 - * - * 此参数用于吸液后在液面下保持的时间。这个参数的设定根据tip头的类型和液体的粘稠度有关。 - * 如果此值设定的时间太短则液体不能完全充满tip头。 - * - */ - public Integer settlingTime = 0; // (ms) 设置 - - // - // 转移时多吸入的量 - // - public Integer transportVolume = 0; // 转移过程中多吸入的量,精度0.1ul (放滴落) - public Integer transportVolumePmVCpyId = 0; // 吸入过量空气时泵机速率 - - // - // 混匀pm速率 - // - public Integer mixPmVCpyId = 0; // 混匀时泵机速率配置 - // - // 分配配置 - // - public Integer jetPmVCpyId = 0; // 喷射时泵机速率配置 jet_pm_vcpyid - public Integer distributePmVCpyId = 0; // 分配时泵机速率配置 distribu_pm_vpyid - - public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 - - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(LiquidInfoIndex index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(LiquidInfoIndex index, Integer itermVal) throws AppException; - } - - - public static PipetteLiquidInfo build(AssignObjectItemFn assignFn) throws AppException { - PipetteLiquidInfo info = new PipetteLiquidInfo(); - info.assignObject(assignFn); - return info; - } - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (LiquidInfoIndex idx : LiquidInfoIndex.values()) { - try { - PipetteLiquidInfo.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (LiquidInfoIndex idx : LiquidInfoIndex.values()) { - try { - Integer val = (Integer) PipetteLiquidInfo.class.getDeclaredField(idx.name()).get(this); - if (val == null) - continue; - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - PipetteLiquidInfo info = new PipetteLiquidInfo(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> { - System.out.println("Index: " + index + ", Value: " + val); - }); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java deleted file mode 100644 index f504594..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java +++ /dev/null @@ -1,62 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.PMVConfigIndex; -import a8k.app.type.exception.AppException; - -public class PipettePMVCfg { - public Integer acc = 0; - public Integer dec = 0; - public Integer vStart = 0; - public Integer vStop = 0; - public Integer vMax = 0; - public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 - - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(PMVConfigIndex index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(PMVConfigIndex index, Integer itermVal) throws AppException; - } - - public static PipettePMVCfg build(AssignObjectItemFn assignFn) throws AppException { - PipettePMVCfg info = new PipettePMVCfg(); - info.assignObject(assignFn); - return info; - } - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (PMVConfigIndex idx : PMVConfigIndex.values()) { - try { - PipettePMVCfg.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (PMVConfigIndex idx : PMVConfigIndex.values()) { - try { - Integer val = (Integer) PipettePMVCfg.class.getDeclaredField(idx.name()).get(this); - if (val == null) - continue; - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - PipettePMVCfg info = new PipettePMVCfg(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> { - System.out.println("Index: " + index + ", Value: " + val); - }); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java deleted file mode 100644 index d140384..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java +++ /dev/null @@ -1,84 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.PlatformInfoIndex; -import a8k.app.type.exception.AppException; - -public class PipettePlatInfo { - /** - * @brief 工作参考平面 - * 代码中并不使用这个位置,这个参数只是为了后续 - * 如果平台高度发生变化时,可以通过调整dzero使得 - * work_ref_plane数值不变。 - */ - public Integer workRefPos = 0; // - - public Integer tipPickingPos = 0; // 开始取tip位置(绝对位置0.1mm) - public Integer tipPickingSearchRange = 0; // 取tip的范围 - public Integer tipPickingAppendDistance = 0; // 取tip时z轴的附加距离 - public Integer tipPickingSettlingTime = 0; - - public Integer tipDepositPos = 0; // 丢tip位置(绝对位置0.1mm) - public Integer transformPos = 0; // 移液枪安全移动的高度(绝对位置0.1mm) - /** - * @brief tip类型 - * - * TS1000UL = 0, // 1000ul, max=1002.6ul - * TS200UL = 1, // 200ul, max=250ul - * TS50UL = 2, // 50ul, max=62ul - * TS20UL = 3, // 20ul, max=40ul - */ - public Integer tipType = 0; - public Integer tipLength = 0; // tip长度 - - public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 - - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(PlatformInfoIndex index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(PlatformInfoIndex index, Integer itermVal) throws AppException; - } - - public static PipettePlatInfo build(AssignObjectItemFn assignFn) throws AppException { - PipettePlatInfo info = new PipettePlatInfo(); - info.assignObject(assignFn); - return info; - } - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (PlatformInfoIndex idx : PlatformInfoIndex.values()) { - try { - PipettePlatInfo.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (PlatformInfoIndex idx : PlatformInfoIndex.values()) { - try { - Integer val = (Integer) PipettePlatInfo.class.getDeclaredField(idx.name()).get(this); - if (val == null) - continue; - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - PipettePlatInfo info = new PipettePlatInfo(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> { - System.out.println("Index: " + index + ", Value: " + val); - }); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java deleted file mode 100644 index 8fffbef..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java +++ /dev/null @@ -1,74 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.ZMBasicConfigIndex; -import a8k.app.type.exception.AppException; - -public class PipetteZMBCfg { - public Integer shaft = 0; // Z轴电机运动方向调整 - public Integer oneCirclePulse = 0; // 电子齿轮比-分子 - public Integer oneCirclePulseDenominator = 0; // 电子齿轮比-分母 - public Integer ihold = 0; // - public Integer irun = 0; // - public Integer iholddelay = 0; // - public Integer iglobalscaler = 0; // - public Integer mind = 0; // - public Integer maxd = 0; // - public Integer tzerowait = 0; // - public Integer encResolution = 0; // - public Integer enableEnc = 0; // - public Integer dzero = 0; // - public Integer ioTriggerAppendDistance = 0; // - public Integer posDeviTolerance = 0; // - public Integer mres = 0; // - public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 - - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(ZMBasicConfigIndex index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(ZMBasicConfigIndex index, Integer itermVal) throws AppException; - } - - public static PipetteZMBCfg build(AssignObjectItemFn assignFn) throws AppException { - PipetteZMBCfg info = new PipetteZMBCfg(); - info.assignObject(assignFn); - return info; - } - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (ZMBasicConfigIndex idx : ZMBasicConfigIndex.values()) { - try { - PipetteZMBCfg.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (ZMBasicConfigIndex idx : ZMBasicConfigIndex.values()) { - try { - Integer val = (Integer) PipetteZMBCfg.class.getDeclaredField(idx.name()).get(this); - if (val == null) - continue; - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - PipetteZMBCfg info = new PipetteZMBCfg(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> { - System.out.println("Index: " + index + ", Value: " + val); - }); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java deleted file mode 100644 index b4bbc94..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java +++ /dev/null @@ -1,67 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cfgbean; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.ZMVConfigIndex; -import a8k.app.type.exception.AppException; - -public class PipetteZMVCfg { - public Integer vstart = 0; - public Integer a1 = 0; - public Integer amax = 0; - public Integer v1 = 0; - public Integer dmax = 0; - public Integer d1 = 0; - public Integer vstop = 0; - public Integer vmax = 0; - public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 - - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(ZMVConfigIndex index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(ZMVConfigIndex index, Integer itermVal) throws AppException; - } - - public static PipetteZMVCfg build(AssignObjectItemFn assignFn) throws AppException { - PipetteZMVCfg info = new PipetteZMVCfg(); - info.assignObject(assignFn); - return info; - } - - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (ZMVConfigIndex idx : ZMVConfigIndex.values()) { - try { - PipetteZMVCfg.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (ZMVConfigIndex idx : ZMVConfigIndex.values()) { - try { - Integer val = (Integer) PipetteZMVCfg.class.getDeclaredField(idx.name()).get(this); - if (val == null) - continue; - - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - PipetteZMVCfg info = new PipetteZMVCfg(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> { - System.out.println("Index: " + index + ", Value: " + val); - }); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java deleted file mode 100644 index dfdcc2f..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java +++ /dev/null @@ -1,41 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx; - -public enum ContainerCpyId { - Default, - LittleBufferCup, //小瓶缓冲液 - LargeBufferCup,//大瓶缓冲液 - DetectSubstancesCup,//探测物质 - ShortWholeBufferTube,//小全血试管 - HighWholeBufferTube,//高全血试管 - MiniBlood,//阳普管 - BulletTube1P5,//子弹头1.5ml - BulletTube0P5,//子弹头0.5ml - StoolTestTube,//粪便试管 - ReactionPlate, - NotSet, - ; - - public static ContainerCpyId of(Integer val) { - if (val < 0) - return NotSet; - - for (ContainerCpyId idx : ContainerCpyId.values()) { - if (idx.ordinal() == val) { - return idx; - } - } - return NotSet; - } - - public static Integer of(ContainerCpyId idx) { - if (idx == null) - return -1; - if (idx.equals(NotSet)) - return -1; - return idx.ordinal(); - } - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java deleted file mode 100644 index 0b79af3..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java +++ /dev/null @@ -1,44 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx; - -/** - * 液体类型配置索引 - * - * @Warning: - * 底层CpyIdx为, 0, 1, 2, 3, 4, 5, 不区分具体类型 - * 上层应用,根据需求自定义类型 - */ -public enum LiquidConfigCpyIdx { - Default, - WholeBlood, //全血 - SerumOrPlasma,//血清或血浆 - BufferSolution,//缓冲液 - Water,//水 - NotSet, - ; - - public static LiquidConfigCpyIdx of(Integer val) { - if (val < 0) - return NotSet; - - for (LiquidConfigCpyIdx idx : LiquidConfigCpyIdx.values()) { - if (idx.ordinal() == val) { - return idx; - } - } - return NotSet; - } - - public static Integer of(LiquidConfigCpyIdx idx) { - if (idx == null) - return -1; - if (idx.equals(NotSet)) - return -1; - return idx.ordinal(); - } - - public Integer toInteger() { - if (this.equals(NotSet)) - return -1; - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java deleted file mode 100644 index 08d6ec9..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java +++ /dev/null @@ -1,42 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx; - -/** - * 泵电机速度配置索引 - */ -public enum PMVCpyIdx { - VDefault, // 默认速度 - VSlowLv1, // 慢速 - VSlowLv2, // 慢速 - VSlowLv3, // 慢速 - VMid, // 中速 - VQuick, // 快速 - VMax, // 高速 - VLld, // 液面探测vlld - - NotSet, - ; - - public static PMVCpyIdx of(Integer val) { - if (val < 0) - return NotSet; - - for (PMVCpyIdx idx : PMVCpyIdx.values()) { - if (idx.ordinal() == val) { - return idx; - } - } - return NotSet; - } - - public static Integer of(PMVCpyIdx idx) { - if (idx == null) - return -1; - if (idx.equals(NotSet)) - return -1; - return idx.ordinal(); - } - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java deleted file mode 100644 index f4d6342..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java +++ /dev/null @@ -1,26 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx; - -public enum PlatInfoCpyIdx { - Default, - TransparentTip, - NotSet, - ; - - public Integer toInteger() { - if (this.equals(NotSet)) - return -1; - return ordinal(); - } - - static public PlatInfoCpyIdx of(Integer val) { - if (val < 0) - return NotSet; - for (PlatInfoCpyIdx idx : PlatInfoCpyIdx.values()) { - if (idx.ordinal() == val) { - return idx; - } - } - - return NotSet; - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java deleted file mode 100644 index 6f1de15..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java +++ /dev/null @@ -1,40 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx; - -/** - * Z轴电机速度配置索引 - */ -public enum ZMVCpyIdx { - VDefault, // 默认速度 - VMoveToZero, // 回零速度 - VLookZeroEdge, // 找零点偏移速度 - VLld, // 液面探测vlld - VSwap, // 交换液面探测 - VLlf, // 液面基础速度配置 - PickingTip,// 取tip - NotSet, - ; - - public static ZMVCpyIdx of(Integer val) { - if (val < 0) - return NotSet; - - for (ZMVCpyIdx idx : ZMVCpyIdx.values()) { - if (idx.ordinal() == val) { - return idx; - } - } - return NotSet; - } - - public static Integer of(ZMVCpyIdx idx) { - if (idx == null) - return -1; - if (idx.equals(NotSet)) - return -1; - return idx.ordinal(); - } - - public Integer toInteger() { - return ordinal(); - } -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/AspirationParam.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/AspirationParam.java deleted file mode 100644 index de1b480..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/AspirationParam.java +++ /dev/null @@ -1,117 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.param; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.AspirationParamId; -import a8k.app.type.exception.AppException; - -public class AspirationParam { - // - // 吸取体积 - // - public Integer volume = 100; - // - // 容器 - // - public Integer containerPos = 0; - public Integer containerInfoCpyId = 0; - // - // 液体类型 - // - public Integer liquidCfgIdx = 0; - // - // 吸取模式 - // - public Integer aspirationMode = 0; - // - // lld配置 - // - public Integer lldEnable = 0; - public Integer lldType = 0; - public Integer lldEnableProtect = 0; - // - // llf配置 - // - public Integer mixLlfEnable = 0; - public Integer llfEnable = 0; - // - // 混匀配置 - // - public Integer mixVolume = 0; - public Integer mixTimes = 0; - - public AspirationParam() {} - - public AspirationParam(Integer volumex100nl, - Integer containerPos, - ContainerCpyId containerInfoCpyId, - LiquidConfigCpyIdx liquidCfgIdx, - Integer aspirationMode, - Integer lldEnable, - Integer lldType, - Integer lldEnableProtect, - Integer mixLlfEnable, - Integer llfEnable, - Integer mixVolume, - Integer mixTimes) { - this.volume = volumex100nl; - this.containerPos = containerPos; - this.containerInfoCpyId = containerInfoCpyId.toInteger(); - this.liquidCfgIdx = liquidCfgIdx.toInteger(); - this.aspirationMode = aspirationMode; - this.lldEnable = lldEnable; - this.lldType = lldType; - this.lldEnableProtect = lldEnableProtect; - this.mixLlfEnable = mixLlfEnable; - this.llfEnable = llfEnable; - this.mixVolume = mixVolume; - this.mixTimes = mixTimes; - } - - @FunctionalInterface - public interface AssignObjectItemFn { - Integer assignVal(AspirationParamId index) throws AppException; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(AspirationParamId index, Integer itermVal) throws AppException; - } - - public static AspirationParam build(AssignObjectItemFn assignFn) throws AppException { - AspirationParam info = new AspirationParam(); - info.assignObject(assignFn); - return info; - } - - public void assignObject(AssignObjectItemFn assignFn) throws AppException { - for (AspirationParamId idx : AspirationParamId.values()) { - try { - AspirationParam.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (AspirationParamId idx : AspirationParamId.values()) { - try { - Integer val = (Integer) AspirationParam.class.getDeclaredField(idx.name()).get(this); - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - AspirationParam info = new AspirationParam(); - info.assignObject(Enum::ordinal); - - info.serialization((index, val) -> { - System.out.println("Index: " + index + ", Value: " + val); - }); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java b/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java deleted file mode 100644 index ae71333..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java +++ /dev/null @@ -1,81 +0,0 @@ -package a8k.app.channel.iflytophald.type.protocol.pipette_module.param; - -import a8k.app.channel.iflytophald.type.protocol.pipette_module.DistribuAllParamId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.DistribuType; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; -import a8k.app.type.exception.AppException; - -public class DistribuAllParam { - // - // 容器位置 - // - public Integer containerPos = 0; // 容器位置 - - // - // 目标容器信息 - // - public Integer destContainerCpyid = 0; // 目标容器配置索引 - public Integer destContainerIsEmpty = 0; // 目标容器是否为空 - public Integer destLiquidCfgIndex = 0; // 目标容器中的液体类型 - - // - // 分配方式 - // - public Integer distribuType = 0; // 分配类型 0:液面上分配,1:液面下分配 - - // - // 混匀配置 - // - public Integer mixVolume = 0; // 混匀体积 - public Integer mixTimes = 0; // 混匀次数 - // - // 其他配置 - // - public Integer zmAutoMoveToZero = 0; // zm自动归零 - - public DistribuAllParam() { - // 默认构造函数 - } - - public DistribuAllParam(Integer containerPos, - ContainerCpyId destContainerCpyid, - LiquidConfigCpyIdx destLiquidCfgIndex, - Boolean destContainerIsEmpty, - DistribuType distribuType, - Integer mixVolume, - Integer mixTimes, - Boolean zmAutoMoveToZero) { - this.containerPos = containerPos; - this.destContainerCpyid = destContainerCpyid.toInteger(); - this.destContainerIsEmpty = destContainerIsEmpty ? 1 : 0; - this.destLiquidCfgIndex = destLiquidCfgIndex.toInteger(); - this.distribuType = distribuType.toInteger(); - this.mixVolume = mixVolume; - this.mixTimes = mixTimes; - this.zmAutoMoveToZero = zmAutoMoveToZero ? 1 : 0; - } - - @FunctionalInterface - public interface SerializationObjectItemFn { - void serializeObject(DistribuAllParamId index, Integer itermVal) throws AppException; - } - - - public void serialization(SerializationObjectItemFn fn) throws AppException { - for (DistribuAllParamId idx : DistribuAllParamId.values()) { - try { - Integer val = (Integer) DistribuAllParam.class.getDeclaredField(idx.name()).get(this); - fn.serializeObject(idx, val); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - - public static void main(String[] args) throws AppException { - DistribuAllParam info = new DistribuAllParam(); - info.serialization((index, val) -> System.out.println("Index: " + index + ", Value: " + val)); - } - -} diff --git a/src/main/java/a8k/app/channel/iflytophald/utils/OptGainConvert.java b/src/main/java/a8k/app/channel/iflytophald/utils/OptGainConvert.java deleted file mode 100644 index 22f7f42..0000000 --- a/src/main/java/a8k/app/channel/iflytophald/utils/OptGainConvert.java +++ /dev/null @@ -1,79 +0,0 @@ -package a8k.app.channel.iflytophald.utils; - -import a8k.app.type.a8k.opt.A8kOptType; - -/** - * 光学增益转换器 - * 用于将增益倍率(1,2,3,4)转换成对应的原始增益值(寄存器设置值) - */ -public class OptGainConvert { - - static public class FOptGainConvert { - public double scanerToRealGain(int gain) { - double scanGain = 0; - scanGain = (((100. / 256.) * (double) gain) + 0.125) / 2.15 + 1.; //和硬件电路有关 - return scanGain; - } - - public int scanerToRawGain(double scanGain) { - int scan_gain_raw = 0; - scan_gain_raw = (int) (((scanGain - 1.0) * 2.15 - 0.125) * 255. / 100. + 0.5); //和硬件电路有关 - if (scan_gain_raw < 1) - scan_gain_raw = 1; - if (scan_gain_raw > 255) - scan_gain_raw = 255; - return scan_gain_raw; - } - - - } - - static public class TOptGainConvert { - public int scanerToRawGain(double scanGain) { - // opamp_gain = (((100.0 * (float) scan_gain_raw) / 255) + 2.4) / 4.7; - int scan_gain_raw = 0; - scan_gain_raw = (int) ((scanGain * 4.7 - 2.4) * 256. / 100. + 0.5); //和硬件电路有关 - if (scan_gain_raw < 1) - scan_gain_raw = 1; - if (scan_gain_raw > 255) - scan_gain_raw = 255; - return scan_gain_raw; - } - - public double scanerToRealGain(int gain) { - double scanGain = 0; - scanGain = (((100.0 * (double) gain) / 256) + 2.4) / 4.7; //和硬件电路有关 - return scanGain; - } - - - } - - - public static double scanerToRealGain(A8kOptType type, int gain) { - if (type == A8kOptType.FOPT) { - return new FOptGainConvert().scanerToRealGain(gain); - } else if (type == A8kOptType.TOPT) { - return new TOptGainConvert().scanerToRealGain(gain); - } - return 0; - } - - public static int scanerToRawGain(A8kOptType type, double scanGain) { - if (type == A8kOptType.FOPT) { - return new FOptGainConvert().scanerToRawGain(scanGain); - } else if (type == A8kOptType.TOPT) { - return new TOptGainConvert().scanerToRawGain(scanGain); - } - return 0; - } - - public static void main(String[] args) { - TOptGainConvert tgc = new TOptGainConvert(); - System.out.printf("t gain range %f->%f%n", tgc.scanerToRealGain(0), tgc.scanerToRealGain(255)); - - FOptGainConvert fgc = new FOptGainConvert(); - System.out.printf("f gain range %f->%f%n", fgc.scanerToRealGain(0), fgc.scanerToRealGain(255)); - - } -} diff --git a/src/main/java/a8k/app/channel/net/BiLisDoubleTrackTcpClient.java b/src/main/java/a8k/app/channel/net/BiLisDoubleTrackTcpClient.java deleted file mode 100644 index b1a3333..0000000 --- a/src/main/java/a8k/app/channel/net/BiLisDoubleTrackTcpClient.java +++ /dev/null @@ -1,249 +0,0 @@ -package a8k.app.channel.net; - -import a8k.app.type.lisprotocol.BiLisDoubleTrackFrame; -import a8k.app.utils.ByteArrayUtils; -import a8k.app.utils.NettyUtils; -import io.netty.bootstrap.Bootstrap; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.*; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.timeout.IdleState; -import io.netty.handler.timeout.IdleStateEvent; -import io.netty.handler.timeout.IdleStateHandler; -import lombok.extern.slf4j.Slf4j; - -import java.util.concurrent.TimeUnit; - -@Slf4j -@ChannelHandler.Sharable -public class BiLisDoubleTrackTcpClient extends ChannelInboundHandlerAdapter { - private final static Integer reconnectDelay = 5; // 重连延迟时间, - private final static Integer readIDLETime = 30; // 重连延迟时间, - private final static Integer rxBufferSize = 1024; // 接收数据缓冲区大小,单位字节 - - @FunctionalInterface - public interface OnDataReceivedListener { - void onDataReceived(byte[] data); - } - - @FunctionalInterface - public interface OnLostConnectionListener { - void onLostConnection(); - } - - private final EventLoopGroup group = NettyUtils.buildEventLoopGroup("BiLisDoubleTrackTcpClient", 1); - private final Bootstrap bootstrap = new Bootstrap(); - private String serverIp; - private Integer port; - private volatile Channel channel; - private volatile boolean isShuttingDown = false; - private final ByteBuf rxBuffer = Unpooled.buffer(rxBufferSize); // 接收数据缓冲区,初始大小为1024字节 - private OnDataReceivedListener onDataReceivedListener; - private OnLostConnectionListener onLostConnectionListener; - - // - // External API - // - - /** - * 启动TCP客户端连接到指定服务器 - * @param serverIp 服务器IP地址 - * @param port 服务器端口号 - */ - public void start(String serverIp, Integer port) { - this.serverIp = serverIp; - this.port = port; - - bootstrap.group(group) - .channel(NioSocketChannel.class) - .option(ChannelOption.TCP_NODELAY, true) - .option(ChannelOption.SO_KEEPALIVE, true) - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) - .handler(new ChannelInitializer() { - @Override - protected void initChannel(SocketChannel ch) { - // 添加空闲状态检测 - ch.pipeline().addLast(new IdleStateHandler(readIDLETime, 0, 0, TimeUnit.MILLISECONDS)); - ch.pipeline().addLast(BiLisDoubleTrackTcpClient.this); - } - }); - doConnect(); - } - - /** - * 关闭TCP客户端 - */ - public synchronized void shutdown() { - isShuttingDown = true; - if (channel != null) { - channel.close(); - } - group.shutdownGracefully(); - } - - /** - * 断开当前连接,5s后自动重连 - */ - public synchronized void disconnect() { - if (channel != null) { - channel.close(); - channel = null; - } - } - - - /** - * 发送数据到服务器 - * @param data 要发送的数据,字节数组格式 - */ - public synchronized void tx(byte[] data) { - if (channel != null && channel.isActive()) { - ByteBuf buf = Unpooled.wrappedBuffer(data); - channel.writeAndFlush(buf).addListener(future -> { - if (!future.isSuccess()) { - log.error("Failed to send data tail,{}", future.cause().getMessage()); - } - }); - log.debug("TX:{}", ByteArrayUtils.toByteString(data)); - } else { - log.warn("Channel is not active, cannot send data: {}", data); - // 可以考虑在这里实现消息队列,等连接恢复后重发 - } - } - - /** - * 注册数据接收监听器 - * @param listener 监听器实例 - */ - public synchronized void regRxMessageListener(OnDataReceivedListener listener) { - this.onDataReceivedListener = listener; - } - - public synchronized void regOnLostConnectionListener(OnLostConnectionListener listener) { - this.onLostConnectionListener = listener; - } - - public synchronized boolean isConnected() { - return channel != null && channel.isActive(); - } - - // - // PRIVATE - // - private void reportRxData(byte[] data) { - log.debug("RX:({} bytes): {}", data.length, ByteArrayUtils.toByteString(data)); - if (onDataReceivedListener != null) { - onDataReceivedListener.onDataReceived(data); - } else { - log.warn("No OnDataReceivedListener registered, data will be ignored: {}", ByteArrayUtils.toByteString(data)); - } - } - - @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { - // 处理空闲事件 - if (evt instanceof IdleStateEvent e) { - if (e.state() == IdleState.READER_IDLE && rxBuffer.readableBytes() > 0) { - // 读取空闲,检查是否有待处理数据 - byte[] rxBytes = null; - synchronized (rxBuffer) { - byte[] bytes = new byte[rxBuffer.readableBytes()]; - rxBuffer.readBytes(bytes); - rxBytes = bytes; - rxBuffer.clear(); // 清空缓冲区 - } - reportRxData(rxBytes); - } - } - } - - // 处理接收到的消息 - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - // 直接接收原始ByteBuf - if (msg instanceof ByteBuf buf) { - try { - //接收并缓存数据 - synchronized (rxBuffer) { - byte[] bytes = new byte[buf.readableBytes()]; - buf.readBytes(bytes); - if (rxBuffer.writableBytes() < bytes.length) { - log.warn("rxBuffer is full, clearing buffer before writing new data."); - rxBuffer.clear(); // 清空缓冲区 - } - - if (rxBuffer.readableBytes() == 0 && bytes.length == 1 - && (bytes[0] == BiLisDoubleTrackFrame.ACK || bytes[0] == BiLisDoubleTrackFrame.EOT) - ) { - //如果接收到的是ACK或EOT,直接报告数据 - reportRxData(bytes); - } else { - rxBuffer.writeBytes(bytes); // 将接收到的数据写入缓冲区 - } - } - } finally { - buf.release(); // 重要:释放ByteBuf - } - } else { - log.warn("Unexpected message type: {}", msg.getClass()); - } - } - - - private void doConnect() { - if (isShuttingDown) { - return; - } - log.info("try connect to {}:{}", serverIp, port); - bootstrap.connect(serverIp, port).addListener((ChannelFuture future) -> { - if (future.isSuccess()) { - log.info("successfully connected to {}:{}", serverIp, port); - channel = future.channel(); - } else { - log.error("failed,{}", future.cause().getMessage()); - if (!isShuttingDown) - group.schedule(this::doConnect, reconnectDelay, TimeUnit.SECONDS); - } - }); - } - - @Override - public synchronized void channelInactive(ChannelHandlerContext ctx) throws Exception { - log.warn("Connection lost, trying to reconnect..."); - if (channel != null && channel.equals(ctx.channel())) { - channel = null; - } - // 自动重连逻辑 - if (!isShuttingDown) - group.schedule(this::doConnect, reconnectDelay, TimeUnit.SECONDS); - } - - // - // Main - // - public static void main(String[] args) { - BiLisDoubleTrackTcpClient client = new BiLisDoubleTrackTcpClient(); - client.start("0.0.0.0", 777); - - int count = 0; - while (true) { - try { - count++; - byte[] data = {0x01, 0x02, 0x03, 0x04, 0x05}; - client.tx(data); - Thread.sleep(1000); // 主线程保持运行状态 - if (count == 5) { - client.disconnect(); // 5秒后关闭客户端 - } - } catch (InterruptedException e) { - log.error("Main thread interrupted: {}", e.getMessage()); - Thread.currentThread().interrupt(); - break; - } - } - } - - -} \ No newline at end of file diff --git a/src/main/java/a8k/app/channel/net/BiLisSingleTrackTcpClient.java b/src/main/java/a8k/app/channel/net/BiLisSingleTrackTcpClient.java deleted file mode 100644 index 850108d..0000000 --- a/src/main/java/a8k/app/channel/net/BiLisSingleTrackTcpClient.java +++ /dev/null @@ -1,127 +0,0 @@ -package a8k.app.channel.net; - -import a8k.app.utils.NettyUtils; -import io.netty.bootstrap.Bootstrap; -import io.netty.channel.*; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.codec.LineBasedFrameDecoder; -import io.netty.handler.codec.string.StringDecoder; -import io.netty.handler.codec.string.StringEncoder; -import lombok.extern.slf4j.Slf4j; - -import java.util.concurrent.TimeUnit; - -@Slf4j -@ChannelHandler.Sharable -public class BiLisSingleTrackTcpClient extends SimpleChannelInboundHandler { - static private final Integer reconnectDelay = 5; // 重连延迟时间,单位秒 - - - private final EventLoopGroup group = NettyUtils.buildEventLoopGroup("BoditechLisSingleTrackTcpClient", 1); - private final Bootstrap bootstrap = new Bootstrap(); - private String serverIp; - private Integer port; - private volatile Channel channel; - private volatile boolean isShuttingDown = false; - - public void start(String serverIp, Integer port) { - this.serverIp = serverIp; - this.port = port; - - bootstrap.group(group) - .channel(NioSocketChannel.class) - .option(ChannelOption.TCP_NODELAY, true) - .option(ChannelOption.SO_KEEPALIVE, true) - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) - .handler(new ChannelInitializer() { - @Override - protected void initChannel(SocketChannel ch) { - ch.pipeline() - .addLast(new LineBasedFrameDecoder(1024))//以/r/n为结束符的解码器 - .addLast(new StringEncoder()) - .addLast(new StringDecoder()) - .addLast(BiLisSingleTrackTcpClient.this); - } - }); - - doConnect(); - } - - public synchronized void shutdown() { - isShuttingDown = true; - if (channel != null) { - channel.close(); - } - group.shutdownGracefully(); - } - - public synchronized boolean isConnected() { - return channel != null && channel.isActive(); - } - - public synchronized void tx(String data) { - if (channel != null && channel.isActive()) { - channel.writeAndFlush(data).addListener(future -> { - if (!future.isSuccess()) { - log.error("Failed to send data tail"); - } - }); - } else { - log.warn("Channel is not active, cannot send data: {}", data); - // 可以考虑在这里实现消息队列,等连接恢复后重发 - } - } - - private void doConnect() { - if (isShuttingDown) { - return; - } - log.info("try connect to {}:{}", serverIp, port); - bootstrap.connect(serverIp, port).addListener((ChannelFuture future) -> { - if (future.isSuccess()) { - log.info("successfully connected to {}:{}", serverIp, port); - channel = future.channel(); - } else { - log.error("failed,{}", future.cause().getMessage()); - if (!isShuttingDown) - group.schedule(this::doConnect, 5, TimeUnit.SECONDS); - } - }); - } - - @Override - public synchronized void channelInactive(ChannelHandlerContext ctx) throws Exception { - log.warn("Connection lost, trying to reconnect..."); - if (channel != null && channel.equals(ctx.channel())) { - channel = null; - } - // 重连逻辑 - if (!isShuttingDown) - group.schedule(this::doConnect, reconnectDelay, TimeUnit.SECONDS); - } - - - // 处理接收到的消息 - @Override - protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { - log.info("Received message from server: {}({})", msg, msg.length()); - } - - public static void main(String[] args) { - BiLisSingleTrackTcpClient client = new BiLisSingleTrackTcpClient(); - client.start("0.0.0.0", 777); - - int count = 0; - while (true) { - try { - client.tx("Test message " + (++count)); - Thread.sleep(1000); // 主线程保持运行状态 - } catch (InterruptedException e) { - log.error("Main thread interrupted: {}", e.getMessage()); - Thread.currentThread().interrupt(); - break; - } - } - } -} \ No newline at end of file diff --git a/src/main/java/a8k/app/client/BiLisDoubleTrackTcpClient.java b/src/main/java/a8k/app/client/BiLisDoubleTrackTcpClient.java new file mode 100644 index 0000000..c0028ff --- /dev/null +++ b/src/main/java/a8k/app/client/BiLisDoubleTrackTcpClient.java @@ -0,0 +1,246 @@ +package a8k.app.client; + +import a8k.app.type.lisprotocol.BiLisDoubleTrackFrame; +import a8k.app.utils.ByteArrayUtils; +import a8k.app.utils.NettyUtils; +import io.netty.bootstrap.Bootstrap; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.*; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.timeout.IdleState; +import io.netty.handler.timeout.IdleStateEvent; +import io.netty.handler.timeout.IdleStateHandler; +import lombok.extern.slf4j.Slf4j; + +import java.util.concurrent.TimeUnit; + +@Slf4j +@ChannelHandler.Sharable +public class BiLisDoubleTrackTcpClient extends ChannelInboundHandlerAdapter { + private final static Integer reconnectDelay = 5; // 重连延迟时间, + private final static Integer readIDLETime = 30; // 重连延迟时间, + private final static Integer rxBufferSize = 1024; // 接收数据缓冲区大小,单位字节 + + @FunctionalInterface + public interface OnDataReceivedListener { + void onDataReceived(byte[] data); + } + + @FunctionalInterface + public interface OnLostConnectionListener { + void onLostConnection(); + } + + private final EventLoopGroup group = NettyUtils.buildEventLoopGroup("BiLisDoubleTrackTcpClient", 1); + private final Bootstrap bootstrap = new Bootstrap(); + private String serverIp; + private Integer port; + private volatile Channel channel; + private volatile boolean isShuttingDown = false; + private final ByteBuf rxBuffer = Unpooled.buffer(rxBufferSize); // 接收数据缓冲区,初始大小为1024字节 + private OnDataReceivedListener onDataReceivedListener; + + + // + // External API + // + + /** + * 启动TCP客户端连接到指定服务器 + * @param serverIp 服务器IP地址 + * @param port 服务器端口号 + */ + public void start(String serverIp, Integer port) { + this.serverIp = serverIp; + this.port = port; + + bootstrap.group(group) + .channel(NioSocketChannel.class) + .option(ChannelOption.TCP_NODELAY, true) + .option(ChannelOption.SO_KEEPALIVE, true) + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) + .handler(new ChannelInitializer() { + @Override + protected void initChannel(SocketChannel ch) { + // 添加空闲状态检测 + ch.pipeline().addLast(new IdleStateHandler(readIDLETime, 0, 0, TimeUnit.MILLISECONDS)); + ch.pipeline().addLast(BiLisDoubleTrackTcpClient.this); + } + }); + doConnect(); + } + + /** + * 关闭TCP客户端 + */ + public synchronized void shutdown() { + isShuttingDown = true; + if (channel != null) { + channel.close(); + } + group.shutdownGracefully(); + } + + /** + * 断开当前连接,5s后自动重连 + */ + public synchronized void disconnect() { + if (channel != null) { + channel.close(); + channel = null; + } + } + + + /** + * 发送数据到服务器 + * @param data 要发送的数据,字节数组格式 + */ + public synchronized void tx(byte[] data) { + if (channel != null && channel.isActive()) { + ByteBuf buf = Unpooled.wrappedBuffer(data); + channel.writeAndFlush(buf).addListener(future -> { + if (!future.isSuccess()) { + log.error("Failed to send data tail,{}", future.cause().getMessage()); + } + }); + log.debug("TX:{}", ByteArrayUtils.toByteString(data)); + } else { + log.warn("Channel is not active, cannot send data: {}", data); + // 可以考虑在这里实现消息队列,等连接恢复后重发 + } + } + + /** + * 注册数据接收监听器 + * @param listener 监听器实例 + */ + public synchronized void regRxMessageListener(OnDataReceivedListener listener) { + this.onDataReceivedListener = listener; + } + + + public synchronized boolean isConnected() { + return channel != null && channel.isActive(); + } + + // + // PRIVATE + // + private void reportRxData(byte[] data) { + log.debug("RX:({} bytes): {}", data.length, ByteArrayUtils.toByteString(data)); + if (onDataReceivedListener != null) { + onDataReceivedListener.onDataReceived(data); + } else { + log.warn("No OnDataReceivedListener registered, data will be ignored: {}", ByteArrayUtils.toByteString(data)); + } + } + + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { + // 处理空闲事件 + if (evt instanceof IdleStateEvent e) { + if (e.state() == IdleState.READER_IDLE && rxBuffer.readableBytes() > 0) { + // 读取空闲,检查是否有待处理数据 + byte[] rxBytes = null; + synchronized (rxBuffer) { + byte[] bytes = new byte[rxBuffer.readableBytes()]; + rxBuffer.readBytes(bytes); + rxBytes = bytes; + rxBuffer.clear(); // 清空缓冲区 + } + reportRxData(rxBytes); + } + } + } + + // 处理接收到的消息 + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + // 直接接收原始ByteBuf + if (msg instanceof ByteBuf buf) { + try { + //接收并缓存数据 + synchronized (rxBuffer) { + byte[] bytes = new byte[buf.readableBytes()]; + buf.readBytes(bytes); + if (rxBuffer.writableBytes() < bytes.length) { + log.warn("rxBuffer is full, clearing buffer before writing new data."); + rxBuffer.clear(); // 清空缓冲区 + } + + if (rxBuffer.readableBytes() == 0 && bytes.length == 1 + && (bytes[0] == BiLisDoubleTrackFrame.ACK || bytes[0] == BiLisDoubleTrackFrame.EOT) + ) { + //如果接收到的是ACK或EOT,直接报告数据 + reportRxData(bytes); + } else { + rxBuffer.writeBytes(bytes); // 将接收到的数据写入缓冲区 + } + } + } finally { + buf.release(); // 重要:释放ByteBuf + } + } else { + log.warn("Unexpected message type: {}", msg.getClass()); + } + } + + + private void doConnect() { + if (isShuttingDown) { + return; + } + log.warn("try connect to {}:{}", serverIp, port); + bootstrap.connect(serverIp, port).addListener((ChannelFuture future) -> { + if (future.isSuccess()) { + log.info("successfully connected to {}:{}", serverIp, port); + channel = future.channel(); + } else { + log.warn("failed,{}", future.cause().getMessage()); + if (!isShuttingDown) + group.schedule(this::doConnect, reconnectDelay, TimeUnit.SECONDS); + } + }); + } + + @Override + public synchronized void channelInactive(ChannelHandlerContext ctx) throws Exception { + log.warn("Connection lost, trying to reconnect..."); + if (channel != null && channel.equals(ctx.channel())) { + channel = null; + } + // 自动重连逻辑 + if (!isShuttingDown) + group.schedule(this::doConnect, reconnectDelay, TimeUnit.SECONDS); + } + + // + // Main + // + public static void main(String[] args) { + BiLisDoubleTrackTcpClient client = new BiLisDoubleTrackTcpClient(); + client.start("0.0.0.0", 777); + + int count = 0; + while (true) { + try { + count++; + byte[] data = {0x01, 0x02, 0x03, 0x04, 0x05}; + client.tx(data); + Thread.sleep(1000); // 主线程保持运行状态 + if (count == 5) { + client.disconnect(); // 5秒后关闭客户端 + } + } catch (InterruptedException e) { + log.error("Main thread interrupted: {}", e.getMessage()); + Thread.currentThread().interrupt(); + break; + } + } + } + + +} \ No newline at end of file diff --git a/src/main/java/a8k/app/client/BiLisSingleTrackTcpClient.java b/src/main/java/a8k/app/client/BiLisSingleTrackTcpClient.java new file mode 100644 index 0000000..1fbec4e --- /dev/null +++ b/src/main/java/a8k/app/client/BiLisSingleTrackTcpClient.java @@ -0,0 +1,127 @@ +package a8k.app.client; + +import a8k.app.utils.NettyUtils; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.*; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.codec.LineBasedFrameDecoder; +import io.netty.handler.codec.string.StringDecoder; +import io.netty.handler.codec.string.StringEncoder; +import lombok.extern.slf4j.Slf4j; + +import java.util.concurrent.TimeUnit; + +@Slf4j +@ChannelHandler.Sharable +public class BiLisSingleTrackTcpClient extends SimpleChannelInboundHandler { + static private final Integer reconnectDelay = 5; // 重连延迟时间,单位秒 + + + private final EventLoopGroup group = NettyUtils.buildEventLoopGroup("BoditechLisSingleTrackTcpClient", 1); + private final Bootstrap bootstrap = new Bootstrap(); + private String serverIp; + private Integer port; + private volatile Channel channel; + private volatile boolean isShuttingDown = false; + + public void start(String serverIp, Integer port) { + this.serverIp = serverIp; + this.port = port; + + bootstrap.group(group) + .channel(NioSocketChannel.class) + .option(ChannelOption.TCP_NODELAY, true) + .option(ChannelOption.SO_KEEPALIVE, true) + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) + .handler(new ChannelInitializer() { + @Override + protected void initChannel(SocketChannel ch) { + ch.pipeline() + .addLast(new LineBasedFrameDecoder(1024))//以/r/n为结束符的解码器 + .addLast(new StringEncoder()) + .addLast(new StringDecoder()) + .addLast(BiLisSingleTrackTcpClient.this); + } + }); + + doConnect(); + } + + public synchronized void shutdown() { + isShuttingDown = true; + if (channel != null) { + channel.close(); + } + group.shutdownGracefully(); + } + + public synchronized boolean isConnected() { + return channel != null && channel.isActive(); + } + + public synchronized void tx(String data) { + if (channel != null && channel.isActive()) { + channel.writeAndFlush(data).addListener(future -> { + if (!future.isSuccess()) { + log.error("Failed to send data tail"); + } + }); + } else { + log.warn("Channel is not active, cannot send data: {}", data); + // 可以考虑在这里实现消息队列,等连接恢复后重发 + } + } + + private void doConnect() { + if (isShuttingDown) { + return; + } + log.info("try connect to {}:{}", serverIp, port); + bootstrap.connect(serverIp, port).addListener((ChannelFuture future) -> { + if (future.isSuccess()) { + log.info("successfully connected to {}:{}", serverIp, port); + channel = future.channel(); + } else { + log.error("failed,{}", future.cause().getMessage()); + if (!isShuttingDown) + group.schedule(this::doConnect, 5, TimeUnit.SECONDS); + } + }); + } + + @Override + public synchronized void channelInactive(ChannelHandlerContext ctx) throws Exception { + log.warn("Connection lost, trying to reconnect..."); + if (channel != null && channel.equals(ctx.channel())) { + channel = null; + } + // 重连逻辑 + if (!isShuttingDown) + group.schedule(this::doConnect, reconnectDelay, TimeUnit.SECONDS); + } + + + // 处理接收到的消息 + @Override + protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception { + log.info("Received message from server: {}({})", msg, msg.length()); + } + + public static void main(String[] args) { + BiLisSingleTrackTcpClient client = new BiLisSingleTrackTcpClient(); + client.start("0.0.0.0", 777); + + int count = 0; + while (true) { + try { + client.tx("Test message " + (++count)); + Thread.sleep(1000); // 主线程保持运行状态 + } catch (InterruptedException e) { + log.error("Main thread interrupted: {}", e.getMessage()); + Thread.currentThread().interrupt(); + break; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/a8k/app/config/A8kSubModuleInitRegConfig.java b/src/main/java/a8k/app/config/A8kSubModuleInitRegConfig.java index bd929e7..b1a7c68 100644 --- a/src/main/java/a8k/app/config/A8kSubModuleInitRegConfig.java +++ b/src/main/java/a8k/app/config/A8kSubModuleInitRegConfig.java @@ -1,7 +1,7 @@ package a8k.app.config; -import a8k.app.channel.iflytophald.type.protocol.ModuleType; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.type.protocol.ModuleType; +import a8k.app.iflytophald.type.protocol.RegIndex; import a8k.app.utils.ZList; import jakarta.annotation.PostConstruct; import org.springframework.stereotype.Component; diff --git a/src/main/java/a8k/app/config/IflytophaldConnectionConfig.java b/src/main/java/a8k/app/config/IflytophaldConnectionConfig.java index 6ecdeee..213ea73 100644 --- a/src/main/java/a8k/app/config/IflytophaldConnectionConfig.java +++ b/src/main/java/a8k/app/config/IflytophaldConnectionConfig.java @@ -1,6 +1,6 @@ package a8k.app.config; -import a8k.app.channel.iflytophald.channel.A8kCanBusConnection; +import a8k.app.iflytophald.channel.A8kCanBusCommunicationChannel; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -26,7 +26,7 @@ public class IflytophaldConnectionConfig { } @Bean - A8kCanBusConnection a8kCanBusBaseService() { - return new A8kCanBusConnection(getCmdChBaseUrl("zexcan"), getDatachUrl("zexcan")); + A8kCanBusCommunicationChannel a8kCanBusBaseService() { + return new A8kCanBusCommunicationChannel(getCmdChBaseUrl("zexcan"), getDatachUrl("zexcan")); } } diff --git a/src/main/java/a8k/app/constant/ActionOvertimeConstant.java b/src/main/java/a8k/app/constant/ActionOvertimeConstant.java index 0deb7ca..af33a42 100644 --- a/src/main/java/a8k/app/constant/ActionOvertimeConstant.java +++ b/src/main/java/a8k/app/constant/ActionOvertimeConstant.java @@ -1,8 +1,8 @@ package a8k.app.constant; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; import jakarta.annotation.PostConstruct; import org.springframework.stereotype.Component; diff --git a/src/main/java/a8k/app/constant/MiniServoConstant.java b/src/main/java/a8k/app/constant/MiniServoConstant.java index 7c5c363..45fe044 100644 --- a/src/main/java/a8k/app/constant/MiniServoConstant.java +++ b/src/main/java/a8k/app/constant/MiniServoConstant.java @@ -1,6 +1,6 @@ package a8k.app.constant; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.type.protocol.MiniServoMId; import org.springframework.util.Assert; import java.util.Map; diff --git a/src/main/java/a8k/app/controler/api/v1/app/assistant/ApiRetTestControler.java b/src/main/java/a8k/app/controler/api/v1/app/assistant/ApiRetTestControler.java index 0750909..f569680 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/assistant/ApiRetTestControler.java +++ b/src/main/java/a8k/app/controler/api/v1/app/assistant/ApiRetTestControler.java @@ -1,8 +1,8 @@ package a8k.app.controler.api.v1.app.assistant; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.type.exception.AppException; import a8k.app.type.ui.ApiRet; import a8k.app.type.error.*; diff --git a/src/main/java/a8k/app/controler/api/v1/app/ctrl/OsCtrlControler.java b/src/main/java/a8k/app/controler/api/v1/app/ctrl/OsCtrlControler.java index ba1033d..7ecf703 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/ctrl/OsCtrlControler.java +++ b/src/main/java/a8k/app/controler/api/v1/app/ctrl/OsCtrlControler.java @@ -4,7 +4,7 @@ import a8k.OS; import a8k.app.service.os.OSBeepCtrlService; import a8k.app.service.os.OSDeviceInfoMgrService; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.statemgr.DeviceWorkStateMgrService; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.type.ui.ApiRet; diff --git a/src/main/java/a8k/app/controler/api/v1/app/data/A8kProjectCardControler.java b/src/main/java/a8k/app/controler/api/v1/app/data/A8kProjectCardControler.java index 1ac1964..b83a7f9 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/data/A8kProjectCardControler.java +++ b/src/main/java/a8k/app/controler/api/v1/app/data/A8kProjectCardControler.java @@ -1,6 +1,6 @@ package a8k.app.controler.api.v1.app.data; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.background.ProjIDCardCtrlAndMonitorService; import a8k.app.service.data.ProjIdCardInfoMgrService; import a8k.app.service.statemgr.GStateMgrService; diff --git a/src/main/java/a8k/app/controler/api/v1/app/data/UsrControler.java b/src/main/java/a8k/app/controler/api/v1/app/data/UsrControler.java index 7426ef9..f91708e 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/data/UsrControler.java +++ b/src/main/java/a8k/app/controler/api/v1/app/data/UsrControler.java @@ -1,6 +1,6 @@ package a8k.app.controler.api.v1.app.data; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.data.AppUserMgrService; import a8k.app.dao.type.db.AppUser; import a8k.app.type.exception.AppException; diff --git a/src/main/java/a8k/app/controler/api/v1/app/ws/AppStateWebsocketEndpoint.java b/src/main/java/a8k/app/controler/api/v1/app/ws/AppStateWebsocketEndpoint.java index dd17065..fa5c5c6 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/ws/AppStateWebsocketEndpoint.java +++ b/src/main/java/a8k/app/controler/api/v1/app/ws/AppStateWebsocketEndpoint.java @@ -32,7 +32,6 @@ public class AppStateWebsocketEndpoint { // 保存 session 到对象 this.session = session; SpringBootBeanUtil.getBean(AppWebSocketEndpointMgr.class).pushStateWebsocketSession(session); - log.info("[websocket] 新的连接:id={}", this.session.getId()); } // 连接关闭 diff --git a/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java b/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java index 71814e4..32f7eca 100644 --- a/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java +++ b/src/main/java/a8k/app/controler/api/v1/app/ws/AppWebSocketEndpointMgr.java @@ -36,10 +36,10 @@ public class AppWebSocketEndpointMgr { public static class Report { - public String messageType = "Report"; - public String dataType; - public Object data; - public Long timestamp = (System.currentTimeMillis()); + public String messageType = "Report"; + public String dataType; + public Object data; + public Long timestamp = (System.currentTimeMillis()); public Report(String dataType, Object object) { this.dataType = dataType; @@ -189,23 +189,15 @@ public class AppWebSocketEndpointMgr { } public void quickReportStateSchedule(boolean force) { - reportState("ConsumablesState", consumablesMgrService.getStateVersion(), force, - consumablesMgrService::getState); - reportState("EngineerModeState", engineerModeStateMgrService.getVersion(), force, - engineerModeStateMgrService::getState); - reportState("DeviceWorkState", deviceWorkStateMgrService.getVersion(), force, - deviceWorkStateMgrService::getDeviceWorkState); - - reportState("OptScanModuleState", optScanModuleStateMgr.getStateVersion(), force, - optScanModuleStateMgr::getOptScanModule); - reportState("TubeHolderSetting", tubeHolderSettingMgrService.getTubeHolderSettingVersion(), force, - tubeHolderSettingMgrService::getTubeHolderSettings); - - reportState("AppFlagStateList", appFlagStateMgrService.getStateVersion(), force, - appFlagStateMgrService::getFlagState); - reportState("MessageBoxState", frontEndMessageBoxAndEventMgr.getMessageBoxStateVersion(), force, - frontEndMessageBoxAndEventMgr::getMessageBoxState); + reportState("ConsumablesState", consumablesMgrService.getStateVersion(), force, consumablesMgrService::getState); + reportState("EngineerModeState", engineerModeStateMgrService.getVersion(), force, engineerModeStateMgrService::getState); + reportState("DeviceWorkState", deviceWorkStateMgrService.getVersion(), force, deviceWorkStateMgrService::getDeviceWorkState); + reportState("OptScanModuleState", optScanModuleStateMgr.getStateVersion(), force, optScanModuleStateMgr::getOptScanModule); + reportState("TubeHolderSetting", tubeHolderSettingMgrService.getTubeHolderSettingVersion(), force, tubeHolderSettingMgrService::getTubeHolderSettings); + + reportState("AppFlagStateList", appFlagStateMgrService.getStateVersion(), force, appFlagStateMgrService::getFlagState); + reportState("MessageBoxState", frontEndMessageBoxAndEventMgr.getMessageBoxStateVersion(), force, frontEndMessageBoxAndEventMgr::getMessageBoxState); reportState("TubeHolderState", tubeStateMgrService.getVersion(), force, tubeStateMgrService::getTubeHolderState); reportState("EmergencyPosState", tubeStateMgrService.getVersion(), force, tubeStateMgrService::getEmergencyPosRunState); diff --git a/src/main/java/a8k/app/controler/api/v1/engineer/LiquidAbsorptionAndDistributionTestControler.java b/src/main/java/a8k/app/controler/api/v1/engineer/LiquidAbsorptionAndDistributionTestControler.java index af7b619..f42e94e 100644 --- a/src/main/java/a8k/app/controler/api/v1/engineer/LiquidAbsorptionAndDistributionTestControler.java +++ b/src/main/java/a8k/app/controler/api/v1/engineer/LiquidAbsorptionAndDistributionTestControler.java @@ -2,7 +2,7 @@ package a8k.app.controler.api.v1.engineer; import a8k.app.service.engineer.qatest.LiquidAbsorptionAndDistributionTestService; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.exception.AppException; import a8k.app.type.ui.ApiRet; import io.swagger.v3.oas.annotations.Operation; diff --git a/src/main/java/a8k/app/dao/A8kProjExtInfoCardDao.java b/src/main/java/a8k/app/dao/A8kProjExtInfoCardDao.java index 6cc8ce8..b14fe23 100644 --- a/src/main/java/a8k/app/dao/A8kProjExtInfoCardDao.java +++ b/src/main/java/a8k/app/dao/A8kProjExtInfoCardDao.java @@ -3,7 +3,7 @@ package a8k.app.dao; import a8k.app.dao.type.common.CommonPage; import a8k.app.type.exception.AppException; import a8k.app.dao.type.db.ProjExtInfoCard; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.data.UtilsProjectColorAllocer; import a8k.app.utils.ZSqlite; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/app/dao/SubModuleConfigDao.java b/src/main/java/a8k/app/dao/SubModuleConfigDao.java index 79e2dde..6aa3f32 100644 --- a/src/main/java/a8k/app/dao/SubModuleConfigDao.java +++ b/src/main/java/a8k/app/dao/SubModuleConfigDao.java @@ -1,8 +1,7 @@ package a8k.app.dao; import a8k.app.dao.type.db.SubModuleConfigValue; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.utils.ZSqlite; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/app/dao/SubModuleRegInitialValueDao.java b/src/main/java/a8k/app/dao/SubModuleRegInitialValueDao.java index c0d828b..3e23974 100644 --- a/src/main/java/a8k/app/dao/SubModuleRegInitialValueDao.java +++ b/src/main/java/a8k/app/dao/SubModuleRegInitialValueDao.java @@ -1,8 +1,8 @@ package a8k.app.dao; import a8k.app.dao.type.db.SubModuleRegInitialValue; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.RegIndex; import a8k.app.utils.ZSqlite; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/app/dao/type/db/SubModuleConfigValue.java b/src/main/java/a8k/app/dao/type/db/SubModuleConfigValue.java index 4169644..af87dbd 100644 --- a/src/main/java/a8k/app/dao/type/db/SubModuleConfigValue.java +++ b/src/main/java/a8k/app/dao/type/db/SubModuleConfigValue.java @@ -1,8 +1,7 @@ package a8k.app.dao.type.db; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.ModuleType; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.ModuleType; import java.io.Serializable; diff --git a/src/main/java/a8k/app/dao/type/db/SubModuleRegInitialValue.java b/src/main/java/a8k/app/dao/type/db/SubModuleRegInitialValue.java index 37b7cd1..d17c6fa 100644 --- a/src/main/java/a8k/app/dao/type/db/SubModuleRegInitialValue.java +++ b/src/main/java/a8k/app/dao/type/db/SubModuleRegInitialValue.java @@ -1,7 +1,7 @@ package a8k.app.dao.type.db; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.RegIndex; import java.io.Serializable; diff --git a/src/main/java/a8k/app/factory/A8kPacketFactory.java b/src/main/java/a8k/app/factory/A8kPacketFactory.java index 08dcf01..36c2b9b 100644 --- a/src/main/java/a8k/app/factory/A8kPacketFactory.java +++ b/src/main/java/a8k/app/factory/A8kPacketFactory.java @@ -1,7 +1,7 @@ package a8k.app.factory; -import a8k.app.channel.iflytophald.type.protocol.A8kPacket; -import a8k.app.channel.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.A8kPacket; +import a8k.app.iflytophald.type.protocol.CmdId; import java.util.List; diff --git a/src/main/java/a8k/app/factory/BiLisDoubleTrackFrameFactory.java b/src/main/java/a8k/app/factory/BiLisDoubleTrackFrameFactory.java index d674a85..24ce4b2 100644 --- a/src/main/java/a8k/app/factory/BiLisDoubleTrackFrameFactory.java +++ b/src/main/java/a8k/app/factory/BiLisDoubleTrackFrameFactory.java @@ -2,6 +2,8 @@ package a8k.app.factory; import a8k.app.constant.AppConstant; import a8k.app.dao.type.db.ReactionRecord; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.type.exception.AppException; import a8k.app.type.lisprotocol.BiLisDoubleTrackFrame; import a8k.app.type.lisprotocol.BiLisDoubleTrackFrameBuildContext; import a8k.app.type.lisprotocol.BiLisFrameParseErrorCode; @@ -19,7 +21,7 @@ import java.lang.reflect.Field; @Slf4j public class BiLisDoubleTrackFrameFactory { // - static public BiLisDoubleTrackFrameBuildContext createRFrame(ReactionRecord reactionRecord, Integer subProjIndex) { + static public BiLisDoubleTrackFrameBuildContext createRFrame(ReactionRecord reactionRecord, Integer subProjIndex) throws AppException { //R|A10|123456789|^PCT/CRP^CRP^#|46|mg/L|0.5-200||L_1^_03|F||||20141201144906||0| BiLisDoubleTrackFrameBuildContext buildContext = new BiLisDoubleTrackFrameBuildContext(); @@ -80,7 +82,7 @@ public class BiLisDoubleTrackFrameFactory { } - static public BiLisDoubleTrackFrameBuildContext createQFrameBytes(String deviceName, String barcode) { + static public BiLisDoubleTrackFrameBuildContext createQFrameBytes(String deviceName, String barcode) throws AppException { BiLisDoubleTrackFrameBuildContext context = new BiLisDoubleTrackFrameBuildContext(); BiLisDoubleTrackFrame frame = new BiLisDoubleTrackFrame(); @@ -144,7 +146,7 @@ public class BiLisDoubleTrackFrameFactory { char[] checkcode = computeChecksum(cmdContent); - if (!isCheckcodeEq(c1,c2,checkcode)) { + if (!isCheckcodeEq(c1, c2, checkcode)) { log.warn("Received frame has invalid checksum: {}, {} !={} {}", c1, c2, checkcode[0], checkcode[1]); throw new BiLisFrameParseException(BiLisFrameParseErrorCode.ChecksumError, "rx checksum error: " + c1 + ", " + c2); } @@ -183,14 +185,14 @@ public class BiLisDoubleTrackFrameFactory { } - static public void serialize(BiLisDoubleTrackFrameBuildContext buildContext, BiLisDoubleTrackFrame frame) { + static public void serialize(BiLisDoubleTrackFrameBuildContext buildContext, BiLisDoubleTrackFrame frame) throws AppException { /* * Frame Structure: * STX,FN,Content,ETX,C1,C2,CR,LF */ if (frame.frameType != BiLisDoubleTrackFrame.STX) { log.warn("Frame type is not STX, cannot serialize: {}", frame.frameType); - buildContext.buildSuccess = false; + throw AppException.of(A8kEcode.CODEERROR, "Frame type is not STX, cannot serialize: %s", frame.frameType); } if ((frame.frameContent instanceof QFrame @@ -201,7 +203,7 @@ public class BiLisDoubleTrackFrameFactory { createBiLisDoubleTrackFrame(buildContext, content); } else { log.warn("Unsupported frame content type: {}", frame.frameContent.getClass().getSimpleName()); - buildContext.buildSuccess = false; + throw AppException.of(A8kEcode.CODEERROR, "Unsupported frame content type: %s", frame.frameContent.getClass().getSimpleName()); } } diff --git a/src/main/java/a8k/app/factory/FakeAppErrorFactory.java b/src/main/java/a8k/app/factory/FakeAppErrorFactory.java index 9a43654..7d4c76b 100644 --- a/src/main/java/a8k/app/factory/FakeAppErrorFactory.java +++ b/src/main/java/a8k/app/factory/FakeAppErrorFactory.java @@ -1,8 +1,8 @@ package a8k.app.factory; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.service.analyzer.ConsumableStateAnalyzerService; import a8k.app.type.error.AEConsumeNotEnoughError; import a8k.app.type.error.AEHardwareError; diff --git a/src/main/java/a8k/app/i18n/Internationalization.java b/src/main/java/a8k/app/i18n/Internationalization.java index 6446ead..48bc5be 100644 --- a/src/main/java/a8k/app/i18n/Internationalization.java +++ b/src/main/java/a8k/app/i18n/Internationalization.java @@ -1,11 +1,11 @@ package a8k.app.i18n; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.optalgo.type.ReactionResultStatus; import a8k.app.type.AppFlagKey; import a8k.app.type.a8k.BloodType; import a8k.app.type.error.ConsumablesScanReportErrorType; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; public class Internationalization { public static String A8kEcode2String(A8kEcode ecode) { @@ -84,6 +84,10 @@ public class Internationalization { case APPE_WAST_BIN_IS_FULL -> "废料箱已满"; case SYS_CMD_EXEC_OVERTIME -> "系统指令超时"; case NETWORK_PARAMETER_ERROR -> "网络参数错误"; + case LIS_LOST_CONNECTION -> "LIS断开连接"; + case LIS_REPORT_RECORD_FAIL -> "LIS上报记录失败"; + case LIS_REQUEST_SAMPLE_INFO_FAIL -> "LIS请求样本信息失败"; + case LIS_REQUEST_SAMPLE_INFO_PARSE_RESPONSE_FAIL -> "LIS请求样本信息解析响应失败"; default -> ecode.toString(); }; } diff --git a/src/main/java/a8k/app/iflytophald/A8kChannelStateMgr.java b/src/main/java/a8k/app/iflytophald/A8kChannelStateMgr.java new file mode 100644 index 0000000..a6b4920 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/A8kChannelStateMgr.java @@ -0,0 +1,19 @@ +package a8k.app.iflytophald; + +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +@RequiredArgsConstructor +public class A8kChannelStateMgr { + private final A8kCanBusBaseDriver canBus; + + + public Boolean isCanBusConnected() { + return canBus.isConnect(); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/channel/A8kCanBusCommunicationChannel.java b/src/main/java/a8k/app/iflytophald/channel/A8kCanBusCommunicationChannel.java new file mode 100644 index 0000000..c956404 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/channel/A8kCanBusCommunicationChannel.java @@ -0,0 +1,362 @@ +package a8k.app.iflytophald.channel; + +import a8k.OS; +import a8k.app.client.iflytophald.type.protocol.*; +import a8k.app.iflytophald.type.protocol.*; +import a8k.app.type.appevent.A8kCanBusOnConnectEvent; +import a8k.app.type.appevent.A8kHardwareReport; +import a8k.app.type.error.AEHardwareError; +import a8k.app.type.exception.AppException; +import a8k.app.factory.A8kPacketFactory; +import a8k.app.service.background.AppEventBusService; +import a8k.app.utils.ByteArrayUtils; +import a8k.app.utils.ZList; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.java_websocket.client.WebSocketClient; +import org.java_websocket.enums.ReadyState; +import org.java_websocket.handshake.ServerHandshake; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; + +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + + +@Slf4j +public class A8kCanBusCommunicationChannel extends WebSocketClient { + @Resource + AppEventBusService eventBus; + + String datachurl = null; + String cmdchurl = null; + Boolean firstCall = true; + + @Value("${iflytophald.enable}") + Boolean iflytophaldEnable; + + + static class ProcessContext { + BlockingQueue receiptQueue = new LinkedBlockingQueue<>(); // + A8kPacket cmdPacket; + Map txcmdcache = new HashMap<>(); + + + public A8kPacket getReceipt(long overtime) { + long end = OS.getMonotonicClockTimestamp() + overtime; + A8kPacket packet = null; + while (OS.getMonotonicClockTimestamp() < end) { + try { + packet = receiptQueue.poll(2, TimeUnit.MILLISECONDS); + } catch (InterruptedException ignored) { + } + if (packet != null) { + this.cmdPacket = null; + return packet; + } + } + + synchronized (this) { + try { + packet = receiptQueue.poll(1, TimeUnit.MILLISECONDS); + } catch (InterruptedException ignored) { + } + receiptQueue.clear(); + this.cmdPacket = null; + return packet; + } + } + + synchronized void pushReceipt(A8kPacket receipt) { + if (this.cmdPacket != null && this.cmdPacket.getPacketIndex() == receipt.getPacketIndex()) { + if (this.cmdPacket.getModuleId() == receipt.getModuleId() && this.cmdPacket.getCmdId() == receipt.getCmdId()) { + receiptQueue.add(receipt); + this.cmdPacket = null; + } else { + log.warn("RX index equal, but cmdId not equal, {} {}", this.cmdPacket, receipt); + } + } else { + log.warn("RX unmatched index receipt, {} {}", this.cmdPacket, receipt); + log.warn("."); + } + } + + synchronized void setWaitingReceiptIndex(A8kPacket cmdPacket) { + if (!receiptQueue.isEmpty()) { + log.warn("some packets in receiptQueue, clear it"); + for (A8kPacket p : receiptQueue) { + log.warn("unprocess receipt: {}", p); + } + } + receiptQueue.clear(); + this.cmdPacket = cmdPacket; + } + + + synchronized void storageTxLastCmd(A8kPacket pack) { + MId mid = MId.valueOf(pack.getModuleId()); + CmdId cmdId = CmdId.valueOf(pack.getCmdId()); + if (cmdId != null && cmdId.isActionCmd()) + txcmdcache.put(mid, cmdId); + } + + synchronized CmdId getLastTxCmd(MId mid) { + return txcmdcache.get(mid); + } + } + + + ProcessContext context = new ProcessContext(); + int packetIndex = 0;//发送包的packetIndex + + + public A8kCanBusCommunicationChannel(String cmdchurl, String datachurl) { + super(URI.create(datachurl)); + log.info("new A8kCanBusConnection: {} {}", cmdchurl, datachurl); + + this.datachurl = datachurl; + this.cmdchurl = cmdchurl; + packetIndex = 0; + + + } + + @Override public void onOpen(ServerHandshake serverHandshake) { + log.info("a8k canbus connect sucess"); + eventBus.pushEvent(new A8kCanBusOnConnectEvent()); + } + + @Override public void onMessage(String s) { + log.debug("RX-RAW: {}", s); + processCanRxMessage(s); + } + + @Override public void onClose(int i, String s, boolean b) { + log.warn("a8k canbus lost connection..."); + } + + @Override public void onError(Exception e) { + log.info("a8k can-websocket-channel on error"); + } + + + synchronized public A8kPacket callcmd(MId moduleId, CmdId cmdId, Integer... param) throws AppException { + var packet = packParamsToPacket(moduleId.toInt(), cmdId.toInt(), ZList.of(param)); + return autoReSend(packet, A8kPacket.CMD_OVERTIME); + } + + synchronized public A8kPacket callcmd(MId moduleId, CmdId cmdId, Long overtime, Integer... params) throws AppException { + var packet = packParamsToPacket(moduleId.toInt(), cmdId.toInt(), ZList.of(params)); + return autoReSend(packet, overtime); + } + + synchronized public A8kPacket send(A8kPacket pack, int overtime) throws AppException { + return priSend(pack, overtime); + } + + synchronized public ModuleStatus moduleGetStatus(MId id) throws AppException { + var getStatusPacket = packParamsToPacket(id.toInt(), CmdId.module_get_status.toInt(), ZList.of()); + for (int i = 0; i < 10; i++) { + try { + return ModuleStatus.valueOf(priSend(getStatusPacket, 30).getContentI32(0)); + } catch (AppException ignored) { + } + restartCanif(); + OS.hsleep(10); + } + throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, + MId.valueOf(getStatusPacket.getModuleId()), CmdId.valueOf(getStatusPacket.getCmdId()))); + + } + + // + // PRIVATE + // + @Scheduled(fixedRate = 10000) + private void autoConnect() { + if (!iflytophaldEnable) + return; + + if (!isOpen()) { + if (getReadyState().equals(ReadyState.NOT_YET_CONNECTED)) { + try { + connect(); + } catch (IllegalStateException ignored) { + } + } else if (getReadyState().equals(ReadyState.CLOSED)) { + reconnect(); + } + } + } + + /** + * 强制关闭websocket连接,让其与canbus服务重连 + */ + private A8kPacket packParamsToPacket(Integer moduleId, Integer cmdId, List params) { + return A8kPacketFactory.buildCMDPacket(moduleId, cmdId, params); + } + + + private A8kPacket autoReSend(A8kPacket pack, long overtime) throws AppException { + if (firstCall) { + firstCall = false; + restartCanif(); + } + + for (int j = 0; j < 2; j++) { + for (int i = 0; i < 5; i++) { + try { + return this.priSend(pack, overtime); + } catch (AppException e) { + if (!e.error.code.equals(A8kEcode.LOW_ERROR_OVERTIME)) { + throw e; + } + } + log.error("send cmd {} {} fail", pack, pack.toByteString()); + OS.hsleep(100); + log.error("retry {}", i); + } + restartCanif(); + } + + throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()))); + } + + + private A8kPacket priSend(A8kPacket pack, long overtime) throws AppException { + try { + return _priSend(pack, overtime); + } catch (AppException e) { + throw e; + } catch (Exception e) { + log.error("priSend error", e); + throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()))); + } + } + + + AppException buildOvertimeError(A8kPacket pack) { + return AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()))); + } + + private A8kPacket _priSend(A8kPacket pack, long overtime) throws AppException { + // alloc new packetIndex + packetIndex = packetIndex + 1; + if (packetIndex > 30000) { + packetIndex = 1; + } + + //set waiting receipt index + pack.setPacketIndex(packetIndex); + context.storageTxLastCmd(pack); + context.setWaitingReceiptIndex(pack); + + // TX packet + String txpacket = pack.toByteString(); + log.debug("TX-RAW: {} | {}", txpacket, pack); + send(txpacket); + + + A8kPacket receipt; + receipt = context.getReceipt(overtime); + if (receipt == null) { + throw buildOvertimeError(pack); + } + + if (receipt.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) { + throw AppException.of(new AEHardwareError(A8kEcode.fromInt(receipt.getContentI32(0)), + MId.valueOf(pack.getModuleId()), + CmdId.valueOf(pack.getCmdId()), + txpacket, + receipt.toByteString() + ) + ); + } + return receipt; + } + + /** + * 处理接收到的消息 + */ + private void processCanRxMessage(String s) { + byte[] rx = ByteArrayUtils.hexStringToBytes(s); + if (rx == null || rx.length == 0) { + log.warn("rx is empty"); + return; + } + + if (rx.length < A8kPacket.PACKET_MIN_LEN) { + log.warn("rx is too short,{}", s); + return; + } + + A8kPacket packet = new A8kPacket(rx); + + if (packet.getCheckcode() != packet.computeCheckcode()) { + log.warn("Rx packet checkcode error: {}, expect: {} but got: {}", packet, packet.computeCheckcode(), packet.getCheckcode()); + return; + } + + if (!packet.isSupportPacket()) { + log.warn("Rx packet not support: {}", packet); + return; + } + + + if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK || packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) { + log.debug("RX-ACK |RAW:{}| {}", s, packet); + context.pushReceipt(packet); + } else if (packet.getPacketType() == A8kPacket.PACKET_TYPE_EVENT) { + log.debug("RX-REPORT |RAW:{}| {}", s, packet); + eventBus.pushEvent(new A8kHardwareReport(packet)); + } else { + log.warn("RX-UNPROCESSABLE: |RAW:{}| {}", s, packet); + } + } + + public synchronized CmdId getLastTxCmd(MId mid) { + return context.getLastTxCmd(mid); + } + + public void restartCanif() { + callLocalCmd("restart"); + } + + + public HttpResponse callLocalCmd(String path) { + // 创建一个HttpClient实例 + HttpClient httpClient = HttpClient.newHttpClient(); + HttpRequest httpRequest = HttpRequest.newBuilder().uri(URI.create(String.format("%s/%s", cmdchurl, path))).build(); + HttpResponse ret = null; + try { + ret = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); + } catch (Exception e) { + log.error("callcmd error", e); + return null; + } + return ret; + } + + public static void main(String[] args) { + HttpClient httpClient = HttpClient.newHttpClient(); + HttpRequest httpRequest = HttpRequest.newBuilder().uri(URI.create("http://192.168.8.10:19004/zexcan/restart")).build(); + HttpResponse ret = null; + try { + ret = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); + log.info("ret: \t{}", ret.body()); + } catch (Exception e) { + log.error("callcmd error", e); + } + } + +} + + diff --git a/src/main/java/a8k/app/iflytophald/channel/LisUartCommunicationChannel.java b/src/main/java/a8k/app/iflytophald/channel/LisUartCommunicationChannel.java new file mode 100644 index 0000000..c7b235c --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/channel/LisUartCommunicationChannel.java @@ -0,0 +1,237 @@ +package a8k.app.iflytophald.channel; + +import a8k.app.config.IflytophaldConnectionConfig; +import a8k.app.iflytophald.utils.IflytophaldChannelCtrlRequester; +import a8k.app.utils.ByteArrayUtils; +import jakarta.annotation.PostConstruct; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.java_websocket.client.WebSocketClient; +import org.java_websocket.enums.ReadyState; +import org.java_websocket.handshake.ServerHandshake; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.nio.ByteBuffer; + + +@Slf4j +@Component +@RequiredArgsConstructor +public class LisUartCommunicationChannel { + + @Value("${iflytophald.enable}") + Boolean iflytophaldEnable; + + + private final String channelName = "lis"; + private final String charsetName = "UTF-8"; + + private final IflytophaldConnectionConfig config; + private final IflytophaldChannelCtrlRequester cmdSender; + + private OnMessageListener onMessageListener; + private WebSocketClient conn; + + private Integer baudRate = 115200; + private Boolean syncBaudRateSuc = false; + private final Object baudRateLock = new Object(); + private Boolean loopbackMode = false; + + + synchronized public void tx(byte[] toSend) { + if (toSend == null || toSend.length == 0) { + return; + } + conn.send(toSend); + } + + synchronized public void tx(String toSend) { + try { + conn.send(toSend.getBytes(charsetName)); + } catch (UnsupportedEncodingException e) { + log.error("tx error", e); + } + } + + synchronized public void regRxMessageListener(OnMessageListener listener) { + this.onMessageListener = listener; + } + synchronized public void unRegRxMessageListener() { + this.onMessageListener = null; + } + + synchronized public boolean isConnected() { + return conn != null && conn.isOpen(); + } + + public synchronized Boolean setBaudRate(Integer baudRate) { + if (baudRate == null) { + log.warn("setBaudRate: baudRate is null or empty"); + return false; + } + syncBaudRateSuc = false; + syncSetBaudRate(baudRate); + return true; + } + + public synchronized void setInLoopbackMode(boolean inLoopback) { + synchronized (this.baudRateLock) { + loopbackMode = inLoopback; + } + } + + public Boolean isInLoopbackMode() { + synchronized (this.baudRateLock) { + return loopbackMode; + } + } + + public Integer getBaudRateDirect() { + synchronized (this.baudRateLock) { + if (!isConnected()) { + return this.baudRate; + } + + if (syncBaudRateSuc) { + return this.baudRate; + } + + var receipt = cmdSender.callCmd(channelName, "getBaudrate", GetBaudrateResponse.class); + if (receipt == null || receipt.status != 0 || receipt.data == null) { + log.error("getBaudRateDirect: callCmd returned null or error"); + return null; + } + syncBaudRateSuc = receipt.data.baudrate != null && receipt.data.baudrate.equals(this.baudRate); + return receipt.data.baudrate; + } + } + + + // + // PRIVATE + // + + @FunctionalInterface + public interface OnMessageListener { + void onMessage(byte[] bytes); + } + + static public class GetBaudrateResponse { + public Integer baudrate; + } + + + private void onMessage(ByteBuffer bytes) { + byte[] byteArray = new byte[bytes.remaining()]; + bytes.get(byteArray); + log.debug("onMessage: {}", ByteArrayUtils.toByteString(byteArray)); + if (onMessageListener != null) { + onMessageListener.onMessage(byteArray); + } + if (loopbackMode) { + // 如果是环回模式,则直接发送回去 + tx(byteArray); + } + } + + @PostConstruct + void init() { + // 初始化连接 + String url = config.getDatachUrl(channelName); + log.info("LisUartChannel url: {}", url); + conn = new WebSocketClient(URI.create(url)) { + @Override + public void onOpen(ServerHandshake serverHandshake) { + LisUartCommunicationChannel.this.onOpen(serverHandshake); + } + + @Override + public void onMessage(String s) { + log.error("onMessage: received string message {}, this should not happen in LisUartChannel", s); + } + + @Override + public void onClose(int i, String s, boolean b) { + LisUartCommunicationChannel.this.onClose(i, s, b); + } + + @Override + public void onError(Exception e) { + LisUartCommunicationChannel.this.onError(e); + } + + @Override + public void onMessage(ByteBuffer bytes) { + LisUartCommunicationChannel.this.onMessage(bytes); + } + }; + conn.connect(); + } + + private void onOpen(ServerHandshake serverHandshake) { + log.info("connect success"); + syncBaudRateSuc = false; + syncSetBaudRate(null); + } + + private void onClose(int i, String s, boolean b) { + log.warn("lost connection..."); + } + + private void onError(Exception e) { + log.info("on error"); + } + + private void syncSetBaudRate(Integer baudRate) { + synchronized (this.baudRateLock) { + if (baudRate != null) { + this.baudRate = baudRate; + } + if (!isConnected()) { + log.warn("lis channel is not connected, sync later"); + return; + } + + if (syncBaudRateSuc) { + return; + } + + var receipt = cmdSender.callCmd(channelName, "setBaudrate", Void.class, String.format("baudrate=%s", this.baudRate)); + if (receipt == null || receipt.status != 0) { + log.error("syncSetBaudRate: callCmd returned null"); + syncBaudRateSuc = false; + return; + } + log.info("syncSetBaudRate: set baudrate to {}", this.baudRate); + syncBaudRateSuc = true; + } + } + + @Scheduled(fixedRate = 1000) + private void autoConnect() { + if (!iflytophaldEnable) { + return; + } + + if (!conn.isOpen()) { + if (conn.getReadyState().equals(ReadyState.NOT_YET_CONNECTED)) { + try { + conn.connect(); + } catch (IllegalStateException ignored) { + } + } else if (conn.getReadyState().equals(ReadyState.CLOSED)) { + conn.reconnect(); + } + } else { + if (!syncBaudRateSuc) { + syncSetBaudRate(null); + } + } + } +} + + diff --git a/src/main/java/a8k/app/iflytophald/channel/PrinterUartCommunicationChannel.java b/src/main/java/a8k/app/iflytophald/channel/PrinterUartCommunicationChannel.java new file mode 100644 index 0000000..a0957de --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/channel/PrinterUartCommunicationChannel.java @@ -0,0 +1,164 @@ +package a8k.app.iflytophald.channel; + +import a8k.app.config.IflytophaldConnectionConfig; +import jakarta.annotation.PostConstruct; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.java_websocket.client.WebSocketClient; +import org.java_websocket.enums.ReadyState; +import org.java_websocket.handshake.ServerHandshake; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.LinkedList; +import java.util.Queue; + + +@Slf4j +@Component +@RequiredArgsConstructor +public class PrinterUartCommunicationChannel { + @Value("${iflytophald.enable}") + Boolean iflytophaldEnable; + + WebSocketClient conn; + + private final IflytophaldConnectionConfig config; + private Queue sendQueue = new LinkedList<>(); + + @PostConstruct + void init() { + String url = config.getDatachUrl("printer"); + log.info("PrinterUartChannel url: {}", url); + conn = new WebSocketClient(URI.create(url)) { + @Override + public void onOpen(ServerHandshake serverHandshake) { + PrinterUartCommunicationChannel.this.onOpen(serverHandshake); + } + + @Override + public void onMessage(String s) { + PrinterUartCommunicationChannel.this.onMessage(s); + } + + @Override + public void onClose(int i, String s, boolean b) { + PrinterUartCommunicationChannel.this.onClose(i, s, b); + } + + @Override + public void onError(Exception e) { + PrinterUartCommunicationChannel.this.onError(e); + } + }; + conn.connect(); + } + + /** + * 打印字符串 + * @param fmt 格式化字符串 + * @param args 参数 + * 1. 打印%时候,需要使用%%,否则会报错 + * + */ + public void printf(String fmt, Object... args) { + if (conn.isOpen()) { + String s = String.format(fmt, args); + try { + byte[] toSend = s.getBytes("GBK"); + pushToSend(toSend); + } catch (UnsupportedEncodingException e) { + log.error("charset error", e); + } + } else { + log.warn("PrinterUartChannel is not open"); + } + } + + public void printfEnd() { + if (conn.isOpen()) { + printf("\r\n"); + printf("\r\n"); + printf("\r\n"); + } + } + + + // + // PRIVATE + // + + + private void onOpen(ServerHandshake serverHandshake) { + log.info("a8k canbus connect sucess"); + } + + private void onMessage(String s) { + } + + private void onClose(int i, String s, boolean b) { + log.warn("a8k canbus lost connection..."); + } + + private void onError(Exception e) { + log.info("a8k can-websocket-channel on error"); + } + + + synchronized private void pushToSend(byte[] toSend) { + sendQueue.add(toSend); + } + + synchronized private byte[] popToSend() { + if (!sendQueue.isEmpty()) { + return sendQueue.poll(); + } + return null; + } + + // conn.send(toSend); + // if (toSend.length > 10) { + // OS.forceSleep(150); + // } + @Scheduled(fixedRate = 400) + private void autoSend() { + while (true) { + var tosend = popToSend(); + if (tosend != null) { + if (conn.isOpen()) { + conn.send(tosend); + } + if (tosend.length > 2) { + break; + } + } else { + break; + } + + } + + } + + + @Scheduled(fixedRate = 10000) + private void autoConnect() { + if (!iflytophaldEnable) { + return; + } + if (!conn.isOpen()) { + if (conn.getReadyState().equals(ReadyState.NOT_YET_CONNECTED)) { + try { + conn.connect(); + } catch (IllegalStateException ignored) { + } + } else if (conn.getReadyState().equals(ReadyState.CLOSED)) { + conn.reconnect(); + } + } + } +} + + diff --git a/src/main/java/a8k/app/iflytophald/driver/A8kCanBusBaseDriver.java b/src/main/java/a8k/app/iflytophald/driver/A8kCanBusBaseDriver.java new file mode 100644 index 0000000..dab8097 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/A8kCanBusBaseDriver.java @@ -0,0 +1,144 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.iflytophald.channel.A8kCanBusCommunicationChannel; +import a8k.app.client.iflytophald.type.protocol.*; +import a8k.app.iflytophald.type.protocol.*; +import a8k.app.type.error.AEHardwareError; +import a8k.app.type.exception.AppException; +import a8k.OS; +import a8k.app.utils.ByteArrayUtils; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.net.URISyntaxException; + +@Component +@Slf4j +public class A8kCanBusBaseDriver { + @Resource + A8kCanBusCommunicationChannel connection; + + + @Value("${iflytophald.enable}") + Boolean iflytophaldEnable; + + @PostConstruct + public void init() throws URISyntaxException { + if (iflytophaldEnable) { + connection.connect(); + } else { + log.warn("canBus is disabled"); + } + } + + /** + * 强制关闭websocket连接,让其与canbus服务重连 + */ + public void forceShutdown() { + connection.close(); + } + + // + // BASE_OPERATION + // + + public A8kPacket callcmd(MId moduleId, CmdId cmdId, Integer... param) throws AppException { + return connection.callcmd(moduleId, cmdId, param); + } + + public A8kPacket callcmd(MId moduleId, CmdId cmdId, Long overtime, Integer... params) throws AppException { + return connection.callcmd(moduleId, cmdId, overtime, params); + } + + synchronized public A8kPacket send(A8kPacket pack, int overtime) throws AppException { + return connection.send(pack, overtime); + } + + // + // MODULE FUNCTION + // + + public void moduleStop(MId id) throws AppException { + connection.callcmd(id, CmdId.module_stop); + } + + public void moduleStopNoException(MId id) { + try { + moduleStop(id); + } catch (AppException ignored) { + } + } + + public ModuleStatus moduleGetStatus(MId id) throws AppException { + return connection.moduleGetStatus(id); + } + + public void moduleSetReg(MId id, RegIndex regindex, Integer reg) throws AppException { + connection.callcmd(id, CmdId.module_set_reg, 100L, regindex.index, reg); + } + + public Integer moduleGetReg(MId id, RegIndex regindex) throws AppException { + var packet = connection.callcmd(id, CmdId.module_get_reg, 100L, regindex.index); + return packet.getContentI32(0); + } + + public A8kEcode moduleGetError(MId id) throws AppException { + var packet = connection.callcmd(id, CmdId.module_get_error); + return A8kEcode.fromInt(packet.getContentI32(0)); + } + + public Integer moduleGetDetailError(MId id) throws AppException { + return connection.callcmd(id, CmdId.module_get_detail_error).getContentI32(0); + } + + public Integer moduleReadVersion(MId id) throws AppException { + return connection.callcmd(id, CmdId.module_get_version).getContentI32(0); + } + + public ModuleType moduleReadType(MId id) throws AppException { + var packet = connection.callcmd(id, CmdId.module_get_type); + return ModuleType.of(packet.getContentI32(0)); + } + + public byte[] a8kIdcardReaderReadRaw() throws AppException { + int i = 0; + byte[] result = new byte[0]; + while (true) { + var rxPacket = connection.callcmd(MId.A8kIdCardReader, CmdId.a8000_idcard_reader_read_raw, i++); + if (rxPacket.getCmdContent().length == 0) { + break; + } + result = ByteArrayUtils.concat(result, rxPacket.getCmdContent()); + } + return result; + } + + public void waitForMod(MId mid, Integer acitionOvertime) throws AppException { + long startedAt = OS.getMonotonicClockTimestamp(); + CmdId action = connection.getLastTxCmd(mid); + do { + ModuleStatus statu = moduleGetStatus(mid); + if (statu == ModuleStatus.IDLE) { + break; + } else if (statu == ModuleStatus.ERROR) { + log.error("{} waitting for action {} , catch error {}, defail ecode {}", mid, action, moduleGetError(mid), moduleGetDetailError(mid)); + throw AppException.of(new AEHardwareError(moduleGetError(mid), mid, action)); + } + long now = OS.getMonotonicClockTimestamp(); + if (now - startedAt > acitionOvertime) { + log.error("{} waitting for action {} overtime({})", mid, action, acitionOvertime); + moduleStopNoException(mid); + throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_ACTION_OVERTIME, mid, action)); + } + OS.hsleep(30); + } while (true); + } + + public boolean isConnect() { + return connection.isOpen(); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/driver/CodeScanerDriver.java b/src/main/java/a8k/app/iflytophald/driver/CodeScanerDriver.java new file mode 100644 index 0000000..b82714f --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/CodeScanerDriver.java @@ -0,0 +1,96 @@ +package a8k.app.iflytophald.driver; + +import a8k.OS; +import a8k.app.iflytophald.type.protocol.A8kPacket; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.type.exception.AppException; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +@Component +public class CodeScanerDriver { + + @Resource + A8kCanBusBaseDriver canBus; + + public String pipetteModCodeScannerScanCode(Integer overtime) throws AppException { + try { + codeScanerStartScan(MId.PipetteModCodeScanner); + String result = codeScanerWaittingForResult(MId.PipetteModCodeScanner, overtime); + codeScanerStopScan(MId.PipetteModCodeScanner); + return result; + } catch (AppException e) { + return ""; + } + } + + public String pipetteModCodeScannerScanCode() throws AppException { + return pipetteModCodeScannerScanCode(1000); + } + + public void pipetteModCodeScannerStartScan() throws AppException { + codeScanerStartScan(MId.PipetteModCodeScanner); + } + + public void pipetteModCodeScannerStopScan() throws AppException { + codeScanerStopScan(MId.PipetteModCodeScanner); + } + + + public String feedingModScannerModCodeScannerScanCode(Integer waittime) { + try { + codeScanerStartScan(MId.FeedingModScannerMod); + String result = codeScanerWaittingForResult(MId.FeedingModScannerMod, waittime); + codeScanerStopScan(MId.FeedingModScannerMod); + return result; + } catch (AppException e) { + return ""; + } + } + + public void feedingModScannerModCodeScannerStartScan() throws AppException { + codeScanerStartScan(MId.FeedingModScannerMod); + } + + public void feedingModScannerModCodeScannerStopScan() throws AppException { + codeScanerStopScan(MId.FeedingModScannerMod); + } + + private String codeScanerReadScanerResult(MId id) throws AppException { + A8kPacket ack = canBus.callcmd(id, CmdId.code_scaner_read_scaner_result); + var contentBytes = ack.getCmdContent(); + return new String(contentBytes); + } + + private Boolean codeScanerResultIsReady(MId id) throws AppException { + var packet = canBus.callcmd(id, CmdId.code_scaner_result_is_ready); + return packet.getContentI32(0) != 0; + } + + private String codeScanerWaittingForResult(MId mid, Integer acitionOvertime) throws AppException { + long startedAt = OS.getMonotonicClockTimestamp(); + do { + if (codeScanerResultIsReady(mid)) + break; + long now = OS.getMonotonicClockTimestamp(); + if (now - startedAt > acitionOvertime) { + codeScanerStopScan(mid); + return null; + } + OS.hsleep(100); + } while (true); + codeScanerStopScan(mid); + return codeScanerReadScanerResult(mid); + } + + + private void codeScanerStartScan(MId id) throws AppException { + canBus.callcmd(id, CmdId.code_scaner_start_scan); + } + + private void codeScanerStopScan(MId id) throws AppException { + canBus.callcmd(id, CmdId.code_scaner_stop_scan); + } +} + diff --git a/src/main/java/a8k/app/iflytophald/driver/HbotDriver.java b/src/main/java/a8k/app/iflytophald/driver/HbotDriver.java new file mode 100644 index 0000000..e7e02d8 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/HbotDriver.java @@ -0,0 +1,95 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.HbotRegIndex; +import a8k.app.type.a8k.Pos2d; +import a8k.app.type.exception.AppException; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Component; + +@Component +public class HbotDriver { + + @Resource + A8kCanBusBaseDriver canBus; + + Integer actionOvertime = 10000; + Integer moveToZeroActionOvertime = 20000; + + public void enable(Integer enable) throws AppException { + canBus.callcmd(MId.HbotM, CmdId.xymotor_enable, enable); + } + + private void moveBy(Integer x, Integer y) throws AppException { + canBus.callcmd(MId.HbotM, CmdId.xymotor_move_by, x, y); + } + + public void moveByBlock(Integer x, Integer y) throws AppException { + moveBy(x, y); + canBus.waitForMod(MId.HbotM, actionOvertime); + } + + private void moveTo(Integer x, Integer y) throws AppException { + canBus.callcmd(MId.HbotM, CmdId.xymotor_move_to, x, y); + } + + public void moveToBlock(Integer x, Integer y) throws AppException { + moveTo(x, y); + canBus.waitForMod(MId.HbotM, actionOvertime); + } + + private void moveToZero() throws AppException { + canBus.callcmd(MId.HbotM, CmdId.xymotor_move_to_zero); + } + + public void moveToZeroBlock() throws AppException { + moveToZero(); + canBus.waitForMod(MId.HbotM, moveToZeroActionOvertime); + } + + public Pos2d readPos() throws AppException { + Pos2d pos = new Pos2d(0, 0); + var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_pos); + pos.x = packet.getContentI32(0); + pos.y = packet.getContentI32(1); + return pos; + } + + public Boolean readInIO(Integer ioIndex) throws AppException { + var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_inio, ioIndex); + return packet.getContentI32(0) != 0; + } + + public void setPos(Integer x, Integer y) throws AppException { + canBus.callcmd(MId.HbotM, CmdId.xymotor_set_pos, x, y); + } + + public void moveByDirectBlock(Integer motor1_dpos, Integer motor2_dpos) throws AppException { + canBus.callcmd(MId.HbotM, CmdId.xymotor_motor_move_by_direct, motor1_dpos, motor2_dpos); + canBus.waitForMod(MId.HbotM, actionOvertime); + } + + public Integer[] readEncDirect() throws AppException { + var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_enc_direct); + Integer[] enc = new Integer[2]; + enc[0] = packet.getContentI32(0); + enc[1] = packet.getContentI32(1); + return enc; + } + + public Integer hbotReadInioIndexInStm32(Integer ioIndex) throws AppException { + var packet = canBus.callcmd(MId.HbotM, CmdId.xymotor_read_inio_index_in_stm32, ioIndex); + return packet.getContentI32(0); + } + + public void setReg(HbotRegIndex regIndex, Integer value) throws AppException { + canBus.moduleSetReg(MId.HbotM, regIndex.regIndex, value); + } + + public Integer getReg(HbotRegIndex regIndex) throws AppException { + return canBus.moduleGetReg(MId.HbotM, regIndex.regIndex); + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/driver/InputDetectDriver.java b/src/main/java/a8k/app/iflytophald/driver/InputDetectDriver.java new file mode 100644 index 0000000..cd44783 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/InputDetectDriver.java @@ -0,0 +1,50 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.type.error.AECodeError; +import a8k.app.type.exception.AppException; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.InputIOId; +import a8k.app.iflytophald.type.protocol.ModuleType; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class InputDetectDriver { + + private final A8kCanBusBaseDriver a8KCanBusBaseDriver; + + public Boolean getIOState(InputIOId ioid) throws AppException { + while (true) { + Boolean firstReadIO = priGetIOState(ioid, 100); + Boolean secondReadIO = priGetIOState(ioid, 100); + if (firstReadIO == secondReadIO) { + if (ioid.mirror) { + return !firstReadIO; + } + return firstReadIO; + } else { + log.warn("getIOState {} not match, retry", ioid); + } + } + } + + public Boolean getIOQuickState(InputIOId ioid) throws AppException { + return priGetIOState(ioid, 50); + } + + + private Boolean priGetIOState(InputIOId ioid, long overtime) throws AppException { + if (ioid.mtype == ModuleType.Board) { + return a8KCanBusBaseDriver.callcmd(ioid.mid, CmdId.extboard_read_inio, overtime, ioid.ioIndex).getContentI32(0) != 0; + } else if (ioid.mtype == ModuleType.TMCStepMotor) { + return a8KCanBusBaseDriver.callcmd(ioid.mid, CmdId.step_motor_read_io_state, overtime, ioid.ioIndex).getContentI32(0) != 0; + } else if (ioid.mtype == ModuleType.MiniServo) { + return a8KCanBusBaseDriver.callcmd(ioid.mid, CmdId.mini_servo_read_io_state, overtime, ioid.ioIndex).getContentI32(0) != 0; + } else { + throw new AppException(new AECodeError(String.format("IOID MODULE TYPE %s NOT SUPPORT", ioid.mtype))); + } + } +} diff --git a/src/main/java/a8k/app/iflytophald/driver/MiniServoDriver.java b/src/main/java/a8k/app/iflytophald/driver/MiniServoDriver.java new file mode 100644 index 0000000..fb4657a --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/MiniServoDriver.java @@ -0,0 +1,218 @@ +package a8k.app.iflytophald.driver; + +import a8k.OS; +import a8k.app.constant.MiniServoConstant; +import a8k.app.client.iflytophald.type.protocol.*; +import a8k.app.iflytophald.type.protocol.*; +import a8k.app.type.error.AEHardwareError; +import a8k.app.type.exception.AppException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + + +@Component +@Slf4j +@RequiredArgsConstructor +public class MiniServoDriver { + final private A8kCanBusBaseDriver canBus; + + public void moduleStop(MiniServoMId id) throws AppException { + canBus.moduleStop(id.mid); + } + + public void miniServoEnable(MiniServoMId id, int enable) throws AppException { + log.debug("{} miniServoEnable {}", id.mid, enable); + callcmd(id.mid, CmdId.mini_servo_enable, enable); + } + + public void miniServoForceEnable(MiniServoMId id, int enable) { + try { + miniServoEnable(id, enable); + } catch (AppException e) { + log.error("miniServoForceEnable error", e); + } + } + + public Boolean miniServoPing(MiniServoMId id) { + try { + miniServoReadPos(id); + } catch (AppException e) { + return false; + } + return true; + } + + public int miniServoReadPos(MiniServoMId id) throws AppException { + var packet = callcmd(id.mid, CmdId.mini_servo_read_pos); + return packet.getContentI32(0); + } + + public void miniServoMoveToZeroBlock(MiniServoMId id) throws AppException { + log.debug("{} miniServoMoveToZeroBlock", id.mid); + miniServoMoveToBlock(id, MiniServoConstant.getZeroPos(id)); + } + + public void miniServoMoveToRefBlock(MiniServoMId id) throws AppException { + log.debug("{} miniServoMoveToRefBlock", id.mid); + miniServoMoveToBlock(id, MiniServoConstant.getRefPos(id)); + } + + + private void miniServoMoveTo(MiniServoMId id, int pos) throws AppException { + callcmd(id.mid, CmdId.mini_servo_move_to, pos); + } + + public void miniServoMoveToBlock(MiniServoMId id, int pos) throws AppException { + log.debug("{} miniServoMoveTo {}", id.mid, pos); + int retry = 0; + do { + try { + miniServoMoveTo(id, pos); + canBus.waitForMod(id.mid, MiniServoConstant.actionOvertime); + return; + } catch (AppException e) { + if (e.getError().code.equals(A8kEcode.LOW_ERROR_SUBDEVICE_OVERTIME)) { + log.warn("CALL miniServoMoveToBlock {} FAIL, SUB DEVICE OVERTIME", id); + if (retry > 3) { + throw e; + } + } else { + throw e; + } + } + OS.hsleep(1000); + retry++; + } while (true); + } + + + public void miniServoRotate(MiniServoMId id, int direction) throws AppException { + log.debug("{} miniServoRotate {}", id.mid, direction); + callcmd(id.mid, CmdId.mini_servo_rotate, direction); + } + + public void miniServoActiveCfg(MiniServoMId id) throws AppException { + callcmd(id.mid, CmdId.mini_servo_active_cfg); + } + + public void miniServoStop(MiniServoMId id) throws AppException { + callcmd(id.mid, CmdId.mini_servo_stop); + } + + public void miniServoSetMidPoint(MiniServoMId id) throws AppException { + callcmd(id.mid, CmdId.mini_servo_set_mid_point); + } + + public int miniServoReadIoState(MiniServoMId id) throws AppException { + var packet = callcmd(id.mid, CmdId.mini_servo_read_io_state); + return packet.getContentI32(0); + } + + public void miniServoRotateBlock(MiniServoMId id, int direction) throws AppException { + miniServoRotate(id, direction); + canBus.waitForMod(id.mid, MiniServoConstant.actionOvertime); + } + + public void miniServoRotateWithTorque(MiniServoMId id, int torque) throws AppException { + log.debug("{} miniServoRotateWithTorque {}", id.mid, torque); + callcmd(id.mid, CmdId.mini_servo_rotate_with_torque, torque); + } + + public void waitForMod(MiniServoMId mid) throws AppException { + canBus.waitForMod(mid.mid, MiniServoConstant.actionOvertime); + } + + public void waitForMod(MiniServoMId... mid) throws AppException { + for (MiniServoMId m : mid) { + waitForMod(m); + } + } + + + // kmini_servo_set_cur_pos + private void miniServoSetCurPos(MiniServoMId id, Integer pos) throws AppException { + log.debug("{} miniServoSetCurPos {}", id.mid, pos); + callcmd2(id.mid, CmdId.mini_servo_set_cur_pos, 5000L, pos); + } + + public Integer miniServoSetRefPos(MiniServoMId id) throws AppException { + miniServoSetCurPos(id, MiniServoConstant.getRefPos(id)); + return MiniServoConstant.getRefPos(id); + } + + public void setReg(MiniServoMId id, MiniServoRegIndex regindex, int val) throws AppException { + log.debug("{} setReg {} {}", id.mid, regindex, val); + canBus.moduleSetReg(id.mid, regindex.regIndex, val); + } + + public Integer getReg(MiniServoMId id, MiniServoRegIndex regindex) throws AppException { + return canBus.moduleGetReg(id.mid, regindex.regIndex); + } + + public Integer getRegNoEx(MiniServoMId id, MiniServoRegIndex regindex) { + try { + return canBus.moduleGetReg(id.mid, regindex.regIndex); + } catch (AppException e) { + log.error("readRegNoEx error", e); + return null; + } + } + + public void miniServoWaitIsNotMove(MiniServoMId id, int acitionOvertime) throws AppException { + long startedAt = OS.getMonotonicClockTimestamp(); + do { + var isMove = canBus.moduleGetReg(id.mid, RegIndex.kreg_mini_servo_is_move); + if (isMove != 0) { + break; + } + long now = OS.getMonotonicClockTimestamp(); + if (now - startedAt > acitionOvertime) { + throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, id.mid, null)); + } + + } while (true); + } + + private A8kPacket callcmd(MId id, CmdId cmdId, Integer... args) throws AppException { + int retry = 0; + do { + try { + return canBus.callcmd(id, cmdId, args); + } catch (AppException e) { + if (e.getError().code.equals(A8kEcode.LOW_ERROR_SUBDEVICE_OVERTIME)) { + log.warn("CALL CMD {} FAIL, SUB DEVICE OVERTIME", cmdId); + if (retry > 3) { + throw e; + } + } else { + throw e; + } + } + OS.hsleep(1000); + retry++; + } while (true); + } + + private A8kPacket callcmd2(MId id, CmdId cmdId, Long timeout, Integer... args) throws AppException { + int retry = 0; + do { + try { + return canBus.callcmd(id, cmdId, timeout, args); + } catch (AppException e) { + if (e.getError().code.equals(A8kEcode.LOW_ERROR_SUBDEVICE_OVERTIME)) { + log.warn("CALL CMD2 {} FAIL, SUB DEVICE OVERTIME", cmdId); + if (retry > 3) { + throw e; + } + } else { + throw e; + } + } + OS.hsleep(1000); + retry++; + } while (true); + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/driver/ModuleEnableCtrlDriver.java b/src/main/java/a8k/app/iflytophald/driver/ModuleEnableCtrlDriver.java new file mode 100644 index 0000000..aa95f5e --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/ModuleEnableCtrlDriver.java @@ -0,0 +1,169 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.type.protocol.StepMotorMId; +import a8k.app.type.exception.AppException; +import a8k.app.iflytophald.type.protocol.MId; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +@RequiredArgsConstructor +public class ModuleEnableCtrlDriver { + + private final HbotDriver hbotDriver; + private final PipetteCtrlDriverV2 pipetteCtrlDriver; + private final StepMotorCtrlDriver stepMotorCtrlDriver; + private final MiniServoDriver miniServoDriver; + private final A8kCanBusBaseDriver canBus; + + public void forceDisableAllMotor() { + // StepMotorMId.values() + for (StepMotorMId stepMotorMId : StepMotorMId.values()) { + try { + stepMotorCtrlDriver.stepMotorEnable(stepMotorMId, 0); + } catch (AppException e) { + log.info("disableStepMotor: {} failed, {}", stepMotorMId, e.getMessage()); + } + } + + for (MiniServoMId miniServoMId : MiniServoMId.values()) { + try { + miniServoDriver.miniServoEnable(miniServoMId, 0); + } catch (AppException e) { + log.info("disableMiniServo: {} failed, {}", miniServoMId, e.getMessage()); + } + } + + try { + hbotDriver.enable(0); + } catch (AppException e) { + log.info("hbotDriver disable failed, {}", e.getMessage()); + } + + try { + pipetteCtrlDriver.zMotorEnable(0); + } catch (AppException e) { + log.info("pipetteCtrlDriver: zMotorEnable failed, {}", e.getMessage()); + } + } + + public void stopAllMotor() 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 { + canBus.moduleStop(MId.IncubatorRotateCtrlM); + } catch (AppException ignored) { + } + + for (var motorId : StepMotorMId.values()) { + try { + stepMotorCtrlDriver.stepMotorEnable(motorId, 0); + } catch (AppException ignored) { + } + } + + for (var miniServoId : MiniServoMId.values()) { + try { + miniServoDriver.miniServoEnable(miniServoId, 0); + } catch (AppException ignored) { + } + } + + hbotDriver.enable(0); + pipetteCtrlDriver.zMotorEnable(0); + } + + + public void stopHeating() throws AppException { + canBus.moduleStop(MId.IncubatorTCM); + canBus.moduleStop(MId.PlatesBoxTCM); + } + + public void enableAllMotor() throws AppException { + try { + for (StepMotorMId stepMotorMId : StepMotorMId.values()) + stepMotorCtrlDriver.stepMotorEnable(stepMotorMId, 1); + + + for (MiniServoMId miniServoMId : MiniServoMId.values()) + miniServoDriver.miniServoEnable(miniServoMId, 1); + + hbotDriver.enable(1); + pipetteCtrlDriver.zMotorEnable(1); + } catch (AppException e) { + forceDisableAllMotor(); + throw e; + } + + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/driver/OptModuleDriver.java b/src/main/java/a8k/app/iflytophald/driver/OptModuleDriver.java new file mode 100644 index 0000000..6b20b9a --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/OptModuleDriver.java @@ -0,0 +1,126 @@ +package a8k.app.iflytophald.driver; + +import a8k.OS; +import a8k.app.factory.A8kPacketFactory; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.ModuleStatus; +import a8k.app.iflytophald.type.protocol.OptModuleRegIndex; +import a8k.app.type.error.AEHardwareError; +import a8k.app.type.exception.AppException; +import a8k.app.utils.ByteArrayUtils; +import a8k.app.utils.ZJsonNode; +import a8k.app.utils.ZList; +import com.fasterxml.jackson.databind.JsonNode; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Component +@Slf4j +public class OptModuleDriver { + public enum OptScanDirection { + FORWARD, //从左向右扫描 + BACKWARD; + + public Integer getInteger() { + return this == FORWARD ? 1 : -1; + } + } + + @Resource + A8kCanBusBaseDriver canBus; + + + void waittingForOptFinish(Integer overtime) throws AppException { + long startedAt = OS.getMonotonicClockTimestamp(); + + do { + var packet = A8kPacketFactory.buildCMDPacket(MId.OptMod.toInt(), CmdId.module_get_status.toInt(), ZList.of()); + ModuleStatus statu = null; + try { + statu = ModuleStatus.valueOf(canBus.send(packet, 50).getContentI32(0)); + } catch (Exception ignored) { + } + + + if (statu == null || statu == ModuleStatus.BUSY) { + log.info("Waitting for Opt Finish"); + } else if (statu == ModuleStatus.IDLE) { + log.info("Opt Finish"); + break; + } else if (statu == ModuleStatus.ERROR) { + throw AppException.of(new AEHardwareError(canBus.moduleGetError(MId.OptMod), MId.OptMod, CmdId.a8k_opt_v2_t_start_scan)); + } + + if (OS.getMonotonicClockTimestamp() - startedAt > overtime) { + throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_ACTION_OVERTIME, MId.OptMod, CmdId.a8k_opt_v2_t_start_scan)); + } + OS.forceSleep(100); + } while (true); + + } + + + public void optTStartScan(OptScanDirection scanDirection, Integer lasterGain, Integer scanGain) throws AppException { + log.info("OptTStartScan scanDirection:{} lasterGain:{} scanGain:{}", scanDirection, lasterGain, scanGain); + canBus.callcmd(MId.OptMod, CmdId.a8k_opt_v2_t_start_scan, scanDirection.getInteger(), lasterGain, scanGain); + //TODO: 2024-10-26 zhaohe,修改底层,光学结束上报一条完成事件 + long startedAt = OS.getMonotonicClockTimestamp(); + OS.forceSleep(100); + waittingForOptFinish(10 * 1000); + log.info("opt t scan use {}s", (OS.getMonotonicClockTimestamp() - startedAt) / 1000.0); + } + + public void optFStartScan(OptScanDirection scanDirection, Integer lasterGain, Integer scanGain) throws AppException { + log.info("OptFStartScan scanDirection:{} lasterGain:{} scanGain:{}", scanDirection, lasterGain, scanGain); + canBus.callcmd(MId.OptMod, CmdId.a8k_opt_v2_f_start_scan, scanDirection.getInteger(), lasterGain, scanGain); + //TODO: 2024-10-26 zhaohe,修改底层,光学结束上报一条完成事件 + long startedAt = OS.getMonotonicClockTimestamp(); + OS.forceSleep(100); + waittingForOptFinish(10 * 1000); + log.info("opt f scan use {}s", (OS.getMonotonicClockTimestamp() - startedAt) / 1000.0); + } + + public Integer[] optReadRaw() throws AppException { + int i = 0; + List result = new ArrayList<>(); + while (true) { + var rxPacket = canBus.callcmd(MId.OptMod, CmdId.a8k_opt_v2_read_raw, i++); + if (rxPacket.getCmdContent().length == 0) { + break; + } + var rawdata = ByteArrayUtils.readU16bitArray(rxPacket.getCmdContent()); + result.addAll(Arrays.asList(rawdata)); + } + return result.toArray(new Integer[0]); + } + + public Integer getReg(OptModuleRegIndex regIndex) throws AppException { + return canBus.moduleGetReg(MId.OptMod, regIndex.regIndex); + } + + public void setReg(OptModuleRegIndex regIndex, Integer value) throws AppException { + canBus.moduleSetReg(MId.OptMod, regIndex.regIndex, value); + } + + public JsonNode readAllRegJson() throws AppException { + ZJsonNode node = new ZJsonNode(); + for (OptModuleRegIndex reg : OptModuleRegIndex.values()) { + try { + Integer val = getReg(reg); + node.get(reg.name()).set(val); + } catch (AppException e) { + node.get(reg.name()).set(e.getError().code); + } + } + return node.get(); + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/driver/OutputIOCtrlDriver.java b/src/main/java/a8k/app/iflytophald/driver/OutputIOCtrlDriver.java new file mode 100644 index 0000000..241a4e8 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/OutputIOCtrlDriver.java @@ -0,0 +1,24 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.ModuleType; +import a8k.app.type.error.AECodeError; +import a8k.app.type.exception.AppException; +import a8k.app.iflytophald.type.protocol.OutputIOId; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class OutputIOCtrlDriver { + + private final A8kCanBusBaseDriver canBus; + + public void setIOState(OutputIOId outputIOId, Boolean state) throws AppException { + if (outputIOId.mtype == ModuleType.Board) { + canBus.callcmd(outputIOId.mid, CmdId.extboard_write_outio, outputIOId.ioIndex, state ? 1 : 0); + } else { + throw new AppException(new AECodeError("IOID MODULE TYPE %s NOT SUPPORT", outputIOId.mtype)); + } + } +} diff --git a/src/main/java/a8k/app/iflytophald/driver/PipetteCtrlDriverV2.java b/src/main/java/a8k/app/iflytophald/driver/PipetteCtrlDriverV2.java new file mode 100644 index 0000000..404a79d --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/PipetteCtrlDriverV2.java @@ -0,0 +1,666 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.client.iflytophald.type.protocol.*; +import a8k.app.iflytophald.type.protocol.pipette_module.DistribuAllParamId; +import a8k.app.iflytophald.type.protocol.pipette_module.PipetteConfig; +import a8k.app.iflytophald.type.protocol.pipette_module.PipetteStateIndex; +import a8k.app.client.iflytophald.type.protocol.pipette_module.cfg.*; +import a8k.app.client.iflytophald.type.protocol.pipette_module.cfgbean.*; +import a8k.app.client.iflytophald.type.protocol.pipette_module.cpyidx.*; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.*; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.*; +import a8k.app.iflytophald.type.protocol.pipette_module.param.AspirationParam; +import a8k.app.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; +import a8k.app.constant.ActionOvertimeConstant; +import a8k.app.iflytophald.type.protocol.pipette_module.AspirationParamId; +import a8k.app.iflytophald.type.protocol.*; +import a8k.app.iflytophald.type.protocol.pipette_module.cfgbean.*; +import a8k.app.type.exception.AppException; +import a8k.app.utils.ZJsonHelper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +@RequiredArgsConstructor +@Slf4j +public class PipetteCtrlDriverV2 { + private final A8kCanBusBaseDriver canBus; + private final ActionOvertimeConstant actionOvertimeConstant; + + public void moduleStop() throws AppException { + canBus.moduleStop(MId.PipetteMod); + } + + public ModuleStatus moduleGetStatus() throws AppException { + return canBus.moduleGetStatus(MId.PipetteMod); + } + + public A8kEcode moduleGetErrors() throws AppException { + return canBus.moduleGetError(MId.PipetteMod); + } + + public String moduleGetDetailStatus() throws AppException { + Integer code = canBus.moduleGetDetailError(MId.PipetteMod); + return String.format("0x%08X", code); + } + + public void setZMBCfg(ZMBasicConfigIndex index, Integer val) throws AppException { + log.info("setZMBCfg: index={}, val={}", index, val); + callcmd(MId.PipetteMod, CmdId.pipette_set_zmbcfg, index.toInteger(), val); + } + + public Integer getZMBCfg(ZMBasicConfigIndex index) throws AppException { + Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_zmbcfg, index.toInteger()).getContentI32(0); + log.info("getZMBCfg: index={} --> {}", index, ret); + return ret; + } + + public void setPMBCfg(PMBasicConfigIndex index, Integer val) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_set_pmbcfg, index.toInteger(), val); + } + + public Integer getPMBCfg(PMBasicConfigIndex index) throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_get_pmbcfg, index.toInteger()).getContentI32(0); + } + + /** + * 设置平台信息 + * + * @param cpyid 第几份 + * @param index 平台信息索引 + * @param val 值 + * @throws AppException 异常 + */ + public void setPlatInfo(Integer cpyid, PlatformInfoIndex index, Integer val) throws AppException { + log.info("setPlatInfo: cpyid={}, index={} , {}", cpyid, index, val); + callcmd(MId.PipetteMod, CmdId.pipette_set_platinfo, cpyid, index.toInteger(), val); + } + + /** + * 获取平台信息 + * + * @param cpyid 第几份 + * @param index 索引 + * @return 值 + * @throws AppException 异常 + */ + public Integer getPlatInfo(Integer cpyid, PlatformInfoIndex index) throws AppException { + Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_platinfo, cpyid, index.toInteger()).getContentI32(0); + log.info("getPlatInfo: cpyid={}, index={} --> {}", cpyid, index, ret); + return ret; + } + + /** + * 设置容器信息 + * + * @param cpyid 第几份 + * @param index 容器信息索引 + * @param val 值 + * @throws AppException 异常 + */ + public void setZMVCfg(ZMVCpyIdx cpyid, ZMVConfigIndex index, Integer val) throws AppException { + log.info("setZMVCfg: cpyid={}, index={} , {}", cpyid, index, val); + callcmd(MId.PipetteMod, CmdId.pipette_set_zmvcfg, cpyid.toInteger(), index.toInteger(), val); + } + + /** + * 获取容器信息 + * + * @param cpyid 第几份 + * @param index 索引 + * @return 值 + * @throws AppException 异常 + */ + public Integer getZMVCfg(ZMVCpyIdx cpyid, ZMVConfigIndex index) throws AppException { + Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_zmvcfg, cpyid.toInteger(), index.toInteger()).getContentI32(0); + log.info("getZMVCfg: cpyid={}, index={} --> {}", cpyid, index, ret); + return ret; + } + + /** + * 设置泵机速度 + * + * @param cpyid 第几份 + * @param index 泵机信息索引 + * @param val 值 + * @throws AppException 异常 + */ + public void setPMVCfg(PMVCpyIdx cpyid, PMVConfigIndex index, Integer val) throws AppException { + log.info("setPMVCfg: cpyid={}, index={} , {}", cpyid, index, val); + callcmd(MId.PipetteMod, CmdId.pipette_set_pmvcfg, cpyid.toInteger(), index.toInteger(), val); + } + + /** + * 获取泵机速度 + * + * @param cpyid 第几份 + * @param index 索引 + * @return 值 + * @throws AppException 异常 + */ + public Integer getPMVCfg(PMVCpyIdx cpyid, PMVConfigIndex index) throws AppException { + Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_pmvcfg, cpyid.toInteger(), index.toInteger()).getContentI32(0); + log.info("getPMVCfg: cpyid={}, index={} --> {}", cpyid, index, ret); + return ret; + } + + /** + * 设置容器信息 + * + * @param cpyid 第几份 + * @param index 容器信息索引 + * @param val 值 + * @throws AppException 异常 + */ + public void setContainerInfo(Integer cpyid, ContainerInfoIndex index, Integer val) throws AppException { + log.info("setContainerInfo: cpyid={}, index={} , {}", cpyid, index, val); + callcmd(MId.PipetteMod, CmdId.pipette_set_container_info, cpyid, index.toInteger(), val); + } + + public void setContainerInfo(ContainerCpyId cpyid, ContainerInfoIndex index, Integer val) throws AppException { + setContainerInfo(cpyid.toInteger(), index, val); + } + + /** + * 获取容器信息 + * + * @param cpyid 第几份 + * @param index 索引 + * @return 值 + * @throws AppException 异常 + */ + public Integer getContainerInfo(Integer cpyid, ContainerInfoIndex index) throws AppException { + Integer val = callcmd(MId.PipetteMod, CmdId.pipette_get_container_info, cpyid, index.toInteger()).getContentI32(0); + log.info("getContainerInfo: cpyid={}, index={} --> {}", cpyid, index, val); + return val; + + } + + public Integer getContainerInfo(ContainerCpyId cpyid, ContainerInfoIndex index) throws AppException { + return getContainerInfo(cpyid.toInteger(), index); + } + + /** + * 设置液体信息 + * + * @param cpyid 第几份 + * @param index 液体信息索引 + * @param val 值 + * @throws AppException 异常 + */ + public void setLiquidInfo(Integer cpyid, LiquidInfoIndex index, Integer val) throws AppException { + log.info("setLiquidInfo: cpyid={}, index={} , {}", cpyid, index, val); + callcmd(MId.PipetteMod, CmdId.pipette_set_liquid_info, cpyid, index.toInteger(), val); + } + + public void setLiquidInfo(LiquidConfigCpyIdx cpyid, LiquidInfoIndex index, Integer val) throws AppException { + setLiquidInfo(cpyid.toInteger(), index, val); + } + + public void setCommonConfig(PipetteCommonConfigIndex index, Integer val) throws AppException { + log.info("setCommonConfig: index={}, val={}", index, val); + callcmd(MId.PipetteMod, CmdId.pipette_set_common_cfg, index.toInteger(), val); + } + + public Integer getCommonConfig(PipetteCommonConfigIndex index) throws AppException { + Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_common_cfg, index.toInteger()).getContentI32(0); + log.info("getCommonConfig: index={} --> {}", index, ret); + return ret; + } + + /** + * 获取液体信息 + * + * @param cpyid 第几份 + * @param index 索引 + * @return 值 + * @throws AppException 异常 + */ + public Integer getLiquidInfo(Integer cpyid, LiquidInfoIndex index) throws AppException { + Integer ret = callcmd(MId.PipetteMod, CmdId.pipette_get_liquid_info, cpyid, index.toInteger()).getContentI32(0); + log.info("getLiquidInfo: cpyid={}, index={} --> {}", cpyid, index, ret); + return ret; + } + + public Integer getLiquidInfo(LiquidConfigCpyIdx cpyid, LiquidInfoIndex index) throws AppException { + return getLiquidInfo(cpyid.toInteger(), index); + } + + public Integer getPlatInfoMaxCpyId() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_get_platinfo_max_cpyid).getContentI32(0); + } + + public Integer getZMVCfgMaxCpyId() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_get_zmvcfg_max_cpyid).getContentI32(0); + } + + public Integer getPMVCfgMaxCpyId() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_get_pmvcfg_max_cpyid).getContentI32(0); + } + + public Integer getContainerInfoMaxCpyId() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_get_container_info_max_cpyid).getContentI32(0); + } + + // pipette_get_liquid_info_max_cpyid + public Integer getLiquidInfoMaxCpyId() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_get_liquid_info_max_cpyid).getContentI32(0); + } + + /*********************************************************************************************************************** + * Z轴控制 * + ***********************************************************************************************************************/ + + public void zMotorEnable(Integer enable) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_zmotor_enable, enable); + } + + public void zMotorMoveZeroBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_zero); + waitForMod(CmdId.pipette_zmotor_move_zero); + } + + public void zMotorMoveToZeroPointQuickBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_to_zero_point_quick); + waitForMod(CmdId.pipette_zmotor_move_to_zero_point_quick); + } + + public void zMotorMeasureDistance() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_zmotor_measure_distance); + waitForMod(CmdId.pipette_zmotor_measure_distance); + + } + + public Integer zMotorReadMeasureDistanceResult() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_measure_distance_result).getContentI32(0); + } + + public void zMotorMoveByBlock(Integer distance) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_by, distance); + waitForMod(CmdId.pipette_zmotor_move_by); + } + + public void zMotorMoveToBlock(Integer position) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_to, position); + waitForMod(CmdId.pipette_zmotor_move_to); + } + + public Boolean zMotorReadZeroPointState() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_zero_point_state).getContentI32(0) != 0; + } + + public Integer zMotorReadDevStatusCache() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_dev_status_cache).getContentI32(0); + } + + public Integer zMotorReadPos() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_pos).getContentI32(0); + } + + public Integer zMotorReadEncPos() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_zmotor_read_enc_pos).getContentI32(0); + } + // pipette_zmotor_move_to_tip_deposit + + public void zMotorMoveToTipDepositBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_zmotor_move_to_tip_deposit); + waitForMod(CmdId.pipette_zmotor_move_to_tip_deposit); + } + + // /*********************************************************************************************************************** + // * PUMP * + // ***********************************************************************************************************************/ + public void initPumpDeviceBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_init_device); + waitForMod(CmdId.pipette_pump_init_device); + } + + + public void takeTipBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_take_tip); + waitForMod(CmdId.pipette_pump_take_tip); + } + + public void depositTipBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_deposit_tip); + waitForMod(CmdId.pipette_pump_deposit_tip); + } + + public void putBakTipBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_putbak_tip); + waitForMod(CmdId.pipette_pump_putbak_tip); + } + + public void pierceThroughBlock(ContainerCpyId containerCpyId, Integer containerPos) throws AppException { + log.info("pierceThroughBlock: containerCpyId={}, containerPos={}", containerCpyId, containerPos); + callcmd(MId.PipetteMod, CmdId.pipette_pump_pierce_through, containerCpyId.toInteger(), containerPos); + waitForMod(CmdId.pipette_pump_pierce_through); + } + + public void aspirateSetParam(AspirationParamId param, Integer val) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_aspirate_set_param, param.toInteger(), val); + } + + public void aspirateSetParam(AspirationParam param) throws AppException { + log.info("aspirateSetParam :\n{}", ZJsonHelper.objToPrettyJson(param)); + param.serialization(this::aspirateSetParam); + } + + public void aspirateBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_aspirate); + waitForMod(CmdId.pipette_pump_aspirate); + } + + public void aspirateBlock(AspirationParam aspirationParam) throws AppException { + aspirateSetParam(aspirationParam); + aspirateBlock(); + } + + public void distributeAllSetParam(DistribuAllParamId param, Integer val) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_distribu_all_set_param, param.toInteger(), val); + } + + public void distributeAllSetParam(DistribuAllParam param) throws AppException { + log.info("distributeAllSetParam :\n{}", ZJsonHelper.objToPrettyJson(param)); + param.serialization(this::distributeAllSetParam); + } + + public void distributeAllBlock() throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_pump_distribu_all); + waitForMod(CmdId.pipette_pump_distribu_all); + } + + public void distributeAllBlock(DistribuAllParam distribuAllParam) throws AppException { + distributeAllSetParam(distribuAllParam); + distributeAllBlock(); + } + + public void pipetteTestPumpMoveToX100nl(Integer x100nl, Integer vcfgIndex) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_pump_move_to_x100nl, x100nl, vcfgIndex); + waitForMod(CmdId.pipette_test_pump_move_to_x100nl); + } + + public void pipetteTestLld(Integer containerPos, ContainerCpyId containerCpyId, LiquidConfigCpyIdx liquidCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_lld, containerPos, containerCpyId.toInteger(), liquidCpyId.toInteger()); + waitForMod(CmdId.pipette_test_lld); + } + + public void pipetteTestMoveToContainerBottom(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_container_bottom, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_container_bottom); + } + + public void pipetteTestMoveToContainerBottomSectionBegin(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_container_bottom_section_begin, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_container_bottom_section_begin); + } + + public void pipetteTestMoveToImmersionPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_immersion_pos, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_immersion_pos); + } + + public void pipetteTestMoveToLeavingHeightPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_leaving_height_pos, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_leaving_height_pos); + } + + public void pipetteTestMoveToJetPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_jet_pos, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_jet_pos); + } + + public void pipetteTestMoveToLldStartSearchPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_lld_start_search_pos, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_lld_start_search_pos); + } + + public void pipetteTestMoveToFixWaterLevelPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_fix_water_level_pos, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_fix_water_level_pos); + } + + public void pipetteTestMoveToPiercePos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_pierce_pos, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_pierce_pos); + } + + public void pipetteTestMoveToLldEndPos(Integer containerPos, ContainerCpyId containerCpyId) throws AppException { + callcmd(MId.PipetteMod, CmdId.pipette_test_move_to_lld_end_pos, containerPos, containerCpyId.toInteger()); + waitForMod(CmdId.pipette_test_move_to_lld_end_pos); + } + + /** + * 测试pipette模块的连接性 + * @throws AppException 连接异常 + * + * @Warning: 该指令超时时间过长, 除了在测试pipette模块连接性时, 请不要使用该指令 + */ + public void pipetteTestConnectivity() throws AppException { + canBus.callcmd(MId.PipetteMod, CmdId.pipette_test_connectivity, 2000L); + } + + public Integer readState(PipetteStateIndex index) throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_read_state, index.toInteger()).getContentI32(0); + } + + static public class PipetteGunConnectivityTestReport { + public Boolean io1Connected; + public Boolean uart232Connected; + public Boolean uart485Connected; + } + + public PipetteGunConnectivityTestReport readPipetteConnectedState() throws AppException { + Integer io1_connected = readState(PipetteStateIndex.testPipetteIo1Connected); + Integer uart232_connected = readState(PipetteStateIndex.testPipetteUart232Connected); + Integer uart485_connected = readState(PipetteStateIndex.testPipetteUart485Connected); + + PipetteGunConnectivityTestReport report = new PipetteGunConnectivityTestReport(); + report.io1Connected = io1_connected == 1; + report.uart232Connected = uart232_connected == 1; + report.uart485Connected = uart485_connected == 1; + return report; + } + + + public Boolean readTipState() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_read_tip_state).getContentI32(0) != 0; + } + + public Integer readPressure() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_read_pressure).getContentI32(0); + } + + public Integer readCapacitance() throws AppException { + return callcmd(MId.PipetteMod, CmdId.pipette_read_capacitance).getContentI32(0); + } + + + public List getAspPressureData() throws AppException { + List pressuredata = new ArrayList<>(); + for (int i = 0; ; i++) { + A8kPacket packet = callcmd(MId.PipetteMod, CmdId.pipette_get_asp_pressure_data, i); + if (packet.getDataLen() == 0) { + break; + } + var content = packet.getContentI16Array(); + for (Integer val : content) { + pressuredata.add(val); + } + } + return pressuredata; + } + + + // + // UTILS + // + private A8kPacket callcmd(MId moduleId, CmdId cmdId, Integer... param) throws AppException { + return canBus.callcmd(moduleId, cmdId, param); + } + + private void waitForMod(CmdId action) throws AppException { + canBus.waitForMod(MId.PipetteMod, actionOvertimeConstant.get(MId.PipetteMod, action)); + } + + + // + // Config + // + public void setLiquidInfo(LiquidConfigCpyIdx cpyIdx, PipetteLiquidInfo val) throws AppException { + if (val == null) { + log.error("setLiquidInfo val is null"); + return; + } + val.serialization((index, itermVal) -> setLiquidInfo(cpyIdx.toInteger(), index, itermVal)); + } + + public PipetteLiquidInfo getLiquidInfo(LiquidConfigCpyIdx cpyIdx) throws AppException { + return PipetteLiquidInfo.build((LiquidInfoIndex index) -> getLiquidInfo(cpyIdx.toInteger(), index)); + } + + public void applyPlatInfo(Integer cpyIdx, PipettePlatInfo val) throws AppException { + if (val == null) { + log.error("applyPlatInfo val is null"); + return; + } + val.serialization((index, itermVal) -> setPlatInfo(cpyIdx, index, itermVal)); + } + + public PipettePlatInfo getPlatInfo(Integer cpyIdx) throws AppException { + return PipettePlatInfo.build((PlatformInfoIndex index) -> getPlatInfo(cpyIdx, index)); + } + + public void setContainerInfo(ContainerCpyId cpyIdx, PipetteContainerInfo val) throws AppException { + if (val == null) { + log.error("setContainerInfo val is null"); + return; + } + val.serialization((index, itermVal) -> setContainerInfo(cpyIdx.toInteger(), index, itermVal)); + } + + public PipetteContainerInfo getContainerInfo(ContainerCpyId cpyIdx) throws AppException { + return PipetteContainerInfo.build((ContainerInfoIndex index) -> getContainerInfo(cpyIdx.toInteger(), index)); + } + + + public void setPMVCfg(PMVCpyIdx idx, PipettePMVCfg val) throws AppException { + if (val == null) { + log.error("setPMVCfg val is null"); + return; + } + val.serialization((index, itermVal) -> setPMVCfg(idx, index, itermVal)); + } + + public PipettePMVCfg getPMVCfg(PMVCpyIdx idx) throws AppException { + return PipettePMVCfg.build((PMVConfigIndex index) -> getPMVCfg(idx, index)); + } + + public void setZMBCfg(PipetteZMBCfg val) throws AppException { + if (val == null) { + log.error("setZMBCfg val is null"); + return; + } + val.serialization(this::setZMBCfg); + } + + public PipetteZMBCfg getZMBCfg() throws AppException { + return PipetteZMBCfg.build(this::getZMBCfg); + } + + + public void setZMVCfg(ZMVCpyIdx idx, PipetteZMVCfg val) throws AppException { + if (val == null) { + log.error("setZMVCfg val is null"); + return; + } + val.serialization((index, itermVal) -> setZMVCfg(idx, index, itermVal)); + } + + public PipetteZMVCfg getZMVCfg(ZMVCpyIdx idx) throws AppException { + return PipetteZMVCfg.build((ZMVConfigIndex index) -> getZMVCfg(idx, index)); + } + + public void setCommonConfig(PipetteCommonConfig val) throws AppException { + if (val == null) { + log.error("setCommonConfig val is null"); + return; + } + val.serialization(this::setCommonConfig); + } + + public PipetteCommonConfig getCommonConfig() throws AppException { + return PipetteCommonConfig.build(this::getCommonConfig); + } + + public PipetteConfig getConfig() throws AppException { + PipetteConfig cfg = new PipetteConfig(); + cfg.zmBCfgs = getZMBCfg(); + cfg.commonCfg = getCommonConfig(); + + for (int i = 0; i < PlatInfoCpyIdx.values().length; i++) { + cfg.platInfos.add(getPlatInfo(i)); + } + for (int i = 0; i < ContainerCpyId.values().length; i++) { + if (ContainerCpyId.values()[i].equals(ContainerCpyId.NotSet)) + continue; + cfg.containerInfos.add(getContainerInfo(ContainerCpyId.values()[i])); + } + for (int i = 0; i < LiquidConfigCpyIdx.values().length; i++) { + if (LiquidConfigCpyIdx.values()[i].equals(LiquidConfigCpyIdx.NotSet)) + continue; + cfg.liquidInfos.add(getLiquidInfo(LiquidConfigCpyIdx.values()[i])); + } + for (int i = 0; i < ZMVCpyIdx.values().length; i++) { + if (ZMVCpyIdx.values()[i].equals(ZMVCpyIdx.NotSet)) + continue; + cfg.zmVCfgs.add(getZMVCfg(ZMVCpyIdx.values()[i])); + } + for (int i = 0; i < PMVCpyIdx.values().length; i++) { + if (PMVCpyIdx.values()[i].equals(PMVCpyIdx.NotSet)) + continue; + cfg.pmVCfgs.add(getPMVCfg(PMVCpyIdx.values()[i])); + } + return cfg; + } + + public void setConfig(PipetteConfig cfg) throws AppException { + if (cfg == null) { + log.error("updateConfig cfg is null"); + return; + } + Long start = System.currentTimeMillis(); + setZMBCfg(cfg.zmBCfgs); + setCommonConfig(cfg.commonCfg); + for (int i = 0; i < cfg.platInfos.size(); i++) { + applyPlatInfo(i, cfg.platInfos.get(i)); + } + for (int i = 0; i < cfg.containerInfos.size(); i++) { + if (ContainerCpyId.values()[i].equals(ContainerCpyId.NotSet)) + break; + setContainerInfo(ContainerCpyId.values()[i], cfg.containerInfos.get(i)); + } + for (int i = 0; i < cfg.liquidInfos.size(); i++) { + if (LiquidConfigCpyIdx.values()[i].equals(LiquidConfigCpyIdx.NotSet)) + break; + setLiquidInfo(LiquidConfigCpyIdx.values()[i], cfg.liquidInfos.get(i)); + } + for (int i = 0; i < cfg.zmVCfgs.size(); i++) { + if (ZMVCpyIdx.values()[i].equals(ZMVCpyIdx.NotSet)) + break; + setZMVCfg(ZMVCpyIdx.values()[i], cfg.zmVCfgs.get(i)); + } + for (int i = 0; i < cfg.pmVCfgs.size(); i++) { + if (PMVCpyIdx.values()[i].equals(PMVCpyIdx.NotSet)) + break; + setPMVCfg(PMVCpyIdx.values()[i], cfg.pmVCfgs.get(i)); + } + + log.info("sync config to pipette module completed, cost {} ms", System.currentTimeMillis() - start); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/driver/StepMotorCtrlDriver.java b/src/main/java/a8k/app/iflytophald/driver/StepMotorCtrlDriver.java new file mode 100644 index 0000000..647924b --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/StepMotorCtrlDriver.java @@ -0,0 +1,230 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.constant.ActionOvertimeConstant; +import a8k.app.client.iflytophald.type.protocol.*; +import a8k.app.iflytophald.type.protocol.*; +import a8k.app.type.exception.AppException; +import a8k.app.utils.ZJsonHelper; +import a8k.iflyutils.BitUtils; +import com.fasterxml.jackson.databind.node.ObjectNode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +@Slf4j +public class StepMotorCtrlDriver { + + final private A8kCanBusBaseDriver canBus; + + private final ActionOvertimeConstant actionOvertimeConstant; + + public static class StepMotorErrorInfo { + public A8kEcode ecode; + + public Integer sgResult; + public Integer fsActive; + public Integer csActual; + public Integer stallGuard; + public Integer ot; + public Integer otpw; + public Integer s2ga; + public Integer s2gb; + public Integer ola; + public Integer olb; + public Integer stst; + + static StepMotorErrorInfo build(A8kEcode ecode, Integer detailEcode) throws AppException { + StepMotorErrorInfo errorInfo = new StepMotorErrorInfo(); + errorInfo.ecode = ecode; + int ioff = 0; + errorInfo.sgResult = BitUtils.getBitValueAsInt(detailEcode, ioff, 10); + ioff += 10; + ioff += 5; + errorInfo.fsActive = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.csActual = BitUtils.getBitValueAsInt(detailEcode, ioff, 5); + ioff += 5; + ioff += 3; + errorInfo.stallGuard = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.ot = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.otpw = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.s2ga = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.s2gb = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.ola = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.olb = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + ioff += 1; + errorInfo.stst = BitUtils.getBitValueAsInt(detailEcode, ioff, 1); + return errorInfo; + } + + public static void main(String[] args) { + } + } + + public StepMotorErrorInfo readErrorInfo(StepMotorMId mid) throws AppException { + A8kEcode ecode = canBus.moduleGetError(mid.mid); + Integer detailEcode = canBus.moduleGetDetailError(mid.mid); + return StepMotorErrorInfo.build(ecode, detailEcode); + } + + public void stepMotorEasyMoveBy(StepMotorMId id, Integer dpos) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_move_by, dpos); + } + + public void stepMotorEasyMoveTo(StepMotorMId id, Integer pos) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to, pos); + } + + public void stepMotorEasyMoveToZero(StepMotorMId id) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to_zero); + } + + public void setCurrentPos(StepMotorMId id, Integer pos) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_set_current_pos, pos); + } + + void stepMotorEasyMoveToZeroPointQuick(StepMotorMId id) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to_zero_point_quick); + } + + void stepMotorEasyMoveToEndPoint(StepMotorMId id) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_move_to_end_point); + } + + public void stepMotorEnable(StepMotorMId mid, Integer enable) throws AppException { + canBus.callcmd(mid.mid, CmdId.step_motor_enable, enable); + } + + public Integer stepMotorReadPos(StepMotorMId id) throws AppException { + A8kPacket packet = canBus.callcmd(id.mid, CmdId.step_motor_read_pos); + return packet.getContentI32(0); + } + + public Integer stepMotorReadEncPos(StepMotorMId id) throws AppException { + A8kPacket packet = canBus.callcmd(id.mid, CmdId.step_motor_read_enc_pos); + return packet.getContentI32(0); + } + + public void stepMotorEasyRotate(StepMotorMId id, Integer direction) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_rotate, direction); + } + + public void stepMotorEasyMoveByBlock(StepMotorMId id, Integer dpos) throws AppException { + log.debug("stepMotorEasyMoveByBlock {} {}", id, dpos); + stepMotorEasyMoveBy(id, dpos); + canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_by)); + } + + public void waitForMod(StepMotorMId id, Integer overtime) throws AppException { + canBus.waitForMod(id.mid, overtime); + } + + public void stepMotorEasyMoveToBlock(StepMotorMId id, Integer pos) throws AppException { + log.debug("stepMotorEasyMoveToBlock {} {}", id, pos); + stepMotorEasyMoveTo(id, pos); + canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to)); + } + + public void stepMotorEasyMoveToZeroBlock(StepMotorMId id) throws AppException { + log.debug("stepMotorEasyMoveToZeroBlock {}", id); + stepMotorEasyMoveToZero(id); + canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to_zero)); + } + + public Integer stepMotorReadPosByMoveToZeroBlock(StepMotorMId id) throws AppException { + stepMotorEnable(id, 1); + stepMotorEasyMoveToZeroBlock(id); + Integer nowpos = stepMotorReadPos(id); + Integer measurepos = -canBus.moduleGetReg(id.mid, RegIndex.kreg_step_motor_dpos) + nowpos; + stepMotorEnable(id, 0); + return measurepos; + } + + public void stepMotorEasyMoveToZeroPointQuickBlock(StepMotorMId id) throws AppException { + stepMotorEasyMoveToZeroPointQuick(id); + canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to_zero_point_quick)); + } + + public void stepMotorStop(StepMotorMId id) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_stop, 0); + } + + + // step_motor_move_by(0x021d, "STEP_MOTOR_MOVE_BY"), // (dpos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) + // step_motor_move_to(0x021e, "STEP_MOTOR_MOVE_TO"), // (pos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) + // step_motor_move_to_zero_point_quick(0x021f, "STEP_MOTOR_MOVE_TO_ZERO_POINT_QUICK"), // (speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) + // step_motor_rotate(0x0220, "STEP_MOTOR_ROTATE"), // + + public void moveByBlock(StepMotorMId id, Integer dpos, StepMotorSpeedLevel speedLevel) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_move_by, dpos, speedLevel.ordinal()); + waitForMod(id, actionOvertimeConstant.get(id, CmdId.step_motor_move_by)); + } + + public void moveToBlock(StepMotorMId id, Integer pos, StepMotorSpeedLevel speedLevel) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_move_to, pos, speedLevel.ordinal()); + waitForMod(id, actionOvertimeConstant.get(id, CmdId.step_motor_move_to)); + } + + public void moveToZeroQuickBlock(StepMotorMId id, StepMotorSpeedLevel speedLevel) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_move_to_zero_point_quick, speedLevel.ordinal()); + waitForMod(id, actionOvertimeConstant.get(id, CmdId.step_motor_move_to_zero_point_quick)); + } + + public void rotate(StepMotorMId id, Integer direction, StepMotorSpeedLevel speedLevel) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_rotate, direction, speedLevel.ordinal()); + + } + + public Boolean stepMotorReadIoState(StepMotorMId id, Integer ioindex) throws AppException { + var packet = canBus.callcmd(id.mid, CmdId.step_motor_read_io_state, ioindex); + return packet.getContentI32(0) != 0; + } + + public void stepMotorEasyMoveToEndPointBlock(StepMotorMId id) throws AppException { + stepMotorEasyMoveToEndPoint(id); + canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_move_to_end_point)); + } + + void stepMotorEasyReciprocatingMotion(StepMotorMId id, Integer startpos, Integer endpos, Integer times) throws AppException { + canBus.callcmd(id.mid, CmdId.step_motor_easy_reciprocating_motion, startpos, endpos, times); + } + + public void stepMotorEasyReciprocatingMotionBlock(StepMotorMId id, Integer startpos, Integer endpos, Integer times) throws AppException { + stepMotorEasyReciprocatingMotion(id, startpos, endpos, times); + canBus.waitForMod(id.mid, actionOvertimeConstant.get(id, CmdId.step_motor_easy_reciprocating_motion)); + } + + public Boolean isHasMoveToZero(StepMotorMId id) throws AppException { + return getReg(id, StepMotorRegIndex.kreg_step_motor_has_move_zero) != 0; + } + + public void setReg(StepMotorMId id, StepMotorRegIndex regIndex, Integer val) throws AppException { + canBus.moduleSetReg(id.mid, regIndex.regIndex, val); + } + + public Integer getReg(StepMotorMId id, StepMotorRegIndex regIndex) throws AppException { + return canBus.moduleGetReg(id.mid, regIndex.regIndex); + } + + public void resetRegs(StepMotorMId id) throws AppException { + canBus.callcmd(id.mid, CmdId.module_reset_reg); + } + + public Object getAllReg(StepMotorMId id) throws AppException { + ObjectNode node = ZJsonHelper.createObjectNode(); + for (StepMotorRegIndex regIndex : StepMotorRegIndex.values()) { + Integer regVal = getReg(id, regIndex); + log.debug("read reg {} -> {}", regIndex, regVal); + node.put(regIndex.name(), getReg(id, regIndex)); + } + return node; + } +} diff --git a/src/main/java/a8k/app/iflytophald/driver/WaterTemperatureControllerDriver.java b/src/main/java/a8k/app/iflytophald/driver/WaterTemperatureControllerDriver.java new file mode 100644 index 0000000..03c1e9c --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/driver/WaterTemperatureControllerDriver.java @@ -0,0 +1,103 @@ +package a8k.app.iflytophald.driver; + +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.TemperatureControlerMid; +import a8k.app.iflytophald.type.protocol.TemperatureControlerRegIndex; +import a8k.app.service.param.misc.TemperatureCtrlParamMgr; +import a8k.app.type.exception.AppException; +import a8k.app.type.param.TemperatureCtrlParam; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class WaterTemperatureControllerDriver { + @Resource + A8kCanBusBaseDriver canBus; + + Double incubatorTCMTempOffset = 0.0; + Double platesBoxTCMTempOffset = 0.0; + + @Resource + TemperatureCtrlParamMgr temperatureCtrlParamMgr; + + public void startCtrlTemperature(Double incubatorTemperature, Double platesBoxTemperature) throws AppException { + + incubatorTCMTempOffset = temperatureCtrlParamMgr.getParam(TemperatureCtrlParam.IncubatorTCMTempOffset); + platesBoxTCMTempOffset = temperatureCtrlParamMgr.getParam(TemperatureCtrlParam.PlatesBoxTCMTempOffset); + + Integer incubatorTCMSetTemp = (int) ((incubatorTemperature + incubatorTCMTempOffset) * 10); + Integer platesBoxTCMSetTemp = (int) ((platesBoxTemperature + platesBoxTCMTempOffset) * 10); + + log.info("startCtrlTemperature incubatorTCMSetTemp {}", incubatorTCMSetTemp); + log.info("startCtrlTemperature platesBoxTCMSetTemp {}", platesBoxTCMSetTemp); + + canBus.callcmd(TemperatureControlerMid.IncubatorTCM.mid, CmdId.temp_controler_start_hearting, incubatorTCMSetTemp); + canBus.callcmd(TemperatureControlerMid.PlatesBoxTCM.mid, CmdId.temp_controler_start_hearting, platesBoxTCMSetTemp); + } + + public void stopCtrlTemperature() throws AppException { + canBus.callcmd(TemperatureControlerMid.IncubatorTCM.mid, CmdId.temp_controler_stop_hearting); + canBus.callcmd(TemperatureControlerMid.PlatesBoxTCM.mid, CmdId.temp_controler_stop_hearting); + } + + public Double readIncubateBoxTemperature() throws AppException { + Integer readval = readReg(TemperatureControlerMid.IncubatorTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval); + Double readvalDouble = readval * 0.1; + return readvalDouble - incubatorTCMTempOffset; + } + + public Double readPlateBoxTemperature() throws AppException { + Integer readval = readReg(TemperatureControlerMid.PlatesBoxTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval); + Double readvalDouble = readval * 0.1; + return readvalDouble - platesBoxTCMTempOffset; + } + + + public void startCtrlTemperature(TemperatureControlerMid mid, Double temperature) throws AppException { + Integer setTemp = (int) ((temperature) * 10); + canBus.callcmd(mid.mid, CmdId.temp_controler_start_hearting, setTemp); + } + + public void stopCtrlTemperature(TemperatureControlerMid mid) throws AppException { + canBus.callcmd(mid.mid, CmdId.temp_controler_stop_hearting); + } + + public void setPeltierPower(TemperatureControlerMid mid, Integer val0To100) throws AppException { + canBus.callcmd(mid.mid, CmdId.temp_controler_set_peltier_power_level, val0To100); + } + + public void setCtrlFanLevel(TemperatureControlerMid mid, Integer val0To100) throws AppException { + canBus.callcmd(mid.mid, CmdId.temp_controler_set_fan_level, val0To100); + } + + public void setWaterPumpSpeed(TemperatureControlerMid mid, Integer val0To100) throws AppException { + canBus.callcmd(mid.mid, CmdId.temp_controler_set_pump_level, val0To100); + } + + public Double readFeedbakTemperature(TemperatureControlerMid mid) throws AppException { + Integer readval = readReg(mid, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval); + return readval * 0.1; + } + + + public Integer readIncubateBoxPWMOutput() throws AppException { + return readReg(TemperatureControlerMid.IncubatorTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_nowoutput); + } + + public Integer readPlateBoxPWMOutput() throws AppException { + return readReg(TemperatureControlerMid.PlatesBoxTCM, TemperatureControlerRegIndex.kreg_water_cooling_tmp_controler_pid_nowoutput); + } + + + public Integer readReg(TemperatureControlerMid mid, TemperatureControlerRegIndex regIndex) throws AppException { + return canBus.moduleGetReg(mid.mid, regIndex.regIndex); + } + + public void setReg(TemperatureControlerMid mid, TemperatureControlerRegIndex regIndex, Integer val) throws AppException { + canBus.moduleSetReg(mid.mid, regIndex.regIndex, val); + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/type/channelctrl/IflytophaldResponse.java b/src/main/java/a8k/app/iflytophald/type/channelctrl/IflytophaldResponse.java new file mode 100644 index 0000000..f06e48c --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/channelctrl/IflytophaldResponse.java @@ -0,0 +1,8 @@ +package a8k.app.iflytophald.type.channelctrl; + +public class IflytophaldResponse { + public Integer status; + public String msg; + public T data; + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/A8kEcode.java b/src/main/java/a8k/app/iflytophald/type/protocol/A8kEcode.java new file mode 100644 index 0000000..8e44ab0 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/A8kEcode.java @@ -0,0 +1,277 @@ +package a8k.app.iflytophald.type.protocol; + +import lombok.extern.slf4j.Slf4j; + +/** + * 错误分类 + * 10, + * 为代码错误,代码没有BUG的情况下,这个错误时不会出现的,前端打印出错误,和错误携带的栈信息,方便产品维护时,非程序员能够提供详细的错误的信息。 + * + * + * + * + * + */ +@Slf4j +public enum A8kEcode { + + SUC(0), + // + // 代码错误,代码没有BUG的情况下,前端直接打印错误信息和栈信息即可 + // + CODEERROR(10), //代码错误 + ERROR_WORK_MODE(11), //工作模式错误 + ZAPP_INTERRUPT_EXCEPTION(12), + ERROR_OPERATION(13), //操作错误 + IP_FORMAT_ERROR(14), //IP地址格式错误 + SHUTDOWN_ERROR_DEVICE_IS_WORKING(15), //设备正在工作中,不允许关机 + LOGIN_OUT_ERROR_DEVICE_IS_WORKING(16), //设备正在工作中,不允许退出登录 + DEVICE_IS_BUSY(17), //设备正在工作中,不允许操作 + SYS_EXCEPTION(18), //系统异常 + DEVICE_NOT_INIT(19), //设备未初始化 + APPE_PAUSE_OPERATION_NOT_SUPPORT_IN_ENGINEER_TASK(20), // + APPE_CONTINUE_OPERATION_NOT_SUPPORT_IN_ENGINEER_TASK(21), // + APPE_WAST_BIN_IS_FULL(22), //废料箱已满 + SYS_CMD_EXEC_OVERTIME(23), //Linux命令执行超时 + NETWORK_PARAMETER_ERROR(24), //网络参数错误 + + LIS_LOST_CONNECTION(25), //LIS连接错误 + LIS_REPORT_RECORD_FAIL(26), //Lis报告记录失败 + LIS_REQUEST_SAMPLE_INFO_FAIL(27), //Lis请求样本信息失败 + LIS_REQUEST_SAMPLE_INFO_PARSE_RESPONSE_FAIL(28), //Lis请求样本信息失败 + LIS_SAMPLE_TYPE_NOT_SUPPORT(29), //Lis样本类型不支持 + + + // + // 参数错误 + // + PE_PARAM_OUT_OF_RANGE(100),//参数超出范围 + // + // 用户错误 + // + USR_ALREADY_EXIST(110),//用户已存在 + USR_NOT_EXIT(111), //用户不存在 + USR_PASSWORD_ERROR(112),//用户密码错误 + USR_PASSWORD_IS_EMPTY(113),//用户密码为空 + USR_OLD_PASSWORD_ERROR(114),//用户旧密码错误 + + // + // ID卡错误 + // + APPE_A8K_ID_CARD_NOT_MOUNTED(120), //ID卡未挂载 + // + // 试管配置管理服务相关错误码 + // + APPE_TUBE_HOLDER_SETTING_IS_LOCKED(130),//试管架设置被锁定,已锁定的,说明当前后台正在使用这个配置,是不允许修改 + APPE_TUBEHOLDER_SETTING_ERROR(131), //试管架配置错误 + + // + // 急诊错误 + // + APPE_EMERGENCY_SAMPLE_IS_PROCESSING(141), //添加急诊样本失败,急诊样本还没有处理完成 (这个错误发生在前端,没有做好状态检测) + APPE_ADD_EMERGENCY_ACTION_IS_NOT_ALLOWED_WHEN_WORKING(142),//添加急诊样本失败,设备正在运行中 (这个错误发生在前端,没有做好状态检测) + // + // 设备操作操作 + // + APPE_DEVICE_IS_IN_FATAL_ERROR(150),//设备处于严重错误,请关机后重启设备进行恢复 + APPE_DEVICE_INIT_CHECK_FAIL(151),//设备初始化检查失败 + + APPE_DO_ACTION_FAIL_DEVICE_IS_WORKING(152),//设备正在工作中,不允许执行操作 + APPE_CONSUMABLES_IS_IN_USE_NOT_ALLOW_UNSTALL(153),//耗材正在使用中,不允许卸载 + + DEVICE_STARTUP_IN_PROGRESS(154), // 设备启动中,请稍后 + // + // 业务流程中的错误 + // 1. 点击开始运行后,设备在运行过程中出现的错误 + // 2. 下面错误,中文情况下,直接显示注释信息即可 + // + //扫描耗材错误 + APPE_NO_UNINSTALLED_CONSUMABLE(160),//没有未安装的耗材 + + + APPE_TIP_G1_SETTING_NUM_MISMATCH_ERROR(161),//Tip设置数量错误 + APPE_TIP_G2_SETTING_NUM_MISMATCH_ERROR(162),//Tip设置数量错误 + APPE_TIP_G3_SETTING_NUM_MISMATCH_ERROR(163),//Tip设置数量错误 + + APPE_INACTIVE_TUBEHOLDER_SETTING_EXISTS(164),//有试管架配置未激活 + + + //入料阶段错误 + APPE_SCAN_TUBEHOLDER_TYPE_TIMEOUT(200),//扫描试管架类型超时 + APPE_TUBE_HOLDER_TYPE_IS_NOT_SUPPORT(201),//试管架类型不支持 + APPE_INFEED_OVERTIME_FAIL(202),//入料超时失败 + APPE_TUBEHOLDER_IS_EMPTY(203),//试管架中没有试管 + + //样本处理过程中的错误 + APPE_PUT_TIP_FAIL(210),//丢弃Tip失败 + APPE_TAKE_TIP_FAIL(211),//取Tip失败 + APPE_DETECT_SAMPLE_FAIL(212),// 检测样本失败 + APPE_TAKE_LARGE_BUFFER_LIQUID_FAIL(213),//取大瓶缓冲液失败 + APPE_TAKE_SAMPLE_FAIL(214),//取大瓶缓冲液失败 + + + //出料阶段错误 + APPE_EJECT_TUBEHOLDER_TIMEOUT(220),//弹出试管架超时 + APPE_NO_TUBE_IN_HOLDER(221),//试管架中没有试管 + APPE_CONSUME_NOT_ENOUGH(222),//耗材不足 + APPE_TIP_NOT_ENOUGH(223),//tip不足 + APPE_ROLLBACK_TUBEHOLDER_TIMEOUT(224),//回滚试管架超时 + + APPE_OUTFEED_AREA_IS_FULL(225),//出料区满 + + + //运行中的公用错误 + APPE_A8K_PROJ_CARD_PARSE_ERROR(300), //ID卡解析错误 + APPE_A8K_PROJ_CARD_EXPIRYED(301), //ID卡过期 + APPE_A8K_PROJ_ID_IS_EMPTY(302), //项目ID为空 + PROJ_CARD_ERROR_WRONG_UNSUPPORTED(303), //项目不支持 + APPE_PULLER_MOTOR_INIT_POS_ERROR(305), //初始化阶段,拉板电机没有处于零点位置 + APPE_PUSHER_MOTOR_INIT_POS_ERROR(306), //初始化阶段,推板电机没有处于零点位置 + APPE_PLATE_STUCK_DETECTOR_SENSOR_TRIGGER(307), //卡板检测传感器触发 + APPE_TUBE_X_CHANNEL_IS_NOT_EMPTY(308), //试管架通道有异物 + APPE_PLATE_BOX_NOT_COVER(309), //板夹仓未盖 + APPE_DEVICE_NOT_INITED(310), //设备未初始化 + APPE_SHAKE_MODULE_CLAMPM_NOT_IN_ZERO_POS(311), //摇匀模组夹紧模块没有在零点位置 + APPE_INCUBATION_PLATE_OUTLET_STUCK_DETECTOR_SENSOR_IS_TRIGGER(312), //孵育板出料口卡板检测传感器触发 + APPE_INCUBATION_PLATE_INLET_STUCK_DETECTOR_SENSOR_IS_TRIGGER(313), //孵育板入料口卡板检测传感器触发 + APPE_DEVICE_IS_WORKING(314), //设备正在工作中,不允许执行操作 + + + // + // ID卡检验错误 + // + PROJ_CARD_ERROR_EXPIRYED(500),//ID卡验证错误,过期 + PROJ_CARD_ERROR_WRONG_FUNCTION_NUM(500),//ID卡验证错误,函数数量错误 + PROJ_CARD_ERROR_WRONG_OPT_NUM(500),//ID卡验证错误,光学数量错误 + PROJ_CARD_ERROR_WRONG_FUNCTION_X_TYPE(500),//ID卡验证错误,公式X类型错误 + PROJ_CARD_ERROR_WRONG_FUNCTION_JUDGE_X_TYPE(500),//ID卡验证错误,公式X类型错误 + PROJ_CARD_ERROR_WRONG_FUNCTION_L_X_TYPE(500),//ID卡验证错误,公式X类型错误 + PROJ_CARD_ERROR_WRONG_FUNCTION_H_X_TYPE(500),//ID卡验证错误,公式X类型错误 + PROJ_CARD_ERROR_WRONG_FUNCTION_X_SCOPE(500),//ID卡验证错误,公式X的范围错误 + PROJ_CARD_ERROR_WRONG_FUNCTION_LIMIT_SCOPE(500),//ID卡验证错误,光学数量错误 + PROJ_CARD_ERROR_WRONG_FUNCTION_TYPE(500),//ID卡验证错误,公式类型错误 + + PROJ_CARD_ERROR_WRONG_RESULT_UNIT_TYPE(500),//ID卡验证错误,Unit类型错误 + PROJ_CARD_ERROR_WRONG_RESULT_UNIT2_COEFFICIENT(500),//ID卡验证错误,Unit2转换系数错误 + PROJ_CARD_ERROR_WRONG_RESULT_UNIT3_COEFFICIENT(500),//ID卡验证错误,Unit3转换系数错误 + + // PROJ_CARD_ERROR_WRONG_UNSUPPORTED(520),//ID卡验证错误,不支持的ID卡 + PROJ_CARD_ERROR_BUILD_IN_PROJ_INFO_ERROR(521),//ID卡验证错误,内置项目信息错误 + PROJ_CARD_ERROR_ID_CARD_VERSION_IS_LOWER_THAN_STORED(522),//ID卡验证错误,ID卡版本低于存储的版本 + + + // + // LowBoard 底层错误,直接打印错误英文 + // + LOW_ERROR_HARDWARE_ERROR_START(1000), + LOW_ERROR_BOARD_COMMON_ERROR(1001), + LOW_ERROR_PARAM_OUT_OF_RANGE(1102), + LOW_ERROR_CMD_NOT_SUPPORT(1103), + LOW_ERROR_DEVICE_IS_BUSY(1104), + LOW_ERROR_DEVICE_IS_OFFLINE(1105), + LOW_ERROR_OVERTIME(1106), + LOW_ERROR_NO_ACK(1107), + LOW_ERROR_ERROR_ACK(1108), + LOW_ERROR_DEVICE_OFFLINE(1109), + LOW_ERROR_SUBDEVICE_OVERTIME(1111), + LOW_ERROR_BUFFER_NOT_ENOUGH(1112), + LOW_ERROR_CMD_PARAM_NUM_ERROR(1114), + LOW_ERROR_CHECKCODE_IS_ERROR(1115), + LOW_ERROR_ILLEGAL_OPERATION(1116), + LOW_ERROR_ACTION_OVERTIME(1117), + LOW_ERROR_MODULE_OPERATION_BREAK_BY_USER(1202), + LOW_ERROR_MODULE_NOT_FIND_REG(1207), + LOW_ERROR_XYMOTOR_X_FIND_ZERO_EDGE_FAIL(1306), + LOW_ERROR_XYMOTOR_Y_FIND_ZERO_EDGE_FAIL(1307), + LOW_ERROR_XYMOTOR_NOT_ENABLE(1308), + LOW_ERROR_XYMOTOR_TARGET_POS_OUT_OF_RANGE(1309), + LOW_ERROR_XYMOTOR_NOT_MOVE_TO_ZERO(1310), + LOW_ERROR_PIPETTE_ERROR_NO_ERROR(1400), + LOW_ERROR_PIPETTE_ERROR_INIT_FAIL(1401), + LOW_ERROR_PIPETTE_ERROR_INVALID_CMD(1402), + LOW_ERROR_PIPETTE_ERROR_INVALID_ARG(1403), + LOW_ERROR_PIPETTE_ERROR_PRESSURE_SENSOR_ERROR(1404), + LOW_ERROR_PIPETTE_ERROR_OVER_PRESSURE(1405), + LOW_ERROR_PIPETTE_ERROR_LLD_ERROR(1406), //一般为lld时移液枪吸液过快,导致很快到达最大行程 + LOW_ERROR_PIPETTE_ERROR_DEVICE_NOT_INIT(1407), + LOW_ERROR_PIPETTE_ERROR_TIP_POP_ERROR(1408), + LOW_ERROR_PIPETTE_ERROR_PUMP_OVERLOAD(1409), + LOW_ERROR_PIPETTE_ERROR_TIP_DROP(1410), + LOW_ERROR_PIPETTE_ERROR_CAN_BUS_ERROR(1411), + LOW_ERROR_PIPETTE_ERROR_INVALID_CHECKSUM(1412), + LOW_ERROR_PIPETTE_ERROR_EEPROM_ERROR(1413), + LOW_ERROR_PIPETTE_ERROR_CMD_BUFFER_EMPTY(1414), + LOW_ERROR_PIPETTE_ERROR_CMD_BUFFER_OVERFLOW(1415), + LOW_ERROR_PIPETTE_ERROR_TIP_BLOCK(1416), + LOW_ERROR_PIPETTE_ERROR_AIR_SUCTION(1417), + LOW_ERROR_PIPETTE_ERROR_BUBBLE(1418), + LOW_ERROR_PIPETTE_ERROR_VOLUME_ERROR(1419), + LOW_ERROR_PIPETTE_ERROR_TIP_ALREADY_LOAD(1420), + LOW_ERROR_PIPETTE_ERROR_TIP_LOAD_FAIL(1421), + LOW_ERROR_PIPETTE_ERROR_NO_TIP_WHEN_LLD(1422), + + LOW_ERROR_PIPETTE_ERROR_TIPISLOAD_WHEN_LLD_PREPARE(1500), + LOW_ERROR_PIPETTE_ERROR_UNINITIALIZED(1501), + LOW_ERROR_PIPETTE_ERROR_NOT_LLD_PREPARE(1502), + LOW_ERROR_PIPETTE_ERROR_PUMP_LOAD_VAL_IS_NOT_EMPTY(1503), + LOW_ERROR_PIPETTE_LLD_ERROR_NO_LIQUID_DETECTED(1504), + LOW_ERROR_PIPETTE_LLD_ERROR_PUMP_REACH_MAX_POS(1505), + LOW_ERROR_PIPETTE_PM_POSITIONING_ABNORMALITY(1506), // 电机定位异常 + LOW_ERROR_PIPETTE_NO_LIQUID_IN_IT(1507), // 泵内无液体 + + + LOW_ERROR_STEP_MOTOR_NOT_FOUND_ZERO_POINT(1600), + LOW_ERROR_STEP_MOTOR_NOT_GO_ZERO(1601), + LOW_ERROR_STEP_MOTOR_OVER_TEMPERATURE(1602), + LOW_ERROR_STEP_MOTOR_OVER_VOLTAGE(1603), + LOW_ERROR_STEP_MOTOR_RUN_OVERTIME(1604), + LOW_ERROR_STEP_MOTOR_NOT_ENABLE(1605), + LOW_ERROR_STEP_MOTOR_IO_INDEX_OUT_OF_RANGE(1606), + LOW_ERROR_STEP_MOTOR_SUBIC_RESET(1607), + LOW_ERROR_STEP_MOTOR_DRV_ERR(1608), + LOW_ERROR_STEP_MOTOR_UV_CP(1609), + LOW_ERROR_STEP_MOTOR_NOT_FOUND_POINT_EDGE(1610), + LOW_ERROR_STEP_MOTOR_LOST_STEP(1611), + LOW_ERROR_STEP_MOTOR_NOT_MOVE_TO_ZERO(1612), + LOW_ERROR_STEP_MOTOR_OT(1613), + LOW_ERROR_STEP_MOTOR_OTPW(1614), + LOW_ERROR_STEP_MOTOR_S2GA(1615), + LOW_ERROR_STEP_MOTOR_S2GB(1616), + LOW_ERROR_STEP_MOTOR_OLA(1617), + LOW_ERROR_STEP_MOTOR_OLB(1618), + LOW_ERROR_MINI_SERVO_NOT_ENABLE(1700), + LOW_ERROR_MINI_SERVO_MODE_NOT_SUPPORT(1701), + LOW_ERROR_FAN_HARDWARE_FAULT(1800), + LOW_ERROR_WATER_COOLING_FAN_ERROR(1900), + LOW_ERROR_WATER_COOLING_TEMPERATURE_SENSOR_ERROR(1902), + LOW_ERROR_WATER_COOLING_PUMP_IS_ERROR(1903), + LOW_ERROR_WATER_COOLING_PELTER_IS_ERROR(1904), + // + // 底层扩展错误码,由java定义 + // + LOW_EXT_ERROR_UNKNOWN_INDEX_ERROR(5000), //代码错误,未知错误 + LOW_EXT_ERROR_CMD_NOT_SUPPORT(5001), //代码错误,未知错误 + LOW_EXT_ERROR_MOTOR_AT_WRONG_POS(5002),//电机在错误的位置 + ; + + public final int index; + public int rawindex = 0; + + A8kEcode(int index) { + this.index = index; + } + + + static public A8kEcode fromInt(int index) { + for (var e : A8kEcode.values()) { + if (e.index == index) { + return e; + } + } + log.error("未知错误码:{}", index); + A8kEcode.LOW_EXT_ERROR_UNKNOWN_INDEX_ERROR.rawindex = index; + return A8kEcode.LOW_EXT_ERROR_UNKNOWN_INDEX_ERROR; + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/A8kPacket.java b/src/main/java/a8k/app/iflytophald/type/protocol/A8kPacket.java new file mode 100644 index 0000000..bb62121 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/A8kPacket.java @@ -0,0 +1,236 @@ +package a8k.app.iflytophald.type.protocol; + +import a8k.app.utils.ByteArrayUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.Assert; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +public class A8kPacket { + + //#pragma pack(push, 1) + //typedef struct { + // uint8_t packetType; + // uint16_t cmdid; + // uint8_t moduleId; + // uint16_t index; + // uint8_t datalen; + // uint8_t data[]; + // /* int8_t checksum;*/ + //} zcr_cmd_header_t; + // + //#pragma pack(pop) + //typedef enum { + // kptv2_cmd = 0xA0, + // kptv2_ack = 0xA1, + // kptv2_error_ack = 0xA2, + // kptv2_event = 0xA3, + //} zcan_cmd_packet_type_t; + // + + /** + * + * @WARNING + * 1. 修改这里时,需要注意连同createPacket一起修改 + * 2. PACKET_MIN_LEN 比Header多一个字节,是因为还有一个字节的校验位 + */ + + public static final int PACKET_TYPE_OFFSET = 0; + public static final int CMDID_OFFSET = 1; + public static final int MODULE_ID_OFFSET = 3; + public static final int INDEX_OFFSET = 4; + public static final int DATA_LEN_OFFSET = 6; + public static final int DATA_OFFSET = 7; + + public static final int PACKET_MIN_LEN = 8;// + + public static final int CMD_OVERTIME = 1500; + + + public static final int PACKET_TYPE_CMD = 0xA0; + public static final int PACKET_TYPE_ACK = 0xA1; + public static final int PACKET_TYPE_ERROR_ACK = 0xA2; + public static final int PACKET_TYPE_EVENT = 0xA3; + + public static final Logger logger = LoggerFactory.getLogger(A8kPacket.class); + + byte[] raw; + + public A8kPacket(byte[] cmd) { + raw = new byte[cmd.length]; + System.arraycopy(cmd, 0, raw, 0, cmd.length); + } + + public void setPacketIndex(int packetIndex) { + ByteArrayUtils.setU16bit(raw, INDEX_OFFSET, packetIndex); + int checkcode = computeCheckcode(); + ByteArrayUtils.setU8(raw, raw.length - 1, checkcode); + } + + + public int getPacketIndex() { + return ByteArrayUtils.readU16bit(raw, INDEX_OFFSET); + } + + public int getCmdId() { + return ByteArrayUtils.readU16bit(raw, CMDID_OFFSET); + } + + public int getPacketType() { + return ByteArrayUtils.readU8bit(raw, PACKET_TYPE_OFFSET); + } + + public int getModuleId() { + return ByteArrayUtils.readU8bit(raw, MODULE_ID_OFFSET); + } + + public int getDataLen() { + return ByteArrayUtils.readU8bit(raw, DATA_LEN_OFFSET); + } + + public byte[] getCmdContent() { + if (raw.length < PACKET_MIN_LEN) { + return new byte[0]; + } + byte[] cmdcontent = new byte[getDataLen()]; + System.arraycopy(raw, DATA_OFFSET, cmdcontent, 0, getDataLen()); + return cmdcontent; + } + + public int[] getContentI16Array() { + int[] ret = new int[getDataLen() / 2]; + for (int i = 0; i < ret.length; i++) { + ret[i] = ByteArrayUtils.readS16bit(raw, DATA_OFFSET + i * 2); + } + return ret; + } + + + public int getContentI32(int index) { + return ByteArrayUtils.read32bit(raw, DATA_OFFSET + index * 4); + } + + public int getCheckcode() { + return ByteArrayUtils.readU8bit(raw, raw.length - 1); + } + + public int computeCheckcode() { + int checkcode = 0; + for (int i = 0; i < raw.length - 1; i++) { + checkcode += raw[i]; + } + return checkcode & 0xFF; + } + + public String toByteString() { + return ByteArrayUtils.toByteString(raw); + } + + public String toString() { + int packetType = getPacketType(); + String ret = ""; + + CmdId cmdId = CmdId.valueOf(getCmdId()); + Assert.isTrue(cmdId != null, "cmdId is null"); + if (packetType == PACKET_TYPE_CMD) { + + if (cmdId.equals(CmdId.module_get_reg) || cmdId.equals(CmdId.module_set_reg)) { + RegIndex regIndex = RegIndex.valueOf(getContentI32(0)); + if (regIndex != null) { + ret = String.format("[CMD ] index:[%d] %s %s %s(%d) %d", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), regIndex, regIndex.index, getContentI32(1)); + } else { + ret = String.format("[CMD ] index:[%d] %s unkown_index(%d) %d", getPacketIndex(), cmdId, + getContentI32(0), getContentI32(1)); + } + } else { + if (cmdId.getCmdAttachType() == CmdId.ATTACH_IS_INT32) { + ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); + } else { + ret = String.format("[CMD ] index:[%d] (%s %s(%d) :param:[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), ByteArrayUtils.toByteString(getCmdContent())); + } + } + + } else if (packetType == PACKET_TYPE_ACK) { + if (cmdId.getReceiptAttachType() == CmdId.ATTACH_IS_INT32) { + ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, + formatInt32ATTACH(getCmdContent())); + } else { + ret = String.format("[ACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, + ByteArrayUtils.toByteString(getCmdContent())); + } + } else if (packetType == PACKET_TYPE_ERROR_ACK) { + ret = String.format("[EACK ] index:[%d] (%s :[%s])", getPacketIndex(), cmdId, (getContentI32(0))); + } else if (packetType == PACKET_TYPE_EVENT) { + if (cmdId.getCmdAttachType() == CmdId.ATTACH_IS_INT32) { + ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent())); + } else { + ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, + MId.valueOf(getModuleId()), getModuleId(), ByteArrayUtils.toByteString(getCmdContent())); + } + } else { + ret = String.format("Unknown packet type: %d", packetType); + } + return ret; + } + + private String formatInt32ATTACH(byte[] attach) { + StringBuilder ret = new StringBuilder(); + for (int i = 0; i < attach.length; i += 4) { + if (i + 3 >= attach.length) + break; + if (i != 0) + ret.append(","); + ret.append(String.format("%d", ByteArrayUtils.read32bit(attach, i))); + } + return ret.toString(); + } + + public Boolean isSupportPacket() { + CmdId cmdid = CmdId.valueOf(getCmdId()); + if (cmdid == null) { + return false; + } + if (CmdId.module_get_reg.equals(cmdid) || CmdId.module_set_reg.equals(cmdid)) { + if (getPacketType() == PACKET_TYPE_CMD) { + RegIndex regIndex = RegIndex.valueOf(getContentI32(0)); + return regIndex != null; + } + } + return true; + } + + + static public A8kPacket createPacket(Integer moduleId, int packetType, Integer cmdId, Integer[] params) { + int bufferSize = A8kPacket.PACKET_MIN_LEN + 4 * params.length; + ByteBuffer buffer = ByteBuffer.allocate(bufferSize); + buffer.order(ByteOrder.LITTLE_ENDIAN); + buffer.put((byte) (packetType & 0xff)); // packetType + buffer.putShort((short) (cmdId & 0xffff)); // cmdid + buffer.put((byte) (moduleId & 0xFF)); // moduleId + buffer.put((byte) 0x4C); // index + buffer.put((byte) 0x00); // index + buffer.put((byte) (params.length * 4)); // datalen + for (int value : params) { + buffer.putInt(value); + } + // int8_t checksum; + int checksum = 0; + for (int i = 0; i < bufferSize - 1; i++) { + checksum += buffer.get(i); + } + buffer.put((byte) checksum); + return new A8kPacket(buffer.array()); + } + + public static void main(String[] args) { + var packet = createPacket(41, A8kPacket.PACKET_TYPE_CMD, CmdId.module_stop.index, new Integer[]{}); + logger.info("{}", packet.toByteString()); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/CmdId.java b/src/main/java/a8k/app/iflytophald/type/protocol/CmdId.java new file mode 100644 index 0000000..86a0cf6 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/CmdId.java @@ -0,0 +1,277 @@ +package a8k.app.iflytophald.type.protocol; + +public enum CmdId { + NotSet(0xFFFF, "NOACTION"),// + + board_reset(0x0000, "复位板子"),// + event_bus_reg_change_report(0x0064, "寄存器修改事件"),// + // + + module_ping(0x0101, "MODULE_PING"), + module_stop(0x0102, "MODULE_STOP"), + + module_get_error(0x0110, "MODULE_GET_ERROR"), + module_get_detail_error(0x0111, "MODULE_GET_DETAIL_ERROR"), + module_clear_error(0x0112, "MODULE_CLEAR_ERROR"), + + module_set_reg(0x0120, "MODULE_SET_REG"), + module_get_reg(0x0121, "MODULE_GET_REG"), + module_reset_reg(0x0123, "MODULE_RESET_REG"), + + module_get_version(0x0130, "MODULE_GET_VERSION"), + module_get_type(0x0131, "MODULE_GET_TYPE"), + module_get_status(0x0132, "MODULE_GET_STATUS"), + + + // module_active_cfg(0x0110, "激活配置"),// + // + xymotor_enable(0x0301, "XYMOTOR_ENABLE"),// + xymotor_move_by(0x0302, "XYMOTOR_MOVE_BY"),// + xymotor_move_to(0x0303, "XYMOTOR_MOVE_TO"),// + xymotor_move_to_zero(0x0304, "XYMOTOR_MOVE_TO_ZERO"),// + xymotor_read_pos(0x0306, "XYMOTOR_READ_POS"),// + xymotor_read_inio_index_in_stm32(0x0307, "XYMOTOR_READ_INIO_INDEX_IN_STM32"),// + xymotor_read_inio(0x0308, "XYMOTOR_READ_INIO"),// + xymotor_set_pos(0x0309, "XYMOTOR_SET_POS"),// + xymotor_motor_move_by_direct(0x030a, "XYMOTOR_MOTOR_MOVE_BY_DIRECT"),// + xymotor_read_enc_direct(0x030b, "XYMOTOR_READ_ENC_DIRECT"),// + // + a8k_opt_v2_read_raw(0x0609, "A8K_OPT_V2_READ_RAW"),// + // + a8k_opt_v2_t_start_scan(0x0700, "A8K_OPT_V2_T_START_SCAN"),// + a8k_opt_v2_f_start_scan(0x0701, "A8K_OPT_V2_F_START_SCAN"),// + a8k_opt_v2_t_open_laster(0x070a, "A8K_OPT_V2_T_OPEN_LASTER"),// + a8k_opt_v2_t_close_laster(0x070b, "A8K_OPT_V2_T_CLOSE_LASTER"),// + a8k_opt_v2_t_readVal(0x070c, "A8K_OPT_V2_T_READVAL"),// + a8k_opt_v2_f_open_laster(0x070d, "A8K_OPT_V2_F_OPEN_LASTER"),// + a8k_opt_v2_f_close_laster(0x070e, "A8K_OPT_V2_F_CLOSE_LASTER"),// + a8k_opt_v2_f_readVal(0x070f, "A8K_OPT_V2_F_READVAL"),// + // + step_motor_enable(0x0201, "STEP_MOTOR_ENABLE"),// + step_motor_read_pos(0x020b, "STEP_MOTOR_READ_POS"),// + step_motor_read_enc_pos(0x020c, "STEP_MOTOR_READ_ENC_POS"),// + step_motor_easy_rotate(0x0211, "STEP_MOTOR_EASY_ROTATE"),// + step_motor_easy_move_by(0x0212, "STEP_MOTOR_EASY_MOVE_BY"),// + step_motor_easy_move_to(0x0213, "STEP_MOTOR_EASY_MOVE_TO"),// + step_motor_easy_move_to_zero(0x0214, "STEP_MOTOR_EASY_MOVE_TO_ZERO"),// + step_motor_easy_set_current_pos(0x0215, "STEP_MOTOR_EASY_SET_CURRENT_POS"),// + step_motor_easy_move_to_io(0x0216, "STEP_MOTOR_EASY_MOVE_TO_IO"),// + step_motor_stop(0x0228, "STEP_MOTOR_STOP"),// + step_motor_move_by(0x021d, "STEP_MOTOR_MOVE_BY"), // (dpos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) + step_motor_move_to(0x021e, "STEP_MOTOR_MOVE_TO"), // (pos,speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) + step_motor_move_to_zero_point_quick(0x021f, "STEP_MOTOR_MOVE_TO_ZERO_POINT_QUICK"), // (speedlevel)->null speedlevel=0,1,2,3(default,low,mid,high) + step_motor_rotate(0x0220, "STEP_MOTOR_ROTATE"), // + + step_motor_active_cfg(0x0229, "STEP_MOTOR_ACTIVE_CFG"),// + step_motor_read_io_state(0x022a, "STEP_MOTOR_READ_IO_STATE"),// + step_motor_easy_move_to_end_point(0x022c, "STEP_MOTOR_EASY_MOVE_TO_END_POINT"),// + step_motor_read_tmc5130_status(0x0232, "STEP_MOTOR_READ_TMC5130_STATUS"),// + step_motor_read_tmc5130_state(0x0233, "STEP_MOTOR_READ_TMC5130_STATE"),// + step_motor_read_io_index_in_stm32(0x0238, "STEP_MOTOR_READ_IO_INDEX_IN_STM32"),// + step_motor_set_subdevice_reg(0x0239, "STEP_MOTOR_SET_SUBDEVICE_REG"),// + step_motor_get_subdevice_reg(0x023a, "STEP_MOTOR_GET_SUBDEVICE_REG"),// + step_motor_easy_reciprocating_motion(0x022d, "STEP_MOTOR_EASY_RECIPROCATING_MOTION"),// + step_motor_easy_move_to_zero_point_quick(0x022e, "STEP_MOTOR_EASY_MOVE_TO_ZERO_POINT_QUICK"),// + // + mini_servo_enable(0x6601, "MINI_SERVO_ENABLE"),// + mini_servo_read_pos(0x6602, "MINI_SERVO_READ_POS"),// + mini_servo_active_cfg(0x6603, "MINI_SERVO_ACTIVE_CFG"),// + mini_servo_stop(0x6604, "MINI_SERVO_STOP"),// + mini_servo_set_mid_point(0x6607, "MINI_SERVO_SET_MID_POINT"),// + mini_servo_read_io_state(0x6608, "MINI_SERVO_READ_IO_STATE"),// + mini_servo_move_to(0x6609, "MINI_SERVO_MOVE_TO"),// + mini_servo_rotate(0x660a, "MINI_SERVO_ROTATE"),// + mini_servo_rotate_with_torque(0x660b, "MINI_SERVO_ROTATE_WITH_TORQUE"),// + mini_servo_set_cur_pos(0x660c, "MINI_SERVO_SET_CUR_POS"),// + // + extboard_read_inio(0x6701, "EXTBOARD_READ_INIO"),// + extboard_write_outio(0x6702, "EXTBOARD_WRITE_OUTIO"),// + extboard_read_muti_inio(0x6703, "EXTBOARD_READ_MUTI_INIO"),// + extboard_read_inio_index_in_stm32(0x6704, "EXTBOARD_READ_INIO_INDEX_IN_STM32"),// + extboard_read_outio_index_in_stm32(0x6705, "EXTBOARD_READ_OUTIO_INDEX_IN_STM32"),// + extboard_read_outio(0x6706, "EXTBOARD_READ_OUTIO"),// + code_scaner_start_scan(0x6801, "CODE_SCANER_START_SCAN"),// + code_scaner_stop_scan(0x6802, "CODE_SCANER_STOP_SCAN"),// + code_scaner_result_is_ready(0x6803, "CODE_SCANER_RESULT_IS_READY"),// + code_scaner_read_scaner_result(0x6804, "CODE_SCANER_READ_SCANER_RESULT"),// + code_scaner_get_result_length(0x6805, "CODE_SCANER_GET_RESULT_LENGTH"),// + // + fan_controler_set_speed(0x6900, "FAN_CONTROLER_SET_SPEED"),// + // + temp_controler_start_hearting(0x7000, "TEMP_CONTROLER_START_HEARTING"),// + temp_controler_stop_hearting(0x7001, "TEMP_CONTROLER_STOP_HEARTING"),// + temp_controler_set_peltier_power_level(0x7002, "TEMP_CONTROLER_SET_PELTIER_POWER_LEVEL"),// + temp_controler_set_pump_level(0x7003, "TEMP_CONTROLER_SET_PUMP_LEVEL"),// + temp_controler_set_fan_level(0x7004, "TEMP_CONTROLER_SET_FAN_LEVEL"),// + temp_controler_enable_log(0x7005, "TEMP_CONTROLER_ENABLE_LOG"),// + // + a8000_idcard_reader_read_raw(0x7100, "A8000_IDCARD_READER_READ_RAW"),// + a8000_idcard_write_raw(0x7101, "A8000_IDCARD_WRITE_RAW"),// + a8000_idcard_erase(0x7102, "A8000_IDCARD_ERASE"),// + a8000_idcard_earse_unlock(0x7103, "A8000_IDCARD_EARSE_UNLOCK"),// + // + event_a8000_idcard_online(0x71c8, "EVENT_A8000_IDCARD_ONLINE"),// + event_a8000_idcard_offline(0x71c9, "EVENT_A8000_IDCARD_OFFLINE"),// + // + // plate_code_scaner_push_card_and_scan(0x7301, "PLATE_CODE_SCANER_PUSH_CARD_AND_SCAN"),// + // plate_code_scaner_stop_scan(0x7302, "PLATE_CODE_SCANER_STOP_SCAN"),// + // plate_code_scaner_read_result(0x7303, "PLATE_CODE_SCANER_READ_RESULT"),// + // plate_code_scaner_read_result_point_num(0x7304, "PLATE_CODE_SCANER_READ_RESULT_POINT_NUM"),// + // plate_code_scaner_read_code(0x7305, "PLATE_CODE_SCANER_READ_CODE"),// + // plate_code_scaner_adc_readraw(0x7306, "PLATE_CODE_SCANER_ADC_READRAW"),// + // plate_code_scaner_open_laser(0x7307, "PLATE_CODE_SCANER_OPEN_LASER"),// + // plate_code_scaner_close_laser(0x7308, "PLATE_CODE_SCANER_CLOSE_LASER"),// + // + + + pipette_set_zmbcfg(0x7401, "pipette_set_zmbcfg"), + pipette_get_zmbcfg(0x7402, "pipette_get_zmbcfg"), + pipette_set_pmbcfg(0x7403, "pipette_set_pmbcfg"), + pipette_get_pmbcfg(0x7404, "pipette_get_pmbcfg"), + pipette_set_platinfo(0x7405, "pipette_set_platinfo"), + pipette_get_platinfo(0x7406, "pipette_get_platinfo"), + pipette_set_zmvcfg(0x7407, "pipette_set_zmvcfg"), + pipette_get_zmvcfg(0x7408, "pipette_get_zmvcfg"), + pipette_set_pmvcfg(0x7409, "pipette_set_pmvcfg"), + pipette_get_pmvcfg(0x740A, "pipette_get_pmvcfg"), + pipette_set_container_info(0x740B, "pipette_set_container_info"), + pipette_get_container_info(0x740C, "pipette_get_container_info"), + pipette_set_liquid_info(0x740D, "pipette_set_liquid_info"), + pipette_get_liquid_info(0x740E, "pipette_get_liquid_info"), + pipette_get_platinfo_max_cpyid(0x7410, "pipette_get_platinfo_max_cpyid"), + pipette_get_zmvcfg_max_cpyid(0x7411, "pipette_get_zmvcfg_max_cpyid"), + pipette_get_pmvcfg_max_cpyid(0x7412, "pipette_get_pmvcfg_max_cpyid"), + pipette_get_container_info_max_cpyid(0x7413, "pipette_get_container_info_max_cpyid"), + pipette_get_liquid_info_max_cpyid(0x7414, "pipette_get_liquid_info_max_cpyid"), + pipette_set_common_cfg(0x7415, "pipette_set_common_cfg"), + pipette_get_common_cfg(0x7416, "pipette_get_common_cfg"), + + pipette_zmotor_enable(0x7500, "pipette_zmotor_enable"), + pipette_zmotor_move_zero(0x7501, "pipette_zmotor_move_zero"), + pipette_zmotor_move_to_zero_point_quick(0x7502, "pipette_zmotor_move_to_zero_point_quick"), + pipette_zmotor_measure_distance(0x7503, "pipette_zmotor_measure_distance"), + pipette_zmotor_read_measure_distance_result(0x7504, "pipette_zmotor_read_measure_distance_result"), + pipette_zmotor_move_by(0x7505, "pipette_zmotor_move_by"), + pipette_zmotor_move_to(0x7506, "pipette_zmotor_move_to"), + pipette_zmotor_read_zero_point_state(0x7507, "pipette_zmotor_read_zero_point_state"), + pipette_zmotor_read_dev_status_cache(0x7508, "pipette_zmotor_read_dev_status_cache"), + pipette_zmotor_read_pos(0x7509, "pipette_zmotor_read_pos"), + pipette_zmotor_read_enc_pos(0x750A, "pipette_zmotor_read_enc_pos"), + pipette_zmotor_move_to_tip_deposit(0x750B, "pipette_zmotor_move_to_tip_deposit"), + + + pipette_pump_init_device(0x7580, "pipette_pump_init_device"), + pipette_pump_take_tip(0x7581, "pipette_pump_take_tip"), + pipette_pump_deposit_tip(0x7582, "pipette_pump_put_tip"), + pipette_pump_pierce_through(0x7583, "pipette_pump_aspirate_set_param"), + pipette_pump_aspirate_set_param(0x7584, "pipette_pump_aspirate_set_param"), + pipette_pump_aspirate(0x7585, "pipette_pump_aspirate"), + pipette_get_sensor_sample_data(0x7587, "pipette_get_sensor_sample_data"), + pipette_get_sensor_sample_data_num(0x7588, "pipette_get_sensor_sample_data_num"), + pipette_read_state(0x7589, "pipette_read_state"), + pipette_pump_putbak_tip(0x758A, "pipette_pump_cutback_tip"), + pipette_read_tip_state(0x758B, "pipette_read_tip_state"), + pipette_read_pressure(0x758C, "pipette_read_pressure"), + pipette_read_capacitance(0x758D, "pipette_read_capacitance"), + pipette_pump_distribu_all_set_param(0x758E, "pipette_pump_distribu_all_set_param"), // {paramid,val}, ack:{} + pipette_pump_distribu_all(0x758F, "pipette_pump_distribu_all"), // {}, ack:{} + pipette_get_asp_pressure_data(0x7590, "pipette_get_asp_pressure_data"), // {section_off}, ack:{int16_t data[]} + + + pipette_test_pump_move_to_x100nl(0x7600, "pipette_test_pump_move_to_x100nl"), // int32_t x100nl, int32_t vcfgindex + pipette_test_lld(0x7601, "pipette_test_lld"), // int32_t container_pos, int32_t container_cpyid, int32_t liquid_cpyid + pipette_test_move_to_container_bottom(0x7602, "pipette_test_move_to_container_bottom"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_container_bottom_section_begin(0x7603, "pipette_test_move_to_container_bottom_section_begin"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_immersion_pos(0x7604, "pipette_test_move_to_immersion_pos"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_leaving_height_pos(0x7605, "pipette_test_move_to_leaving_height_pos"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_jet_pos(0x7606, "pipette_test_move_to_jet_pos"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_lld_start_search_pos(0x7607, "pipette_test_move_to_lld_start_search_pos"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_fix_water_level_pos(0x7608, "pipette_test_move_to_fix_water_level_pos"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_pierce_pos(0x7609, "pipette_test_move_to_pierce_pos"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_move_to_lld_end_pos(0x760A, "pipette_test_move_to_lld_end_pos"), // int32_t container_pos, int32_t container_cpyid, + pipette_test_connectivity(0x760B, "pipette_test_connectivity"), // 测试电缆连接性 {}, ack:{} + + ; + public final static int ATTACH_IS_BYTES = 1; + public final static int ATTACH_IS_INT32 = 2; + public final int index; + public final String chName; + + + // public final int cmdAttachType = ATTACH_IS_INT32; + // public final int receiptAttachType = ATTACH_IS_INT32; + // public final boolean trace = true; + // public final boolean actionCmd = true; + + CmdId(int index, String chname) { + this.index = index; + this.chName = chname; + } + + public int toInt() { + return index; + } + + public static CmdId valueOf(int val) { + CmdId[] values = CmdId.values(); + for (CmdId e : values) { + if (e.toInt() == val) + return e; + } + return null; + } + + public static String toString(int val) { + CmdId[] values = CmdId.values(); + for (CmdId e : values) { + if (e.toInt() == val) { + return e.toString(); + } + } + return "unkown(" + val + ")"; + } + + public String getChname() { + return chName; + } + + public Boolean eq(Integer index) { + return this.index == index; + } + + + public int getCmdAttachType() { + return switch (this) { + case a8000_idcard_write_raw -> ATTACH_IS_BYTES; + default -> ATTACH_IS_INT32; + }; + } + + public int getReceiptAttachType() { + return switch (this) { + case a8k_opt_v2_read_raw, a8000_idcard_reader_read_raw -> ATTACH_IS_BYTES; + default -> ATTACH_IS_INT32; + }; + } + + public boolean isTrace() { + return true; + } + + public boolean isActionCmd() { + + return switch (this) { + case module_get_status, + module_get_error, + xymotor_read_pos, + xymotor_read_inio, + step_motor_read_io_state, + extboard_read_inio, + extboard_read_muti_inio, + module_get_reg, + module_set_reg, + code_scaner_result_is_ready -> false; + default -> true; + }; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/HbotRegIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/HbotRegIndex.java new file mode 100644 index 0000000..5825814 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/HbotRegIndex.java @@ -0,0 +1,48 @@ +package a8k.app.iflytophald.type.protocol; + +public enum HbotRegIndex { +// kreg_module_version(RegIndex.kreg_module_version), // 模块版本 +// kreg_module_type(RegIndex.kreg_module_type), // 模块类型 +// kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error +// kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag + + kreg_xyrobot_io_state(RegIndex.kreg_xyrobot_io_state), // + kreg_xyrobot_is_enable(RegIndex.kreg_xyrobot_is_enable), // + kreg_xyrobot_robot_type(RegIndex.kreg_xyrobot_robot_type), // + kreg_xyrobot_one_circle_pulse(RegIndex.kreg_xyrobot_one_circle_pulse), // + kreg_xyrobot_one_circle_pulse_denominator(RegIndex.kreg_xyrobot_one_circle_pulse_denominator), // + kreg_xyrobot_ihold(RegIndex.kreg_xyrobot_ihold), // + kreg_xyrobot_irun(RegIndex.kreg_xyrobot_irun), // + kreg_xyrobot_iholddelay(RegIndex.kreg_xyrobot_iholddelay), // + kreg_xyrobot_iglobalscaler(RegIndex.kreg_xyrobot_iglobalscaler), // + kreg_xyrobot_vstart(RegIndex.kreg_xyrobot_vstart), // + kreg_xyrobot_a1(RegIndex.kreg_xyrobot_a1), // + kreg_xyrobot_amax(RegIndex.kreg_xyrobot_amax), // + kreg_xyrobot_v1(RegIndex.kreg_xyrobot_v1), // + kreg_xyrobot_dmax(RegIndex.kreg_xyrobot_dmax), // + kreg_xyrobot_d1(RegIndex.kreg_xyrobot_d1), // + kreg_xyrobot_vstop(RegIndex.kreg_xyrobot_vstop), // + kreg_xyrobot_tzerowait(RegIndex.kreg_xyrobot_tzerowait), // + kreg_xyrobot_enc_resolution(RegIndex.kreg_xyrobot_enc_resolution), // + kreg_xyrobot_enable_enc(RegIndex.kreg_xyrobot_enable_enc), // + kreg_xyrobot_x_shaft(RegIndex.kreg_xyrobot_x_shaft), // + kreg_xyrobot_y_shaft(RegIndex.kreg_xyrobot_y_shaft), // + kreg_xyrobot_min_x(RegIndex.kreg_xyrobot_min_x), // + kreg_xyrobot_min_y(RegIndex.kreg_xyrobot_min_y), // + kreg_xyrobot_max_x(RegIndex.kreg_xyrobot_max_x), // + kreg_xyrobot_max_y(RegIndex.kreg_xyrobot_max_y), // + kreg_xyrobot_run_to_zero_speed(RegIndex.kreg_xyrobot_run_to_zero_speed), // + kreg_xyrobot_look_zero_edge_speed(RegIndex.kreg_xyrobot_look_zero_edge_speed), // + kreg_xyrobot_shift_x(RegIndex.kreg_xyrobot_shift_x), // + kreg_xyrobot_shift_y(RegIndex.kreg_xyrobot_shift_y), // + kreg_xyrobot_pos_devi_tolerance(RegIndex.kreg_xyrobot_pos_devi_tolerance), // + kreg_xyrobot_io_trigger_append_distance(RegIndex.kreg_xyrobot_io_trigger_append_distance), // + kreg_xyrobot_default_velocity(RegIndex.kreg_xyrobot_default_velocity), // + ; + + public final RegIndex regIndex; + HbotRegIndex(RegIndex regIndex) { + this.regIndex = regIndex; + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/InputIOId.java b/src/main/java/a8k/app/iflytophald/type/protocol/InputIOId.java new file mode 100644 index 0000000..a2db301 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/InputIOId.java @@ -0,0 +1,45 @@ +package a8k.app.iflytophald.type.protocol; + +public enum InputIOId { + TubeHeightPPS("入料平移通道-试管高低检测IO", ModuleType.Board, MId.FeedingModBoard, 0, false), //高低试管检测IO + TubeExistPPS("入料平移通道-试管有无光电", ModuleType.Board, MId.FeedingModBoard, 4, false),//试管有无光电 + THChOuterPPS("入料平移通道-外光电", ModuleType.Board, MId.FeedingModBoard, 1, false),//试管架转移通道有无检测 外 + THChInterPPS("入料平移通道-内光电", ModuleType.Board, MId.FeedingModBoard, 2, false),//试管架转移通道有无检测 内 + InfeedPPS("入料区有无光电", ModuleType.Board, MId.FeedingModBoard, 5, false),//试管架入料位置 试管架有无检测 + OutfeedPPS("出料位有无检测", ModuleType.Board, MId.FeedingModBoard, 3, false),//试管出料位置 试管架有无检测 + + RecycleBinOverflowPPS("废料仓满溢检测", ModuleType.Board, MId.PlatesBoxTCMBoard, 2, false),//废料桶满溢检测 + RecycleBinInPlacePPS("废料仓到位检测", ModuleType.Board, MId.OptModBoard, 1, false),//废料桶到位检测 + IncubationPlateOutletStuckPPS("光学模组-入口-卡板-检测", ModuleType.Board, MId.OptModBoard, 4, false),//废料桶到位检测 + + PlateBoxCoverClosurePPS("板夹仓-仓门光电", ModuleType.Board, MId.PlatesBoxBoard, 0, true),//板夹仓舱盖闭合检测 + IncubationPlateInletStuckPPS("板夹仓-卡板光电", ModuleType.Board, MId.PlatesBoxBoard, 1, false),//板夹仓卡板检测 + + + + //转盘逻辑相关光电 + //钩板电机,零点光电,终点光电 + PullerMZeroPPS("光学模组-拉杆电机-零点光电", ModuleType.TMCStepMotor, MId.OptModPullM, 0, false),// + PullerMEndPPS("光学模组-拉杆电机-限位光电", ModuleType.TMCStepMotor, MId.OptModPullM, 1, false),// + //推板电机,零点光电,终点光电 + PusherMZeroPPS("推杆电机-零点光电", ModuleType.TMCStepMotor, MId.PlatesBoxPusherM, 0, false),// + PusherMEndPPS("推杆电机-终点光电", ModuleType.TMCStepMotor, MId.PlatesBoxPusherM, 1, false),// + ; + + final public String chname; + final public ModuleType mtype; + final public MId mid; + final public int ioIndex; + final public boolean mirror; + + InputIOId(String chname, ModuleType mtype, MId mid, int ioIndex, boolean mirror) { + this.chname = chname; + this.mtype = mtype; + this.mid = mid; + this.ioIndex = ioIndex; + this.mirror = mirror; + + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/LldType.java b/src/main/java/a8k/app/iflytophald/type/protocol/LldType.java new file mode 100644 index 0000000..5871133 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/LldType.java @@ -0,0 +1,25 @@ +package a8k.app.iflytophald.type.protocol; + +/** + * 液位探测方式 + */ +public enum LldType { + // 电容式 + kclld(0), + + // 电压式 + kplld(1), + + // 混合式 + kmixlld(2); + + + private final int index; + + LldType(int index) { + this.index = index; + } + public int getIndex() { + return index; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/MId.java b/src/main/java/a8k/app/iflytophald/type/protocol/MId.java new file mode 100644 index 0000000..04283c8 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/MId.java @@ -0,0 +1,89 @@ +package a8k.app.iflytophald.type.protocol; + +public enum MId { + NotSet(0, "未设置"),// + HbotBoard(10, "机械臂板模块"),// + HbotM(11, "机械臂XY"),// + // + PlatesBoxBoard(20, "板夹仓模块"),// + PlatesBoxYM(21, "板夹仓移动电机"),// + PlatesBoxPusherM(22, "板夹仓推杆电机"),// + // PlatesBoxScanner(23, "板夹仓扫码模组"),// + // + ShakeModBoard(30, "摇匀模组板"),// + ShakeModClampingM(31, "试管固定夹爪电机"),// + ShakeModGripperZM(32, "摇匀升降电机"),// + ShakeModShakeM(33, "试管摇匀电机"),// + ShakeModGripperYSV(34, "摇匀前后移动舵机"),// + ShakeModGripperSV(35, "摇匀试管帽夹爪舵机"),// + ShakeModTubeScanerClampingSV(36, "试管架扫码夹紧舵机"),// + ShakeModTubeScanerRotateSV(37, "试管架旋转舵机"),// + ShakeModLiftingSV(38, "试管顶升舵机"),// + // + PlatesBoxTCMBoard(40, "反应板夹温度控制板"),// + PlatesBoxTCM(41, "反应板夹温度控制模块"),// + WbTubeFanMod(42, "气溶胶风扇"),// + // + IncubatorTCMBoard(50, "温度控制"),// + IncubatorTCM(51, "温度控制"),// + // + FeedingModBoard(60, "出入料模块"),// + FeedingModInfeedM(61, "入料电机"),// + FeedingModXM(62, "试管架平移电机"),// + FeedingModOutfeedM(63, "出料电机"),// + FeedingModScannerMod(64, "试管架扫码器"),// + // + IncubatorRotateBoard(70, "孵育盘旋转板"),// + IncubatorRotateCtrlM(71, "孵育盘旋转"),// + // + PipetteModBoard(80, "机械臂Z轴板"),// + PipetteMod(82, "移液枪"),// + PipetteModCodeScanner(83, "物料扫码器"),// + // + OptModBoard(90, "光学模组板"),// + OptModScannerM(91, "板卡扫描电机"),// + OptModPullM(92, "板卡推杆电机"),// + OptMod(93, "扫描仪"),// + // + A8kIdCardReaderBoard(100, "A8K读卡器板"),// + A8kIdCardReader(101, "A8K读卡器"),// + ; + + + final public String chname; + final public int index; + + MId(int index, String chname) { + this.chname = chname; + this.index = index; + } + + public int toInt() { + return index; + } + + + public static MId valueOf(Integer val) { + return valueOf(val.intValue()); + } + + public static MId valueOf(int val) { + MId[] values = MId.values(); + for (MId e : values) { + if (e.toInt() == val) + return e; + } + return null; + } + + public static String toString(int val) { + MId[] values = MId.values(); + for (MId e : values) { + if (e.toInt() == val) { + return e.toString(); + } + } + return "unkown(" + val + ")"; + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/MiniServoMId.java b/src/main/java/a8k/app/iflytophald/type/protocol/MiniServoMId.java new file mode 100644 index 0000000..dd29f7a --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/MiniServoMId.java @@ -0,0 +1,20 @@ +package a8k.app.iflytophald.type.protocol; + +import org.springframework.util.Assert; + +public enum MiniServoMId { + ShakeModGripperYSV(MId.ShakeModGripperYSV),// 夹爪Y轴 + ShakeModGripperSV(MId.ShakeModGripperSV),// 夹爪舵机 + ShakeModTubeScanerClampingSV(MId.ShakeModTubeScanerClampingSV),//扫码夹紧 + ShakeModTubeScanerRotateSV(MId.ShakeModTubeScanerRotateSV),//扫码旋转 + ShakeModLiftingSV(MId.ShakeModLiftingSV),//试管升降 + ; + + final public MId mid; + + MiniServoMId(MId mid) { + Assert.isTrue(this.name().equals(mid.name()), "MiniServoMid Init fail"); + this.mid = mid; + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/MiniServoRegIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/MiniServoRegIndex.java new file mode 100644 index 0000000..3119f65 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/MiniServoRegIndex.java @@ -0,0 +1,69 @@ +package a8k.app.iflytophald.type.protocol; + +public enum MiniServoRegIndex { + // kreg_module_version(RegIndex.kreg_module_version), // 模块版本 + // kreg_module_type(RegIndex.kreg_module_type), // 模块类型 + // kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error + // kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag + + kreg_mini_servo_pos(RegIndex.kreg_mini_servo_pos), // 位置 + kreg_mini_servo_limit_velocity(RegIndex.kreg_mini_servo_limit_velocity), // 限制速度 + kreg_mini_servo_limit_torque(RegIndex.kreg_mini_servo_limit_torque), // 限制扭矩 + kreg_mini_servo_protective_torque(RegIndex.kreg_mini_servo_protective_torque), // 保护扭矩 + kreg_mini_servo_is_move(RegIndex.kreg_mini_servo_is_move), // 是否在运动 + + + kreg_mini_servo_status(RegIndex.kreg_mini_servo_status), // 舵机状态 + kreg_mini_servo_voltage(RegIndex.kreg_mini_servo_voltage), // 电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V + kreg_mini_servo_current(RegIndex.kreg_mini_servo_current), // 电流 反馈当前工作电流值,单位为ma + kreg_mini_servo_temperature(RegIndex.kreg_mini_servo_temperature), // 温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 + kreg_mini_servo_loadvalue(RegIndex.kreg_mini_servo_loadvalue), // 负载值 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 + kreg_mini_servo_target_pos_tolerance(RegIndex.kreg_mini_servo_target_pos_tolerance), // 目标位置容忍度 + + + kreg_mini_servo_firmware_main_version(RegIndex.kreg_mini_servo_firmware_main_version), // 固件主版本号 + kreg_mini_servo_firmware_sub_version(RegIndex.kreg_mini_servo_firmware_sub_version), // 固件次版本号 + kreg_mini_servo_servo_main_version(RegIndex.kreg_mini_servo_servo_main_version), // 舵机主版本号 + kreg_mini_servo_servo_sub_version(RegIndex.kreg_mini_servo_servo_sub_version), // 舵机次版本号 + kreg_mini_servo_servo_min_angle(RegIndex.kreg_mini_servo_servo_min_angle), // 最小角度限制 + kreg_mini_servo_servo_max_angle(RegIndex.kreg_mini_servo_servo_max_angle), // 最大角度限制 + kreg_mini_servo_servo_max_temp(RegIndex.kreg_mini_servo_servo_max_temp), // 最高温度上限 + kreg_mini_servo_servo_max_voltage(RegIndex.kreg_mini_servo_servo_max_voltage), // 最高输入电压 + kreg_mini_servo_servo_min_voltage(RegIndex.kreg_mini_servo_servo_min_voltage), // 最低输入电压 + kreg_mini_servo_servo_max_torque(RegIndex.kreg_mini_servo_servo_max_torque), // 最大扭矩 + kreg_mini_servo_servo_unload_condition(RegIndex.kreg_mini_servo_servo_unload_condition), // 卸载条件 + kreg_mini_servo_servo_p(RegIndex.kreg_mini_servo_servo_p), // P 比例系 + kreg_mini_servo_servo_d(RegIndex.kreg_mini_servo_servo_d), // D 微分系 + kreg_mini_servo_servo_i(RegIndex.kreg_mini_servo_servo_i), // I + kreg_mini_servo_servo_min_start(RegIndex.kreg_mini_servo_servo_min_start), // 最小启动 + kreg_mini_servo_servo_cw_dead_zone(RegIndex.kreg_mini_servo_servo_cw_dead_zone), // 顺时针不灵敏区 + kreg_mini_servo_servo_ccw_dead_zone(RegIndex.kreg_mini_servo_servo_ccw_dead_zone), // 逆时针不灵敏 + kreg_mini_servo_servo_protect_current(RegIndex.kreg_mini_servo_servo_protect_current), // 保护电流 + kreg_mini_servo_servo_protect_torque(RegIndex.kreg_mini_servo_servo_protect_torque), // 保护扭矩 0->100 ,触发后,需要写入与组转方向相反的位置指令,进行解除 + kreg_mini_servo_servo_protect_time(RegIndex.kreg_mini_servo_servo_protect_time), // 保护时间 + kreg_mini_servo_servo_overload_torque(RegIndex.kreg_mini_servo_servo_overload_torque), // 过载扭矩 + kreg_mini_servo_servo_speed_p(RegIndex.kreg_mini_servo_servo_speed_p), // 速度闭环P比例参数 + kreg_mini_servo_servo_overload_time(RegIndex.kreg_mini_servo_servo_overload_time), // 过流保护时间 + kreg_mini_servo_servo_speed_i(RegIndex.kreg_mini_servo_servo_speed_i), // 速度闭环I积分参数 + kreg_mini_servo_servo_torque_switch(RegIndex.kreg_mini_servo_servo_torque_switch), // 扭矩开关 + kreg_mini_servo_servo_acc(RegIndex.kreg_mini_servo_servo_acc), // 加速度 + kreg_mini_servo_servo_target_pos(RegIndex.kreg_mini_servo_servo_target_pos), // 目标位置 + kreg_mini_servo_servo_run_time(RegIndex.kreg_mini_servo_servo_run_time), // 运行时间 + kreg_mini_servo_servo_run_speed(RegIndex.kreg_mini_servo_servo_run_speed), // 运行速度 + kreg_mini_servo_servo_torque_limit(RegIndex.kreg_mini_servo_servo_torque_limit), // 转矩限制 + kreg_mini_servo_servo_lock_flag(RegIndex.kreg_mini_servo_servo_lock_flag), // 锁标志 + kreg_mini_servo_servo_current_pos(RegIndex.kreg_mini_servo_servo_current_pos), // 当前位置 + kreg_mini_servo_servo_current_speed(RegIndex.kreg_mini_servo_servo_current_speed), // 当前速度 + kreg_mini_servo_servo_current_load(RegIndex.kreg_mini_servo_servo_current_load), // 当前负载 bit10为方向位 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 + kreg_mini_servo_servo_current_voltage(RegIndex.kreg_mini_servo_servo_current_voltage), // 当前电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V + kreg_mini_servo_servo_current_temp(RegIndex.kreg_mini_servo_servo_current_temp), // 当前温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 + kreg_mini_servo_servo_status(RegIndex.kreg_mini_servo_servo_status), // 舵机状态 + kreg_mini_servo_servo_move_flag(RegIndex.kreg_mini_servo_servo_move_flag), // 移动标志 + kreg_mini_servo_servo_current_current(RegIndex.kreg_mini_servo_servo_current_current), // 当前电流 反馈当前工作电流值,单位为6.26.5mA,最大可反馈电流为500*6.5mA=3250mA + ; + public final RegIndex regIndex; + + MiniServoRegIndex(RegIndex regIndex) { + this.regIndex = regIndex; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/ModuleStatus.java b/src/main/java/a8k/app/iflytophald/type/protocol/ModuleStatus.java new file mode 100644 index 0000000..8448f42 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/ModuleStatus.java @@ -0,0 +1,26 @@ +package a8k.app.iflytophald.type.protocol; + +import org.springframework.util.Assert; + +public enum ModuleStatus { + IDLE(0), // + BUSY(1), // + ERROR(2),// + ; + + final public int index; + + ModuleStatus(int index) { + this.index = index; + } + + public int getIndex() { + return index; + } + + public static ModuleStatus valueOf(int value) { // 手写的从int到enum的转换函数 + Assert.isTrue((value >= 0 && value <= 2), String.format("(value=%s value >= 0 && value <= 2)", value)); + return values()[value]; + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/ModuleType.java b/src/main/java/a8k/app/iflytophald/type/protocol/ModuleType.java new file mode 100644 index 0000000..d26ace4 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/ModuleType.java @@ -0,0 +1,34 @@ +package a8k.app.iflytophald.type.protocol; + +public enum ModuleType { + Board(0), // 板子 + HBOT(1), // hbot模块 + WaterCoolingTempCtrl(2), // 温度控制 + FanCtrl(3), // 风扇控制 + CodeScaner(4), // 扫码器 + TMCStepMotor(5), // 步进电机 + MiniServo(6), // 舵机 + PipetteGunCtrl(7), // 移液体枪控制 + + A8kOptical(100), // a8000光学模组 + A8KIdCardReader(101), // id卡读卡器 + A8KPlateCodeScaner(102), // 反应板条扫码器 + + UNKNOWN(999); // 未知类型 + public final int code; + + ModuleType(int val) { + this.code = val; + } + + static public ModuleType of(int val) { + for (ModuleType type : ModuleType.values()) { + if (type.code == val) { + return type; + } + } + return UNKNOWN; + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/OptModuleRegIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/OptModuleRegIndex.java new file mode 100644 index 0000000..3137c08 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/OptModuleRegIndex.java @@ -0,0 +1,51 @@ +package a8k.app.iflytophald.type.protocol; + +public enum OptModuleRegIndex { + kreg_a8k_opt_t_pos_offset(RegIndex.kreg_a8k_opt_t_pos_offset), + kreg_a8k_opt_f_pos_offset(RegIndex.kreg_a8k_opt_f_pos_offset), + kreg_a8k_opt_t_reverse_scan_pos_offset(RegIndex.kreg_a8k_opt_t_reverse_scan_pos_offset), + kreg_a8k_opt_f_reverse_scan_pos_offset(RegIndex.kreg_a8k_opt_f_reverse_scan_pos_offset), + kreg_a8k_opt_scan_step_interval(RegIndex.kreg_a8k_opt_scan_step_interval), + kreg_a8k_opt_scan_pointnum(RegIndex.kreg_a8k_opt_scan_pointnum), + + kreg_a8k_opt_f_scan_vdefault(RegIndex.kreg_a8k_opt_f_scan_vdefault), // + kreg_a8k_opt_f_scan_vstart(RegIndex.kreg_a8k_opt_f_scan_vstart), // + kreg_a8k_opt_f_scan_a1(RegIndex.kreg_a8k_opt_f_scan_a1), // + kreg_a8k_opt_f_scan_amax(RegIndex.kreg_a8k_opt_f_scan_amax), // + kreg_a8k_opt_f_scan_v1(RegIndex.kreg_a8k_opt_f_scan_v1), // + kreg_a8k_opt_f_scan_dmax(RegIndex.kreg_a8k_opt_f_scan_dmax), // + kreg_a8k_opt_f_scan_d1(RegIndex.kreg_a8k_opt_f_scan_d1), // + kreg_a8k_opt_f_scan_vstop(RegIndex.kreg_a8k_opt_f_scan_vstop), // + kreg_a8k_opt_f_scan_tzerowait(RegIndex.kreg_a8k_opt_f_scan_tzerowait), // + kreg_a8k_opt_f_scan_irun(RegIndex.kreg_a8k_opt_f_scan_irun), // + + kreg_a8k_opt_t_scan_vdefault(RegIndex.kreg_a8k_opt_t_scan_vdefault), // + kreg_a8k_opt_t_scan_vstart(RegIndex.kreg_a8k_opt_t_scan_vstart), // + kreg_a8k_opt_t_scan_a1(RegIndex.kreg_a8k_opt_t_scan_a1), // + kreg_a8k_opt_t_scan_amax(RegIndex.kreg_a8k_opt_t_scan_amax), // + kreg_a8k_opt_t_scan_v1(RegIndex.kreg_a8k_opt_t_scan_v1), // + kreg_a8k_opt_t_scan_dmax(RegIndex.kreg_a8k_opt_t_scan_dmax), // + kreg_a8k_opt_t_scan_d1(RegIndex.kreg_a8k_opt_t_scan_d1), // + kreg_a8k_opt_t_scan_vstop(RegIndex.kreg_a8k_opt_t_scan_vstop), // + kreg_a8k_opt_t_scan_tzerowait(RegIndex.kreg_a8k_opt_t_scan_tzerowait), // + kreg_a8k_opt_t_scan_irun(RegIndex.kreg_a8k_opt_t_scan_irun), // + + kreg_a8k_opt_barcode_scan_vdefault(RegIndex.kreg_a8k_opt_barcode_scan_vdefault), // + kreg_a8k_opt_barcode_scan_vstart(RegIndex.kreg_a8k_opt_barcode_scan_vstart), // + kreg_a8k_opt_barcode_scan_a1(RegIndex.kreg_a8k_opt_barcode_scan_a1), // + kreg_a8k_opt_barcode_scan_amax(RegIndex.kreg_a8k_opt_barcode_scan_amax), // + kreg_a8k_opt_barcode_scan_v1(RegIndex.kreg_a8k_opt_barcode_scan_v1), // + kreg_a8k_opt_barcode_scan_dmax(RegIndex.kreg_a8k_opt_barcode_scan_dmax), // + kreg_a8k_opt_barcode_scan_d1(RegIndex.kreg_a8k_opt_barcode_scan_d1), // + kreg_a8k_opt_barcode_scan_vstop(RegIndex.kreg_a8k_opt_barcode_scan_vstop), // + kreg_a8k_opt_barcode_scan_tzerowait(RegIndex.kreg_a8k_opt_barcode_scan_tzerowait), // + kreg_a8k_opt_barcode_scan_irun(RegIndex.kreg_a8k_opt_barcode_scan_irun), // + + + ; + public final RegIndex regIndex; + + OptModuleRegIndex(RegIndex regIndex) { + this.regIndex = regIndex; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/OutputIOId.java b/src/main/java/a8k/app/iflytophald/type/protocol/OutputIOId.java new file mode 100644 index 0000000..88801a2 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/OutputIOId.java @@ -0,0 +1,23 @@ +package a8k.app.iflytophald.type.protocol; + +public enum OutputIOId { + RecycleBinOverflowPPSPowerCtrl("废料仓-光栅电源", ModuleType.Board, MId.PlatesBoxTCMBoard, 0, false),//废料桶光栅电源 + BeepCtrl("蜂鸣器", ModuleType.Board, MId.IncubatorTCMBoard, 0, false),//蜂鸣器 + ; + + final public String chname; + final public ModuleType mtype; + final public MId mid; + final public int ioIndex; + final public boolean mirror; + + OutputIOId(String chname, ModuleType mtype, MId mid, int ioIndex, boolean mirror) { + this.chname = chname; + this.mtype = mtype; + this.mid = mid; + this.ioIndex = ioIndex; + this.mirror = mirror; + + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/PipetteRegIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/PipetteRegIndex.java new file mode 100644 index 0000000..92e383a --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/PipetteRegIndex.java @@ -0,0 +1,78 @@ +package a8k.app.iflytophald.type.protocol; + +import org.springframework.util.Assert; + +public enum PipetteRegIndex { +// kreg_module_version(RegIndex.kreg_module_version), // 模块版本 +// kreg_module_type(RegIndex.kreg_module_type), // 模块类型 +// kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error +// kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag + + kreg_pipette_pos_nl(RegIndex.kreg_pipette_pos_nl), // 移液枪位置 + kreg_pipette_capactitance_val(RegIndex.kreg_pipette_capactitance_val), // 移液枪电容值 + kreg_pipette_tip_state(RegIndex.kreg_pipette_tip_state), // 移动液枪tip状态 + + // kreg_pipette_limit_ul(RegIndex.kreg_pipette_limit_ul), // + // kreg_pipette_pump_acc(RegIndex.kreg_pipette_pump_acc), // + // kreg_pipette_pump_dec(RegIndex.kreg_pipette_pump_dec), // + // kreg_pipette_pump_vstart(RegIndex.kreg_pipette_pump_vstart), // + // kreg_pipette_pump_vstop(RegIndex.kreg_pipette_pump_vstop), // + // kreg_pipette_pump_vmax(RegIndex.kreg_pipette_pump_vmax), // + // kreg_pipette_aspirate_distribut_pump_vel(RegIndex.kreg_pipette_aspirate_distribut_pump_vel), // + // kreg_pipette_lld_pump_vel(RegIndex.kreg_pipette_lld_pump_vel), // + // kreg_pipette_lld_motor_vel_rpm(RegIndex.kreg_pipette_lld_motor_vel_rpm), // + // kreg_pipette_lld_detect_period_ms(RegIndex.kreg_pipette_lld_detect_period_ms), // + // kreg_pipette_lld_prepare_pos(RegIndex.kreg_pipette_lld_prepare_pos), // + // kreg_pipette_lld_prepare_distribut_pos(RegIndex.kreg_pipette_lld_prepare_distribut_pos), // + + kreg_pipette_zm_pos(RegIndex.kreg_pipette_zm_pos), + kreg_pipette_zm_is_enable(RegIndex.kreg_pipette_zm_is_enable), + kreg_pipette_zm_dpos(RegIndex.kreg_pipette_zm_dpos), + + kreg_pipette_zm_shaft(RegIndex.kreg_pipette_zm_shaft), + kreg_pipette_zm_one_circle_pulse(RegIndex.kreg_pipette_zm_one_circle_pulse), + kreg_pipette_zm_one_circle_pulse_denominator(RegIndex.kreg_pipette_zm_one_circle_pulse_denominator), + kreg_pipette_zm_default_velocity(RegIndex.kreg_pipette_zm_default_velocity), + kreg_pipette_zm_ihold(RegIndex.kreg_pipette_zm_ihold), + kreg_pipette_zm_irun(RegIndex.kreg_pipette_zm_irun), + kreg_pipette_zm_iholddelay(RegIndex.kreg_pipette_zm_iholddelay), + kreg_pipette_zm_iglobalscaler(RegIndex.kreg_pipette_zm_iglobalscaler), + kreg_pipette_zm_run_to_zero_speed(RegIndex.kreg_pipette_zm_run_to_zero_speed), + kreg_pipette_zm_look_zero_edge_speed(RegIndex.kreg_pipette_zm_look_zero_edge_speed), + kreg_pipette_zm_max_d(RegIndex.kreg_pipette_zm_max_d), + kreg_pipette_zm_min_d(RegIndex.kreg_pipette_zm_min_d), + + kreg_pipette_zm_vstart(RegIndex.kreg_pipette_zm_vstart), + kreg_pipette_zm_a1(RegIndex.kreg_pipette_zm_a1), + kreg_pipette_zm_amax(RegIndex.kreg_pipette_zm_amax), + kreg_pipette_zm_v1(RegIndex.kreg_pipette_zm_v1), + kreg_pipette_zm_dmax(RegIndex.kreg_pipette_zm_dmax), + kreg_pipette_zm_d1(RegIndex.kreg_pipette_zm_d1), + kreg_pipette_zm_vstop(RegIndex.kreg_pipette_zm_vstop), + kreg_pipette_zm_tzerowait(RegIndex.kreg_pipette_zm_tzerowait), + kreg_pipette_zm_enc_resolution(RegIndex.kreg_pipette_zm_enc_resolution), + kreg_pipette_zm_enable_enc(RegIndex.kreg_pipette_zm_enable_enc), + kreg_pipette_zm_dzero(RegIndex.kreg_pipette_zm_dzero), + kreg_pipette_zm_pos_devi_tolerance(RegIndex.kreg_pipette_zm_pos_devi_tolerance), + kreg_pipette_zm_io_trigger_append_distance(RegIndex.kreg_pipette_zm_io_trigger_append_distance), + kreg_pipette_zm_mres(RegIndex.kreg_pipette_zm_mres), + kreg_pipette_zm_encpos(RegIndex.kreg_pipette_zm_encpos), + ; + + public final RegIndex regIndex; + + PipetteRegIndex(RegIndex regIndex) { + Assert.isTrue(this.name().equals(regIndex.name()), "PipetteRegIndex name must be equal to RegIndex name"); + this.regIndex = regIndex; + } + + public static PipetteRegIndex valueOf(int val) { + PipetteRegIndex[] values = PipetteRegIndex.values(); + for (PipetteRegIndex regindex : values) { + if (regindex.regIndex.index == val) { + return regindex; + } + } + return null; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/RegIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/RegIndex.java new file mode 100644 index 0000000..c2fd78e --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/RegIndex.java @@ -0,0 +1,330 @@ +package a8k.app.iflytophald.type.protocol; + +public enum RegIndex { + + /******************************************************************************* + * 模块通用配置和状态 * + *******************************************************************************/ + // kreg_module_version(0), // 模块版本 + // kreg_module_type(1), // 模块类型 + // kreg_module_status(2), // 0idle,1busy,2error + // kreg_module_errorcode(3), // inited_flag + // kreg_module_detail_errorcode(4), // 详细的错误信息,该位置的定义根据module_errorcode的不同,而不同 + // kreg_extboard_resetflag(100), + + + /*********************************************************************************************************************** + * 水冷温度控制器 * + ***********************************************************************************************************************/ + kreg_water_cooling_tmp_controler_pid_target(3000), // 目标数值 + kreg_water_cooling_tmp_controler_pid_nowoutput(3001), // 当前输出 + kreg_water_cooling_tmp_controler_pid_feedbackval(3002), // 当前输出 + kreg_water_cooling_tmp_controler_temp0(3003), // 温度1 + kreg_water_cooling_tmp_controler_temp1(3004), // 温度2 + kreg_water_cooling_tmp_controler_temp2(3005), // 温度3 + kreg_water_cooling_tmp_controler_temp3(3006), // 温度4 + + kreg_water_cooling_tmp_controler_pid_kp(3050), // kp + kreg_water_cooling_tmp_controler_pid_ki(3051), // ki + kreg_water_cooling_tmp_controler_pid_kd(3052), // kd + kreg_water_cooling_tmp_controler_pid_max_output(3053), // 最大输出 + kreg_water_cooling_tmp_controler_pid_min_output(3054), // 最小输出 + kreg_water_cooling_tmp_controler_pid_max_integral(3055), // 最大积分 + kreg_water_cooling_tmp_controler_pid_min_integral(3056), // 最小积分 + kreg_water_cooling_tmp_controler_pid_error_limit(3057), // 误差限制 + kreg_water_cooling_tmp_controler_pid_compute_interval(3058), // 计算间隔 + + /******************************************************************************* + * 移液枪状态 * + *******************************************************************************/ + kreg_pipette_pos_nl(4000), // 移液枪位置 + kreg_pipette_capactitance_val(4001), // 移液枪电容值 + kreg_pipette_tip_state(4002, false), // 移动液枪tip状态 + + kreg_pipette_zm_pos(4101), + kreg_pipette_zm_is_enable(4102), + kreg_pipette_zm_dpos(4103), + kreg_pipette_zm_shift(4105), + kreg_pipette_zm_shaft(4106), + kreg_pipette_zm_one_circle_pulse(4107), + kreg_pipette_zm_one_circle_pulse_denominator(4108), + kreg_pipette_zm_default_velocity(4109), + kreg_pipette_zm_ihold(4110), + kreg_pipette_zm_irun(4111), + kreg_pipette_zm_iholddelay(4112), + kreg_pipette_zm_iglobalscaler(4113), + kreg_pipette_zm_run_to_zero_speed(4114), + kreg_pipette_zm_look_zero_edge_speed(4115), + kreg_pipette_zm_max_d(4116), + kreg_pipette_zm_min_d(4117), + kreg_pipette_zm_in_debug_mode(4118), + kreg_pipette_zm_vstart(4119), + kreg_pipette_zm_a1(4120), + kreg_pipette_zm_amax(4121), + kreg_pipette_zm_v1(4122), + kreg_pipette_zm_dmax(4123), + kreg_pipette_zm_d1(4124), + kreg_pipette_zm_vstop(4125), + kreg_pipette_zm_tzerowait(4126), + kreg_pipette_zm_enc_resolution(4127), + kreg_pipette_zm_enable_enc(4128), + kreg_pipette_zm_dzero(4129), + kreg_pipette_zm_pos_devi_tolerance(4130), + kreg_pipette_zm_io_trigger_append_distance(4131), + kreg_pipette_zm_has_move_zero(4132), // 是否回零 + kreg_pipette_zm_mres(4133), // 电机细分 + kreg_pipette_zm_encpos(4134), // 编码器位置,readonly + /** + * 光学模组 + * + * 扫描零点偏移:(F光学向左扫描的起始位置) + * 扫描方向:1:板卡箭头方向,-1板卡箭头反方向 + * 扫描点数:固定为1200 + * 扫描步距:固定为1 + * 返回点数:(1200) + */ + kreg_a8k_opt_t_pos_offset(4501), // T光学正向扫描,扫描起始位距离零点的偏移 + kreg_a8k_opt_f_pos_offset(4502), // F光学正向扫描,扫描起始位距离零点的偏移 + kreg_a8k_opt_t_reverse_scan_pos_offset(4503), // T光学逆向扫描,扫描起始位距离零点的偏移 + kreg_a8k_opt_f_reverse_scan_pos_offset(4504), // F光学逆向扫描,扫描起始位距离零点的偏移 + kreg_a8k_opt_scan_step_interval(4505), // 参数固定:为1 + kreg_a8k_opt_scan_pointnum(4506), // 参数固定:为1200个点 + // kreg_a8k_opt_scan_vdefault(4520), + // kreg_a8k_opt_scan_vstart(4521), + // kreg_a8k_opt_scan_a1(4522), + // kreg_a8k_opt_scan_amax(4523), + // kreg_a8k_opt_scan_v1(4524), + // kreg_a8k_opt_scan_dmax(4525), + // kreg_a8k_opt_scan_d1(4526), + // kreg_a8k_opt_scan_vstop(4527), + // kreg_a8k_opt_scan_tzerowait(4528), + + kreg_a8k_opt_f_scan_vdefault(4600), // + kreg_a8k_opt_f_scan_vstart(4601), // + kreg_a8k_opt_f_scan_a1(4602), // + kreg_a8k_opt_f_scan_amax(4603), // + kreg_a8k_opt_f_scan_v1(4604), // + kreg_a8k_opt_f_scan_dmax(4605), // + kreg_a8k_opt_f_scan_d1(4606), // + kreg_a8k_opt_f_scan_vstop(4607), // + kreg_a8k_opt_f_scan_tzerowait(4608), // + kreg_a8k_opt_f_scan_irun(4609), // + + kreg_a8k_opt_t_scan_vdefault(4700), // + kreg_a8k_opt_t_scan_vstart(4701), // + kreg_a8k_opt_t_scan_a1(4702), // + kreg_a8k_opt_t_scan_amax(4703), // + kreg_a8k_opt_t_scan_v1(4704), // + kreg_a8k_opt_t_scan_dmax(4705), // + kreg_a8k_opt_t_scan_d1(4706), // + kreg_a8k_opt_t_scan_vstop(4707), // + kreg_a8k_opt_t_scan_tzerowait(4708), // + kreg_a8k_opt_t_scan_irun(4709), // + + kreg_a8k_opt_barcode_scan_vdefault(4800), // + kreg_a8k_opt_barcode_scan_vstart(4801), // + kreg_a8k_opt_barcode_scan_a1(4802), // + kreg_a8k_opt_barcode_scan_amax(4803), // + kreg_a8k_opt_barcode_scan_v1(4804), // + kreg_a8k_opt_barcode_scan_dmax(4805), // + kreg_a8k_opt_barcode_scan_d1(4806), // + kreg_a8k_opt_barcode_scan_vstop(4807), // + kreg_a8k_opt_barcode_scan_tzerowait(4808), // + kreg_a8k_opt_barcode_scan_irun(4809), // + + + /*********************************************************************************************************************** + * XYROBOT * + ***********************************************************************************************************************/ + + kreg_xyrobot_io_state(9900, false), // + kreg_xyrobot_is_enable(9901), // + kreg_xyrobot_robot_type(9950), // + kreg_xyrobot_one_circle_pulse(9951), // + kreg_xyrobot_one_circle_pulse_denominator(9952), // + kreg_xyrobot_ihold(9954), // + kreg_xyrobot_irun(9955), // + kreg_xyrobot_iholddelay(9956), // + kreg_xyrobot_iglobalscaler(9957), // + kreg_xyrobot_vstart(9958), // + kreg_xyrobot_a1(9959), // + kreg_xyrobot_amax(9960), // + kreg_xyrobot_v1(9961), // + kreg_xyrobot_dmax(9962), // + kreg_xyrobot_d1(9963), // + kreg_xyrobot_vstop(9964), // + kreg_xyrobot_tzerowait(9965), // + kreg_xyrobot_enc_resolution(9966), // + kreg_xyrobot_enable_enc(9967), // + kreg_xyrobot_x_shaft(9968), // + kreg_xyrobot_y_shaft(9969), // + kreg_xyrobot_min_x(9972), // + kreg_xyrobot_min_y(9973), // + kreg_xyrobot_max_x(9974), // + kreg_xyrobot_max_y(9975), // + kreg_xyrobot_run_to_zero_speed(9976), // + kreg_xyrobot_look_zero_edge_speed(9977), // + kreg_xyrobot_shift_x(9978), // + kreg_xyrobot_shift_y(9979), // + kreg_xyrobot_pos_devi_tolerance(9980), // + kreg_xyrobot_io_trigger_append_distance(9981), // + kreg_xyrobot_default_velocity(10000), // + + /*********************************************************************************************************************** + * step_motor * + ***********************************************************************************************************************/ + + kreg_step_motor_pos(10101), // 机器人x坐标 + kreg_step_motor_is_enable(10102), // 是否使能 + kreg_step_motor_dpos(10103), // 执行完上一条指令后的相对位移 + kreg_step_motor_has_move_zero(10104), // 是否回零 + // kreg_step_motor_shift(10150), // x偏移 + kreg_step_motor_shaft(10151), // x轴是否反转 + kreg_step_motor_one_circle_pulse(10152), // x轴一圈脉冲数 + kreg_step_motor_one_circle_pulse_denominator(10153), // 设置一圈脉冲数的分母 + kreg_step_motor_default_velocity(10154), // 默认速度 + kreg_step_motor_low_velocity(10155), // 低速 + kreg_step_motor_mid_velocity(10156), // 中速 + kreg_step_motor_high_velocity(10157), // 高速 + kreg_step_motor_ihold(10158), // 步进电机电流配置 + kreg_step_motor_irun(10159), // 步进电机电流配置 + kreg_step_motor_iholddelay(10160), // 步进电机电流配置 + kreg_step_motor_iglobalscaler(10161), // 步进电机电流配置 + kreg_step_motor_mres(10162), // 电机细分 + kreg_step_motor_run_to_zero_speed(10173), // 回零速度 + kreg_step_motor_look_zero_edge_speed(10175), // 找零边缘速度 + kreg_step_motor_max_d(10178), // 最大限制距离 + kreg_step_motor_min_d(10179), // 最小限制距离 + kreg_step_motor_in_debug_mode(10180), // 驱动器处于调试模式 + kreg_step_motor_vstart(10181), // a1起作用的速度 + kreg_step_motor_a1(10182), // + kreg_step_motor_amax(10183), // + kreg_step_motor_v1(10184), // + kreg_step_motor_dmax(10185), // + kreg_step_motor_d1(10186), // + kreg_step_motor_vstop(10187), // + kreg_step_motor_tzerowait(10188), // + kreg_step_motor_enc_resolution(10189), // 编码器分辨率 1000,1024,4000,4096,16384 + kreg_step_motor_enable_enc(10190), // + kreg_step_motor_dzero_pos(10191), // 驱动器处于调试模式 + kret_step_motor_pos_devi_tolerance(10192), // 位置偏差容忍度 + kret_step_motor_io_trigger_append_distance(10193), // 移动到io时,附加的距离 + kreg_step_motor_zero_io_mirror(10194), //零点IO有效位是否翻转 + kreg_step_motor_limit_io_mirror(10195), //限位IO有效位是否翻转 + + /*********************************************************************************************************************** + * step_motor * + ***********************************************************************************************************************/ + + kreg_mini_servo_pos(10201), // 位置 + kreg_mini_servo_limit_velocity(10251), // 限制速度 + kreg_mini_servo_limit_torque(10252), // 限制扭矩 + kreg_mini_servo_protective_torque(10253), // 保护扭矩 + kreg_mini_servo_is_move(10254), // 是否在运动 + kreg_mini_servo_status(10255), // 舵机状态 + kreg_mini_servo_voltage(10256), // 电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V + kreg_mini_servo_current(10257), // 电流 反馈当前工作电流值,单位为ma + kreg_mini_servo_temperature(10258), // 温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 + kreg_mini_servo_loadvalue(10259), // 负载值 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 + kreg_mini_servo_target_pos_tolerance(10260), // 目标位置容忍度 + + + kreg_mini_servo_firmware_main_version(10500), // 固件主版本号 + kreg_mini_servo_firmware_sub_version(10501), // 固件次版本号 + kreg_mini_servo_servo_main_version(10503), // 舵机主版本号 + kreg_mini_servo_servo_sub_version(10504), // 舵机次版本号 + kreg_mini_servo_servo_min_angle(10509), // 最小角度限制 + kreg_mini_servo_servo_max_angle(10511), // 最大角度限制 + kreg_mini_servo_servo_max_temp(10513), // 最高温度上限 + kreg_mini_servo_servo_max_voltage(10514), // 最高输入电压 + kreg_mini_servo_servo_min_voltage(10515), // 最低输入电压 + kreg_mini_servo_servo_max_torque(10516), // 最大扭矩 + kreg_mini_servo_servo_unload_condition(10519), // 卸载条件 + kreg_mini_servo_servo_p(10521), // P 比例系 + kreg_mini_servo_servo_d(10522), // D 微分系 + kreg_mini_servo_servo_i(10523), // I + kreg_mini_servo_servo_min_start(10524), // 最小启动 + kreg_mini_servo_servo_cw_dead_zone(10526), // 顺时针不灵敏区 + kreg_mini_servo_servo_ccw_dead_zone(10527), // 逆时针不灵敏 + kreg_mini_servo_servo_protect_current(10528), // 保护电流 + kreg_mini_servo_servo_protect_torque(10534), // 保护扭矩 0->100 ,触发后,需要写入与组转方向相反的位置指令,进行解除 + kreg_mini_servo_servo_protect_time(10535), // 保护时间 + kreg_mini_servo_servo_overload_torque(10536), // 过载扭矩 + kreg_mini_servo_servo_speed_p(10537), // 速度闭环P比例参数 + kreg_mini_servo_servo_overload_time(10538), // 过流保护时间 + kreg_mini_servo_servo_speed_i(10539), // 速度闭环I积分参数 + kreg_mini_servo_servo_torque_switch(10540), // 扭矩开关 + kreg_mini_servo_servo_acc(10541), // 加速度 + kreg_mini_servo_servo_target_pos(10542), // 目标位置 + kreg_mini_servo_servo_run_time(10544), // 运行时间 + kreg_mini_servo_servo_run_speed(10546), // 运行速度 + kreg_mini_servo_servo_torque_limit(10548), // 转矩限制 + kreg_mini_servo_servo_lock_flag(10555), // 锁标志 + kreg_mini_servo_servo_current_pos(10556), // 当前位置 + kreg_mini_servo_servo_current_speed(10558), // 当前速度 + kreg_mini_servo_servo_current_load(10560), // 当前负载 bit10为方向位 输出驱动电机的当前占空比电压,单位为0.1%,取值0-1000 + kreg_mini_servo_servo_current_voltage(10562), // 当前电压 反馈当前舵机工作电压,反馈精度为0.1V,即120*0.1=12V + kreg_mini_servo_servo_current_temp(10563), // 当前温度 反馈当前舵机内部工作温度,反馈精度为1摄氏度 + kreg_mini_servo_servo_status(10565), // 舵机状态 + kreg_mini_servo_servo_move_flag(10566), // 移动标志 + kreg_mini_servo_servo_current_current(10569), // 当前电流 反馈当前工作电流值,单位为6.26.5mA,最大可反馈电流为500*6.5mA=3250mA + + + /*********************************************************************************************************************** + * ID_CARD_READER * + ***********************************************************************************************************************/ + + kreg_id_card_reader_raw_sector_size(10301), // + + kreg_id_card_reader_raw_sector_num(10302), // + + kreg_id_card_reader_is_online(10303, false), // + + /*********************************************************************************************************************** + * 板夹仓扫码 * + ***********************************************************************************************************************/ + + kreg_plate_code_scaner_laster_intensity(10401), // + + kreg_plate_code_scaner_scan_gain(10402), // + + kreg_plate_code_scaner_scan_velocity(10403), // + + kreg_plate_code_scaner_scan_start_pos(10404), // + + kreg_plate_code_scaner_final_stop_pos(10405), // + + kreg_plate_code_scaner_code_judgment_threshold(10406), // + + kreg_plate_code_scaner_item(10407), // + + kreg_plate_code_scaner_lot(10408), // + + kreg_plate_code_scaner_rawcode(10409), // + + kreg_plate_code_scaner_code_legal(10410); // + + public final int index; + public final Boolean trace; + + RegIndex(int regIndex) { + this.index = regIndex; + this.trace = true; + } + + RegIndex(int regIndex, Boolean trace) { + this.index = regIndex; + this.trace = trace; + } + + public static RegIndex valueOf(int val) { + RegIndex[] values = RegIndex.values(); + for (RegIndex regindex : values) { + if (regindex.index == val) { + return regindex; + } + } + return null; + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorMId.java b/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorMId.java new file mode 100644 index 0000000..c118194 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorMId.java @@ -0,0 +1,24 @@ +package a8k.app.iflytophald.type.protocol; + +import org.springframework.util.Assert; + +public enum StepMotorMId { + PlatesBoxYM(MId.PlatesBoxYM),// + PlatesBoxPusherM(MId.PlatesBoxPusherM),// + ShakeModClampingM(MId.ShakeModClampingM),// + ShakeModGripperZM(MId.ShakeModGripperZM),// + ShakeModShakeM(MId.ShakeModShakeM),// + FeedingModInfeedM(MId.FeedingModInfeedM),// + FeedingModXM(MId.FeedingModXM),// + FeedingModOutfeedM(MId.FeedingModOutfeedM),// + IncubatorRotateCtrlM(MId.IncubatorRotateCtrlM),// + OptModScannerM(MId.OptModScannerM),//),// + OptModPullM(MId.OptModPullM),// + ; + final public MId mid; + + StepMotorMId(MId mid) { + Assert.isTrue(this.name().equals(mid.name()),"StepMotorMId init fail"); + this.mid = mid; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorRegIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorRegIndex.java new file mode 100644 index 0000000..0a067f5 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorRegIndex.java @@ -0,0 +1,55 @@ +package a8k.app.iflytophald.type.protocol; + +public enum StepMotorRegIndex { + // kreg_module_version(RegIndex.kreg_module_version), // 模块版本 + // kreg_module_type(RegIndex.kreg_module_type), // 模块类型 + // kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error + // kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag + /*********************************************************************************************************************** + * step_motor * + ***********************************************************************************************************************/ + kreg_step_motor_pos(RegIndex.kreg_step_motor_pos), // 机器人x坐标 + kreg_step_motor_is_enable(RegIndex.kreg_step_motor_is_enable), // 是否使能 + kreg_step_motor_dpos(RegIndex.kreg_step_motor_dpos), // 执行完上一条指令后的相对位移 + kreg_step_motor_has_move_zero(RegIndex.kreg_step_motor_has_move_zero), // 是否已经移动到零点 + // kreg_step_motor_shift(RegIndex.kreg_step_motor_shift), // x偏移 + kreg_step_motor_shaft(RegIndex.kreg_step_motor_shaft), // x轴是否反转 + kreg_step_motor_one_circle_pulse(RegIndex.kreg_step_motor_one_circle_pulse), // x轴一圈脉冲数 + kreg_step_motor_one_circle_pulse_denominator(RegIndex.kreg_step_motor_one_circle_pulse_denominator), // 设置一圈脉冲数的分母 + kreg_step_motor_default_velocity(RegIndex.kreg_step_motor_default_velocity), // 默认速度 + kreg_step_motor_low_velocity(RegIndex.kreg_step_motor_low_velocity), + kreg_step_motor_mid_velocity(RegIndex.kreg_step_motor_mid_velocity), + kreg_step_motor_high_velocity(RegIndex.kreg_step_motor_high_velocity), + kreg_step_motor_ihold(RegIndex.kreg_step_motor_ihold), // 步进电机电流配置 + kreg_step_motor_irun(RegIndex.kreg_step_motor_irun), // 步进电机电流配置 + kreg_step_motor_iholddelay(RegIndex.kreg_step_motor_iholddelay), // 步进电机电流配置 + kreg_step_motor_iglobalscaler(RegIndex.kreg_step_motor_iglobalscaler), // 步进电机电流配置 + kreg_step_motor_mres(RegIndex.kreg_step_motor_mres), // 步进电机电流配置 + + kreg_step_motor_run_to_zero_speed(RegIndex.kreg_step_motor_run_to_zero_speed), // 回零速度 + kreg_step_motor_look_zero_edge_speed(RegIndex.kreg_step_motor_look_zero_edge_speed), // 找零边缘速度 + kreg_step_motor_max_d(RegIndex.kreg_step_motor_max_d), // 最大限制距离 + kreg_step_motor_min_d(RegIndex.kreg_step_motor_min_d), // 最小限制距离 + kreg_step_motor_in_debug_mode(RegIndex.kreg_step_motor_in_debug_mode), // 驱动器处于调试模式 + kreg_step_motor_vstart(RegIndex.kreg_step_motor_vstart), // a1起作用的速度 + kreg_step_motor_a1(RegIndex.kreg_step_motor_a1), // + kreg_step_motor_amax(RegIndex.kreg_step_motor_amax), // + kreg_step_motor_v1(RegIndex.kreg_step_motor_v1), // + kreg_step_motor_dmax(RegIndex.kreg_step_motor_dmax), // + kreg_step_motor_d1(RegIndex.kreg_step_motor_d1), // + kreg_step_motor_vstop(RegIndex.kreg_step_motor_vstop), // + kreg_step_motor_tzerowait(RegIndex.kreg_step_motor_tzerowait), // + kreg_step_motor_enc_resolution(RegIndex.kreg_step_motor_enc_resolution), // 编码器分辨率 1000,1024,4000,4096,16384 + kreg_step_motor_enable_enc(RegIndex.kreg_step_motor_enable_enc), // + kreg_step_motor_dzero_pos(RegIndex.kreg_step_motor_dzero_pos), // 驱动器处于调试模式 + kret_step_motor_pos_devi_tolerance(RegIndex.kret_step_motor_pos_devi_tolerance), // 位置偏差容忍度 + kret_step_motor_io_trigger_append_distance(RegIndex.kret_step_motor_io_trigger_append_distance), // 移动到io时,附加的距离 + kreg_step_motor_zero_io_mirror(RegIndex.kreg_step_motor_zero_io_mirror), // 零点io镜像 + kreg_step_motor_limit_io_mirror(RegIndex.kreg_step_motor_limit_io_mirror), // 限位io镜像 + ; + public final RegIndex regIndex; + + StepMotorRegIndex(RegIndex regIndex) { + this.regIndex = regIndex; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorSpeedLevel.java b/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorSpeedLevel.java new file mode 100644 index 0000000..f0653d8 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/StepMotorSpeedLevel.java @@ -0,0 +1,9 @@ +package a8k.app.iflytophald.type.protocol; + +public enum StepMotorSpeedLevel { + DEFAULT, + LOW, + MID, + HIGH, + ; +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerMid.java b/src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerMid.java new file mode 100644 index 0000000..773f7e0 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerMid.java @@ -0,0 +1,15 @@ +package a8k.app.iflytophald.type.protocol; + +import org.springframework.util.Assert; + +public enum TemperatureControlerMid { + PlatesBoxTCM(MId.PlatesBoxTCM), + IncubatorTCM(MId.IncubatorTCM), + ; + final public MId mid; + + TemperatureControlerMid(MId mid) { + Assert.isTrue(this.name().equals(mid.name()), "StepMotorMId init fail"); + this.mid = mid; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerRegIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerRegIndex.java new file mode 100644 index 0000000..95eb951 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/TemperatureControlerRegIndex.java @@ -0,0 +1,40 @@ +package a8k.app.iflytophald.type.protocol; + +import org.springframework.util.Assert; + +public enum TemperatureControlerRegIndex { + kreg_water_cooling_tmp_controler_pid_target(RegIndex.kreg_water_cooling_tmp_controler_pid_target), + kreg_water_cooling_tmp_controler_pid_nowoutput(RegIndex.kreg_water_cooling_tmp_controler_pid_nowoutput), + kreg_water_cooling_tmp_controler_pid_feedbackval(RegIndex.kreg_water_cooling_tmp_controler_pid_feedbackval), + kreg_water_cooling_tmp_controler_temp0(RegIndex.kreg_water_cooling_tmp_controler_temp0), + kreg_water_cooling_tmp_controler_temp1(RegIndex.kreg_water_cooling_tmp_controler_temp1), + kreg_water_cooling_tmp_controler_temp2(RegIndex.kreg_water_cooling_tmp_controler_temp2), + kreg_water_cooling_tmp_controler_temp3(RegIndex.kreg_water_cooling_tmp_controler_temp3), + kreg_water_cooling_tmp_controler_pid_kp(RegIndex.kreg_water_cooling_tmp_controler_pid_kp), + kreg_water_cooling_tmp_controler_pid_ki(RegIndex.kreg_water_cooling_tmp_controler_pid_ki), + kreg_water_cooling_tmp_controler_pid_kd(RegIndex.kreg_water_cooling_tmp_controler_pid_kd), + kreg_water_cooling_tmp_controler_pid_max_output(RegIndex.kreg_water_cooling_tmp_controler_pid_max_output), + kreg_water_cooling_tmp_controler_pid_min_output(RegIndex.kreg_water_cooling_tmp_controler_pid_min_output), + kreg_water_cooling_tmp_controler_pid_max_integral(RegIndex.kreg_water_cooling_tmp_controler_pid_max_integral), + kreg_water_cooling_tmp_controler_pid_min_integral(RegIndex.kreg_water_cooling_tmp_controler_pid_min_integral), + kreg_water_cooling_tmp_controler_pid_error_limit(RegIndex.kreg_water_cooling_tmp_controler_pid_error_limit), + kreg_water_cooling_tmp_controler_pid_compute_interval(RegIndex.kreg_water_cooling_tmp_controler_pid_compute_interval), + + ; + public final RegIndex regIndex; + + TemperatureControlerRegIndex(RegIndex regIndex) { + Assert.isTrue(this.name().equals(regIndex.name()), "PipetteRegIndex name must be equal to RegIndex name"); + this.regIndex = regIndex; + } + + public static TemperatureControlerRegIndex valueOf(int val) { + TemperatureControlerRegIndex[] values = TemperatureControlerRegIndex.values(); + for (TemperatureControlerRegIndex regindex : values) { + if (regindex.regIndex.index == val) { + return regindex; + } + } + return null; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/AspirationParamId.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/AspirationParamId.java new file mode 100644 index 0000000..8f4ecfd --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/AspirationParamId.java @@ -0,0 +1,42 @@ +package a8k.app.iflytophald.type.protocol.pipette_module; + +public enum AspirationParamId { + // + // 吸取体积 + // + volume, + // + // 容器 + // + containerPos, + containerInfoCpyId, + // + // 液体类型 + // + liquidCfgIdx, + // + // 吸取模式 + // + aspirationMode, + // + // lld配置 + // + lldEnable, + lldType, + lldEnableProtect, + // + // llf配置 + // + mixLlfEnable, + llfEnable, + // + // 混匀配置 + // + mixVolume, + mixTimes, + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java new file mode 100644 index 0000000..b3211c5 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuAllParamId.java @@ -0,0 +1,35 @@ +package a8k.app.iflytophald.type.protocol.pipette_module; + +public enum DistribuAllParamId { + // + // 容器位置 + // + containerPos, // 容器位置 + + // + // 目标容器信息 + // + destContainerCpyid, // 目标容器配置索引 + destContainerIsEmpty, // 目标容器是否为空 + destLiquidCfgIndex, // 目标容器中的液体类型 + + // + // 分配方式 + // + distribuType, // 分配类型 0:液面上分配,1:液面下分配 + + // + // 混匀配置 + // + mixVolume, // 混匀体积 + mixTimes, // 混匀次数 + // + // 其他配置 + // + zmAutoMoveToZero, // zm自动归零 + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuType.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuType.java new file mode 100644 index 0000000..2a97e65 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/DistribuType.java @@ -0,0 +1,11 @@ +package a8k.app.iflytophald.type.protocol.pipette_module; + +public enum DistribuType { + JET_DIST, //液面上分配 + SURFACE_DIST, //液体表面分配 + ; + + public Integer toInteger() { + return this.ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteConfig.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteConfig.java new file mode 100644 index 0000000..953d8f1 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteConfig.java @@ -0,0 +1,19 @@ +package a8k.app.iflytophald.type.protocol.pipette_module; + +import a8k.app.client.iflytophald.type.protocol.pipette_module.cfgbean.*; +import a8k.app.iflytophald.type.protocol.pipette_module.cfgbean.*; + +import java.util.ArrayList; +import java.util.List; + +public class PipetteConfig { + public PipetteZMBCfg zmBCfgs; + public PipetteCommonConfig commonCfg; + + public List platInfos = new ArrayList<>(); + public List containerInfos = new ArrayList<>(); + public List liquidInfos = new ArrayList<>(); + public List zmVCfgs = new ArrayList<>(); + public List pmVCfgs = new ArrayList<>(); + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java new file mode 100644 index 0000000..c13b347 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/PipetteStateIndex.java @@ -0,0 +1,32 @@ +package a8k.app.iflytophald.type.protocol.pipette_module; + +public enum PipetteStateIndex { + enable, + dul, + dpos, + zmHasMoveZero, + + aspirationOk, + pumpLldReachLimit, + detectedLiquid, + waterLevel, + tipblock, + airsuction, + bubble, + + + asynchronousResult0, + asynchronousResult1, + + platinfoCpyid,//当前plateinfoCpyId + + testPipetteIo1Connected, + testPipetteIo1Reverse, + testPipetteUart485Connected, + testPipetteUart232Connected, + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/TipType.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/TipType.java new file mode 100644 index 0000000..fc8d879 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/TipType.java @@ -0,0 +1,34 @@ +package a8k.app.iflytophald.type.protocol.pipette_module; + +public enum TipType { + TS1000UL, // 0 1000ul max=1002.6ul + TS200UL, // 1 200ul max=250ul + TS50UL, // 2 50ul max=62ul + TS20UL, // 3 20ul max=40ul + NotSet, + ; + + public static TipType of(Integer val) { + if (val < 0) + return NotSet; + + for (TipType idx : TipType.values()) { + if (idx.ordinal() == val) { + return idx; + } + } + return NotSet; + } + + public static Integer of(TipType idx) { + if (idx == null) + return -1; + if (idx.equals(NotSet)) + return -1; + return idx.ordinal(); + } + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java new file mode 100644 index 0000000..9a35b83 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ContainerInfoIndex.java @@ -0,0 +1,23 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +public enum ContainerInfoIndex { + containerType, // 容器类型 0:平面 1:flat(平底) 2:conical(锥底) 3:round(圆底) + containerNeckPos, // 容器,瓶口位置(相对位置0.1mm) + containerDepth, // 容器,深度(0.1mm) + containerRound, // 容器,直径(0.1mm) + containerBottomSectionHeight, // 容器,瓶底高度(0.1mm) + immersionDepth, // 侵入液面高度,即液面以下的高度,精度0.1mm + leavingHeight, // 离开液面高度,此位置ZEUS开始缓慢进入液面或离开液面,精度0.1mm + jetHeight, // 喷射高度(0.1mm) + lldStartSearchDepth, // lld开始搜索时位置冗余,精度0.1mm,abspos = container_neck_pos + lld_start_search_pos_redundancy + fixAspirationDepth, // 固定吸液深度((0.1mm),当lld失能时,移液枪先移动到这个位置,然后开始吸液 + llfVConvertCoefficient, // 液面跟随转换系数 0.0001 llf_zm_vel = aspiration_pm_vel * llf_vconvert_coneff * 0.0001 + pierceDepth, // 穿刺深度(0.1mm),用于刺破容器防尘膜 + lldEndPosMargin, // 液面跟随结束位置冗余(0.1mm),用于液面跟随结束时,移液枪的冗余位置 + mark, + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java new file mode 100644 index 0000000..00abb29 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/LiquidInfoIndex.java @@ -0,0 +1,76 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +public enum LiquidInfoIndex { + // // + // // lld + // // + plldPmVCpyId, // 液面探测时泵机速率 + plldThreshold, // 液面探测阈值 + plldZmVel, // 液面探测时泵机速率 + plldInvasionDepth,//液面探测时,会多侵入液面一定深度,这个深度和plld阈值和zm_vel速度有关 (0.1mm) + + // // + // // 清空tip配置 + // // + emptyTipPmVCpyId, // 清空tip速度 + // // + // // 吸入空气 + // // + blowoutAirVolume, // 清空空气量,在吸液前吸入的空气量. 精度0.1ul (保证清空tip头) + blowoutAirPmVCpyId, // 吸入空气时泵机速率 + // // + // // 润湿tip头配置 + // // + overAspiratedVolume, // 过量吸液量,先吸入后迅速排出用来润湿tip头,这个用在移液量小于10微升的情况下。精度0.1ul + overAspiratedPmVCpyId, // 过量吸液速度 + // + // aspiration 吸液配置 + // + aspirationPmVCpyIdLow,// 小体积吸液速度 + aspirationPmVCpyIdHigh,// 大体积吸液速度 + aspirationVolumeBreakVal,// 小体积大体积分界点 + volumeCalibrationCoefficientB,// 0.0001 + volumeCalibrationCoefficientK,// 0.0001 + /** + * settling_time(ms) + * + * Settling Time in 1 ms + * This parameter sets how long the tip + * remains in liquid after aspiration or + * dispense before moving out of the + * liquid. The tip geometry and liquid + * viscosity are considered when setting + * this parameter. If settling time is too + * short the liquid has not enough time to fill + * the tip and unwanted air is aspirated + * as soon as the tip is lifted out of the liquid. + * + * 保持时间 + * + * 此参数用于吸液后在液面下保持的时间。这个参数的设定根据tip头的类型和液体的粘稠度有关。 + * 如果此值设定的时间太短则液体不能完全充满tip头。 + * + */ + settlingTime, // (ms) 设置 + // // + // // 转移时多吸入的量 + // // + transportVolume, // 转移过程中多吸入的量,精度0.1ul (放滴落) + transportVolumePmVCpyId, // 吸入过量空气时泵机速率 + // + // // + // // 混匀pm速率 + // // + mixPmVCpyId, // 混匀时泵机速率配置 + // + // 分配配置 + // + jetPmVCpyId, // 喷射时泵机速率配置 jet_pm_vcpyid + distributePmVCpyId, // 分配时泵机速率配置 distribu_pm_vpyid + mark, + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java new file mode 100644 index 0000000..1488073 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMBasicConfigIndex.java @@ -0,0 +1,11 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +public enum PMBasicConfigIndex { + Pad, + mark, + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java new file mode 100644 index 0000000..abbb310 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PMVConfigIndex.java @@ -0,0 +1,16 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +public enum PMVConfigIndex { + acc, // 加速度 level 1…20 default:14 1:797.5 ul/s^2 ... 20:797*20 nl/s^2 + dec, // 减速度 level 1…20 default:14 + vStart, // 启动速度 ul/s (0...319) + vStop, // 停止速度 ul/s (0...319) + vMax, // 最大速度 ul/s (0...2552) +mark, + ; + + public Integer toInteger() { + return ordinal(); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java new file mode 100644 index 0000000..b566a48 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PipetteCommonConfigIndex.java @@ -0,0 +1,14 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +public enum PipetteCommonConfigIndex { + pressureRecordEnable, + platformInfoCpyid, + eachActionDelayTime, + aspiratePressureReportExtendTime, // 吸液压力采集延长时间,吸液完成后,多采集压力的时间 + lldEnableProtect, // 是否启用LLD保护,如果启用,则在LLD过程中,最大探测范围为tip的长度范围 + mark; + + public Integer toInteger() { + return ordinal(); + } +} \ No newline at end of file diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java new file mode 100644 index 0000000..1fe9d11 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/PlatformInfoIndex.java @@ -0,0 +1,34 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +public enum PlatformInfoIndex { + /** + * 工作参考平面 + * 代码中并不使用这个位置,这个参数只是为了后续 + * 如果平台高度发生变化时,可以通过调整dzero使得 + * work_ref_plane数值不变。 + */ + workRefPos, + + tipPickingPos, // 开始取tip位置(绝对位置0.1mm) + tipPickingSearchRange, // 取tip的范围 + tipPickingAppendDistance, // 取tip时z轴的附加距离 + tipPickingSettlingTime, // 取tip时的settling时间 + tipDepositPos, // 丢tip位置(绝对位置0.1mm) + transformPos, // 移液枪安全移动的高度(绝对位置0.1mm) + + /** + * tip类型 + * TS1000UL = 0 // 1000ul max=1002.6ul + * TS200UL = 1 // 200ul max=250ul + * TS50UL = 2 // 50ul max=62ul + * TS20UL = 3 // 20ul max=40ul + */ + tipType, + tipLength, // tip长度 + mark, + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java new file mode 100644 index 0000000..ad5a246 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMBasicConfigIndex.java @@ -0,0 +1,30 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +/** + * Z轴电机基础配置 + */ +public enum ZMBasicConfigIndex { + shaft, + oneCirclePulse, + oneCirclePulseDenominator, + ihold, + irun, + iholddelay, + iglobalscaler, + mind, + maxd, + tzerowait, + encResolution, + enableEnc, + dzero, + ioTriggerAppendDistance, + posDeviTolerance, + mres, + mark, + ; + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java new file mode 100644 index 0000000..a51ff7b --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfg/ZMVConfigIndex.java @@ -0,0 +1,18 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfg; + +public enum ZMVConfigIndex { + vstart, + a1, + amax, + v1, + dmax, + d1, + vstop, + vmax, + mark, + ; + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java new file mode 100644 index 0000000..69f695a --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteCommonConfig.java @@ -0,0 +1,83 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfgbean; + +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.PipetteCommonConfigIndex; +import a8k.app.type.exception.AppException; + +public class PipetteCommonConfig { + + + /** + * @brief + * + * LLD + * 移动到液面之上--> + * 清空TIP + * 吸入空气 + * 移动到液面之下--> + * 吸入 + * 等待一定时间 + * 移动到液面之上(缓慢) + * 吸入一定量的空气 + */ + + // + // lld + // + public Integer pressureRecordEnable = 0; // 是否记录压力数据 + public Integer platformInfoCpyid = 0; // 平台信息配置索引,当调用initPumpDevice时,如果传入的参数为-1,则使用platformInfoMCpyid + public Integer eachActionDelayTime = 0; // 每个动作之间的延时,单位ms (动作调试使用,方便观察液体变化情况) + public Integer aspiratePressureReportExtendTime = 0; // 吸液压力采集延长时间,吸液完成后,多采集压力的时间 + public Integer lldEnableProtect = 0; // 是否启用LLD保护,如果启用,则在LLD过程中,最大探测范围为tip的长度范围 + public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 + + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(PipetteCommonConfigIndex index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(PipetteCommonConfigIndex index, Integer itermVal) throws AppException; + } + + + public static PipetteCommonConfig build(AssignObjectItemFn assignFn) throws AppException { + PipetteCommonConfig info = new PipetteCommonConfig(); + info.assignObject(assignFn); + return info; + } + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (PipetteCommonConfigIndex idx : PipetteCommonConfigIndex.values()) { + try { + PipetteCommonConfig.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (PipetteCommonConfigIndex idx : PipetteCommonConfigIndex.values()) { + try { + Integer val = (Integer) PipetteCommonConfig.class.getDeclaredField(idx.name()).get(this); + if (val == null) + continue; + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + PipetteCommonConfig info = new PipetteCommonConfig(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> { + System.out.println("Index: " + index + ", Value: " + val); + }); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java new file mode 100644 index 0000000..90c3b92 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteContainerInfo.java @@ -0,0 +1,70 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfgbean; + +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.ContainerInfoIndex; +import a8k.app.type.exception.AppException; + +public class PipetteContainerInfo { + public Integer containerType = 0; // 容器类型 0:平面 1:flat(平底) 2:conical(锥底) 3:round(圆底) + public Integer containerNeckPos = 0; // 容器,瓶口位置(相对位置0.1mm) !discard 废弃不再使用 + public Integer containerDepth = 0; // 容器,深度(0.1mm) + public Integer containerRound = 0; // 容器,直径(0.1mm) + public Integer containerBottomSectionHeight = 0; // 容器,瓶底高度(0.1mm) + public Integer immersionDepth = 0; // 侵入液面高度,即液面以下的高度,精度0.1mm + public Integer leavingHeight = 0; // 离开液面高度,此位置ZEUS开始缓慢进入液面或离开液面,精度0.1mm + public Integer jetHeight = 0; // 喷射高度(0.1mm) + public Integer lldStartSearchDepth = 0; // lld开始搜索时位置冗余,精度0.1mm,abspos = container_neck_pos + lld_start_search_pos_redundancy + public Integer fixAspirationDepth = 0; // 固定吸液深度((0.1mm),当lld失能时,移液枪先移动到这个位置,然后开始吸液 + public Integer llfVConvertCoefficient = 0; // 液面跟随转换系数 0.0001 llf_zm_vel = aspiration_pm_vel * llf_vconvert_coneff * 0.0001 + public Integer pierceDepth = 0; // 穿刺深度(0.1mm),用于刺破容器防尘膜 + public Integer lldEndPosMargin = 0; // 液面跟随结束位置冗余(0.1mm),lld_max_pos = container_pos + container_depth - lld_end_pos_margin + public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 + + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(ContainerInfoIndex index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(ContainerInfoIndex index, Integer itermVal) throws AppException; + } + + public static PipetteContainerInfo build(AssignObjectItemFn assignFn) throws AppException { + PipetteContainerInfo info = new PipetteContainerInfo(); + info.assignObject(assignFn); + return info; + } + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (ContainerInfoIndex idx : ContainerInfoIndex.values()) { + try { + PipetteContainerInfo.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (ContainerInfoIndex idx : ContainerInfoIndex.values()) { + try { + Integer val = (Integer) PipetteContainerInfo.class.getDeclaredField(idx.name()).get(this); + if (val == null) + continue; + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + PipetteContainerInfo info = new PipetteContainerInfo(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> System.out.println("Index: " + index + ", Value: " + val)); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java new file mode 100644 index 0000000..b9c3af5 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteLiquidInfo.java @@ -0,0 +1,149 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfgbean; + +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.LiquidInfoIndex; +import a8k.app.type.exception.AppException; + +public class PipetteLiquidInfo { + + + /** + * @brief + * + * LLD + * 移动到液面之上--> + * 清空TIP + * 吸入空气 + * 移动到液面之下--> + * 吸入 + * 等待一定时间 + * 移动到液面之上(缓慢) + * 吸入一定量的空气 + */ + + // + // lld + // + public Integer plldPmVCpyId = 0; // 液面探测时泵机速率 + public Integer plldThreshold = 0; // 液面探测阈值 + public Integer plldZmVel = 0; // 液面探测时泵机速率 + public Integer plldInvasionDepth = 0; + // + // 清空tip配置 + // + public Integer emptyTipPmVCpyId = 0; // 清空tip速度 + + // + // 吸入空气 + // + public Integer blowoutAirVolume = 0; // 清空空气量,在吸液前吸入的空气量. 精度0.1ul (保证清空tip头) + public Integer blowoutAirPmVCpyId = 0; // 吸入空气时泵机速率 + + // + // 润湿tip头配置 + // + public Integer overAspiratedVolume = 0; // 过量吸液量,先吸入后迅速排出用来润湿tip头,这个用在移液量小于10微升的情况下。精度0.1ul + public Integer overAspiratedPmVCpyId = 0; // 过量吸液速度 + + // + // aspiration 吸液配置 + // + public Integer aspirationPmVCpyIdLow = 0; // 小体积吸液速度 + public Integer aspirationPmVCpyIdHigh = 0; // 大体积吸液速度 + public Integer aspirationVolumeBreakVal = 0; // 小体积大体积分界点 + public Integer volumeCalibrationCoefficientB = 0; // 0.0001 + public Integer volumeCalibrationCoefficientK = 0; // 0.0001 + + // + // 保持时间 + // + /** + * @brief settling_time(ms) + * + * Settling Time in 1 ms + * This parameter sets how long the tip + * remains in liquid after aspiration or + * dispense before moving out of the + * liquid. The tip geometry and liquid + * viscosity are considered when setting + * this parameter. If settling time is too + * short the liquid has not enough time to fill + * the tip and unwanted air is aspirated + * as soon as the tip is lifted out of the liquid. + * + * 保持时间 + * + * 此参数用于吸液后在液面下保持的时间。这个参数的设定根据tip头的类型和液体的粘稠度有关。 + * 如果此值设定的时间太短则液体不能完全充满tip头。 + * + */ + public Integer settlingTime = 0; // (ms) 设置 + + // + // 转移时多吸入的量 + // + public Integer transportVolume = 0; // 转移过程中多吸入的量,精度0.1ul (放滴落) + public Integer transportVolumePmVCpyId = 0; // 吸入过量空气时泵机速率 + + // + // 混匀pm速率 + // + public Integer mixPmVCpyId = 0; // 混匀时泵机速率配置 + // + // 分配配置 + // + public Integer jetPmVCpyId = 0; // 喷射时泵机速率配置 jet_pm_vcpyid + public Integer distributePmVCpyId = 0; // 分配时泵机速率配置 distribu_pm_vpyid + + public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 + + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(LiquidInfoIndex index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(LiquidInfoIndex index, Integer itermVal) throws AppException; + } + + + public static PipetteLiquidInfo build(AssignObjectItemFn assignFn) throws AppException { + PipetteLiquidInfo info = new PipetteLiquidInfo(); + info.assignObject(assignFn); + return info; + } + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (LiquidInfoIndex idx : LiquidInfoIndex.values()) { + try { + PipetteLiquidInfo.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (LiquidInfoIndex idx : LiquidInfoIndex.values()) { + try { + Integer val = (Integer) PipetteLiquidInfo.class.getDeclaredField(idx.name()).get(this); + if (val == null) + continue; + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + PipetteLiquidInfo info = new PipetteLiquidInfo(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> { + System.out.println("Index: " + index + ", Value: " + val); + }); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java new file mode 100644 index 0000000..3c3f134 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePMVCfg.java @@ -0,0 +1,62 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfgbean; + +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.PMVConfigIndex; +import a8k.app.type.exception.AppException; + +public class PipettePMVCfg { + public Integer acc = 0; + public Integer dec = 0; + public Integer vStart = 0; + public Integer vStop = 0; + public Integer vMax = 0; + public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 + + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(PMVConfigIndex index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(PMVConfigIndex index, Integer itermVal) throws AppException; + } + + public static PipettePMVCfg build(AssignObjectItemFn assignFn) throws AppException { + PipettePMVCfg info = new PipettePMVCfg(); + info.assignObject(assignFn); + return info; + } + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (PMVConfigIndex idx : PMVConfigIndex.values()) { + try { + PipettePMVCfg.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (PMVConfigIndex idx : PMVConfigIndex.values()) { + try { + Integer val = (Integer) PipettePMVCfg.class.getDeclaredField(idx.name()).get(this); + if (val == null) + continue; + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + PipettePMVCfg info = new PipettePMVCfg(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> { + System.out.println("Index: " + index + ", Value: " + val); + }); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java new file mode 100644 index 0000000..a5a5701 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipettePlatInfo.java @@ -0,0 +1,84 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfgbean; + +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.PlatformInfoIndex; +import a8k.app.type.exception.AppException; + +public class PipettePlatInfo { + /** + * @brief 工作参考平面 + * 代码中并不使用这个位置,这个参数只是为了后续 + * 如果平台高度发生变化时,可以通过调整dzero使得 + * work_ref_plane数值不变。 + */ + public Integer workRefPos = 0; // + + public Integer tipPickingPos = 0; // 开始取tip位置(绝对位置0.1mm) + public Integer tipPickingSearchRange = 0; // 取tip的范围 + public Integer tipPickingAppendDistance = 0; // 取tip时z轴的附加距离 + public Integer tipPickingSettlingTime = 0; + + public Integer tipDepositPos = 0; // 丢tip位置(绝对位置0.1mm) + public Integer transformPos = 0; // 移液枪安全移动的高度(绝对位置0.1mm) + /** + * @brief tip类型 + * + * TS1000UL = 0, // 1000ul, max=1002.6ul + * TS200UL = 1, // 200ul, max=250ul + * TS50UL = 2, // 50ul, max=62ul + * TS20UL = 3, // 20ul, max=40ul + */ + public Integer tipType = 0; + public Integer tipLength = 0; // tip长度 + + public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 + + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(PlatformInfoIndex index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(PlatformInfoIndex index, Integer itermVal) throws AppException; + } + + public static PipettePlatInfo build(AssignObjectItemFn assignFn) throws AppException { + PipettePlatInfo info = new PipettePlatInfo(); + info.assignObject(assignFn); + return info; + } + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (PlatformInfoIndex idx : PlatformInfoIndex.values()) { + try { + PipettePlatInfo.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (PlatformInfoIndex idx : PlatformInfoIndex.values()) { + try { + Integer val = (Integer) PipettePlatInfo.class.getDeclaredField(idx.name()).get(this); + if (val == null) + continue; + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + PipettePlatInfo info = new PipettePlatInfo(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> { + System.out.println("Index: " + index + ", Value: " + val); + }); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java new file mode 100644 index 0000000..577e24d --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMBCfg.java @@ -0,0 +1,74 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfgbean; + +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.ZMBasicConfigIndex; +import a8k.app.type.exception.AppException; + +public class PipetteZMBCfg { + public Integer shaft = 0; // Z轴电机运动方向调整 + public Integer oneCirclePulse = 0; // 电子齿轮比-分子 + public Integer oneCirclePulseDenominator = 0; // 电子齿轮比-分母 + public Integer ihold = 0; // + public Integer irun = 0; // + public Integer iholddelay = 0; // + public Integer iglobalscaler = 0; // + public Integer mind = 0; // + public Integer maxd = 0; // + public Integer tzerowait = 0; // + public Integer encResolution = 0; // + public Integer enableEnc = 0; // + public Integer dzero = 0; // + public Integer ioTriggerAppendDistance = 0; // + public Integer posDeviTolerance = 0; // + public Integer mres = 0; // + public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 + + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(ZMBasicConfigIndex index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(ZMBasicConfigIndex index, Integer itermVal) throws AppException; + } + + public static PipetteZMBCfg build(AssignObjectItemFn assignFn) throws AppException { + PipetteZMBCfg info = new PipetteZMBCfg(); + info.assignObject(assignFn); + return info; + } + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (ZMBasicConfigIndex idx : ZMBasicConfigIndex.values()) { + try { + PipetteZMBCfg.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (ZMBasicConfigIndex idx : ZMBasicConfigIndex.values()) { + try { + Integer val = (Integer) PipetteZMBCfg.class.getDeclaredField(idx.name()).get(this); + if (val == null) + continue; + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + PipetteZMBCfg info = new PipetteZMBCfg(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> { + System.out.println("Index: " + index + ", Value: " + val); + }); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java new file mode 100644 index 0000000..0909b17 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cfgbean/PipetteZMVCfg.java @@ -0,0 +1,67 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cfgbean; + +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.ZMVConfigIndex; +import a8k.app.type.exception.AppException; + +public class PipetteZMVCfg { + public Integer vstart = 0; + public Integer a1 = 0; + public Integer amax = 0; + public Integer v1 = 0; + public Integer dmax = 0; + public Integer d1 = 0; + public Integer vstop = 0; + public Integer vmax = 0; + public Integer mark = 0; // 结构体最后一个数值,设置9973,用于保证单片机端和java端均正确更新了枚举 + + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(ZMVConfigIndex index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(ZMVConfigIndex index, Integer itermVal) throws AppException; + } + + public static PipetteZMVCfg build(AssignObjectItemFn assignFn) throws AppException { + PipetteZMVCfg info = new PipetteZMVCfg(); + info.assignObject(assignFn); + return info; + } + + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (ZMVConfigIndex idx : ZMVConfigIndex.values()) { + try { + PipetteZMVCfg.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (ZMVConfigIndex idx : ZMVConfigIndex.values()) { + try { + Integer val = (Integer) PipetteZMVCfg.class.getDeclaredField(idx.name()).get(this); + if (val == null) + continue; + + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + PipetteZMVCfg info = new PipetteZMVCfg(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> { + System.out.println("Index: " + index + ", Value: " + val); + }); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java new file mode 100644 index 0000000..afeaabc --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ContainerCpyId.java @@ -0,0 +1,41 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cpyidx; + +public enum ContainerCpyId { + Default, + LittleBufferCup, //小瓶缓冲液 + LargeBufferCup,//大瓶缓冲液 + DetectSubstancesCup,//探测物质 + ShortWholeBufferTube,//小全血试管 + HighWholeBufferTube,//高全血试管 + MiniBlood,//阳普管 + BulletTube1P5,//子弹头1.5ml + BulletTube0P5,//子弹头0.5ml + StoolTestTube,//粪便试管 + ReactionPlate, + NotSet, + ; + + public static ContainerCpyId of(Integer val) { + if (val < 0) + return NotSet; + + for (ContainerCpyId idx : ContainerCpyId.values()) { + if (idx.ordinal() == val) { + return idx; + } + } + return NotSet; + } + + public static Integer of(ContainerCpyId idx) { + if (idx == null) + return -1; + if (idx.equals(NotSet)) + return -1; + return idx.ordinal(); + } + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java new file mode 100644 index 0000000..67b6c83 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/LiquidConfigCpyIdx.java @@ -0,0 +1,44 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cpyidx; + +/** + * 液体类型配置索引 + * + * @Warning: + * 底层CpyIdx为, 0, 1, 2, 3, 4, 5, 不区分具体类型 + * 上层应用,根据需求自定义类型 + */ +public enum LiquidConfigCpyIdx { + Default, + WholeBlood, //全血 + SerumOrPlasma,//血清或血浆 + BufferSolution,//缓冲液 + Water,//水 + NotSet, + ; + + public static LiquidConfigCpyIdx of(Integer val) { + if (val < 0) + return NotSet; + + for (LiquidConfigCpyIdx idx : LiquidConfigCpyIdx.values()) { + if (idx.ordinal() == val) { + return idx; + } + } + return NotSet; + } + + public static Integer of(LiquidConfigCpyIdx idx) { + if (idx == null) + return -1; + if (idx.equals(NotSet)) + return -1; + return idx.ordinal(); + } + + public Integer toInteger() { + if (this.equals(NotSet)) + return -1; + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java new file mode 100644 index 0000000..f2fc1f7 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PMVCpyIdx.java @@ -0,0 +1,42 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cpyidx; + +/** + * 泵电机速度配置索引 + */ +public enum PMVCpyIdx { + VDefault, // 默认速度 + VSlowLv1, // 慢速 + VSlowLv2, // 慢速 + VSlowLv3, // 慢速 + VMid, // 中速 + VQuick, // 快速 + VMax, // 高速 + VLld, // 液面探测vlld + + NotSet, + ; + + public static PMVCpyIdx of(Integer val) { + if (val < 0) + return NotSet; + + for (PMVCpyIdx idx : PMVCpyIdx.values()) { + if (idx.ordinal() == val) { + return idx; + } + } + return NotSet; + } + + public static Integer of(PMVCpyIdx idx) { + if (idx == null) + return -1; + if (idx.equals(NotSet)) + return -1; + return idx.ordinal(); + } + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java new file mode 100644 index 0000000..f87f87c --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/PlatInfoCpyIdx.java @@ -0,0 +1,26 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cpyidx; + +public enum PlatInfoCpyIdx { + Default, + TransparentTip, + NotSet, + ; + + public Integer toInteger() { + if (this.equals(NotSet)) + return -1; + return ordinal(); + } + + static public PlatInfoCpyIdx of(Integer val) { + if (val < 0) + return NotSet; + for (PlatInfoCpyIdx idx : PlatInfoCpyIdx.values()) { + if (idx.ordinal() == val) { + return idx; + } + } + + return NotSet; + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java new file mode 100644 index 0000000..2f6a8ee --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/cpyidx/ZMVCpyIdx.java @@ -0,0 +1,40 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.cpyidx; + +/** + * Z轴电机速度配置索引 + */ +public enum ZMVCpyIdx { + VDefault, // 默认速度 + VMoveToZero, // 回零速度 + VLookZeroEdge, // 找零点偏移速度 + VLld, // 液面探测vlld + VSwap, // 交换液面探测 + VLlf, // 液面基础速度配置 + PickingTip,// 取tip + NotSet, + ; + + public static ZMVCpyIdx of(Integer val) { + if (val < 0) + return NotSet; + + for (ZMVCpyIdx idx : ZMVCpyIdx.values()) { + if (idx.ordinal() == val) { + return idx; + } + } + return NotSet; + } + + public static Integer of(ZMVCpyIdx idx) { + if (idx == null) + return -1; + if (idx.equals(NotSet)) + return -1; + return idx.ordinal(); + } + + public Integer toInteger() { + return ordinal(); + } +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/AspirationParam.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/AspirationParam.java new file mode 100644 index 0000000..490441d --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/AspirationParam.java @@ -0,0 +1,117 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.param; + +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; +import a8k.app.iflytophald.type.protocol.pipette_module.AspirationParamId; +import a8k.app.type.exception.AppException; + +public class AspirationParam { + // + // 吸取体积 + // + public Integer volume = 100; + // + // 容器 + // + public Integer containerPos = 0; + public Integer containerInfoCpyId = 0; + // + // 液体类型 + // + public Integer liquidCfgIdx = 0; + // + // 吸取模式 + // + public Integer aspirationMode = 0; + // + // lld配置 + // + public Integer lldEnable = 0; + public Integer lldType = 0; + public Integer lldEnableProtect = 0; + // + // llf配置 + // + public Integer mixLlfEnable = 0; + public Integer llfEnable = 0; + // + // 混匀配置 + // + public Integer mixVolume = 0; + public Integer mixTimes = 0; + + public AspirationParam() {} + + public AspirationParam(Integer volumex100nl, + Integer containerPos, + ContainerCpyId containerInfoCpyId, + LiquidConfigCpyIdx liquidCfgIdx, + Integer aspirationMode, + Integer lldEnable, + Integer lldType, + Integer lldEnableProtect, + Integer mixLlfEnable, + Integer llfEnable, + Integer mixVolume, + Integer mixTimes) { + this.volume = volumex100nl; + this.containerPos = containerPos; + this.containerInfoCpyId = containerInfoCpyId.toInteger(); + this.liquidCfgIdx = liquidCfgIdx.toInteger(); + this.aspirationMode = aspirationMode; + this.lldEnable = lldEnable; + this.lldType = lldType; + this.lldEnableProtect = lldEnableProtect; + this.mixLlfEnable = mixLlfEnable; + this.llfEnable = llfEnable; + this.mixVolume = mixVolume; + this.mixTimes = mixTimes; + } + + @FunctionalInterface + public interface AssignObjectItemFn { + Integer assignVal(AspirationParamId index) throws AppException; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(AspirationParamId index, Integer itermVal) throws AppException; + } + + public static AspirationParam build(AssignObjectItemFn assignFn) throws AppException { + AspirationParam info = new AspirationParam(); + info.assignObject(assignFn); + return info; + } + + public void assignObject(AssignObjectItemFn assignFn) throws AppException { + for (AspirationParamId idx : AspirationParamId.values()) { + try { + AspirationParam.class.getDeclaredField(idx.name()).set(this, assignFn.assignVal(idx)); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (AspirationParamId idx : AspirationParamId.values()) { + try { + Integer val = (Integer) AspirationParam.class.getDeclaredField(idx.name()).get(this); + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + AspirationParam info = new AspirationParam(); + info.assignObject(Enum::ordinal); + + info.serialization((index, val) -> { + System.out.println("Index: " + index + ", Value: " + val); + }); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java new file mode 100644 index 0000000..9659726 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/type/protocol/pipette_module/param/DistribuAllParam.java @@ -0,0 +1,81 @@ +package a8k.app.iflytophald.type.protocol.pipette_module.param; + +import a8k.app.iflytophald.type.protocol.pipette_module.DistribuAllParamId; +import a8k.app.iflytophald.type.protocol.pipette_module.DistribuType; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; +import a8k.app.type.exception.AppException; + +public class DistribuAllParam { + // + // 容器位置 + // + public Integer containerPos = 0; // 容器位置 + + // + // 目标容器信息 + // + public Integer destContainerCpyid = 0; // 目标容器配置索引 + public Integer destContainerIsEmpty = 0; // 目标容器是否为空 + public Integer destLiquidCfgIndex = 0; // 目标容器中的液体类型 + + // + // 分配方式 + // + public Integer distribuType = 0; // 分配类型 0:液面上分配,1:液面下分配 + + // + // 混匀配置 + // + public Integer mixVolume = 0; // 混匀体积 + public Integer mixTimes = 0; // 混匀次数 + // + // 其他配置 + // + public Integer zmAutoMoveToZero = 0; // zm自动归零 + + public DistribuAllParam() { + // 默认构造函数 + } + + public DistribuAllParam(Integer containerPos, + ContainerCpyId destContainerCpyid, + LiquidConfigCpyIdx destLiquidCfgIndex, + Boolean destContainerIsEmpty, + DistribuType distribuType, + Integer mixVolume, + Integer mixTimes, + Boolean zmAutoMoveToZero) { + this.containerPos = containerPos; + this.destContainerCpyid = destContainerCpyid.toInteger(); + this.destContainerIsEmpty = destContainerIsEmpty ? 1 : 0; + this.destLiquidCfgIndex = destLiquidCfgIndex.toInteger(); + this.distribuType = distribuType.toInteger(); + this.mixVolume = mixVolume; + this.mixTimes = mixTimes; + this.zmAutoMoveToZero = zmAutoMoveToZero ? 1 : 0; + } + + @FunctionalInterface + public interface SerializationObjectItemFn { + void serializeObject(DistribuAllParamId index, Integer itermVal) throws AppException; + } + + + public void serialization(SerializationObjectItemFn fn) throws AppException { + for (DistribuAllParamId idx : DistribuAllParamId.values()) { + try { + Integer val = (Integer) DistribuAllParam.class.getDeclaredField(idx.name()).get(this); + fn.serializeObject(idx, val); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + + public static void main(String[] args) throws AppException { + DistribuAllParam info = new DistribuAllParam(); + info.serialization((index, val) -> System.out.println("Index: " + index + ", Value: " + val)); + } + +} diff --git a/src/main/java/a8k/app/iflytophald/utils/IflytophaldChannelCtrlRequester.java b/src/main/java/a8k/app/iflytophald/utils/IflytophaldChannelCtrlRequester.java new file mode 100644 index 0000000..4d3d4cb --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/utils/IflytophaldChannelCtrlRequester.java @@ -0,0 +1,105 @@ +package a8k.app.iflytophald.utils; + +import a8k.app.config.IflytophaldConnectionConfig; +import a8k.app.iflytophald.type.channelctrl.IflytophaldResponse; +import a8k.app.utils.ZJsonHelper; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + +@Component +@Slf4j +@RequiredArgsConstructor +public class IflytophaldChannelCtrlRequester { + + private final IflytophaldConnectionConfig config; + + //http://192.168.8.10:19004/$chname/setBaudrate?baudrate=9600 + public HttpResponse callCmd(String channel, String cmd, String... params) { + return callCmd(config, channel, cmd, params); + } + + public IflytophaldResponse callCmd(String channel, String cmd, Class retType, String... params) { + return callCmdStatic(config.getCmdChBaseUrl(channel), cmd, retType, params); + } + + + static public HttpResponse callCmd(IflytophaldConnectionConfig connectConfig, String channel, String cmd, String... params) { + String baseurl = connectConfig.getCmdChBaseUrl(channel); + return callCmdStatic(baseurl, cmd, params); + } + + static public IflytophaldResponse callCmdStatic(String baseurl, String cmd, Class retType, String... params) { + HttpResponse response = callCmdStatic(baseurl, cmd, params); + if (response == null || response.body() == null) { + return null; + } + try { + ObjectMapper mapper = new ObjectMapper(); + JavaType javaType = mapper.getTypeFactory().constructParametricType(IflytophaldResponse.class, retType); + return mapper.readValue(response.body(), javaType); + } catch (Exception e) { + log.error("callCmd error", e); + return null; + } + } + + static public HttpResponse callCmdStatic(String baseurl, String cmd, String... params) { + // 创建一个HttpClient实例 + HttpClient httpClient = HttpClient.newHttpClient(); + + String paramStr = ""; + if (params != null && params.length > 0) { + StringBuilder sb = new StringBuilder(); + for (String param : params) { + if (!sb.isEmpty()) { + sb.append("&"); + } + sb.append(param); + } + paramStr = "?" + sb.toString(); + } + var url = URI.create(String.format("%s/%s%s", baseurl, cmd, paramStr)); + log.info("callCmd url: {}", url); + HttpRequest httpRequest = HttpRequest.newBuilder().uri(url).build(); + HttpResponse ret = null; + try { + ret = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); + } catch (Exception e) { + log.error("callcmd error", e); + return null; + } + return ret; + } + + static public class GetBaudrateResponse { + public Integer baudrate; + } + + public static void main(String[] args) { + + { + IflytophaldResponse response = + IflytophaldChannelCtrlRequester.callCmdStatic("http://192.168.8.10:19004/lis", "setBaudrate", Void.class, "baudrate=9600"); + log.info("1Response: {}", ZJsonHelper.objToPrettyJson(response)); + } + { + IflytophaldResponse response = + IflytophaldChannelCtrlRequester.callCmdStatic("http://192.168.8.10:19004/lis", "getBaudrate", GetBaudrateResponse.class); + log.info("2Response: {}", ZJsonHelper.objToPrettyJson(response)); + + + } + + + } + + +} diff --git a/src/main/java/a8k/app/iflytophald/utils/OptGainConvert.java b/src/main/java/a8k/app/iflytophald/utils/OptGainConvert.java new file mode 100644 index 0000000..1ffe965 --- /dev/null +++ b/src/main/java/a8k/app/iflytophald/utils/OptGainConvert.java @@ -0,0 +1,79 @@ +package a8k.app.iflytophald.utils; + +import a8k.app.type.a8k.opt.A8kOptType; + +/** + * 光学增益转换器 + * 用于将增益倍率(1,2,3,4)转换成对应的原始增益值(寄存器设置值) + */ +public class OptGainConvert { + + static public class FOptGainConvert { + public double scanerToRealGain(int gain) { + double scanGain = 0; + scanGain = (((100. / 256.) * (double) gain) + 0.125) / 2.15 + 1.; //和硬件电路有关 + return scanGain; + } + + public int scanerToRawGain(double scanGain) { + int scan_gain_raw = 0; + scan_gain_raw = (int) (((scanGain - 1.0) * 2.15 - 0.125) * 255. / 100. + 0.5); //和硬件电路有关 + if (scan_gain_raw < 1) + scan_gain_raw = 1; + if (scan_gain_raw > 255) + scan_gain_raw = 255; + return scan_gain_raw; + } + + + } + + static public class TOptGainConvert { + public int scanerToRawGain(double scanGain) { + // opamp_gain = (((100.0 * (float) scan_gain_raw) / 255) + 2.4) / 4.7; + int scan_gain_raw = 0; + scan_gain_raw = (int) ((scanGain * 4.7 - 2.4) * 256. / 100. + 0.5); //和硬件电路有关 + if (scan_gain_raw < 1) + scan_gain_raw = 1; + if (scan_gain_raw > 255) + scan_gain_raw = 255; + return scan_gain_raw; + } + + public double scanerToRealGain(int gain) { + double scanGain = 0; + scanGain = (((100.0 * (double) gain) / 256) + 2.4) / 4.7; //和硬件电路有关 + return scanGain; + } + + + } + + + public static double scanerToRealGain(A8kOptType type, int gain) { + if (type == A8kOptType.FOPT) { + return new FOptGainConvert().scanerToRealGain(gain); + } else if (type == A8kOptType.TOPT) { + return new TOptGainConvert().scanerToRealGain(gain); + } + return 0; + } + + public static int scanerToRawGain(A8kOptType type, double scanGain) { + if (type == A8kOptType.FOPT) { + return new FOptGainConvert().scanerToRawGain(scanGain); + } else if (type == A8kOptType.TOPT) { + return new TOptGainConvert().scanerToRawGain(scanGain); + } + return 0; + } + + public static void main(String[] args) { + TOptGainConvert tgc = new TOptGainConvert(); + System.out.printf("t gain range %f->%f%n", tgc.scanerToRealGain(0), tgc.scanerToRealGain(255)); + + FOptGainConvert fgc = new FOptGainConvert(); + System.out.printf("f gain range %f->%f%n", fgc.scanerToRealGain(0), fgc.scanerToRealGain(255)); + + } +} diff --git a/src/main/java/a8k/app/service/analyzer/A8kEcodeAnalyzer.java b/src/main/java/a8k/app/service/analyzer/A8kEcodeAnalyzer.java index 97cb57e..b326024 100644 --- a/src/main/java/a8k/app/service/analyzer/A8kEcodeAnalyzer.java +++ b/src/main/java/a8k/app/service/analyzer/A8kEcodeAnalyzer.java @@ -1,6 +1,6 @@ package a8k.app.service.analyzer; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.error.AppError; public class A8kEcodeAnalyzer { diff --git a/src/main/java/a8k/app/service/analyzer/A8kIdCardDataParseService.java b/src/main/java/a8k/app/service/analyzer/A8kIdCardDataParseService.java index 4e3790c..c1a8b0c 100644 --- a/src/main/java/a8k/app/service/analyzer/A8kIdCardDataParseService.java +++ b/src/main/java/a8k/app/service/analyzer/A8kIdCardDataParseService.java @@ -3,7 +3,7 @@ package a8k.app.service.analyzer; import a8k.app.dao.type.combination.ProjBuildInInfo; import a8k.app.service.data.ProjInfoMgrService; import a8k.app.type.a8k.optfn.A8kNormalFn; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.a8k.optfn.A8kOptX; import a8k.app.type.a8k.optfn.A8kPiecewiseFn; import a8k.app.type.a8k.optfn.A8kFnType; diff --git a/src/main/java/a8k/app/service/appsetup/A8kSubModuleRegInitService.java b/src/main/java/a8k/app/service/appsetup/A8kSubModuleRegInitService.java index 216d6ae..8fa0777 100644 --- a/src/main/java/a8k/app/service/appsetup/A8kSubModuleRegInitService.java +++ b/src/main/java/a8k/app/service/appsetup/A8kSubModuleRegInitService.java @@ -6,11 +6,9 @@ import a8k.app.type.BoardVersions; import a8k.app.type.DeviceRunMode; import a8k.app.type.appevent.AppEvent; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.driver.ModuleEnableCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.ModuleType; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.driver.ModuleEnableCtrlDriver; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.service.background.AppEventBusService; import a8k.app.service.data.SubModuleRegInitialValueMgrService; import a8k.app.service.statemgr.GStateMgrService; @@ -32,8 +30,8 @@ import java.util.List; public class A8kSubModuleRegInitService { - private final A8kCanBusService canBus; - private final ModuleEnableCtrlDriver moduleEnableCtrlDriver; + private final A8kCanBusBaseDriver canBus; + private final ModuleEnableCtrlDriver moduleEnableCtrlDriver; private final GStateMgrService gStateMgrService; private final AppEventBusService eventBus; private final SubModuleRegInitialValueMgrService subModuleRegInitialValueMgrService; diff --git a/src/main/java/a8k/app/service/background/ProjIDCardCtrlAndMonitorService.java b/src/main/java/a8k/app/service/background/ProjIDCardCtrlAndMonitorService.java index 0b29f48..4b618d9 100644 --- a/src/main/java/a8k/app/service/background/ProjIDCardCtrlAndMonitorService.java +++ b/src/main/java/a8k/app/service/background/ProjIDCardCtrlAndMonitorService.java @@ -2,16 +2,16 @@ package a8k.app.service.background; import a8k.app.factory.ZAppPromptFactory; -import a8k.app.channel.iflytophald.type.protocol.A8kPacket; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.A8kPacket; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.service.data.ProjInfoMgrService; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.type.appevent.*; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.type.protocol.RegIndex; import a8k.app.dao.type.db.ProjExtInfoCard; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; import a8k.app.service.analyzer.A8kIdCardDataParseService; import a8k.app.dao.type.combination.ProjBuildInInfo; import a8k.app.utils.ZWorkQueue; @@ -30,8 +30,8 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor public class ProjIDCardCtrlAndMonitorService { - private final A8kCanBusService canBus; - private final AppEventBusService eventBus; + private final A8kCanBusBaseDriver canBus; + private final AppEventBusService eventBus; private final A8kIdCardDataParseService idCardDataParseService; private final ProjInfoMgrService projInfoMgrService; private final GStateMgrService gstat; diff --git a/src/main/java/a8k/app/service/background/SensorDataUpdateService.java b/src/main/java/a8k/app/service/background/SensorDataUpdateService.java index 0ad3793..6510de8 100644 --- a/src/main/java/a8k/app/service/background/SensorDataUpdateService.java +++ b/src/main/java/a8k/app/service/background/SensorDataUpdateService.java @@ -1,18 +1,18 @@ package a8k.app.service.background; import a8k.OS; -import a8k.app.channel.iflytophald.driver.InputDetectDriver; -import a8k.app.channel.iflytophald.driver.OutputIOCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.InputIOId; +import a8k.app.iflytophald.driver.InputDetectDriver; +import a8k.app.iflytophald.driver.OutputIOCtrlDriver; +import a8k.app.iflytophald.type.protocol.InputIOId; import a8k.app.service.statemgr.AppFlagStateMgr; import a8k.app.type.AppFlagKey; import a8k.app.type.DeviceRunMode; import a8k.app.type.TemperatureRecordPoint; import a8k.app.type.error.AppError; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.service.statemgr.OptScanModuleStateMgr; -import a8k.app.channel.iflytophald.driver.WaterTemperatureControllerDriver; +import a8k.app.iflytophald.driver.WaterTemperatureControllerDriver; import a8k.app.type.exception.AppException; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; @@ -34,9 +34,9 @@ public class SensorDataUpdateService { private final GStateMgrService gStateMgrService; private final WaterTemperatureControllerDriver waterTemperatureControllerDriver; private final OptScanModuleStateMgr optScanModuleStateMgr; - private final AppEventBusService appEventBusService; - private final A8kCanBusService canBus; - private final OutputIOCtrlDriver outputIOCtrlDriver; + private final AppEventBusService appEventBusService; + private final A8kCanBusBaseDriver canBus; + private final OutputIOCtrlDriver outputIOCtrlDriver; private final InputDetectDriver inputDetectDriver; private final AppFlagStateMgr appFlagStateMgr; diff --git a/src/main/java/a8k/app/service/background/TemperatureCtrlService.java b/src/main/java/a8k/app/service/background/TemperatureCtrlService.java index 9b2a139..b67e0c6 100644 --- a/src/main/java/a8k/app/service/background/TemperatureCtrlService.java +++ b/src/main/java/a8k/app/service/background/TemperatureCtrlService.java @@ -2,8 +2,8 @@ package a8k.app.service.background; import a8k.OS; -import a8k.app.channel.iflytophald.A8kChannelStateMgr; -import a8k.app.channel.iflytophald.driver.WaterTemperatureControllerDriver; +import a8k.app.iflytophald.A8kChannelStateMgr; +import a8k.app.iflytophald.driver.WaterTemperatureControllerDriver; import a8k.app.service.setting.AppSettingsMgrService; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.teststate.VirtualDevice; diff --git a/src/main/java/a8k/app/service/ctrlmodule/TipOperationCtrlModule.java b/src/main/java/a8k/app/service/ctrlmodule/TipOperationCtrlModule.java index 32b3938..668fa55 100644 --- a/src/main/java/a8k/app/service/ctrlmodule/TipOperationCtrlModule.java +++ b/src/main/java/a8k/app/service/ctrlmodule/TipOperationCtrlModule.java @@ -2,8 +2,8 @@ package a8k.app.service.ctrlmodule; import a8k.app.constant.AppConstant; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.lowerctrl.HbotMoveExCtrlService; import a8k.app.service.statemgr.ConsumablesMgrService; import a8k.app.service.statemgr.GStateMgrService; diff --git a/src/main/java/a8k/app/service/data/AppUserMgrService.java b/src/main/java/a8k/app/service/data/AppUserMgrService.java index 480b2fb..f06fc5a 100644 --- a/src/main/java/a8k/app/service/data/AppUserMgrService.java +++ b/src/main/java/a8k/app/service/data/AppUserMgrService.java @@ -4,19 +4,16 @@ import a8k.app.dao.AppUsrDao; import a8k.app.dao.DeviceSettingDao; import a8k.app.dao.type.db.AppUser; import a8k.app.dao.type.db.DeviceSetting; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.background.AppEventBusService; import a8k.app.type.appevent.AppLoginEvent; import a8k.app.type.exception.AppException; import jakarta.annotation.PostConstruct; -import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.stereotype.Component; -import java.time.Duration; -import java.time.Instant; import java.util.List; diff --git a/src/main/java/a8k/app/service/data/ProjIdCardInfoMgrService.java b/src/main/java/a8k/app/service/data/ProjIdCardInfoMgrService.java index d1d5114..665cca6 100644 --- a/src/main/java/a8k/app/service/data/ProjIdCardInfoMgrService.java +++ b/src/main/java/a8k/app/service/data/ProjIdCardInfoMgrService.java @@ -8,7 +8,7 @@ import a8k.app.type.a8k.optfn.A8kNormalFn; import a8k.app.type.a8k.optfn.A8kPiecewiseFn; import a8k.app.type.a8k.optfn.A8kFnType; import a8k.app.type.a8k.proj.A8kResultUnit; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.background.ProjIDCardCtrlAndMonitorService; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.type.a8k.proj.A8kProjInfoCardBreif; diff --git a/src/main/java/a8k/app/service/data/ProjInfoMgrService.java b/src/main/java/a8k/app/service/data/ProjInfoMgrService.java index 52914b9..d714434 100644 --- a/src/main/java/a8k/app/service/data/ProjInfoMgrService.java +++ b/src/main/java/a8k/app/service/data/ProjInfoMgrService.java @@ -4,7 +4,7 @@ import a8k.SpringBootBeanUtil; import a8k.app.dao.A8kProjExtInfoCardDao; import a8k.app.dao.ProjOptInfoDao; import a8k.app.dao.ProjectBaseInfoDao; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.dao.type.db.ProjExtInfoCard; import a8k.app.dao.type.db.ProjectBaseInfo; diff --git a/src/main/java/a8k/app/service/data/SubModuleConfigService.java b/src/main/java/a8k/app/service/data/SubModuleConfigService.java index 6d032c5..d8e2bdc 100644 --- a/src/main/java/a8k/app/service/data/SubModuleConfigService.java +++ b/src/main/java/a8k/app/service/data/SubModuleConfigService.java @@ -2,10 +2,10 @@ package a8k.app.service.data; import a8k.app.dao.SubModuleConfigDao; import a8k.app.dao.type.db.SubModuleConfigValue; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.ModuleType; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.PipetteConfig; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.ModuleType; +import a8k.app.iflytophald.type.protocol.pipette_module.PipetteConfig; import a8k.app.type.exception.AppException; import a8k.app.utils.ZJsonHelper; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/app/service/data/SubModuleRegInitialValueMgrService.java b/src/main/java/a8k/app/service/data/SubModuleRegInitialValueMgrService.java index 06a66a6..7f66fc7 100644 --- a/src/main/java/a8k/app/service/data/SubModuleRegInitialValueMgrService.java +++ b/src/main/java/a8k/app/service/data/SubModuleRegInitialValueMgrService.java @@ -1,14 +1,14 @@ package a8k.app.service.data; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.exception.AppException; import a8k.app.config.A8kSubModuleInitRegConfig; import a8k.app.dao.SubModuleRegInitialValueDao; import a8k.app.dao.type.db.SubModuleRegInitialValue; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.ModuleType; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.ModuleType; +import a8k.app.iflytophald.type.protocol.RegIndex; import a8k.app.utils.ZList; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -23,7 +23,7 @@ import java.util.List; public class SubModuleRegInitialValueMgrService { private final SubModuleRegInitialValueDao subModuleRegInitialValueDao; - private final A8kCanBusService canBus; + private final A8kCanBusBaseDriver canBus; private final A8kSubModuleInitRegConfig a8kSubModuleInitRegConfig; diff --git a/src/main/java/a8k/app/service/engineer/qatest/LiquidAbsorptionAndDistributionTestService.java b/src/main/java/a8k/app/service/engineer/qatest/LiquidAbsorptionAndDistributionTestService.java index d2d35bb..dc55b2a 100644 --- a/src/main/java/a8k/app/service/engineer/qatest/LiquidAbsorptionAndDistributionTestService.java +++ b/src/main/java/a8k/app/service/engineer/qatest/LiquidAbsorptionAndDistributionTestService.java @@ -2,12 +2,12 @@ package a8k.app.service.engineer.qatest; import a8k.app.service.engineer.executor.EngineerModeActionExecutor; import a8k.app.service.engineer.utils.BeforeDoEngineerActionChecker; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.DistribuType; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.AspirationParam; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.DistribuType; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; +import a8k.app.iflytophald.type.protocol.pipette_module.param.AspirationParam; +import a8k.app.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; import a8k.app.service.lowerctrl.*; import a8k.app.service.ctrlmodule.TipOperationCtrlModule; import a8k.app.service.param.hbotpos.HbotLargeBottleBSPosMgr; diff --git a/src/main/java/a8k/app/service/engineer/utils/BeforeDoEngineerActionChecker.java b/src/main/java/a8k/app/service/engineer/utils/BeforeDoEngineerActionChecker.java index a54724b..5bb6730 100644 --- a/src/main/java/a8k/app/service/engineer/utils/BeforeDoEngineerActionChecker.java +++ b/src/main/java/a8k/app/service/engineer/utils/BeforeDoEngineerActionChecker.java @@ -4,7 +4,7 @@ package a8k.app.service.engineer.utils; import a8k.SpringBootBeanUtil; import a8k.app.service.engineer.state.EngineerModeStateMgrService; import a8k.app.service.engineer.type.EngineerWorkState; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.statemgr.DeviceWorkStateMgrService; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.type.a8k.state.enumtype.A8kWorkState; diff --git a/src/main/java/a8k/app/service/lis/BiLisDoubleTrackChannel.java b/src/main/java/a8k/app/service/lis/BiLisDoubleTrackChannel.java index 37aecdd..32ea3fa 100644 --- a/src/main/java/a8k/app/service/lis/BiLisDoubleTrackChannel.java +++ b/src/main/java/a8k/app/service/lis/BiLisDoubleTrackChannel.java @@ -1,12 +1,16 @@ package a8k.app.service.lis; import a8k.OS; -import a8k.app.channel.iflytophald.channel.LisUartChannel; -import a8k.app.channel.net.BiLisDoubleTrackTcpClient; +import a8k.app.iflytophald.channel.LisUartCommunicationChannel; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.client.BiLisDoubleTrackTcpClient; import a8k.app.constant.AppConstant; import a8k.app.dao.type.db.ReactionRecord; import a8k.app.factory.BiLisDoubleTrackFrameFactory; +import a8k.app.type.a8k.BloodType; +import a8k.app.type.exception.AppException; import a8k.app.type.lisprotocol.BiLisDoubleTrackFrame; +import a8k.app.type.lisprotocol.BiLisDoubleTrackFrameBuildContext; import a8k.app.type.lisprotocol.BiLisFrameParseException; import a8k.app.type.lisprotocol.subframe.OFrame; import a8k.app.utils.ByteArrayUtils; @@ -16,7 +20,7 @@ import a8k.app.utils.ZJsonHelper; import lombok.extern.slf4j.Slf4j; @Slf4j -public class BiLisDoubleTrackChannel { +public class BiLisDoubleTrackChannel implements LisChannel { static final Integer PING_PERIOD = 10 * 1000; // Ping周期,单位毫秒 @@ -26,15 +30,16 @@ public class BiLisDoubleTrackChannel { } // Channel - BiLisDoubleTrackTcpClient biLisDoubleTrackTcpClient = new BiLisDoubleTrackTcpClient(); - LisUartChannel lisUartChannel; - Thread monitorThread = new Thread(this::monitorThread); + BiLisDoubleTrackTcpClient biLisDoubleTrackTcpClient = new BiLisDoubleTrackTcpClient(); + LisUartCommunicationChannel lisUartCommunicationChannel; + Thread monitorThread = new Thread(this::monitorThread); //Config String hostIp; Integer port; ChannelType channelType; + Integer baudrate; final ZByteRxBuffer rxBuffer = new ZByteRxBuffer(BiLisDoubleTrackFrame.PACKET_MAX_LENGTH); // 接收数据缓冲区,初始大小为1024字节 @@ -48,12 +53,13 @@ public class BiLisDoubleTrackChannel { channelType = ChannelType.TCP; } - public BiLisDoubleTrackChannel(LisUartChannel lisUartChannel) { - this.lisUartChannel = lisUartChannel; - channelType = ChannelType.UART; + public BiLisDoubleTrackChannel(LisUartCommunicationChannel lisUartCommunicationChannel, Integer baudrate) { + this.lisUartCommunicationChannel = lisUartCommunicationChannel; + channelType = ChannelType.UART; + this.baudrate = baudrate; } - public void start() { + @Override public void start() { isShuttingDown = false; switch (channelType) { @@ -63,23 +69,55 @@ public class BiLisDoubleTrackChannel { monitorThread.start(); } case UART -> { - lisUartChannel.regRxMessageListener(this::onRxFromUART); + lisUartCommunicationChannel.setBaudRate(baudrate); + lisUartCommunicationChannel.regRxMessageListener(this::onRxFromUART); monitorThread.start(); } } } - public boolean isConnected() { + @Override public boolean isConnected() { return connectedState; } - public void shotdown() { + @Override public String getChannelDescription() { + return switch (channelType) { + case UART -> String.format("BiLisDoubleTrackChannel via UART, Baudrate: %d", lisUartCommunicationChannel.getBaudRateDirect()); + case TCP -> String.format("BiLisDoubleTrackChannel via TCP, Host: %s, Port: %d", hostIp, port); + }; + } + + @Override public Boolean isSupportRequestSampleInfo() { + return true; + } + + @Override public LisSampleInfo requestSampleInfo(String sampleId) throws AppException { + OFrame oFrame = requestSampleInfo0(sampleId); + + LisSampleInfo lisSampleInfo = new LisSampleInfo(); + + if (oFrame.sampleType == 0) { + lisSampleInfo.bloodType = BloodType.WHOLE_BLOOD; + } else if (oFrame.sampleType == 1) { + lisSampleInfo.bloodType = BloodType.SERUM_OR_PLASMA; + } else if (oFrame.sampleType == 2) { + lisSampleInfo.bloodType = BloodType.FECES; + } else { + log.warn("BiLisDoubleTrackChannel: 未知样本类型: {}", oFrame.sampleType); + throw AppException.of(A8kEcode.LIS_SAMPLE_TYPE_NOT_SUPPORT, "不支持样本类型: %s", oFrame.sampleTypeToStr()); + } + + lisSampleInfo.projNameList = oFrame.projList; + return lisSampleInfo; + } + + @Override public void shutdown() { isShuttingDown = true; monitorThread.interrupt(); ThreadUtils.threadForceJoin(monitorThread); switch (channelType) { case UART -> { - lisUartChannel.unRegRxMessageListener(); + lisUartCommunicationChannel.unRegRxMessageListener(); } case TCP -> { if (biLisDoubleTrackTcpClient != null) { @@ -90,6 +128,20 @@ public class BiLisDoubleTrackChannel { } } + synchronized private boolean ping(Integer reTryTimes) { + for (int i = 0; i < reTryTimes; i++) { + if (channelType.equals(ChannelType.TCP) && !biLisDoubleTrackTcpClient.isConnected()) { + return false; + } + if (ping()) { + return true; + } else { + log.warn("BiLisDoubleTrackChannel: Ping失败,尝试重试第{}次", i + 1); + } + } + return false; + } + synchronized public boolean ping() { /* * 设备探测协议 @@ -114,7 +166,7 @@ public class BiLisDoubleTrackChannel { return rxAckOrNak; } - public synchronized OFrame requestSampleInfo(String barcode) { + public synchronized OFrame requestSampleInfo0(String barcode) throws AppException { /* * 请求样本信息协议 * TX: FN Q|A5000P|^1111 C1 C2 @@ -123,7 +175,13 @@ public class BiLisDoubleTrackChannel { * RX: */ rxBuffer.clear(); - var cxt = BiLisDoubleTrackFrameFactory.createQFrameBytes(AppConstant.deviceTypeName, barcode); + BiLisDoubleTrackFrameBuildContext cxt = null; + try { + cxt = BiLisDoubleTrackFrameFactory.createQFrameBytes(AppConstant.deviceTypeName, barcode); + } catch (AppException ignored) { + log.error("BiLisDoubleTrackChannel: 创建请求样本信息的Q帧失败,可能是设备类型或条码格式错误"); + throw AppException.of(A8kEcode.CODEERROR, "创建请求样本信息的Q帧失败,可能是设备类型或条码格式错误"); + } txBytes(cxt.frameBytes); ThreadUtils.waitingForSomeCondition("BiLisDoubleTrackChannel", 30, 2000, @@ -132,10 +190,12 @@ public class BiLisDoubleTrackChannel { byte[] rxData = rxBuffer.cpy(); if (rxData.length == 1 && rxData[0] == BiLisDoubleTrackFrame.NAK) { txBytes(new byte[]{BiLisDoubleTrackFrame.EOT}); - return null; + throw AppException.of(A8kEcode.LIS_REQUEST_SAMPLE_INFO_FAIL, + "barcode: %s", barcode); } else if (rxData.length == 0) { txBytes(new byte[]{BiLisDoubleTrackFrame.EOT}); - return null; + throw AppException.of(A8kEcode.LIS_LOST_CONNECTION, + "barcode: %s", barcode); } OFrame oFrame; try { @@ -143,7 +203,8 @@ public class BiLisDoubleTrackChannel { } catch (BiLisFrameParseException e) { log.error("BiLisDoubleTrackChannel: 解析样本信息失败: {}", ByteArrayUtils.toByteString(rxData), e); txBytes(new byte[]{BiLisDoubleTrackFrame.EOT}); - return null; + throw AppException.of(A8kEcode.LIS_REQUEST_SAMPLE_INFO_FAIL, + "barcode: %s", barcode); } log.info("BiLisDoubleTrackChannel: 收到样本信息: {}", ZJsonHelper.objectToJson(oFrame)); @@ -157,42 +218,34 @@ public class BiLisDoubleTrackChannel { return oFrame; } - public boolean reportReactionReport(ReactionRecord reactionRecord) { + public void reportReactionRecord(ReactionRecord reactionRecord) throws AppException { if (reactionRecord == null) { - return false; + throw AppException.of(A8kEcode.CODEERROR, "reactionRecord == null"); } - boolean success = false; for (int i = 0; i < reactionRecord.getSubProjNum(); i++) { var cxt = BiLisDoubleTrackFrameFactory.createRFrame(reactionRecord, i); - if (!cxt.buildSuccess) { - log.error("BiLisDoubleTrackChannel: 发送反应报告失败: {}", ZJsonHelper.objectToJson(cxt)); - break; - } - success = reportRFrameAutoReSend(cxt.frameBytes); - if (!success) { - break; - } + log.info("Report {}", ZJsonHelper.objectToJson(cxt.frame.frameContent)); + reportRFrameAutoReSend(cxt.frameBytes); } - return success; } - private boolean reportRFrameAutoReSend(byte[] rFrame) { + private void reportRFrameAutoReSend(byte[] rFrame) throws AppException { for (int i = 0; i < 3; i++) { if (!connectedState) { log.warn("BiLisDoubleTrackChannel: 连接状态异常,无法发送反应报告"); - return false; + throw AppException.of(A8kEcode.LIS_LOST_CONNECTION); } if (reportRFrame(rFrame)) { - return true; + return; } else { log.warn("BiLisDoubleTrackChannel: 发送反应报告失败,尝试重发第{}次", i + 1); } - } - return false; + throw AppException.of(A8kEcode.LIS_REPORT_RECORD_FAIL, + "BiLisDoubleTrackChannel: 发送反应报告失败,已重试3次仍然失败"); } private boolean reportRFrame(byte[] rFrame) { @@ -215,8 +268,8 @@ public class BiLisDoubleTrackChannel { synchronized public boolean isChannelReady() { switch (channelType) { case UART -> { - if (lisUartChannel != null) { - return lisUartChannel.isConnected(); + if (lisUartCommunicationChannel != null) { + return lisUartCommunicationChannel.isConnected(); } } case TCP -> { @@ -239,7 +292,7 @@ public class BiLisDoubleTrackChannel { void txBytes(byte[] data) { switch (channelType) { - case UART -> lisUartChannel.tx(data); + case UART -> lisUartCommunicationChannel.tx(data); case TCP -> biLisDoubleTrackTcpClient.tx(data); } } @@ -251,13 +304,15 @@ public class BiLisDoubleTrackChannel { if (connectedState) { if (channelType.equals(ChannelType.TCP) && !biLisDoubleTrackTcpClient.isConnected()) { connectedState = false; + log.warn("BiLisDoubleTrackChannel: TCP连接断开,尝试重新连接"); continue; } if (OS.monotonicClockHasElapsed(lastPingTimestamp, PING_PERIOD)) { lastPingTimestamp = OS.getMonotonicClockTimestamp(); - if (!ping()) { + if (!ping(5)) { connectedState = false; + log.warn("BiLisDoubleTrackChannel: Ping失败,连接状态异常"); continue; } } @@ -268,6 +323,7 @@ public class BiLisDoubleTrackChannel { } if (ping()) { + log.info("BiLisDoubleTrackChannel: 连接成功"); connectedState = true; } } diff --git a/src/main/java/a8k/app/service/lis/BiLisSingleTrackChannel.java b/src/main/java/a8k/app/service/lis/BiLisSingleTrackChannel.java index a0f64f3..08695a4 100644 --- a/src/main/java/a8k/app/service/lis/BiLisSingleTrackChannel.java +++ b/src/main/java/a8k/app/service/lis/BiLisSingleTrackChannel.java @@ -1,16 +1,17 @@ package a8k.app.service.lis; -import a8k.app.channel.iflytophald.channel.LisUartChannel; -import a8k.app.channel.net.BiLisSingleTrackTcpClient; +import a8k.app.iflytophald.channel.LisUartCommunicationChannel; +import a8k.app.client.BiLisSingleTrackTcpClient; import a8k.app.dao.type.db.ReactionRecord; import a8k.app.factory.BoditechLisSingleTrackFrameFactory; +import a8k.app.type.exception.AppException; import a8k.app.type.lisprotocol.BiLisSingleTrackFrame; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; -public class BiLisSingleTrackChannel { +public class BiLisSingleTrackChannel implements LisChannel { private static final Logger log = LoggerFactory.getLogger(BiLisSingleTrackChannel.class); enum ChannelType { @@ -18,74 +19,95 @@ public class BiLisSingleTrackChannel { TCP, } - BiLisSingleTrackTcpClient biLisSingleTrackTcpClient; - LisUartChannel lisUartChannel; - ChannelType channelType; + BiLisSingleTrackTcpClient biLisSingleTrackTcpClient; + LisUartCommunicationChannel lisUartCommunicationChannel; + ChannelType channelType; String hostip; Integer port; + Integer baudrate; + public BiLisSingleTrackChannel(String hostip, Integer port) { biLisSingleTrackTcpClient = new BiLisSingleTrackTcpClient(); this.hostip = hostip; - this.port = port; - channelType = ChannelType.TCP; + this.port = port; + channelType = ChannelType.TCP; } - public BiLisSingleTrackChannel(LisUartChannel lisUartChannel) { - this.lisUartChannel = lisUartChannel; - channelType = ChannelType.UART; + public BiLisSingleTrackChannel(LisUartCommunicationChannel lisUartCommunicationChannel, Integer baudrate) { + this.baudrate = baudrate; + this.lisUartCommunicationChannel = lisUartCommunicationChannel; + channelType = ChannelType.UART; } - public void start() { + @Override public void start() { switch (channelType) { case TCP -> { biLisSingleTrackTcpClient.start(hostip, port); } case UART -> { - + lisUartCommunicationChannel.setBaudRate(baudrate); } } } - public boolean isConnected() { + @Override public void shutdown() { switch (channelType) { case UART -> { - if (lisUartChannel != null) { - return lisUartChannel.isConnected(); - } } case TCP -> { if (biLisSingleTrackTcpClient != null) { - return biLisSingleTrackTcpClient.isConnected(); + biLisSingleTrackTcpClient.shutdown(); } } } - return false; } - public void shotdown() { + @Override public void reportReactionRecord(ReactionRecord reactionRecord) { + if (reactionRecord == null) { + return; + } + List frames = BoditechLisSingleTrackFrameFactory.buildBoditechLisSingleTrackFrame(reactionRecord); + for (BiLisSingleTrackFrame frame : frames) { + tx(frame); + } + } + + public boolean isConnected() { switch (channelType) { case UART -> { + if (lisUartCommunicationChannel != null) { + return lisUartCommunicationChannel.isConnected(); + } } case TCP -> { if (biLisSingleTrackTcpClient != null) { - biLisSingleTrackTcpClient.shutdown(); + return biLisSingleTrackTcpClient.isConnected(); } } } + return false; } - public void reportReactionReport(ReactionRecord reactionRecord) { - if (reactionRecord == null) { - return; - } - List frames = BoditechLisSingleTrackFrameFactory.buildBoditechLisSingleTrackFrame(reactionRecord); - for (BiLisSingleTrackFrame frame : frames) { - tx(frame); + @Override public String getChannelDescription() { + if (channelType.equals(ChannelType.UART)) { + return String.format("%s,baudrate:%s", "BiLisSingleTrackChannel", baudrate); + } else if (channelType.equals(ChannelType.TCP)) { + return String.format("%s,ip:%s,port:%s", "BiLisSingleTrackChannel", hostip, port); } + return "BiLisSingleTrackChannel:...."; + } + + @Override public Boolean isSupportRequestSampleInfo() { + return false; + } + + @Override public LisSampleInfo requestSampleInfo(String sampleId) throws AppException { + return null; } + public void tx(BiLisSingleTrackFrame frame) { if (frame == null) { return; @@ -93,9 +115,9 @@ public class BiLisSingleTrackChannel { String frameStr = frame.serialization(); switch (channelType) { case UART -> { - if (lisUartChannel != null) { + if (lisUartCommunicationChannel != null) { log.debug("BoditechLisSingleTrackChannel tx frame by uart: {}", frameStr); - lisUartChannel.tx(frameStr); + lisUartCommunicationChannel.tx(frameStr); } } case TCP -> { diff --git a/src/main/java/a8k/app/service/lis/LisChannel.java b/src/main/java/a8k/app/service/lis/LisChannel.java new file mode 100644 index 0000000..46c1296 --- /dev/null +++ b/src/main/java/a8k/app/service/lis/LisChannel.java @@ -0,0 +1,21 @@ +package a8k.app.service.lis; + +import a8k.app.dao.type.db.ReactionRecord; +import a8k.app.type.exception.AppException; + +public interface LisChannel { + + void start(); + + void shutdown(); + + void reportReactionRecord(ReactionRecord reactionRecord) throws AppException; + + boolean isConnected(); + + String getChannelDescription(); + + Boolean isSupportRequestSampleInfo(); + + LisSampleInfo requestSampleInfo(String sampleId) throws AppException; +} diff --git a/src/main/java/a8k/app/service/lis/LisCommunicationService.java b/src/main/java/a8k/app/service/lis/LisCommunicationService.java index 461cc12..3bbbed2 100644 --- a/src/main/java/a8k/app/service/lis/LisCommunicationService.java +++ b/src/main/java/a8k/app/service/lis/LisCommunicationService.java @@ -1,9 +1,11 @@ package a8k.app.service.lis; -import a8k.app.channel.iflytophald.channel.LisUartChannel; +import a8k.app.iflytophald.channel.LisUartCommunicationChannel; import a8k.app.dao.type.db.LISSetting; import a8k.app.dao.type.db.ReactionRecord; import a8k.app.service.setting.AppSettingsMgrService; +import a8k.app.service.utils.UISender; +import a8k.app.type.exception.AppException; import a8k.app.type.lis.LISDirectionTypeEnum; import a8k.app.type.lis.LISIFType; import a8k.app.type.lis.LISProtocolEnum; @@ -18,14 +20,18 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor @Slf4j public class LisCommunicationService { - private final AppSettingsMgrService appSettingsMgrService; - private final LisUartChannel lisUartChannel; - private LISSetting setting; + private final AppSettingsMgrService appSettingsMgrService; + private final LisUartCommunicationChannel lisUartCommunicationChannel; + + + private LISSetting setting; + private LisChannel lisChannel; + @Value("${lis.enable}") public Boolean lisEnable = true; - BiLisSingleTrackChannel boditechLisSingleTrackChannel; + public void updateLisSetting(LISSetting lisSetting) { if (!lisEnable) { log.warn("LIS communication is disabled by configuration, ignore updateLisSetting"); @@ -37,30 +43,40 @@ public class LisCommunicationService { doUpdateLisSetting(); } - public String getProtocolDetail() { - if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.SINGLE_TRACK, LISIFType.SERIAL)) { - return String.format("%s.%s.%s,baudrate:%s", setting.lisProtocol, setting.lisType, setting.lisIf, setting.lisSerialBaudrate.baudrate); - } else if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.SINGLE_TRACK, LISIFType.NETWORK)) { - return String.format("%s.%s.%s,ip:%s,port:%d", setting.lisProtocol, setting.lisType, setting.lisIf, setting.lisNetIp, setting.lisNetPort); - } else { + public String getChannelDescription() { + if (lisChannel == null) { return String.format("%s.%s.%s", setting.lisProtocol, setting.lisType, setting.lisIf); } + return lisChannel.getChannelDescription(); } public Boolean getConnectionState() { - //巴迪泰串口单向 && 巴迪泰网口单向 - if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.SINGLE_TRACK, null)) { - return boditechLisSingleTrackChannel.isConnected(); + if (lisChannel == null) { + return false; } - return false; + return lisChannel.isConnected(); } public void reportReactionRecord(ReactionRecord reactionRecord) { - //巴迪泰串口单向 && 巴迪泰网口单向 - if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.SINGLE_TRACK, null)) { - boditechLisSingleTrackChannel.reportReactionReport(reactionRecord); - } else { - log.warn("LIS Type is not support, ignore report"); + /* + * 上报失败无须向上返回异常, 静默处理即可 + */ + if (lisChannel == null) { + return; + } + if (!setting.lisAutoExport) { + return; + } + + if (!lisChannel.isConnected()) { + log.warn("LIS channel is not connected, cannot report reaction record."); + return; + } + try { + lisChannel.reportReactionRecord(reactionRecord); + } catch (AppException e) { + log.warn("LIS 上报失败: {}", e.getMessage(), e); + UISender.txWarnMsg("LIS 上报记录 %s 失败, %s", reactionRecord.sampleUserid,e.getMessage()); } } @@ -77,23 +93,33 @@ public class LisCommunicationService { } // - // Channel builder + // !!!构建新的通道 // - private void doUpdateLisSetting() { shutdownAllChannel(); //巴迪泰串口单向 if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.SINGLE_TRACK, LISIFType.SERIAL)) { log.info("new BoditechLisSingleTrackChannel with SERIAL , baudrate: {}", setting.lisSerialBaudrate.baudrate); - lisUartChannel.setBaudRate(setting.lisSerialBaudrate.baudrate); - boditechLisSingleTrackChannel = new BiLisSingleTrackChannel(lisUartChannel); - boditechLisSingleTrackChannel.start(); + lisChannel = new BiLisSingleTrackChannel(lisUartCommunicationChannel, setting.lisSerialBaudrate.baudrate); + lisChannel.start(); } //巴迪泰网口单向 else if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.SINGLE_TRACK, LISIFType.NETWORK)) { log.info("new BoditechLisSingleTrackChannel with NETWORK, ip: {}, port: {}", setting.lisNetIp, setting.lisNetPort); - boditechLisSingleTrackChannel = new BiLisSingleTrackChannel(setting.lisNetIp, setting.lisNetPort); - boditechLisSingleTrackChannel.start(); + lisChannel = new BiLisSingleTrackChannel(setting.lisNetIp, setting.lisNetPort); + lisChannel.start(); + } + //巴迪泰网口双向 + else if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.SINGLE_TRACK, LISIFType.NETWORK)) { + log.info("new BiLisDoubleTrackChannel with NETWORK, ip: {}, port: {}", setting.lisNetIp, setting.lisNetPort); + lisChannel = new BiLisDoubleTrackChannel(setting.lisNetIp, setting.lisNetPort); + lisChannel.start(); + } + //巴迪泰串口双向 + else if (isChannelEq(LISProtocolEnum.Boditech, LISDirectionTypeEnum.DOUBLE_TRACK, LISIFType.SERIAL)) { + log.info("new BiLisDoubleTrackChannel with SERIAL, baudrate: {}", setting.lisSerialBaudrate.baudrate); + lisChannel = new BiLisDoubleTrackChannel(lisUartCommunicationChannel, setting.lisSerialBaudrate.baudrate); + lisChannel.start(); } else { log.warn("Unsupported LIS channel configuration: protocol={}, direction={}, ifType={}", setting.lisProtocol, setting.lisType, setting.lisIf); @@ -117,9 +143,9 @@ public class LisCommunicationService { private void shutdownAllChannel() { - if (boditechLisSingleTrackChannel != null) { - boditechLisSingleTrackChannel.shotdown(); - boditechLisSingleTrackChannel = null; + if (lisChannel != null) { + lisChannel.shutdown(); + lisChannel = null; } log.info("shutdownAllChannel done"); } diff --git a/src/main/java/a8k/app/service/lis/LisSampleInfo.java b/src/main/java/a8k/app/service/lis/LisSampleInfo.java new file mode 100644 index 0000000..a306413 --- /dev/null +++ b/src/main/java/a8k/app/service/lis/LisSampleInfo.java @@ -0,0 +1,12 @@ +package a8k.app.service.lis; + +import a8k.app.type.a8k.BloodType; + +import java.util.ArrayList; +import java.util.List; + +public class LisSampleInfo { + public List projNameList = new ArrayList<>(); + public List projIds = new ArrayList<>(); //项目代码 + public BloodType bloodType = BloodType.WHOLE_BLOOD; //血液类型 +} diff --git a/src/main/java/a8k/app/service/lowerctrl/ConsumablesScanCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/ConsumablesScanCtrlService.java index c3d2762..7947dfb 100644 --- a/src/main/java/a8k/app/service/lowerctrl/ConsumablesScanCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/ConsumablesScanCtrlService.java @@ -1,6 +1,6 @@ package a8k.app.service.lowerctrl; -import a8k.app.channel.iflytophald.driver.CodeScanerDriver; +import a8k.app.iflytophald.driver.CodeScanerDriver; import a8k.app.teststate.VirtualDevice; import a8k.app.type.exception.AppException; import a8k.app.utils.DoAction; diff --git a/src/main/java/a8k/app/service/lowerctrl/HbotMoveCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/HbotMoveCtrlService.java index f2216c5..eaf94da 100644 --- a/src/main/java/a8k/app/service/lowerctrl/HbotMoveCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/HbotMoveCtrlService.java @@ -1,17 +1,17 @@ package a8k.app.service.lowerctrl; import a8k.app.constant.GearBacklashConstant; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.type.a8k.Pos2d; import a8k.app.type.a8k.Pos3d; -import a8k.app.channel.iflytophald.driver.InputDetectDriver; -import a8k.app.channel.iflytophald.driver.HbotDriver; +import a8k.app.iflytophald.driver.InputDetectDriver; +import a8k.app.iflytophald.driver.HbotDriver; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.InputIOId; -import a8k.app.channel.iflytophald.type.protocol.MId; -import a8k.app.channel.iflytophald.type.protocol.RegIndex; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.InputIOId; +import a8k.app.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.RegIndex; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; public class HbotMoveCtrlService { static Logger logger = LoggerFactory.getLogger(HbotMoveCtrlService.class); - private final A8kCanBusService canBus; + private final A8kCanBusBaseDriver canBus; private final PipetteCtrlDriverV2 pipetteCtrlDriver; private final HbotDriver hbotDriver; private final InputDetectDriver inputDetectDriver; diff --git a/src/main/java/a8k/app/service/lowerctrl/HbotMoveExCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/HbotMoveExCtrlService.java index 472d71f..ff971cc 100644 --- a/src/main/java/a8k/app/service/lowerctrl/HbotMoveExCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/HbotMoveExCtrlService.java @@ -1,14 +1,14 @@ package a8k.app.service.lowerctrl; import a8k.app.constant.GearBacklashConstant; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.service.param.hbotpos.*; import a8k.app.type.a8k.ConsumableGroup; import a8k.app.type.a8k.pos.PreReactionPos; import a8k.app.type.a8k.pos.TipGroupPos; import a8k.app.type.a8k.Pos2d; import a8k.app.type.a8k.Pos3d; -import a8k.app.channel.iflytophald.driver.HbotDriver; +import a8k.app.iflytophald.driver.HbotDriver; import a8k.app.type.exception.AppException; import a8k.app.type.param.type.A8kSamplePos; import a8k.app.type.param.hbotpos.HbotSamplePos; diff --git a/src/main/java/a8k/app/service/lowerctrl/LiquidOperationCtrService.java b/src/main/java/a8k/app/service/lowerctrl/LiquidOperationCtrService.java index 094d7d2..fcf297d 100644 --- a/src/main/java/a8k/app/service/lowerctrl/LiquidOperationCtrService.java +++ b/src/main/java/a8k/app/service/lowerctrl/LiquidOperationCtrService.java @@ -3,13 +3,13 @@ package a8k.app.service.lowerctrl; import a8k.app.dao.type.combination.ProjBuildInInfo; import a8k.app.dao.type.db.ProjExtInfoCard; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.DistribuType; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.AspirationParam; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.pipette_module.DistribuType; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; +import a8k.app.iflytophald.type.protocol.pipette_module.param.AspirationParam; +import a8k.app.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; import a8k.app.service.ctrlmodule.TipOperationCtrlModule; import a8k.app.service.param.hbotpos.*; import a8k.app.service.utils.UISender; diff --git a/src/main/java/a8k/app/service/lowerctrl/OptScanModuleLowerCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/OptScanModuleLowerCtrlService.java index 2576baf..00b1ec1 100644 --- a/src/main/java/a8k/app/service/lowerctrl/OptScanModuleLowerCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/OptScanModuleLowerCtrlService.java @@ -4,10 +4,10 @@ import a8k.app.optalgo.type.A8kOptPeakInfo; import a8k.app.constant.OptConstant; import a8k.app.optalgo.A8kOptCurveAnalyzer; import a8k.app.type.a8k.opt.OptScanResult; -import a8k.app.channel.iflytophald.driver.OptModuleDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.OptModuleRegIndex; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.OptModuleDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.OptModuleRegIndex; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.service.utils.UISender; import a8k.app.service.param.optparam.OptModuleExtParamsMgr; import a8k.app.service.param.optparam.OptModuleParamsMgr; @@ -16,7 +16,7 @@ import a8k.app.type.a8k.opt.A8kOptType; import a8k.app.type.a8k.pos.IncubatorPos; import a8k.app.type.exception.AppException; import a8k.app.dao.type.combination.ProjBuildInInfo; -import a8k.app.channel.iflytophald.utils.OptGainConvert; +import a8k.app.iflytophald.utils.OptGainConvert; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; diff --git a/src/main/java/a8k/app/service/lowerctrl/PlateBoxCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/PlateBoxCtrlService.java index b6457e9..35a210a 100644 --- a/src/main/java/a8k/app/service/lowerctrl/PlateBoxCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/PlateBoxCtrlService.java @@ -1,7 +1,7 @@ package a8k.app.service.lowerctrl; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.service.param.pos.PlatesBoxPosParamMgr; import a8k.app.type.a8k.ConsumableGroup; import a8k.app.type.a8k.pos.IncubatorPos; diff --git a/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java index 167b3c3..1b9ba73 100644 --- a/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/TubeFeedingCtrlService.java @@ -2,19 +2,19 @@ package a8k.app.service.lowerctrl; import a8k.OS; import a8k.app.type.a8k.A8kTubeHolderType; -import a8k.app.channel.iflytophald.driver.CodeScanerDriver; -import a8k.app.channel.iflytophald.driver.InputDetectDriver; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.CodeScanerDriver; +import a8k.app.iflytophald.driver.InputDetectDriver; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.service.param.pos.TubeFeedingModuleParamMgr; import a8k.app.service.background.AppEventBusService; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.InputIOId; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.InputIOId; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.type.misc.TubeHolderScanResult; import a8k.app.type.misc.TubeScanResult; import lombok.RequiredArgsConstructor; @@ -29,7 +29,7 @@ public class TubeFeedingCtrlService { static Integer tubeHolderScanOvertime = 3000; // 试管架类型扫码超时 private final AppEventBusService ebus; - private final A8kCanBusService canBus; + private final A8kCanBusBaseDriver canBus; private final TubeFeedingModuleParamMgr stp; private final CodeScanerDriver codeScanner; private final TubeFeedingExCtrlService tubeFeedingExCtrlService; diff --git a/src/main/java/a8k/app/service/lowerctrl/TubeFeedingExCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/TubeFeedingExCtrlService.java index b982161..3ef9439 100644 --- a/src/main/java/a8k/app/service/lowerctrl/TubeFeedingExCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/TubeFeedingExCtrlService.java @@ -2,12 +2,12 @@ package a8k.app.service.lowerctrl; import a8k.app.config.DeviceBehaviorConfig; import a8k.app.constant.MiniServoConstant; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; import a8k.app.constant.ActionOvertimeConstant; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.type.exception.AppException; import a8k.app.service.param.pos.TubePreProcesPosParamMgr; import lombok.RequiredArgsConstructor; @@ -27,8 +27,8 @@ public class TubeFeedingExCtrlService { static Integer overtime = 10000; - private final A8kCanBusService canBus; - private final MiniServoDriver miniServoDriver; + private final A8kCanBusBaseDriver canBus; + private final MiniServoDriver miniServoDriver; private final StepMotorCtrlDriver stepMotorCtrlDriver; private final ActionOvertimeConstant actionOvertimeConstant; private final TubePreProcesPosParamMgr tubePreProcesPosParamMgr; diff --git a/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleCtrlService.java index 0738d25..de5f2e6 100644 --- a/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleCtrlService.java @@ -1,11 +1,11 @@ package a8k.app.service.lowerctrl; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.constant.ActionOvertimeConstant; -import a8k.app.channel.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.CmdId; import a8k.app.service.param.pos.TubePreProcesPosParamMgr; import a8k.app.type.exception.AppException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleExCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleExCtrlService.java index a7f15ba..b4995e8 100644 --- a/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleExCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/TubePreProcessModuleExCtrlService.java @@ -1,9 +1,9 @@ package a8k.app.service.lowerctrl; import a8k.app.constant.MiniServoConstant; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.*; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.*; import a8k.app.type.exception.AppException; import a8k.app.service.param.pos.TubePreProcesPosParamMgr; import a8k.app.utils.ZEQ; diff --git a/src/main/java/a8k/app/service/lowerctrl/TurnableMoveCtrlService.java b/src/main/java/a8k/app/service/lowerctrl/TurnableMoveCtrlService.java index 06c5ae3..9dc5e75 100644 --- a/src/main/java/a8k/app/service/lowerctrl/TurnableMoveCtrlService.java +++ b/src/main/java/a8k/app/service/lowerctrl/TurnableMoveCtrlService.java @@ -1,14 +1,14 @@ package a8k.app.service.lowerctrl; -import a8k.app.channel.iflytophald.driver.InputDetectDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.InputDetectDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.service.param.pos.TurntablePosParamMgr; import a8k.app.type.a8k.pos.IncubatorPos; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.InputIOId; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.InputIOId; import a8k.app.utils.MinRotationAngle; import lombok.RequiredArgsConstructor; @@ -22,8 +22,8 @@ public class TurnableMoveCtrlService { static final Integer overtime = 10000; - private final A8kCanBusService canBus; - private final StepMotorCtrlDriver stepMotorCtrlDriver; + private final A8kCanBusBaseDriver canBus; + private final StepMotorCtrlDriver stepMotorCtrlDriver; private final TurntablePosParamMgr turntablePosParamMgr; private final InputDetectDriver inputDetectDriver; diff --git a/src/main/java/a8k/app/service/mainctrl/AppConsumablesScanService.java b/src/main/java/a8k/app/service/mainctrl/AppConsumablesScanService.java index 04f2a23..349a1bb 100644 --- a/src/main/java/a8k/app/service/mainctrl/AppConsumablesScanService.java +++ b/src/main/java/a8k/app/service/mainctrl/AppConsumablesScanService.java @@ -1,6 +1,6 @@ package a8k.app.service.mainctrl; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.i18n.Internationalization; import a8k.app.dao.type.combination.ProjBuildInInfo; import a8k.app.service.data.ProjInfoMgrService; diff --git a/src/main/java/a8k/app/service/mainctrl/AppDeviceInitCtrlService.java b/src/main/java/a8k/app/service/mainctrl/AppDeviceInitCtrlService.java index 1aaec9b..45ecd96 100644 --- a/src/main/java/a8k/app/service/mainctrl/AppDeviceInitCtrlService.java +++ b/src/main/java/a8k/app/service/mainctrl/AppDeviceInitCtrlService.java @@ -1,7 +1,7 @@ package a8k.app.service.mainctrl; -import a8k.app.channel.iflytophald.driver.*; -import a8k.app.channel.iflytophald.type.protocol.*; +import a8k.app.iflytophald.driver.*; +import a8k.app.iflytophald.type.protocol.*; import a8k.app.service.appsetup.A8kSubModuleRegInitService; import a8k.app.service.background.AppEventBusService; import a8k.app.service.lowerctrl.HbotMoveCtrlService; diff --git a/src/main/java/a8k/app/service/mainctrl/AppDeviceMainFlowCtrlService.java b/src/main/java/a8k/app/service/mainctrl/AppDeviceMainFlowCtrlService.java index be82de5..4df6f14 100644 --- a/src/main/java/a8k/app/service/mainctrl/AppDeviceMainFlowCtrlService.java +++ b/src/main/java/a8k/app/service/mainctrl/AppDeviceMainFlowCtrlService.java @@ -1,7 +1,7 @@ package a8k.app.service.mainctrl; import a8k.app.service.engineer.qatest.EngineerModeActionCtrlService; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.statemgr.AppFlagStateMgr; import a8k.app.service.statemgr.DeviceWorkStateMgrService; import a8k.app.service.statemgr.GStateMgrService; diff --git a/src/main/java/a8k/app/service/mainctrl/MainFlowCtrlScheduler.java b/src/main/java/a8k/app/service/mainctrl/MainFlowCtrlScheduler.java index 0255383..0cd6c34 100644 --- a/src/main/java/a8k/app/service/mainctrl/MainFlowCtrlScheduler.java +++ b/src/main/java/a8k/app/service/mainctrl/MainFlowCtrlScheduler.java @@ -16,7 +16,7 @@ import a8k.app.type.error.AppError; import a8k.app.type.exception.AppException; import a8k.app.type.a8k.state.enumtype.A8kWorkState; import a8k.app.factory.ZAppPromptFactory; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.background.AppEventBusService; import a8k.app.service.utils.UISender; import a8k.app.utils.ZWorkThread; diff --git a/src/main/java/a8k/app/service/mainctrl/TubeHolderSettingMgrService.java b/src/main/java/a8k/app/service/mainctrl/TubeHolderSettingMgrService.java index 3466723..b3d113c 100644 --- a/src/main/java/a8k/app/service/mainctrl/TubeHolderSettingMgrService.java +++ b/src/main/java/a8k/app/service/mainctrl/TubeHolderSettingMgrService.java @@ -5,7 +5,7 @@ import a8k.app.service.statemgr.GStateMgrService; import a8k.app.type.exception.AppException; import a8k.app.type.ui.TubeSetting; import a8k.app.type.ui.TubeHolderSetting; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import cn.hutool.core.util.ObjectUtil; import jakarta.annotation.Resource; import org.slf4j.Logger; diff --git a/src/main/java/a8k/app/service/module/InFeedingCtrlModule.java b/src/main/java/a8k/app/service/module/InFeedingCtrlModule.java index edb6a72..48fc36d 100644 --- a/src/main/java/a8k/app/service/module/InFeedingCtrlModule.java +++ b/src/main/java/a8k/app/service/module/InFeedingCtrlModule.java @@ -5,9 +5,9 @@ import a8k.app.dao.type.db.ReactionRecord; import a8k.app.service.engineer.state.TubeholderExSettingMgr; import a8k.app.service.engineer.type.A8kCmdRunnable; import a8k.app.factory.AppErrorFactory; -import a8k.app.channel.iflytophald.driver.InputDetectDriver; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.InputIOId; +import a8k.app.iflytophald.driver.InputDetectDriver; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.InputIOId; import a8k.app.service.analyzer.A8kEcodeAnalyzer; import a8k.app.service.background.AppEventBusService; import a8k.app.service.lowerctrl.TubeFeedingCtrlService; diff --git a/src/main/java/a8k/app/service/os/OSBeepCtrlService.java b/src/main/java/a8k/app/service/os/OSBeepCtrlService.java index 9562dae..6bcff53 100644 --- a/src/main/java/a8k/app/service/os/OSBeepCtrlService.java +++ b/src/main/java/a8k/app/service/os/OSBeepCtrlService.java @@ -1,9 +1,9 @@ package a8k.app.service.os; import a8k.OS; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.driver.OutputIOCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.OutputIOId; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.driver.OutputIOCtrlDriver; +import a8k.app.iflytophald.type.protocol.OutputIOId; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.teststate.VirtualDevice; import a8k.app.type.exception.AppException; @@ -18,7 +18,7 @@ import org.springframework.stereotype.Component; public class OSBeepCtrlService { - private final A8kCanBusService a8kCanBusService; + private final A8kCanBusBaseDriver a8KCanBusBaseDriver; boolean beepState = false;//beep底层状态 boolean beepStateIsSync = false;//底层状态是否同步 boolean hardwareErrorFlag = false;//硬件错误标志 @@ -54,7 +54,7 @@ public class OSBeepCtrlService { OS.forceSleep(100); } - if (!a8kCanBusService.isConnect()) { + if (!a8KCanBusBaseDriver.isConnect()) { OS.forceSleep(1000); continue; } diff --git a/src/main/java/a8k/app/service/os/OSDeviceInfoMgrService.java b/src/main/java/a8k/app/service/os/OSDeviceInfoMgrService.java index 144f1ab..7c420be 100644 --- a/src/main/java/a8k/app/service/os/OSDeviceInfoMgrService.java +++ b/src/main/java/a8k/app/service/os/OSDeviceInfoMgrService.java @@ -1,10 +1,9 @@ package a8k.app.service.os; import a8k.OS; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.statemgr.GStateMgrService; import a8k.app.type.exception.AppException; -import a8k.app.utils.ZDateUtils; import cn.hutool.core.io.FileUtil; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; @@ -12,8 +11,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.stereotype.Component; -import java.util.Date; - @Component @Slf4j @RequiredArgsConstructor diff --git a/src/main/java/a8k/app/service/os/OSNetworkMgrService.java b/src/main/java/a8k/app/service/os/OSNetworkMgrService.java index e532138..c4b322a 100644 --- a/src/main/java/a8k/app/service/os/OSNetworkMgrService.java +++ b/src/main/java/a8k/app/service/os/OSNetworkMgrService.java @@ -1,7 +1,7 @@ package a8k.app.service.os; import a8k.OS; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.dao.NetworkSettingDao; import a8k.app.dao.type.db.NetworkSetting; import a8k.app.service.statemgr.GStateMgrService; diff --git a/src/main/java/a8k/app/service/peripheral_ctrl/PrinterService.java b/src/main/java/a8k/app/service/peripheral_ctrl/PrinterService.java index 3e96fcb..7290961 100644 --- a/src/main/java/a8k/app/service/peripheral_ctrl/PrinterService.java +++ b/src/main/java/a8k/app/service/peripheral_ctrl/PrinterService.java @@ -2,7 +2,7 @@ package a8k.app.service.peripheral_ctrl; import a8k.app.dao.type.db.ProjExtInfoCard; import a8k.app.dao.type.db.ReactionRecord; -import a8k.app.channel.iflytophald.channel.PrinterUartChannel; +import a8k.app.iflytophald.channel.PrinterUartCommunicationChannel; import a8k.app.i18n.Internationalization; import a8k.app.optalgo.type.ReactionResultStatus; import a8k.app.service.data.ProjInfoMgrService; @@ -23,8 +23,8 @@ import java.util.List; @Slf4j @RequiredArgsConstructor public class PrinterService { - private final PrinterUartChannel printer; - private final ProjInfoMgrService projInfoMgrService; + private final PrinterUartCommunicationChannel printer; + private final ProjInfoMgrService projInfoMgrService; private final GStateMgrService gStateMgrService; diff --git a/src/main/java/a8k/app/service/setting/AppSettingsMgrService.java b/src/main/java/a8k/app/service/setting/AppSettingsMgrService.java index 82cd9b9..488f3a3 100644 --- a/src/main/java/a8k/app/service/setting/AppSettingsMgrService.java +++ b/src/main/java/a8k/app/service/setting/AppSettingsMgrService.java @@ -4,7 +4,7 @@ import a8k.app.dao.DeviceSettingDao; import a8k.app.dao.LISSettingDao; import a8k.app.dao.type.db.DeviceSetting; import a8k.app.dao.type.db.LISSetting; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.data.AppUserMgrService; import a8k.app.type.exception.AppException; import a8k.app.type.lis.LISDirectionTypeEnum; diff --git a/src/main/java/a8k/app/service/statemgr/ConsumablesMgrService.java b/src/main/java/a8k/app/service/statemgr/ConsumablesMgrService.java index e0b35af..b05859b 100644 --- a/src/main/java/a8k/app/service/statemgr/ConsumablesMgrService.java +++ b/src/main/java/a8k/app/service/statemgr/ConsumablesMgrService.java @@ -18,7 +18,7 @@ import a8k.app.type.a8k.proj.A8kReactionFlowType; import a8k.app.type.exception.AppException; import a8k.app.type.a8k.ConsumableGroup; import a8k.app.type.a8k.pos.TipGroupPos; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/a8k/app/service/statemgr/GStateMgrService.java b/src/main/java/a8k/app/service/statemgr/GStateMgrService.java index 24f6ee3..0b8955a 100644 --- a/src/main/java/a8k/app/service/statemgr/GStateMgrService.java +++ b/src/main/java/a8k/app/service/statemgr/GStateMgrService.java @@ -8,7 +8,7 @@ import a8k.app.type.GState; import a8k.app.type.error.AppError; import a8k.app.type.exception.AppException; import a8k.app.type.a8k.state.SensorState; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import jakarta.annotation.PostConstruct; import lombok.Data; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/app/service/statemgr/TubeStateMgr.java b/src/main/java/a8k/app/service/statemgr/TubeStateMgr.java index 3163a6e..7646b3a 100644 --- a/src/main/java/a8k/app/service/statemgr/TubeStateMgr.java +++ b/src/main/java/a8k/app/service/statemgr/TubeStateMgr.java @@ -12,7 +12,7 @@ import a8k.app.type.error.AEConsumeNotEnoughError; import a8k.app.dao.DeviceStatisticDao; import a8k.app.dao.SampleRecordDBDao; import a8k.app.dao.type.db.ProjExtInfoCard; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.utils.UISender; import a8k.app.service.data.ProjInfoMgrService; import a8k.app.type.a8k.state.enumtype.TubeHolderState; diff --git a/src/main/java/a8k/app/service/statemgr/consumables_mgr/TipStateMgr.java b/src/main/java/a8k/app/service/statemgr/consumables_mgr/TipStateMgr.java index 40b9bd5..a12de79 100644 --- a/src/main/java/a8k/app/service/statemgr/consumables_mgr/TipStateMgr.java +++ b/src/main/java/a8k/app/service/statemgr/consumables_mgr/TipStateMgr.java @@ -2,7 +2,7 @@ package a8k.app.service.statemgr.consumables_mgr; import a8k.app.constant.AppConstant; import a8k.app.dao.AppStatePersistenceDao; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.statemgr.DeviceWorkStateMgrService; import a8k.app.type.a8k.container.TipContainer; import a8k.app.type.a8k.pos.TipGroupPos; diff --git a/src/main/java/a8k/app/service/utils/UISender.java b/src/main/java/a8k/app/service/utils/UISender.java index 694182a..900e824 100644 --- a/src/main/java/a8k/app/service/utils/UISender.java +++ b/src/main/java/a8k/app/service/utils/UISender.java @@ -25,12 +25,14 @@ public class UISender { service.pushMessageBox(new MessageBox(MessageLevel.Error, String.format(msg, args))); } - public static void txErrorMsg(Logger logger, AppError e, String msg, Object... args) { - logger.error("{}", String.format(msg, args), e); + public static void txErrorMsg( String msg, Object... args) { var service = SpringBootBeanUtil.getBean(FrontEndMessageBoxAndEventMgr.class); service.pushMessageBox(new MessageBox(MessageLevel.Error, String.format(msg, args))); } - + public static void txWarnMsg( String msg, Object... args) { + var service = SpringBootBeanUtil.getBean(FrontEndMessageBoxAndEventMgr.class); + service.pushMessageBox(new MessageBox(MessageLevel.Warn, String.format(msg, args))); + } public static void txErrorPrompt(AppError error) { var ebus = SpringBootBeanUtil.getBean(AppEventBusService.class); diff --git a/src/main/java/a8k/app/service/utils/ZAppChecker.java b/src/main/java/a8k/app/service/utils/ZAppChecker.java index 2b452a1..88a92b0 100644 --- a/src/main/java/a8k/app/service/utils/ZAppChecker.java +++ b/src/main/java/a8k/app/service/utils/ZAppChecker.java @@ -1,6 +1,6 @@ package a8k.app.service.utils; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.error.AppError; import a8k.app.type.exception.AppException; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/a8k/app/service/virtualstate/DeviceVirtualStateMgrService.java b/src/main/java/a8k/app/service/virtualstate/DeviceVirtualStateMgrService.java index b3cc44d..55aafac 100644 --- a/src/main/java/a8k/app/service/virtualstate/DeviceVirtualStateMgrService.java +++ b/src/main/java/a8k/app/service/virtualstate/DeviceVirtualStateMgrService.java @@ -1,7 +1,7 @@ package a8k.app.service.virtualstate; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.constant.AppConstant; import a8k.app.factory.FakeA8kConsumableContainerFactory; import a8k.app.factory.FakeAppErrorFactory; diff --git a/src/main/java/a8k/app/type/BoardVersions.java b/src/main/java/a8k/app/type/BoardVersions.java index 74d0bd7..e9a42ae 100644 --- a/src/main/java/a8k/app/type/BoardVersions.java +++ b/src/main/java/a8k/app/type/BoardVersions.java @@ -1,6 +1,6 @@ package a8k.app.type; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.MId; import java.io.Serializable; import java.util.ArrayList; diff --git a/src/main/java/a8k/app/type/a8k/state/DeviceWorkState.java b/src/main/java/a8k/app/type/a8k/state/DeviceWorkState.java index e5848cb..0b52225 100644 --- a/src/main/java/a8k/app/type/a8k/state/DeviceWorkState.java +++ b/src/main/java/a8k/app/type/a8k/state/DeviceWorkState.java @@ -1,6 +1,6 @@ package a8k.app.type.a8k.state; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.a8k.state.enumtype.A8kWorkState; import a8k.app.type.a8k.state.enumtype.A8kWorkTaskType; import a8k.app.type.error.AppError; diff --git a/src/main/java/a8k/app/type/appevent/A8kHardwareReport.java b/src/main/java/a8k/app/type/appevent/A8kHardwareReport.java index d1174ee..77bcf4c 100644 --- a/src/main/java/a8k/app/type/appevent/A8kHardwareReport.java +++ b/src/main/java/a8k/app/type/appevent/A8kHardwareReport.java @@ -1,6 +1,6 @@ package a8k.app.type.appevent; -import a8k.app.channel.iflytophald.type.protocol.A8kPacket; +import a8k.app.iflytophald.type.protocol.A8kPacket; import org.springframework.lang.NonNull; /** diff --git a/src/main/java/a8k/app/type/appevent/AppWarningNotifyEvent.java b/src/main/java/a8k/app/type/appevent/AppWarningNotifyEvent.java index 77aaab6..65b2af4 100644 --- a/src/main/java/a8k/app/type/appevent/AppWarningNotifyEvent.java +++ b/src/main/java/a8k/app/type/appevent/AppWarningNotifyEvent.java @@ -1,6 +1,6 @@ package a8k.app.type.appevent; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.error.AppError; public class AppWarningNotifyEvent extends AppEvent { diff --git a/src/main/java/a8k/app/type/error/AECodeError.java b/src/main/java/a8k/app/type/error/AECodeError.java index 963b0d7..7625644 100644 --- a/src/main/java/a8k/app/type/error/AECodeError.java +++ b/src/main/java/a8k/app/type/error/AECodeError.java @@ -1,6 +1,6 @@ package a8k.app.type.error; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.utils.ZJsonHelper; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/src/main/java/a8k/app/type/error/AEConsumeNotEnoughError.java b/src/main/java/a8k/app/type/error/AEConsumeNotEnoughError.java index 348115b..b15f18f 100644 --- a/src/main/java/a8k/app/type/error/AEConsumeNotEnoughError.java +++ b/src/main/java/a8k/app/type/error/AEConsumeNotEnoughError.java @@ -1,7 +1,7 @@ package a8k.app.type.error; import a8k.app.service.analyzer.ConsumableStateAnalyzerService; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import io.swagger.v3.oas.annotations.media.Schema; import java.util.List; diff --git a/src/main/java/a8k/app/type/error/AEHardwareError.java b/src/main/java/a8k/app/type/error/AEHardwareError.java index 42d47a8..4cb978b 100644 --- a/src/main/java/a8k/app/type/error/AEHardwareError.java +++ b/src/main/java/a8k/app/type/error/AEHardwareError.java @@ -1,8 +1,8 @@ package a8k.app.type.error; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; import io.swagger.v3.oas.annotations.media.Schema; public class AEHardwareError extends AppError { diff --git a/src/main/java/a8k/app/type/error/AESimpleErrorPrompt.java b/src/main/java/a8k/app/type/error/AESimpleErrorPrompt.java index 26229a5..0e59745 100644 --- a/src/main/java/a8k/app/type/error/AESimpleErrorPrompt.java +++ b/src/main/java/a8k/app/type/error/AESimpleErrorPrompt.java @@ -1,6 +1,6 @@ package a8k.app.type.error; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; public class AESimpleErrorPrompt extends AppError { public AESimpleErrorPrompt(String exmsg) { diff --git a/src/main/java/a8k/app/type/error/AETubeError.java b/src/main/java/a8k/app/type/error/AETubeError.java index ea9fb13..70ff7a8 100644 --- a/src/main/java/a8k/app/type/error/AETubeError.java +++ b/src/main/java/a8k/app/type/error/AETubeError.java @@ -1,6 +1,6 @@ package a8k.app.type.error; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import io.swagger.v3.oas.annotations.media.Schema; public class AETubeError extends AppError { diff --git a/src/main/java/a8k/app/type/error/AppError.java b/src/main/java/a8k/app/type/error/AppError.java index 4e87ad6..a88b839 100644 --- a/src/main/java/a8k/app/type/error/AppError.java +++ b/src/main/java/a8k/app/type/error/AppError.java @@ -1,6 +1,6 @@ package a8k.app.type.error; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.utils.ZJsonHelper; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/a8k/app/type/exception/AppException.java b/src/main/java/a8k/app/type/exception/AppException.java index a9cb8a9..9dcff10 100644 --- a/src/main/java/a8k/app/type/exception/AppException.java +++ b/src/main/java/a8k/app/type/exception/AppException.java @@ -1,9 +1,9 @@ package a8k.app.type.exception; import a8k.app.type.a8k.pos.TipGroupPos; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; -import a8k.app.channel.iflytophald.type.protocol.CmdId; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.CmdId; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.type.error.AECodeError; import a8k.app.type.error.AESimpleErrorPrompt; import a8k.app.type.error.AppError; diff --git a/src/main/java/a8k/app/type/exception/ZAppInterruptException.java b/src/main/java/a8k/app/type/exception/ZAppInterruptException.java index 8d9eecc..ca043ea 100644 --- a/src/main/java/a8k/app/type/exception/ZAppInterruptException.java +++ b/src/main/java/a8k/app/type/exception/ZAppInterruptException.java @@ -1,6 +1,6 @@ package a8k.app.type.exception; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import lombok.Getter; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/a8k/app/type/lisprotocol/BiLisDoubleTrackFrameBuildContext.java b/src/main/java/a8k/app/type/lisprotocol/BiLisDoubleTrackFrameBuildContext.java index c173c72..35b88c5 100644 --- a/src/main/java/a8k/app/type/lisprotocol/BiLisDoubleTrackFrameBuildContext.java +++ b/src/main/java/a8k/app/type/lisprotocol/BiLisDoubleTrackFrameBuildContext.java @@ -5,6 +5,4 @@ public class BiLisDoubleTrackFrameBuildContext { public byte[] frameBytes; public String frameContentStr; public char[] checksum; - public Boolean buildSuccess = true; - } diff --git a/src/main/java/a8k/app/type/lisprotocol/subframe/OFrame.java b/src/main/java/a8k/app/type/lisprotocol/subframe/OFrame.java index c0fcdd4..a1da3ee 100644 --- a/src/main/java/a8k/app/type/lisprotocol/subframe/OFrame.java +++ b/src/main/java/a8k/app/type/lisprotocol/subframe/OFrame.java @@ -7,7 +7,22 @@ public class OFrame { public String type = "O"; // 请求类型 public String deviceName = "A8000"; public String sampleId = "";// - public List projList = new ArrayList<>(); + public List projList = new ArrayList<>(); public Integer sampleType;//全血0,血清血浆1,尿2,粪便3,唾液4 public String samplingDate;//采样时间 YYYYMMDDhhmmss + + + public String sampleTypeToStr() { + if (sampleType == null) { + return "未知"; + } + return switch (sampleType) { + case 0 -> "全血(0)"; // 全血 + case 1 -> "血清血浆(1)"; // 血清血浆 + case 2 -> "尿(2)"; // 尿 + case 3 -> "粪便(3)"; // 粪便 + case 4 -> "唾液(4)"; // 唾液 + default -> "未知(" + sampleType + ")"; + }; + } } diff --git a/src/main/java/a8k/app/type/ui/ApiRet.java b/src/main/java/a8k/app/type/ui/ApiRet.java index d16ff4d..94e2cff 100644 --- a/src/main/java/a8k/app/type/ui/ApiRet.java +++ b/src/main/java/a8k/app/type/ui/ApiRet.java @@ -1,7 +1,7 @@ package a8k.app.type.ui; import a8k.app.factory.ZAppPromptFactory; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.exception.AppException; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Getter; diff --git a/src/main/java/a8k/app/utils/ActionTaskPool.java b/src/main/java/a8k/app/utils/ActionTaskPool.java index 1edf364..43f21c5 100644 --- a/src/main/java/a8k/app/utils/ActionTaskPool.java +++ b/src/main/java/a8k/app/utils/ActionTaskPool.java @@ -5,7 +5,7 @@ import a8k.app.service.analyzer.A8kEcodeAnalyzer; import a8k.app.type.error.AECodeError; import a8k.app.type.error.AppError; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.type.BoolCondition; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/a8k/extui/oldpage/pos_calibration/HbotTipPosCalibration.java b/src/main/java/a8k/extui/oldpage/pos_calibration/HbotTipPosCalibration.java index 0881be5..60828bf 100644 --- a/src/main/java/a8k/extui/oldpage/pos_calibration/HbotTipPosCalibration.java +++ b/src/main/java/a8k/extui/oldpage/pos_calibration/HbotTipPosCalibration.java @@ -2,13 +2,13 @@ package a8k.extui.oldpage.pos_calibration; import a8k.app.constant.AppConstant; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.service.ctrlmodule.TipOperationCtrlModule; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import a8k.app.service.lowerctrl.HbotMoveCtrlService; import a8k.app.service.param.hbotpos.HbotTipPosMgr; -import a8k.app.channel.iflytophald.driver.HbotDriver; +import a8k.app.iflytophald.driver.HbotDriver; import a8k.app.type.a8k.Pos2d; import a8k.app.type.a8k.Pos3d; import a8k.app.type.a8k.pos.TipGroupPos; diff --git a/src/main/java/a8k/extui/page/apptest/LisTestPage.java b/src/main/java/a8k/extui/page/apptest/LisTestPage.java index 5463bad..0d46ea0 100644 --- a/src/main/java/a8k/extui/page/apptest/LisTestPage.java +++ b/src/main/java/a8k/extui/page/apptest/LisTestPage.java @@ -13,8 +13,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.stream.Stream; - @Component @Slf4j @RequiredArgsConstructor @@ -26,7 +24,7 @@ public class LisTestPage { @ExtApiStatu(name = "", group = "LIS协议", order = 1) public String getLisProtocol() { - return lisCommunicationService.getProtocolDetail(); + return lisCommunicationService.getChannelDescription(); } @ExtApiStatu(name = "", group = "LIS连接状态", order = 2) diff --git a/src/main/java/a8k/extui/page/apptest/PrinterDebugPage.java b/src/main/java/a8k/extui/page/apptest/PrinterDebugPage.java index d30b384..1f82510 100644 --- a/src/main/java/a8k/extui/page/apptest/PrinterDebugPage.java +++ b/src/main/java/a8k/extui/page/apptest/PrinterDebugPage.java @@ -1,7 +1,7 @@ package a8k.extui.page.apptest; import a8k.OS; -import a8k.app.channel.iflytophald.channel.PrinterUartChannel; +import a8k.app.iflytophald.channel.PrinterUartCommunicationChannel; import a8k.app.service.peripheral_ctrl.PrinterService; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtUIPageCfg; @@ -15,29 +15,29 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor public class PrinterDebugPage { - private final PrinterUartChannel printerUartChannel; - private final ExtApiPageMgr extApiPageMgr; + private final PrinterUartCommunicationChannel printerUartDriver; + private final ExtApiPageMgr extApiPageMgr; private final PrinterService printerService; public void printf(String str) { - printerUartChannel.printf(str + "\r\n"); + printerUartDriver.printf(str + "\r\n"); } public void printerTest() { - printerUartChannel.printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"); + printerUartDriver.printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"); OS.forceSleep(100); - printerUartChannel.printf("abcdefghijklmnopqrstuvwxyz\r\n"); + printerUartDriver.printf("abcdefghijklmnopqrstuvwxyz\r\n"); OS.forceSleep(100); - printerUartChannel.printf("0123456789\r\n"); + printerUartDriver.printf("0123456789\r\n"); OS.forceSleep(100); - printerUartChannel.printf("!@#$%%*()^_+\r\n"); + printerUartDriver.printf("!@#$%%*()^_+\r\n"); OS.forceSleep(100); - printerUartChannel.printf("~`!@#$%%^&*()_+|\\{}[]:\";'<>?,./\r\n"); + printerUartDriver.printf("~`!@#$%%^&*()_+|\\{}[]:\";'<>?,./\r\n"); OS.forceSleep(100); - printerUartChannel.printf("中文测试\r\n"); + printerUartDriver.printf("中文测试\r\n"); OS.forceSleep(100); - printerUartChannel.printfEnd(); + printerUartDriver.printfEnd(); } diff --git a/src/main/java/a8k/extui/page/codetest/BiLisDoubleTrackChannelTestPage.java b/src/main/java/a8k/extui/page/codetest/BiLisDoubleTrackChannelTestPage.java index 4dd3d00..76740de 100644 --- a/src/main/java/a8k/extui/page/codetest/BiLisDoubleTrackChannelTestPage.java +++ b/src/main/java/a8k/extui/page/codetest/BiLisDoubleTrackChannelTestPage.java @@ -1,6 +1,12 @@ package a8k.extui.page.codetest; +import a8k.app.dao.type.combination.ProjBuildInInfo; +import a8k.app.dao.type.db.ReactionRecord; +import a8k.app.factory.FakeReactionRecordFactory; +import a8k.app.service.data.ProjInfoMgrService; import a8k.app.service.lis.BiLisDoubleTrackChannel; +import a8k.app.type.exception.AppException; +import a8k.app.type.lisprotocol.subframe.OFrame; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; @@ -17,6 +23,7 @@ public class BiLisDoubleTrackChannelTestPage { private String serverPort = "9973"; BiLisDoubleTrackChannel biLisDoubleTrackChannel; + private final ProjInfoMgrService projInfoMgrService; synchronized public void setServeripAndPort(String serverip, String serverPort) { @@ -30,14 +37,23 @@ public class BiLisDoubleTrackChannelTestPage { log.info("新建连接: {}:{}", serverip, serverPort); } - synchronized public void execPing() { - biLisDoubleTrackChannel.ping(); + synchronized public String execPing() { + if (biLisDoubleTrackChannel.ping()) { + return "Ping成功"; + } else { + return "Ping失败"; + } } - synchronized public void execRequestSampleInfo(String sampleId) { - biLisDoubleTrackChannel.requestSampleInfo(sampleId); - log.info("请求样本信息: {}", sampleId); + synchronized public OFrame execRequestSampleInfo(String sampleId) throws AppException { + return biLisDoubleTrackChannel.requestSampleInfo0(sampleId); + } + synchronized public String reportReactionReport(Integer projectId) throws AppException { + ProjBuildInInfo buildInInfo = projInfoMgrService.getProjBuildInInfo(projectId); + ReactionRecord record = FakeReactionRecordFactory.buildRecord(buildInInfo); + biLisDoubleTrackChannel.reportReactionRecord(record); + return "报告反应上报成功"; } @PostConstruct @@ -48,6 +64,8 @@ public class BiLisDoubleTrackChannelTestPage { .setParamVal("serverPort", () -> serverPort); page.addFunction("新建连接", this::newConnect); page.addFunction("执行Ping", this::execPing); + page.addFunction("报告反应记录", this::reportReactionReport) + .setParamVal("projectId", () -> 1); page.addFunction("请求样本信息", this::execRequestSampleInfo) .setParamVal("sampleId", () -> ""); diff --git a/src/main/java/a8k/extui/page/debug/P02ConsumablesMgrDebugPage.java b/src/main/java/a8k/extui/page/debug/P02ConsumablesMgrDebugPage.java index 305548d..fbaf9cb 100644 --- a/src/main/java/a8k/extui/page/debug/P02ConsumablesMgrDebugPage.java +++ b/src/main/java/a8k/extui/page/debug/P02ConsumablesMgrDebugPage.java @@ -9,7 +9,7 @@ import a8k.app.type.a8k.container.ReactionPlateContainer; import a8k.app.type.error.ConsumablesScanReportErrorType; import a8k.app.type.exception.AppException; import a8k.app.dao.type.db.ProjExtInfoCard; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.data.ProjIdCardInfoMgrService; import a8k.app.service.data.ProjInfoMgrService; import a8k.app.service.mainctrl.AppConsumablesScanService; diff --git a/src/main/java/a8k/extui/page/driver/CodeScannerDriverCtrlPage.java b/src/main/java/a8k/extui/page/driver/CodeScannerDriverCtrlPage.java index 76a42a6..612e1b2 100644 --- a/src/main/java/a8k/extui/page/driver/CodeScannerDriverCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/CodeScannerDriverCtrlPage.java @@ -1,7 +1,7 @@ package a8k.extui.page.driver; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.CodeScanerDriver; +import a8k.app.iflytophald.driver.CodeScanerDriver; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/extui/page/driver/HbotCtrlPage.java b/src/main/java/a8k/extui/page/driver/HbotCtrlPage.java index 358cf0e..b2d32d1 100644 --- a/src/main/java/a8k/extui/page/driver/HbotCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/HbotCtrlPage.java @@ -1,9 +1,9 @@ package a8k.extui.page.driver; import a8k.app.constant.GearBacklashConstant; -import a8k.app.channel.iflytophald.driver.HbotDriver; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.HbotRegIndex; +import a8k.app.iflytophald.driver.HbotDriver; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.HbotRegIndex; import a8k.app.type.a8k.Pos2d; import a8k.app.type.a8k.Pos3d; import a8k.app.type.exception.AppException; diff --git a/src/main/java/a8k/extui/page/driver/MiniServoCtrlPage.java b/src/main/java/a8k/extui/page/driver/MiniServoCtrlPage.java index 237c1e6..4b35931 100644 --- a/src/main/java/a8k/extui/page/driver/MiniServoCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/MiniServoCtrlPage.java @@ -1,9 +1,9 @@ package a8k.extui.page.driver; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; -import a8k.app.channel.iflytophald.type.protocol.MiniServoRegIndex; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.type.protocol.MiniServoRegIndex; import a8k.app.utils.ZJsonNode; import a8k.extui.mgr.ExtApiPageMgr; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/a8k/extui/page/driver/MotorCtrlPage.java b/src/main/java/a8k/extui/page/driver/MotorCtrlPage.java index 3dee261..ec74966 100644 --- a/src/main/java/a8k/extui/page/driver/MotorCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/MotorCtrlPage.java @@ -1,10 +1,10 @@ package a8k.extui.page.driver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorSpeedLevel; +import a8k.app.iflytophald.type.protocol.StepMotorSpeedLevel; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorRegIndex; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.type.protocol.StepMotorRegIndex; import a8k.app.utils.ZJsonNode; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/driver/OptScannerCtrlPage.java b/src/main/java/a8k/extui/page/driver/OptScannerCtrlPage.java index 622311e..7264b6b 100644 --- a/src/main/java/a8k/extui/page/driver/OptScannerCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/OptScannerCtrlPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.driver; -import a8k.app.channel.iflytophald.driver.OptModuleDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; -import a8k.app.channel.iflytophald.type.protocol.OptModuleRegIndex; +import a8k.app.iflytophald.driver.OptModuleDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.type.protocol.OptModuleRegIndex; import a8k.app.type.exception.AppException; import a8k.app.utils.ZJsonNode; import a8k.extui.mgr.ExtApiPageMgr; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCfgSync.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCfgSync.java index 7af8029..7558468 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCfgSync.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCfgSync.java @@ -1,7 +1,7 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.PipetteConfig; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.PipetteConfig; import a8k.app.service.data.FileMgrService; import a8k.app.type.exception.AppException; import a8k.app.utils.ZJsonHelper; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCommonConfigPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCommonConfigPage.java index 55bfb93..bb022b2 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCommonConfigPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunCommonConfigPage.java @@ -1,9 +1,9 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.PipetteCommonConfigIndex; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.PlatInfoCpyIdx; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.PipetteCommonConfigIndex; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.PlatInfoCpyIdx; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunContainerConfigSettingPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunContainerConfigSettingPage.java index 850cb95..9ae4b23 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunContainerConfigSettingPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunContainerConfigSettingPage.java @@ -1,9 +1,9 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.ContainerInfoIndex; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.ContainerInfoIndex; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunLiquidConfigSettingPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunLiquidConfigSettingPage.java index 41c995b..d79b7b0 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunLiquidConfigSettingPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunLiquidConfigSettingPage.java @@ -1,10 +1,10 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.LiquidInfoIndex; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.PMVCpyIdx; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.LiquidInfoIndex; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.PMVCpyIdx; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunOperationCtrlPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunOperationCtrlPage.java index acc76cc..5eed269 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunOperationCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunOperationCtrlPage.java @@ -1,10 +1,10 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.AspirationParam; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; +import a8k.app.iflytophald.type.protocol.pipette_module.param.AspirationParam; +import a8k.app.iflytophald.type.protocol.pipette_module.param.DistribuAllParam; import a8k.app.type.exception.AppException; import a8k.extui.factory.CurveBuilder; import a8k.extui.mgr.ExtApiPageMgr; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPMVelConfigSettingPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPMVelConfigSettingPage.java index ca8dd65..a42bc47 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPMVelConfigSettingPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPMVelConfigSettingPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.PMVConfigIndex; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.PMVCpyIdx; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.PMVConfigIndex; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.PMVCpyIdx; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPlatformSettingPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPlatformSettingPage.java index 06ad323..c0135d9 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPlatformSettingPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunPlatformSettingPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.PlatformInfoIndex; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.PlatformInfoIndex; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunTestCtrlPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunTestCtrlPage.java index a9b8a6c..3b46b41 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunTestCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunTestCtrlPage.java @@ -1,10 +1,10 @@ package a8k.extui.page.driver.pipette_module; import a8k.OS; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.PMVCpyIdx; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ContainerCpyId; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.LiquidConfigCpyIdx; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.PMVCpyIdx; import a8k.app.type.exception.AppException; import a8k.extui.factory.CurveBuilder; import a8k.extui.mgr.ExtApiPageMgr; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMVelConfigSettingPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMVelConfigSettingPage.java index be95c5c..3ac5013 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMVelConfigSettingPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMVelConfigSettingPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cpyidx.ZMVCpyIdx; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.ZMVConfigIndex; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.pipette_module.cpyidx.ZMVCpyIdx; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.ZMVConfigIndex; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMotorCtrlPage.java b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMotorCtrlPage.java index f100776..cd2bc10 100644 --- a/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMotorCtrlPage.java +++ b/src/main/java/a8k/extui/page/driver/pipette_module/PipetteGunZMotorCtrlPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.driver.pipette_module; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.ModuleStatus; -import a8k.app.channel.iflytophald.type.protocol.pipette_module.cfg.ZMBasicConfigIndex; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.type.protocol.ModuleStatus; +import a8k.app.iflytophald.type.protocol.pipette_module.cfg.ZMBasicConfigIndex; import a8k.app.type.exception.AppException; import a8k.app.utils.ZJsonNode; import a8k.extui.mgr.ExtApiPageMgr; diff --git a/src/main/java/a8k/extui/page/extapp/OptModuleParamCalibration.java b/src/main/java/a8k/extui/page/extapp/OptModuleParamCalibration.java index 59d85b2..b15d4e1 100644 --- a/src/main/java/a8k/extui/page/extapp/OptModuleParamCalibration.java +++ b/src/main/java/a8k/extui/page/extapp/OptModuleParamCalibration.java @@ -15,7 +15,7 @@ import a8k.app.service.lowerctrl.PlateBoxCtrlService; import a8k.app.service.param.optparam.OptModuleExtParamsMgr; import a8k.app.type.param.optpos.OptModuleExtParam; import a8k.app.type.a8k.opt.A8kOptType; -import a8k.app.channel.iflytophald.utils.OptGainConvert; +import a8k.app.iflytophald.utils.OptGainConvert; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/extui/page/extapp/TemporaryTestPage.java b/src/main/java/a8k/extui/page/extapp/TemporaryTestPage.java index 192147e..756964f 100644 --- a/src/main/java/a8k/extui/page/extapp/TemporaryTestPage.java +++ b/src/main/java/a8k/extui/page/extapp/TemporaryTestPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.extapp; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; import a8k.app.service.param.pos.TubePreProcesPosParamMgr; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/extapp/profession_test/P02A8kTemperaturaVerfication.java b/src/main/java/a8k/extui/page/extapp/profession_test/P02A8kTemperaturaVerfication.java index 2b15f74..48e3fc6 100644 --- a/src/main/java/a8k/extui/page/extapp/profession_test/P02A8kTemperaturaVerfication.java +++ b/src/main/java/a8k/extui/page/extapp/profession_test/P02A8kTemperaturaVerfication.java @@ -1,6 +1,6 @@ package a8k.extui.page.extapp; -import a8k.app.channel.iflytophald.driver.WaterTemperatureControllerDriver; +import a8k.app.iflytophald.driver.WaterTemperatureControllerDriver; import a8k.app.service.background.TemperatureCtrlService; import a8k.app.service.param.misc.TemperatureCtrlParamMgr; import a8k.app.type.exception.AppException; diff --git a/src/main/java/a8k/extui/page/extapp/tools/MoterMoveUtilsPage.java b/src/main/java/a8k/extui/page/extapp/tools/MoterMoveUtilsPage.java index 501ecf2..47ca934 100644 --- a/src/main/java/a8k/extui/page/extapp/tools/MoterMoveUtilsPage.java +++ b/src/main/java/a8k/extui/page/extapp/tools/MoterMoveUtilsPage.java @@ -1,9 +1,9 @@ package a8k.extui.page.extapp.tools; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; diff --git a/src/main/java/a8k/extui/page/extsetting/db/A8kSubModuleRegAndConfigSyncPage.java b/src/main/java/a8k/extui/page/extsetting/db/A8kSubModuleRegAndConfigSyncPage.java index 9804977..f9abaec 100644 --- a/src/main/java/a8k/extui/page/extsetting/db/A8kSubModuleRegAndConfigSyncPage.java +++ b/src/main/java/a8k/extui/page/extsetting/db/A8kSubModuleRegAndConfigSyncPage.java @@ -1,7 +1,7 @@ package a8k.extui.page.extsetting.db; import a8k.app.controler.filemgr.StorageControler; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; import a8k.app.service.data.SubModuleConfigService; import a8k.app.service.data.SubModuleRegInitialValueMgrService; import a8k.app.type.exception.AppException; @@ -19,9 +19,9 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor public class A8kSubModuleRegAndConfigSyncPage { - private final ExtApiPageMgr extApiPageMgr; - private final A8kCanBusService canBus; - private final SubModuleConfigService subModuleConfigService; + private final ExtApiPageMgr extApiPageMgr; + private final A8kCanBusBaseDriver canBus; + private final SubModuleConfigService subModuleConfigService; private final SubModuleRegInitialValueMgrService subModuleRegInitialValueMgrService; diff --git a/src/main/java/a8k/extui/page/hardwaretest/HBotHardwareTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/HBotHardwareTestPage.java index 0dc03a9..6e55bc4 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/HBotHardwareTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/HBotHardwareTestPage.java @@ -1,7 +1,7 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.HbotDriver; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.HbotDriver; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; diff --git a/src/main/java/a8k/extui/page/hardwaretest/InputIOStateHardwareTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/InputIOStateHardwareTestPage.java index 105240e..61ecb09 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/InputIOStateHardwareTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/InputIOStateHardwareTestPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.hardwaretest; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.InputDetectDriver; -import a8k.app.channel.iflytophald.type.protocol.InputIOId; +import a8k.app.iflytophald.driver.InputDetectDriver; +import a8k.app.iflytophald.type.protocol.InputIOId; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/hardwaretest/LISUartTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/LISUartTestPage.java index f4e2b9d..78c5e68 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/LISUartTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/LISUartTestPage.java @@ -1,6 +1,6 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.channel.LisUartChannel; +import a8k.app.iflytophald.channel.LisUartCommunicationChannel; import a8k.app.type.lis.LISSerialBaudrateType; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; @@ -11,30 +11,30 @@ import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor public class LISUartTestPage { - final private LisUartChannel lisUartChannel; - private final ExtApiPageMgr extApiPageMgr; + final private LisUartCommunicationChannel lisUartCommunicationChannel; + private final ExtApiPageMgr extApiPageMgr; @ExtApiStatu(name = "", group = "波特率", order = 1) public Integer getBaudRate() { - return lisUartChannel.getBaudRateDirect(); + return lisUartCommunicationChannel.getBaudRateDirect(); } @ExtApiStatu(name = "", group = "回环模式", order = 1) public Boolean getLoopbackMode() { - return lisUartChannel.isInLoopbackMode(); + return lisUartCommunicationChannel.isInLoopbackMode(); } public void setBaudRate(LISSerialBaudrateType baudRate) { - lisUartChannel.setBaudRate(baudRate.baudrate); + lisUartCommunicationChannel.setBaudRate(baudRate.baudrate); } public void setInLoopbackMode(Boolean val) { - lisUartChannel.setInLoopbackMode(val); + lisUartCommunicationChannel.setInLoopbackMode(val); } public void sendCommand(String msg) { - lisUartChannel.tx(msg); + lisUartCommunicationChannel.tx(msg); } @PostConstruct diff --git a/src/main/java/a8k/extui/page/hardwaretest/MiniServoHardwareTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/MiniServoHardwareTestPage.java index b4717de..6dbd747 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/MiniServoHardwareTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/MiniServoHardwareTestPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; import a8k.app.service.mainctrl.AppDeviceInitCtrlService; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; diff --git a/src/main/java/a8k/extui/page/hardwaretest/MiniServoPosCalibratePage.java b/src/main/java/a8k/extui/page/hardwaretest/MiniServoPosCalibratePage.java index 1b6fe35..609bbb9 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/MiniServoPosCalibratePage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/MiniServoPosCalibratePage.java @@ -6,8 +6,8 @@ import a8k.app.service.lowerctrl.TubePreProcessModuleCtrlService; import a8k.app.service.param.pos.TubePreProcesPosParamMgr; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/extui/page/hardwaretest/MiscHardwareTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/MiscHardwareTestPage.java index cc80ce9..78dfc2e 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/MiscHardwareTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/MiscHardwareTestPage.java @@ -1,7 +1,7 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.MiniServoDriver; import a8k.app.service.mainctrl.AppDeviceInitCtrlService; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtUIPageCfg; diff --git a/src/main/java/a8k/extui/page/hardwaretest/MotorHardwareTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/MotorHardwareTestPage.java index d356d6b..880d326 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/MotorHardwareTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/MotorHardwareTestPage.java @@ -1,9 +1,8 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorRegIndex; -import a8k.app.channel.iflytophald.type.protocol.StepMotorSpeedLevel; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.type.protocol.StepMotorRegIndex; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtUIPageCfg; diff --git a/src/main/java/a8k/extui/page/hardwaretest/MotorPPSHardwareTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/MotorPPSHardwareTestPage.java index d5903a4..6bccfcf 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/MotorPPSHardwareTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/MotorPPSHardwareTestPage.java @@ -1,9 +1,8 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorRegIndex; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; diff --git a/src/main/java/a8k/extui/page/hardwaretest/OutputIOCtrlTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/OutputIOCtrlTestPage.java index 5edc5f9..e8fb0e3 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/OutputIOCtrlTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/OutputIOCtrlTestPage.java @@ -1,7 +1,7 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.OutputIOCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.OutputIOId; +import a8k.app.iflytophald.driver.OutputIOCtrlDriver; +import a8k.app.iflytophald.type.protocol.OutputIOId; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/hardwaretest/PipetteGunHardwareTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/PipetteGunHardwareTestPage.java index a986d8a..f48aa3d 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/PipetteGunHardwareTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/PipetteGunHardwareTestPage.java @@ -1,7 +1,6 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; -import a8k.app.channel.iflytophald.type.protocol.ModuleStatus; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/hardwaretest/SubBoardProberPage.java b/src/main/java/a8k/extui/page/hardwaretest/SubBoardProberPage.java index 4c20be9..935d708 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/SubBoardProberPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/SubBoardProberPage.java @@ -1,7 +1,7 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.type.protocol.MId; import a8k.app.type.VersionInfo; import a8k.app.type.exception.AppException; import a8k.app.utils.ZList; @@ -22,7 +22,7 @@ public class SubBoardProberPage { ExtApiPageMgr extApiPageMgr; @Resource - A8kCanBusService canBus; + A8kCanBusBaseDriver canBus; Map versionInfos = new HashMap<>(); diff --git a/src/main/java/a8k/extui/page/hardwaretest/SubModuleVersionPreviewPage.java b/src/main/java/a8k/extui/page/hardwaretest/SubModuleVersionPreviewPage.java index 4c6790b..b515bc4 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/SubModuleVersionPreviewPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/SubModuleVersionPreviewPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.hardwaretest; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.channel.A8kCanBusService; -import a8k.app.channel.iflytophald.type.protocol.MId; +import a8k.app.iflytophald.driver.A8kCanBusBaseDriver; +import a8k.app.iflytophald.type.protocol.MId; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; import jakarta.annotation.PostConstruct; @@ -20,7 +20,7 @@ public class SubModuleVersionPreviewPage { ExtApiPageMgr extApiPageMgr; @Resource - A8kCanBusService canBus; + A8kCanBusBaseDriver canBus; public static class VersionInfo { public Integer moduleId; diff --git a/src/main/java/a8k/extui/page/hardwaretest/WaterTempControllerTestPage.java b/src/main/java/a8k/extui/page/hardwaretest/WaterTempControllerTestPage.java index 5f5b275..973eaaa 100644 --- a/src/main/java/a8k/extui/page/hardwaretest/WaterTempControllerTestPage.java +++ b/src/main/java/a8k/extui/page/hardwaretest/WaterTempControllerTestPage.java @@ -1,8 +1,8 @@ package a8k.extui.page.hardwaretest; -import a8k.app.channel.iflytophald.driver.WaterTemperatureControllerDriver; -import a8k.app.channel.iflytophald.type.protocol.TemperatureControlerMid; -import a8k.app.channel.iflytophald.type.protocol.TemperatureControlerRegIndex; +import a8k.app.iflytophald.driver.WaterTemperatureControllerDriver; +import a8k.app.iflytophald.type.protocol.TemperatureControlerMid; +import a8k.app.iflytophald.type.protocol.TemperatureControlerRegIndex; import a8k.app.type.exception.AppException; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; diff --git a/src/main/java/a8k/extui/page/measurement/FeedingModMeasurePage.java b/src/main/java/a8k/extui/page/measurement/FeedingModMeasurePage.java index f205e21..1f9ff4a 100644 --- a/src/main/java/a8k/extui/page/measurement/FeedingModMeasurePage.java +++ b/src/main/java/a8k/extui/page/measurement/FeedingModMeasurePage.java @@ -1,9 +1,9 @@ package a8k.extui.page.measurement; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; diff --git a/src/main/java/a8k/extui/page/measurement/HbotFreedomPosMeasurePage.java b/src/main/java/a8k/extui/page/measurement/HbotFreedomPosMeasurePage.java index 21db082..ec3558e 100644 --- a/src/main/java/a8k/extui/page/measurement/HbotFreedomPosMeasurePage.java +++ b/src/main/java/a8k/extui/page/measurement/HbotFreedomPosMeasurePage.java @@ -1,9 +1,9 @@ package a8k.extui.page.measurement; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.type.a8k.Pos3d; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.HbotDriver; +import a8k.app.iflytophald.driver.HbotDriver; import a8k.app.service.lowerctrl.HbotMoveCtrlService; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; diff --git a/src/main/java/a8k/extui/page/measurement/HbotPosMeasurePage.java b/src/main/java/a8k/extui/page/measurement/HbotPosMeasurePage.java index 12f3bec..128eeed 100644 --- a/src/main/java/a8k/extui/page/measurement/HbotPosMeasurePage.java +++ b/src/main/java/a8k/extui/page/measurement/HbotPosMeasurePage.java @@ -1,12 +1,12 @@ package a8k.extui.page.measurement; import a8k.app.constant.GearBacklashConstant; -import a8k.app.channel.iflytophald.driver.CodeScanerDriver; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.CodeScanerDriver; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.type.a8k.Pos2d; import a8k.app.type.a8k.Pos3d; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.HbotDriver; +import a8k.app.iflytophald.driver.HbotDriver; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/measurement/IncubatorMeasurePage.java b/src/main/java/a8k/extui/page/measurement/IncubatorMeasurePage.java index e6c81e7..0b28f83 100644 --- a/src/main/java/a8k/extui/page/measurement/IncubatorMeasurePage.java +++ b/src/main/java/a8k/extui/page/measurement/IncubatorMeasurePage.java @@ -1,8 +1,8 @@ package a8k.extui.page.measurement; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.extui.mgr.ExtApiPageMgr; import a8k.extui.type.ExtApiStatu; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/measurement/OptModMeasurePage.java b/src/main/java/a8k/extui/page/measurement/OptModMeasurePage.java index ac7554b..9a0edd7 100644 --- a/src/main/java/a8k/extui/page/measurement/OptModMeasurePage.java +++ b/src/main/java/a8k/extui/page/measurement/OptModMeasurePage.java @@ -1,9 +1,9 @@ package a8k.extui.page.measurement; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; diff --git a/src/main/java/a8k/extui/page/measurement/PlatesBoxMeasurePage.java b/src/main/java/a8k/extui/page/measurement/PlatesBoxMeasurePage.java index 8a86eab..2c7e7f4 100644 --- a/src/main/java/a8k/extui/page/measurement/PlatesBoxMeasurePage.java +++ b/src/main/java/a8k/extui/page/measurement/PlatesBoxMeasurePage.java @@ -1,8 +1,8 @@ package a8k.extui.page.measurement; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/a8k/extui/page/measurement/ShakeModStepMotorMeasurePage.java b/src/main/java/a8k/extui/page/measurement/ShakeModStepMotorMeasurePage.java index d496e26..9753612 100644 --- a/src/main/java/a8k/extui/page/measurement/ShakeModStepMotorMeasurePage.java +++ b/src/main/java/a8k/extui/page/measurement/ShakeModStepMotorMeasurePage.java @@ -1,10 +1,10 @@ package a8k.extui.page.measurement; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; -import a8k.app.channel.iflytophald.type.protocol.StepMotorMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.type.protocol.StepMotorMId; import a8k.app.service.param.pos.TubePreProcesPosParamMgr; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/miniservo/MiniServoScanerPage.java b/src/main/java/a8k/extui/page/miniservo/MiniServoScanerPage.java index f2b801b..7ad3065 100644 --- a/src/main/java/a8k/extui/page/miniservo/MiniServoScanerPage.java +++ b/src/main/java/a8k/extui/page/miniservo/MiniServoScanerPage.java @@ -2,8 +2,8 @@ package a8k.extui.page.miniservo; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.type.protocol.MiniServoMId; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.type.protocol.MiniServoMId; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; diff --git a/src/main/java/a8k/extui/page/optalgotest/OptAlgoTestPage.java b/src/main/java/a8k/extui/page/optalgotest/OptAlgoTestPage.java index 8ca150d..65d0525 100644 --- a/src/main/java/a8k/extui/page/optalgotest/OptAlgoTestPage.java +++ b/src/main/java/a8k/extui/page/optalgotest/OptAlgoTestPage.java @@ -2,7 +2,7 @@ package a8k.extui.page.optalgotest; import a8k.app.dao.type.db.ProjExtInfoCard; import a8k.app.dao.type.db.ReactionRecord; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.optalgo.A8kOptCurveAnalyzer; import a8k.app.optalgo.A8kPeakAnalyzer; diff --git a/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPage.java b/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPage.java index d13a9da..fbbebbb 100644 --- a/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPage.java +++ b/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPage.java @@ -7,7 +7,7 @@ import a8k.app.optalgo.type.A8kOptPeakInfo; import a8k.app.type.a8k.BloodType; import a8k.app.type.exception.AppException; import a8k.app.type.a8k.state.SampleInfo; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.data.ProjIdCardInfoMgrService; import a8k.app.service.data.ProjInfoMgrService; import a8k.app.type.a8k.proj.ProjInfo; diff --git a/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPageV2.java b/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPageV2.java index 329dc62..acc7e1f 100644 --- a/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPageV2.java +++ b/src/main/java/a8k/extui/page/test/codetest/OptFormulaTestPageV2.java @@ -10,7 +10,7 @@ import a8k.app.type.a8k.BloodType; import a8k.app.type.exception.AppException; import a8k.app.type.a8k.opt.PeakName; import a8k.app.type.a8k.state.SampleInfo; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.service.data.ProjIdCardInfoMgrService; import a8k.app.service.data.ProjInfoMgrService; import a8k.app.type.a8k.proj.ProjInfo; diff --git a/src/main/java/a8k/extui/page/test/verification/HbotCodeScanPosVerificationPage.java b/src/main/java/a8k/extui/page/test/verification/HbotCodeScanPosVerificationPage.java index 8e1b799..7856af1 100644 --- a/src/main/java/a8k/extui/page/test/verification/HbotCodeScanPosVerificationPage.java +++ b/src/main/java/a8k/extui/page/test/verification/HbotCodeScanPosVerificationPage.java @@ -1,6 +1,6 @@ package a8k.extui.page.test.verification; -import a8k.app.channel.iflytophald.driver.CodeScanerDriver; +import a8k.app.iflytophald.driver.CodeScanerDriver; import a8k.app.service.lowerctrl.HbotMoveExCtrlService; import a8k.app.type.a8k.ConsumableGroup; import a8k.app.type.exception.AppException; diff --git a/src/main/java/a8k/extui/page/test/verification/P10ProjejIDCardTestPage.java b/src/main/java/a8k/extui/page/test/verification/P10ProjejIDCardTestPage.java index 64da3eb..fad9cbf 100644 --- a/src/main/java/a8k/extui/page/test/verification/P10ProjejIDCardTestPage.java +++ b/src/main/java/a8k/extui/page/test/verification/P10ProjejIDCardTestPage.java @@ -2,7 +2,7 @@ package a8k.extui.page.test.verification; import a8k.app.type.exception.AppException; import a8k.app.dao.type.db.ProjExtInfoCard; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.i18n.Internationalization; import a8k.app.service.data.ProjIdCardInfoMgrService; import a8k.app.service.mainctrl.AppDeviceInitCtrlService; diff --git a/src/main/java/a8k/extui/page/test/verification/P31ReactionPlatesTransmitPosVerificationPage.java b/src/main/java/a8k/extui/page/test/verification/P31ReactionPlatesTransmitPosVerificationPage.java index f167942..215212c 100644 --- a/src/main/java/a8k/extui/page/test/verification/P31ReactionPlatesTransmitPosVerificationPage.java +++ b/src/main/java/a8k/extui/page/test/verification/P31ReactionPlatesTransmitPosVerificationPage.java @@ -3,8 +3,8 @@ package a8k.extui.page.test.verification; import a8k.app.type.a8k.ConsumableGroup; import a8k.app.type.a8k.pos.IncubatorPos; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.driver.MiniServoDriver; -import a8k.app.channel.iflytophald.driver.StepMotorCtrlDriver; +import a8k.app.iflytophald.driver.MiniServoDriver; +import a8k.app.iflytophald.driver.StepMotorCtrlDriver; import a8k.app.service.lowerctrl.*; import a8k.extui.mgr.ExtApiPageMgr; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/a8k/extui/page/test/verification/P50VerificationScriptPage.java b/src/main/java/a8k/extui/page/test/verification/P50VerificationScriptPage.java index 05844cc..8ae6722 100644 --- a/src/main/java/a8k/extui/page/test/verification/P50VerificationScriptPage.java +++ b/src/main/java/a8k/extui/page/test/verification/P50VerificationScriptPage.java @@ -1,6 +1,6 @@ package a8k.extui.page.test.verification; -import a8k.app.channel.iflytophald.driver.PipetteCtrlDriverV2; +import a8k.app.iflytophald.driver.PipetteCtrlDriverV2; import a8k.app.service.ctrlmodule.TipOperationCtrlModule; import a8k.app.type.a8k.A8kTubeHolderType; import a8k.app.type.a8k.ConsumableGroup; diff --git a/src/main/java/a8k/extui/type/ret/AppRetV1.java b/src/main/java/a8k/extui/type/ret/AppRetV1.java index 1ae9ec5..9cbf671 100644 --- a/src/main/java/a8k/extui/type/ret/AppRetV1.java +++ b/src/main/java/a8k/extui/type/ret/AppRetV1.java @@ -3,7 +3,7 @@ package a8k.extui.type.ret; import a8k.app.type.error.AECodeError; import a8k.app.type.error.AppError; import a8k.app.type.exception.AppException; -import a8k.app.channel.iflytophald.type.protocol.A8kEcode; +import a8k.app.iflytophald.type.protocol.A8kEcode; import a8k.app.i18n.Internationalization; import jakarta.validation.ValidationException; import lombok.Getter;