From be0a73eb19aedec6d990938bcf0b1bd56ba474d4 Mon Sep 17 00:00:00 2001 From: Xuwznln <18435084+Xuwznln@users.noreply.github.com> Date: Sat, 28 Jun 2025 12:18:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=99=E6=80=81=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E8=AF=86=E5=88=ABget=20status=EF=BC=8C=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E8=A1=A8=E6=94=AF=E6=8C=81python=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devices/characterization_optic.yaml | 60 +-- unilabos/registry/devices/hotel.yaml | 25 +- unilabos/registry/devices/liquid_handler.yaml | 3 +- unilabos/registry/devices/mock_devices.yaml | 230 +---------- .../devices/organic_miscellaneous.yaml | 8 +- unilabos/registry/devices/pump_and_valve.yaml | 245 +----------- .../registry/devices/robot_linear_motion.yaml | 2 - unilabos/registry/devices/temperature.yaml | 45 --- .../registry/devices/vacuum_and_purge.yaml | 44 --- unilabos/registry/devices/virtual_device.yaml | 365 +----------------- unilabos/registry/devices/zhida_hplc.yaml | 23 +- unilabos/registry/registry.py | 13 +- unilabos/ros/nodes/base_device_node.py | 5 +- unilabos/utils/import_manager.py | 16 +- 14 files changed, 60 insertions(+), 1024 deletions(-) diff --git a/unilabos/registry/devices/characterization_optic.yaml b/unilabos/registry/devices/characterization_optic.yaml index ddca2dd..bfd1777 100644 --- a/unilabos/registry/devices/characterization_optic.yaml +++ b/unilabos/registry/devices/characterization_optic.yaml @@ -22,32 +22,6 @@ hplc.agilent: title: check_status 命令参数 type: object type: UniLabJsonCommand - auto-execute_command_from_outer: - feedback: {} - goal: {} - goal_default: - command: null - handles: [] - result: {} - schema: - description: UniLabJsonCommand execute_command_from_outer 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand execute_command_from_outer 的参数schema - properties: - command: - description: '参数: command' - type: string - required: - - command - type: object - result: {} - required: - - goal - title: execute_command_from_outer 命令参数 - type: object - type: UniLabJsonCommand auto-extract_data_from_txt: feedback: {} goal: {} @@ -74,35 +48,6 @@ hplc.agilent: title: extract_data_from_txt 命令参数 type: object type: UniLabJsonCommand - auto-get_data_file: - feedback: {} - goal: {} - goal_default: - after_time: null - mat_index: null - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_data_file 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_data_file 的参数schema - properties: - after_time: - description: '参数: after_time' - type: string - mat_index: - description: '参数: mat_index' - type: string - required: [] - type: object - result: {} - required: - - goal - title: get_data_file 命令参数 - type: object - type: UniLabJsonCommand auto-start_sequence: feedback: {} goal: {} @@ -237,10 +182,10 @@ hplc.agilent: module: unilabos.devices.hplc.AgilentHPLC:HPLCDriver status_types: could_run: bool + data_file: tuple device_status: str driver_init_ok: bool finish_status: str - get_data_file: tuple is_running: bool status_text: str success: bool @@ -467,8 +412,7 @@ raman_home_made: type: object type: SendCmd module: unilabos.devices.raman_uv.home_made_raman:RamanObj - status_types: - status: String + status_types: {} type: python description: Raman spectroscopy device handles: [] diff --git a/unilabos/registry/devices/hotel.yaml b/unilabos/registry/devices/hotel.yaml index abaf871..bfd0090 100644 --- a/unilabos/registry/devices/hotel.yaml +++ b/unilabos/registry/devices/hotel.yaml @@ -1,30 +1,9 @@ hotel.thermo_orbitor_rs2_hotel: class: - action_value_mappings: - auto-get_rotation: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_rotation 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_rotation 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_rotation 命令参数 - type: object - type: UniLabJsonCommand + action_value_mappings: {} module: unilabos.devices.resource_container.container:HotelContainer status_types: - get_rotation: String + rotation: String type: python description: Thermo Orbitor RS2 Hotel handles: [] diff --git a/unilabos/registry/devices/liquid_handler.yaml b/unilabos/registry/devices/liquid_handler.yaml index eec9fc5..f431b49 100644 --- a/unilabos/registry/devices/liquid_handler.yaml +++ b/unilabos/registry/devices/liquid_handler.yaml @@ -4831,8 +4831,7 @@ liquid_handler: type: object type: LiquidHandlerTransfer module: unilabos.devices.liquid_handling.liquid_handler_abstract:LiquidHandlerAbstract - status_types: - name: String + status_types: {} type: python description: Liquid handler device controlled by pylabrobot handles: diff --git a/unilabos/registry/devices/mock_devices.yaml b/unilabos/registry/devices/mock_devices.yaml index 1cf844c..cc4db28 100644 --- a/unilabos/registry/devices/mock_devices.yaml +++ b/unilabos/registry/devices/mock_devices.yaml @@ -22,27 +22,6 @@ mock_chiller: title: emergency_stop 命令参数 type: object type: UniLabJsonCommand - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-heat_chill_start: feedback: {} goal: {} @@ -250,11 +229,11 @@ mock_chiller: module: unilabos.devices.mock.mock_chiller:MockChiller status_types: current_temperature: float - get_status_info: dict is_cooling: bool is_heating: bool purpose: str status: str + status_info: dict target_temperature: float vessel: str type: python @@ -359,27 +338,6 @@ mock_filter: title: filter 命令参数 type: object type: UniLabJsonCommand - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-replace_filter: feedback: {} goal: {} @@ -595,11 +553,11 @@ mock_filter: filtered_volume: float filtrate_vessel: str flow_rate: float - get_status_info: dict is_filtering: bool pressure_drop: float progress: float status: str + status_info: dict stir: bool stir_speed: float target_volume: float @@ -651,27 +609,6 @@ mock_heater: title: emergency_stop 命令参数 type: object type: UniLabJsonCommand - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-heat_chill: feedback: {} goal: {} @@ -1055,12 +992,12 @@ mock_heater: module: unilabos.devices.mock.mock_heater:MockHeater status_types: current_temperature: float - get_status_info: dict heating_power: float is_heating: bool max_temperature: float purpose: str status: str + status_info: dict stir: bool stir_speed: float target_temperature: float @@ -1111,27 +1048,6 @@ mock_pump: title: emergency_stop 命令参数 type: object type: UniLabJsonCommand - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-pause_pump: feedback: {} goal: {} @@ -1513,7 +1429,6 @@ mock_pump: current_device: str flow_rate: float from_vessel: str - get_status_info: dict is_solid: bool is_viscous: bool max_flow_rate: float @@ -1524,6 +1439,7 @@ mock_pump: rinsing_solvent: str rinsing_volume: float status: str + status_info: dict target_flow_rate: float time_remaining: float time_spent: float @@ -1577,27 +1493,6 @@ mock_rotavap: title: emergency_stop 命令参数 type: object type: UniLabJsonCommand - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-set_pump_time: feedback: {} goal: {} @@ -2085,14 +1980,13 @@ mock_rotavap: type: EmptyIn module: unilabos.devices.mock.mock_rotavap:MockRotavap status_types: - get_status_info: dict pump_state: str pump_time: float rotate_speed: float rotate_state: str rotate_time: float status: str - success: String + status_info: dict target_temperature: float temperature: float vacuum_level: float @@ -2121,27 +2015,6 @@ mock_rotavap: mock_separator: class: action_value_mappings: - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-separate: feedback: {} goal: {} @@ -2578,7 +2451,6 @@ mock_separator: status_types: current_device: str from_vessel: str - get_status_info: dict product_phase: str purpose: str repeats: int @@ -2589,6 +2461,7 @@ mock_separator: solvent: str solvent_volume: float status: str + status_info: dict stir_speed: float stir_time: float through: str @@ -2643,27 +2516,6 @@ mock_solenoid_valve: title: close_valve 命令参数 type: object type: UniLabJsonCommand - auto-get_valve_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_valve_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_valve_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_valve_status 命令参数 - type: object - type: UniLabJsonCommand auto-is_closed: feedback: {} goal: {} @@ -2871,7 +2723,6 @@ mock_solenoid_valve: type: StrSingleInput module: unilabos.devices.mock.mock_solenoid_valve:MockSolenoidValve status_types: - get_valve_status: str status: str valve_status: str type: python @@ -2920,27 +2771,6 @@ mock_stirrer: title: emergency_stop 命令参数 type: object type: UniLabJsonCommand - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-heating_control: feedback: {} goal: {} @@ -3288,12 +3118,12 @@ mock_stirrer: type: EmptyIn module: unilabos.devices.mock.mock_stirrer:MockStirrer status_types: - get_status_info: dict heating_power: float heating_state: str max_stir_speed: float max_temperature: float status: str + status_info: dict stir_speed: float stir_state: str target_stir_speed: float @@ -3324,27 +3154,6 @@ mock_stirrer: mock_stirrer_new: class: action_value_mappings: - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-start_stir: feedback: {} goal: {} @@ -3629,12 +3438,12 @@ mock_stirrer_new: type: StopStir module: unilabos.devices.mock.mock_stirrer_new:MockStirrer_new status_types: - get_status_info: dict max_stir_speed: float progress: float purpose: str settling_time: float status: str + status_info: dict stir_speed: float stir_state: str stir_time: float @@ -3686,27 +3495,6 @@ mock_vacuum: title: emergency_stop 命令参数 type: object type: UniLabJsonCommand - auto-get_status_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status_info 命令参数 - type: object - type: UniLabJsonCommand auto-pause_vacuum: feedback: {} goal: {} @@ -4134,13 +3922,13 @@ mock_vacuum: type: EmptyIn module: unilabos.devices.mock.mock_vacuum:MockVacuum status_types: - get_status_info: dict max_pump_speed: float power_state: str pump_efficiency: float pump_speed: float pump_state: str status: str + status_info: dict target_vacuum: float vacuum_level: float type: python diff --git a/unilabos/registry/devices/organic_miscellaneous.yaml b/unilabos/registry/devices/organic_miscellaneous.yaml index 7f5a19d..7dcf87b 100644 --- a/unilabos/registry/devices/organic_miscellaneous.yaml +++ b/unilabos/registry/devices/organic_miscellaneous.yaml @@ -174,9 +174,7 @@ rotavap.one: type: object type: SendCmd module: unilabos.devices.rotavap.rotavap_one:RotavapOne - status_types: - pump_time: Float64 - rotate_time: Float64 + status_types: {} type: python description: Rotavap device handles: [] @@ -453,9 +451,7 @@ separator.homemade: type: object type: SendCmd module: unilabos.devices.separator.homemade_grbl_conductivity:SeparatorController - status_types: - sensordata: Float64 - status: String + status_types: {} type: python description: Separator device with homemade grbl controller handles: [] diff --git a/unilabos/registry/devices/pump_and_valve.yaml b/unilabos/registry/devices/pump_and_valve.yaml index fd0b08a..3abe9e2 100644 --- a/unilabos/registry/devices/pump_and_valve.yaml +++ b/unilabos/registry/devices/pump_and_valve.yaml @@ -22,27 +22,6 @@ solenoid_valve: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_valve_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_valve_position 命令参数 - type: object - type: UniLabJsonCommand auto-is_closed: feedback: {} goal: {} @@ -224,7 +203,6 @@ solenoid_valve: type: StrSingleInput module: unilabos.devices.pump_and_valve.solenoid_valve:SolenoidValve status_types: - get_valve_position: str status: str valve_position: str type: python @@ -273,27 +251,6 @@ solenoid_valve.mock: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_valve_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_valve_position 命令参数 - type: object - type: UniLabJsonCommand auto-is_closed: feedback: {} goal: {} @@ -455,7 +412,6 @@ solenoid_valve.mock: type: EmptyIn module: unilabos.devices.pump_and_valve.solenoid_valve_mock:SolenoidValveMock status_types: - get_valve_position: str status: str valve_position: str type: python @@ -514,174 +470,6 @@ syringe_pump_with_valve.runze: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_max_velocity: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_max_velocity 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_max_velocity 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_max_velocity 命令参数 - type: object - type: UniLabJsonCommand - auto-get_plunger_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_plunger_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_plunger_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_plunger_position 命令参数 - type: object - type: UniLabJsonCommand - auto-get_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_position 命令参数 - type: object - type: UniLabJsonCommand - auto-get_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status 命令参数 - type: object - type: UniLabJsonCommand - auto-get_valve_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_valve_position 命令参数 - type: object - type: UniLabJsonCommand - auto-get_velocity_end: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_velocity_end 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_velocity_end 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_velocity_end 命令参数 - type: object - type: UniLabJsonCommand - auto-get_velocity_grade: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_velocity_grade 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_velocity_grade 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_velocity_grade 命令参数 - type: object - type: UniLabJsonCommand - auto-get_velocity_init: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_velocity_init 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_velocity_init 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_velocity_init 命令参数 - type: object - type: UniLabJsonCommand auto-initialize: feedback: {} goal: {} @@ -703,27 +491,6 @@ syringe_pump_with_valve.runze: title: initialize 命令参数 type: object type: UniLabJsonCommand - auto-list: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand list 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand list 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: list 命令参数 - type: object - type: UniLabJsonCommand auto-pull_plunger: feedback: {} goal: {} @@ -1089,19 +856,15 @@ syringe_pump_with_valve.runze: write: send_command module: unilabos.devices.pump_and_valve.runze_backbone:RunzeSyringePump status_types: - get_max_velocity: String - get_plunger_position: String - get_position: String - get_status: String - get_valve_position: str - get_velocity_end: String - get_velocity_grade: String - get_velocity_init: String max_velocity: float mode: int + plunger_position: String position: float status: str valve_position: str + velocity_end: String + velocity_grade: String + velocity_init: String type: python description: Runze Syringe pump with valve handles: [] diff --git a/unilabos/registry/devices/robot_linear_motion.yaml b/unilabos/registry/devices/robot_linear_motion.yaml index a3abefb..0411a59 100644 --- a/unilabos/registry/devices/robot_linear_motion.yaml +++ b/unilabos/registry/devices/robot_linear_motion.yaml @@ -494,8 +494,6 @@ linear_motion.grbl: type: SingleJointPosition module: unilabos.devices.cnc.grbl_sync:GrblCNC status_types: - get_position: String - get_status: String position: unilabos.messages:Point3D spindle_speed: float status: str diff --git a/unilabos/registry/devices/temperature.yaml b/unilabos/registry/devices/temperature.yaml index a6308a9..b94f939 100644 --- a/unilabos/registry/devices/temperature.yaml +++ b/unilabos/registry/devices/temperature.yaml @@ -245,48 +245,6 @@ heaterstirrer.dalong: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status 命令参数 - type: object - type: UniLabJsonCommand - auto-get_temp: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_temp 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_temp 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_temp 命令参数 - type: object - type: UniLabJsonCommand auto-heatchill: feedback: {} goal: {} @@ -614,8 +572,6 @@ heaterstirrer.dalong: type: SendCmd module: unilabos.devices.heaterstirrer.dalong:HeaterStirrer_DaLong status_types: - get_status: str - get_temp: String status: str stir_speed: float temp: float @@ -849,7 +805,6 @@ tempsensor: module: unilabos.devices.temperature.sensor_node:TempSensorNode status_types: value: float - warning: Float64 type: python description: Temperature sensor handles: [] diff --git a/unilabos/registry/devices/vacuum_and_purge.yaml b/unilabos/registry/devices/vacuum_and_purge.yaml index 4a15c4a..0497ee7 100644 --- a/unilabos/registry/devices/vacuum_and_purge.yaml +++ b/unilabos/registry/devices/vacuum_and_purge.yaml @@ -22,27 +22,6 @@ gas_source.mock: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status 命令参数 - type: object - type: UniLabJsonCommand auto-is_closed: feedback: {} goal: {} @@ -247,7 +226,6 @@ gas_source.mock: type: StrSingleInput module: unilabos.devices.pump_and_valve.vacuum_pump_mock:VacuumPumpMock status_types: - get_status: str status: str type: python description: Mock gas source @@ -301,27 +279,6 @@ vacuum_pump.mock: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status 命令参数 - type: object - type: UniLabJsonCommand auto-is_closed: feedback: {} goal: {} @@ -526,7 +483,6 @@ vacuum_pump.mock: type: StrSingleInput module: unilabos.devices.pump_and_valve.vacuum_pump_mock:VacuumPumpMock status_types: - get_status: str status: str type: python description: Mock vacuum pump diff --git a/unilabos/registry/devices/virtual_device.yaml b/unilabos/registry/devices/virtual_device.yaml index 2538c57..5efc117 100644 --- a/unilabos/registry/devices/virtual_device.yaml +++ b/unilabos/registry/devices/virtual_device.yaml @@ -721,27 +721,6 @@ virtual_gas_source: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status 命令参数 - type: object - type: UniLabJsonCommand auto-initialize: feedback: {} goal: {} @@ -967,7 +946,6 @@ virtual_gas_source: type: StrSingleInput module: unilabos.devices.virtual.virtual_gas_source:VirtualGasSource status_types: - get_status: str status: str type: python description: Virtual gas source @@ -1409,153 +1387,6 @@ virtual_multiway_valve: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_available_ports: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_available_ports 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_available_ports 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_available_ports 命令参数 - type: object - type: UniLabJsonCommand - auto-get_available_positions: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_available_positions 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_available_positions 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_available_positions 命令参数 - type: object - type: UniLabJsonCommand - auto-get_current_port: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_current_port 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_current_port 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_current_port 命令参数 - type: object - type: UniLabJsonCommand - auto-get_current_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_current_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_current_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_current_position 命令参数 - type: object - type: UniLabJsonCommand - auto-get_flow_path: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_flow_path 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_flow_path 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_flow_path 命令参数 - type: object - type: UniLabJsonCommand - auto-get_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_info 命令参数 - type: object - type: UniLabJsonCommand - auto-get_valve_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_valve_position 命令参数 - type: object - type: UniLabJsonCommand auto-is_at_port: feedback: {} goal: {} @@ -1892,17 +1723,15 @@ virtual_multiway_valve: type: SendCmd module: unilabos.devices.virtual.virtual_multiway_valve:VirtualMultiwayValve status_types: + available_ports: dict + available_positions: list + current_port: str current_position: int - get_available_ports: dict - get_available_positions: list - get_current_port: str - get_current_position: int - get_flow_path: str - get_info: dict - get_valve_position: int - max_positions: Int32 + flow_path: str + info: dict status: str target_position: int + valve_position: int valve_state: str type: python description: Virtual 8-Way Valve for flow direction control @@ -2345,7 +2174,6 @@ virtual_pump: current_volume: float from_vessel: str max_volume: float - position: Float64 progress: float status: str to_vessel: str @@ -3044,48 +2872,6 @@ virtual_solenoid_valve: title: close 命令参数 type: object type: UniLabJsonCommandAsync - auto-get_state: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_state 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_state 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_state 命令参数 - type: object - type: UniLabJsonCommand - auto-get_valve_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_valve_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_valve_position 命令参数 - type: object - type: UniLabJsonCommand auto-initialize: feedback: {} goal: {} @@ -3432,10 +3218,10 @@ virtual_solenoid_valve: type: SendCmd module: unilabos.devices.virtual.virtual_solenoid_valve:VirtualSolenoidValve status_types: - get_state: dict - get_valve_position: str is_open: bool + state: dict status: str + valve_position: str valve_state: str type: python description: Virtual Solenoid Valve for simple on/off flow control @@ -3981,111 +3767,6 @@ virtual_transfer_pump: title: fill_syringe 命令参数 type: object type: UniLabJsonCommandAsync - auto-get_current_volume: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_current_volume 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_current_volume 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_current_volume 命令参数 - type: object - type: UniLabJsonCommand - auto-get_position: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_position 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_position 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_position 命令参数 - type: object - type: UniLabJsonCommand - auto-get_pump_info: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_pump_info 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_pump_info 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_pump_info 命令参数 - type: object - type: UniLabJsonCommand - auto-get_remaining_capacity: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_remaining_capacity 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_remaining_capacity 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_remaining_capacity 命令参数 - type: object - type: UniLabJsonCommand - auto-get_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status 命令参数 - type: object - type: UniLabJsonCommand auto-initialize: feedback: {} goal: {} @@ -4495,14 +4176,10 @@ virtual_transfer_pump: module: unilabos.devices.virtual.virtual_transferpump:VirtualTransferPump status_types: current_volume: float - get_current_volume: float - get_position: float - get_pump_info: dict - get_remaining_capacity: float - get_status: str max_velocity: float - max_volume: Float64 position: float + pump_info: dict + remaining_capacity: float status: str transfer_rate: float type: python @@ -4586,27 +4263,6 @@ virtual_vacuum_pump: title: close 命令参数 type: object type: UniLabJsonCommand - auto-get_status: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_status 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_status 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_status 命令参数 - type: object - type: UniLabJsonCommand auto-initialize: feedback: {} goal: {} @@ -4832,7 +4488,6 @@ virtual_vacuum_pump: type: StrSingleInput module: unilabos.devices.virtual.virtual_vacuum_pump:VirtualVacuumPump status_types: - get_status: str status: str type: python description: Virtual vacuum pump diff --git a/unilabos/registry/devices/zhida_hplc.yaml b/unilabos/registry/devices/zhida_hplc.yaml index fa95efe..7918386 100644 --- a/unilabos/registry/devices/zhida_hplc.yaml +++ b/unilabos/registry/devices/zhida_hplc.yaml @@ -99,27 +99,6 @@ zhida_hplc: title: connect 命令参数 type: object type: UniLabJsonCommand - auto-get_methods: - feedback: {} - goal: {} - goal_default: {} - handles: [] - result: {} - schema: - description: UniLabJsonCommand get_methods 的参数schema - properties: - feedback: {} - goal: - description: UniLabJsonCommand get_methods 的参数schema - properties: {} - required: [] - type: object - result: {} - required: - - goal - title: get_methods 命令参数 - type: object - type: UniLabJsonCommand auto-start: feedback: {} goal: {} @@ -226,7 +205,7 @@ zhida_hplc: type: StrSingleInput module: unilabos.devices.zhida_hplc.zhida:ZhidaClient status_types: - get_methods: dict + methods: dict status: dict type: python description: Zhida HPLC diff --git a/unilabos/registry/registry.py b/unilabos/registry/registry.py index deac881..4210c2a 100644 --- a/unilabos/registry/registry.py +++ b/unilabos/registry/registry.py @@ -7,7 +7,7 @@ from typing import Any, Dict, List import yaml -from unilabos.ros.msgs.message_converter import msg_converter_manager, ros_action_to_json_schema +from unilabos.ros.msgs.message_converter import msg_converter_manager, ros_action_to_json_schema, String from unilabos.utils import logger from unilabos.utils.decorator import singleton from unilabos.utils.import_manager import get_enhanced_class_info @@ -180,6 +180,13 @@ class Registry: if not type_name or type_name == "": logger.warning(f"[UniLab Registry] 设备 {device_id} 的 {field_name} 类型为空,跳过替换") return type_name + convert_manager = { # 将python基本对象转为ros2基本对象 + "str": "String", + "bool": "Bool", + "int": "Int64", + "float": "Float64", + } + type_name = convert_manager.get(type_name, type_name) # 替换为ROS2类型 if ":" in type_name: type_class = msg_converter_manager.get_class(type_name) else: @@ -297,6 +304,7 @@ class Registry: device_config["class"]["action_value_mappings"] = {} enhanced_info = {} if complete_registry: + device_config["class"]["status_types"].clear() enhanced_info = get_enhanced_class_info(device_config["class"]["module"], use_dynamic=True) device_config["class"]["status_types"].update( {k: v["return_type"] for k, v in enhanced_info["status_methods"].items()} @@ -306,11 +314,14 @@ class Registry: status_type = "String" # 替换成ROS的String,便于显示 device_config["class"]["status_types"][status_name] = status_type target_type = self._replace_type_with_class(status_type, device_id, f"状态 {status_name}") + if target_type in [dict]: # 对于字典和对象的返回类型,要处理成字符串,直接进行转换 + target_type = String status_str_type_mapping[status_type] = target_type device_config["class"]["status_types"] = dict( sorted(device_config["class"]["status_types"].items()) ) if complete_registry: + device_config["class"]["action_value_mappings"] = {k:v for k, v in device_config["class"]["action_value_mappings"].items() if not k.startswith("auto-")} # 处理动作值映射 device_config["class"]["action_value_mappings"].update( { diff --git a/unilabos/ros/nodes/base_device_node.py b/unilabos/ros/nodes/base_device_node.py index 94b2edf..4b7eb07 100644 --- a/unilabos/ros/nodes/base_device_node.py +++ b/unilabos/ros/nodes/base_device_node.py @@ -168,7 +168,10 @@ class PropertyPublisher: self.print_publish = print_publish self._value = None - self.publisher_ = node.create_publisher(msg_type, f"{name}", 10) + try: + self.publisher_ = node.create_publisher(msg_type, f"{name}", 10) + except AttributeError as ex: + logger.error(f"创建发布者失败,可能由于注册表有误,类型: {msg_type},错误: {ex}\n{traceback.format_exc()}") self.timer = node.create_timer(self.timer_period, self.publish_property) self.__loop = get_event_loop() str_msg_type = str(msg_type)[8:-2] diff --git a/unilabos/utils/import_manager.py b/unilabos/utils/import_manager.py index ec1396b..1ce8b62 100644 --- a/unilabos/utils/import_manager.py +++ b/unilabos/utils/import_manager.py @@ -293,9 +293,12 @@ class ImportManager: elif inspect.ismethod(method) or inspect.isfunction(method): if name.startswith("get_"): + actual_name = name[4:] # 去掉get_前缀 + if actual_name in result["status_methods"]: + continue # get_ 开头的方法归类为status method_info = self._analyze_method_signature(method) - result["status_methods"][name] = method_info + result["status_methods"][actual_name] = method_info elif not name.startswith("_"): # 其他非_开头的方法归类为action method_info = self._analyze_method_signature(method) @@ -346,8 +349,13 @@ class ImportManager: elif self._is_property_method(node): # @property 装饰的方法 result["status_methods"][method_name] = method_info + elif method_name.startswith("get_"): + # get_ 开头的方法归类为status + actual_name = method_name[4:] # 去掉get_前缀 + if actual_name not in result["status_methods"]: + result["status_methods"][actual_name] = method_info else: - # set_ 开头或其他非_开头的方法 + # 其他非_开头的方法归类为action result["action_methods"][method_name] = method_info return result @@ -417,7 +425,9 @@ class ImportManager: if "typing." in annotation_str: # 简化typing类型显示 return ( - annotation_str.replace("typing.", "") if getattr(annotation, "_name", None) is None else annotation._name.lower() + annotation_str.replace("typing.", "") + if getattr(annotation, "_name", None) is None + else annotation._name.lower() ) # 如果是类型对象 if hasattr(annotation, "__name__"):