From e5980c670efd3442124437443cd360cf1148fd64 Mon Sep 17 00:00:00 2001 From: Junhan Chang Date: Mon, 12 May 2025 13:25:21 +0800 Subject: [PATCH] =?UTF-8?q?Add=20registry=20to=20=E7=94=B5=E5=8C=96?= =?UTF-8?q?=E5=AD=A6=E5=B7=A5=E4=BD=9C=E7=AB=99=20&=20=E5=A5=A5=E8=B0=B1?= =?UTF-8?q?=E5=A4=A9=E6=88=90=E6=8B=89=E6=9B=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/dh_7000_eis.py | 2 +- examples/opsky_30007_raman.py | 6 +- .../__init__.py | 0 .../dh_7000.py | 4 +- unilabos/devices/opsky_Raman/__init__.py | 0 .../opsky_ATR30007.py | 19 ++++--- .../characterization_chromatographic.yaml | 44 +++++++++++++++ .../devices/characterization_electric.yaml | 19 +++++++ .../devices/characterization_optic.yaml | 56 ++++++------------- unilabos_msgs/CMakeLists.txt | 2 + unilabos_msgs/action/GetRaman.action | 13 +++++ 11 files changed, 110 insertions(+), 55 deletions(-) rename unilabos/devices/{dh_electrochem => electrochem}/__init__.py (100%) rename unilabos/devices/{dh_electrochem => electrochem}/dh_7000.py (99%) delete mode 100644 unilabos/devices/opsky_Raman/__init__.py rename unilabos/devices/{opsky_Raman => raman_uv}/opsky_ATR30007.py (97%) create mode 100644 unilabos/registry/devices/characterization_chromatographic.yaml create mode 100644 unilabos/registry/devices/characterization_electric.yaml create mode 100644 unilabos_msgs/action/GetRaman.action diff --git a/examples/dh_7000_eis.py b/examples/dh_7000_eis.py index 4c53bdb..6a84a75 100644 --- a/examples/dh_7000_eis.py +++ b/examples/dh_7000_eis.py @@ -6,7 +6,7 @@ if(rclpy.ok() == False): else: print("rclpy already initiated") -from unilabos.devices.dh_electrochem.dh_7000 import DH7000 +from unilabos.devices.electrochem.dh_7000 import DH7000 from unilabos_msgs.action import SendCmd from std_msgs.msg import Float64, String, Int16 from unilabos.ros.device_node_wrapper import ros2_device_node diff --git a/examples/opsky_30007_raman.py b/examples/opsky_30007_raman.py index fc2499f..84c673e 100644 --- a/examples/opsky_30007_raman.py +++ b/examples/opsky_30007_raman.py @@ -6,12 +6,10 @@ if(rclpy.ok() == False): else: print("rclpy already initiated") -from unilabos.devices.opsky_Raman.opsky_ATR30007 import ATR30007 +from unilabos.devices.raman_uv.opsky_ATR30007 import ATR30007 from unilabos_msgs.action import SendCmd -from std_msgs.msg import Float64, String, Int16 from unilabos.ros.device_node_wrapper import ros2_device_node -import clr -import os + # dll_path = r'D:\UniLab\code\DHElecChem\release64' # eccore_dll_path = os.path.join(dll_path, 'ECCore.dll') # os.environ["PATH"] = dll_path + os.pathsep + os.environ["PATH"] diff --git a/unilabos/devices/dh_electrochem/__init__.py b/unilabos/devices/electrochem/__init__.py similarity index 100% rename from unilabos/devices/dh_electrochem/__init__.py rename to unilabos/devices/electrochem/__init__.py diff --git a/unilabos/devices/dh_electrochem/dh_7000.py b/unilabos/devices/electrochem/dh_7000.py similarity index 99% rename from unilabos/devices/dh_electrochem/dh_7000.py rename to unilabos/devices/electrochem/dh_7000.py index dee71e7..9926310 100644 --- a/unilabos/devices/dh_electrochem/dh_7000.py +++ b/unilabos/devices/electrochem/dh_7000.py @@ -498,7 +498,7 @@ class DH7000: print(f"数据已保存到 {save_root}") # === Core: a unified dh_cmd method that calls start_eis or start_lsv according to methods === - def dh_cmd(self, command: str): + def dh_cmd(self, method: str, command: str, resource: dict): """ Unified handler for different commands such as EIS / LSV / CV / CA. In the incoming command JSON, use the key "methods" to specify the measurement type: "eis", "lsv", etc. @@ -516,7 +516,7 @@ class DH7000: print(f"命令参数: {cmd_dict}") # Extract measurement method, default to "EIS" if not specified - method = cmd_dict.pop("methods", "eis").lower() + # method = cmd_dict.pop("methods", "eis").lower() # Extract file save path (may not be provided) save_root = cmd_dict.get("save_root", r"D:\UniLab\results\test") diff --git a/unilabos/devices/opsky_Raman/__init__.py b/unilabos/devices/opsky_Raman/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/unilabos/devices/opsky_Raman/opsky_ATR30007.py b/unilabos/devices/raman_uv/opsky_ATR30007.py similarity index 97% rename from unilabos/devices/opsky_Raman/opsky_ATR30007.py rename to unilabos/devices/raman_uv/opsky_ATR30007.py index 7a31e04..3e943f6 100644 --- a/unilabos/devices/opsky_Raman/opsky_ATR30007.py +++ b/unilabos/devices/raman_uv/opsky_ATR30007.py @@ -1,20 +1,18 @@ -import clr -import os -import time -import pandas as pd import json -import shutil -import sys -import time -from System import Environment +import os -# define class ATR30007 +import clr +import pandas as pd + + +# define class ATR30007 # this class is used to control the ATR30007 Raman workstation class ATR30007: def __init__(self, dll_path: str = r'D:\Raman_RS'): self.dll_path = dll_path self.machine = None + self.status = "Idle" self._load_dll() def _load_dll(self): @@ -59,6 +57,7 @@ class ATR30007: SetC_flag = self.machine.SetCool(CCDTemp) print(f"SetC_flag:{SetC_flag}") #开始采集光谱 + self.status = "Running" Spect = self.machine.AcquireSpectrum() #开始采集光谱谱图数据转换 Spect_data = list(Spect.get_Data()) @@ -70,6 +69,8 @@ class ATR30007: Spect_bLC = list(self.machine.BaseLineCorrect(Spect_data)) #对数据进行boxcar 平滑 Spect_StB = list(self.machine.SmoothBoxcar(Spect_bLC, 10)) + + self.status = "Idle" #关闭仪器 OFF_flag = wrapper.CloseDevice() print(f"OFF_flag: {OFF_flag}") diff --git a/unilabos/registry/devices/characterization_chromatographic.yaml b/unilabos/registry/devices/characterization_chromatographic.yaml new file mode 100644 index 0000000..1c21ce0 --- /dev/null +++ b/unilabos/registry/devices/characterization_chromatographic.yaml @@ -0,0 +1,44 @@ +# 色谱表征设备 +hplc.agilent: + description: HPLC device + class: + module: unilabos.devices.hplc.AgilentHPLC:HPLCDriver + type: python + status_types: + device_status: String + could_run: Bool + driver_init_ok: Bool + is_running: Bool + finish_status: String + status_text: String + action_value_mappings: + execute_command_from_outer: + type: SendCmd + goal: + command: command + feedback: {} + result: + success: success + schema: + properties: + device_status: + type: string + could_run: + type: boolean + driver_init_ok: + type: boolean + is_running: + type: boolean + finish_status: + type: string + status_text: + type: string + required: + - device_status + - could_run + - driver_init_ok + - is_running + - finish_status + - status_text + additionalProperties: false + type: object diff --git a/unilabos/registry/devices/characterization_electric.yaml b/unilabos/registry/devices/characterization_electric.yaml new file mode 100644 index 0000000..39c3f4d --- /dev/null +++ b/unilabos/registry/devices/characterization_electric.yaml @@ -0,0 +1,19 @@ +# 电化学表征设备:电化学工作站、电池测试柜 +electrochem_station.DongHua: + description: Donghua electrochem_station + class: + module: unilabos.devices.electrochem.dh_7000:DH7000 + type: python + status_types: + status: String + action_value_mappings: + dh_cmd: + type: WorkStationRun + goal: + wf_name: method + params: command + resource: resource + feedback: + status: status + result: + success: success \ No newline at end of file diff --git a/unilabos/registry/devices/characterization_optic.yaml b/unilabos/registry/devices/characterization_optic.yaml index 52ffc87..1e8d623 100644 --- a/unilabos/registry/devices/characterization_optic.yaml +++ b/unilabos/registry/devices/characterization_optic.yaml @@ -1,5 +1,5 @@ # 光学表征设备:红外、紫外可见、拉曼等 -raman_home_made: +raman.home_made: description: Raman spectroscopy device class: module: unilabos.devices.raman_uv.home_made_raman:RamanObj @@ -22,46 +22,24 @@ raman_home_made: - status additionalProperties: false type: object -hplc.agilent: - description: HPLC device + +raman.opsky_ATR30007: + description: Raman spectroscopy device class: - module: unilabos.devices.hplc.AgilentHPLC:HPLCDriver + module: unilabos.devices.raman_uv.opsky_raman:ATR30007 type: python status_types: - device_status: String - could_run: Bool - driver_init_ok: Bool - is_running: Bool - finish_status: String - status_text: String + status: String action_value_mappings: - execute_command_from_outer: - type: SendCmd + start_Raman: + type: GetRaman goal: - command: command - feedback: {} - result: - success: success - schema: - properties: - device_status: - type: string - could_run: - type: boolean - driver_init_ok: - type: boolean - is_running: - type: boolean - finish_status: - type: string - status_text: - type: string - required: - - device_status - - could_run - - driver_init_ok - - is_running - - finish_status - - status_text - additionalProperties: false - type: object + integtime: IntegTime + ldpower: LdPower + ldwave: LdWave + ccdtemp: CCDTemp + filename: filename + saveroot: saveroot + feedback: + status: status + result: {} diff --git a/unilabos_msgs/CMakeLists.txt b/unilabos_msgs/CMakeLists.txt index acaad77..aa9b571 100644 --- a/unilabos_msgs/CMakeLists.txt +++ b/unilabos_msgs/CMakeLists.txt @@ -49,6 +49,8 @@ set(action_files "action/Evaporate.action" "action/EvacuateAndRefill.action" + "action/GetRaman.action" + "action/WorkStationRun.action" "action/AGVTransfer.action" ) diff --git a/unilabos_msgs/action/GetRaman.action b/unilabos_msgs/action/GetRaman.action new file mode 100644 index 0000000..3b548c0 --- /dev/null +++ b/unilabos_msgs/action/GetRaman.action @@ -0,0 +1,13 @@ +# Goal +int32 integtime +int32 ldpower +bool ldwave +float64 ccdtemp +string filename +string saveroot +--- +# Result +string success +--- +# Feedback +string status \ No newline at end of file