注册表上报handle和schema (param input)

This commit is contained in:
Xuwznln
2025-05-31 00:00:39 +08:00
parent d2dda6ee03
commit 0f2555c90c
7 changed files with 139 additions and 16 deletions

View File

@@ -5,22 +5,22 @@ class SolenoidValveMock:
def __init__(self, port: str = "COM6"): def __init__(self, port: str = "COM6"):
self._status = "Idle" self._status = "Idle"
self._valve_position = "OPEN" self._valve_position = "OPEN"
@property @property
def status(self) -> str: def status(self) -> str:
return self._status return self._status
@property @property
def valve_position(self) -> str: def valve_position(self) -> str:
return self._valve_position return self._valve_position
def get_valve_position(self) -> str: def get_valve_position(self) -> str:
return self._valve_position return self._valve_position
def set_valve_position(self, position): def set_valve_position(self, position):
self._status = "Busy" self._status = "Busy"
time.sleep(5) time.sleep(5)
self._valve_position = position self._valve_position = position
time.sleep(5) time.sleep(5)
self._status = "Idle" self._status = "Idle"

View File

@@ -4,17 +4,17 @@ import time
class VacuumPumpMock: class VacuumPumpMock:
def __init__(self, port: str = "COM6"): def __init__(self, port: str = "COM6"):
self._status = "OPEN" self._status = "OPEN"
@property @property
def status(self) -> str: def status(self) -> str:
return self._status return self._status
def get_status(self) -> str: def get_status(self) -> str:
return self._status return self._status
def set_status(self, position): def set_status(self, position):
time.sleep(5) time.sleep(5)
self._status = position self._status = position
time.sleep(5) time.sleep(5)

View File

@@ -245,6 +245,21 @@ liquid_handler:
target_vols: target_vols target_vols: target_vols
aspiration_flow_rate: aspiration_flow_rate aspiration_flow_rate: aspiration_flow_rate
dispense_flow_rates: dispense_flow_rates dispense_flow_rates: dispense_flow_rates
handles:
input:
- handler_key: liquid-input
label: Liquid Input
data_type: resource
io_type: target
data_source: handle
data_key: liquid
output:
- handler_key: liquid-output
label: Liquid Output
data_type: resource
io_type: source
data_source: executor
data_key: liquid
schema: schema:
type: object type: object
properties: properties:

View File

@@ -23,20 +23,51 @@ syringe_pump_with_valve.runze:
type: string type: string
description: The position of the valve description: The position of the valve
required: required:
- status - status
- position - position
- valve_position - valve_position
additionalProperties: false additionalProperties: false
solenoid_valve.mock: solenoid_valve.mock:
description: Mock solenoid valve description: Mock solenoid valve
class: class:
module: unilabos.devices.pump_and_valve.solenoid_valve_mock:SolenoidValveMock module: unilabos.devices.pump_and_valve.solenoid_valve_mock:SolenoidValveMock
type: python type: python
status_types:
status: String
valve_position: String
action_value_mappings:
open:
type: EmptyIn
goal: {}
feedback: {}
result: {}
close:
type: EmptyIn
goal: {}
feedback: {}
result: {}
handles:
input:
- handler_key: fluid-input
label: Fluid Input
data_type: fluid
output:
- handler_key: fluid-output
label: Fluid Output
data_type: fluid
init_param_schema:
type: object
properties:
port:
type: string
description: "通信端口"
default: "COM6"
required:
- port
solenoid_valve: solenoid_valve:
description: Solenoid valve description: Solenoid valve
class: class:
module: unilabos.devices.pump_and_valve.solenoid_valve:SolenoidValve module: unilabos.devices.pump_and_valve.solenoid_valve:SolenoidValve
type: python type: python

View File

@@ -22,9 +22,76 @@ vacuum_pump.mock:
string: string string: string
feedback: {} feedback: {}
result: {} result: {}
handles:
input:
- handler_key: fluid-input
label: Fluid Input
data_type: fluid
io_type: target
data_source: handle
data_key: fluid_in
output:
- handler_key: fluid-output
label: Fluid Output
data_type: fluid
io_type: source
data_source: executor
data_key: fluid_out
init_param_schema:
type: object
properties:
port:
type: string
description: "通信端口"
default: "COM6"
required:
- port
gas_source.mock: gas_source.mock:
description: Mock gas source description: Mock gas source
class: class:
module: unilabos.devices.pump_and_valve.vacuum_pump_mock:VacuumPumpMock module: unilabos.devices.pump_and_valve.vacuum_pump_mock:VacuumPumpMock
type: python type: python
status_types:
status: String
action_value_mappings:
open:
type: EmptyIn
goal: {}
feedback: {}
result: {}
close:
type: EmptyIn
goal: {}
feedback: {}
result: {}
set_status:
type: StrSingleInput
goal:
string: string
feedback: {}
result: {}
handles:
input:
- handler_key: fluid-input
label: Fluid Input
data_type: fluid
io_type: target
data_source: handle
data_key: fluid_in
output:
- handler_key: fluid-output
label: Fluid Output
data_type: fluid
io_type: source
data_source: executor
data_key: fluid_out
init_param_schema:
type: object
properties:
port:
type: string
description: "通信端口"
default: "COM6"
required:
- port

View File

@@ -4,4 +4,4 @@ workstation:
module: unilabos.ros.nodes.presets.protocol_node:ROS2ProtocolNode module: unilabos.ros.nodes.presets.protocol_node:ROS2ProtocolNode
type: ros2 type: ros2
schema: schema:
properties: {} properties: {}

View File

@@ -25,9 +25,7 @@ class Registry:
self.ResourceCreateFromOuterEasy = self._replace_type_with_class( self.ResourceCreateFromOuterEasy = self._replace_type_with_class(
"ResourceCreateFromOuterEasy", "host_node", f"动作 create_resource" "ResourceCreateFromOuterEasy", "host_node", f"动作 create_resource"
) )
self.EmptyIn = self._replace_type_with_class( self.EmptyIn = self._replace_type_with_class("EmptyIn", "host_node", f"")
"EmptyIn", "host_node", f""
)
self.device_type_registry = {} self.device_type_registry = {}
self.resource_type_registry = {} self.resource_type_registry = {}
self._setup_called = False # 跟踪setup是否已调用 self._setup_called = False # 跟踪setup是否已调用
@@ -99,6 +97,8 @@ class Registry:
}, },
"icon": "icon_device.webp", "icon": "icon_device.webp",
"registry_type": "device", "registry_type": "device",
"handles": [],
"init_param_schema": {},
"schema": {"properties": {}, "additionalProperties": False, "type": "object"}, "schema": {"properties": {}, "additionalProperties": False, "type": "object"},
"file_path": "/", "file_path": "/",
} }
@@ -132,6 +132,12 @@ class Registry:
resource_info["description"] = "" resource_info["description"] = ""
if "icon" not in resource_info: if "icon" not in resource_info:
resource_info["icon"] = "" resource_info["icon"] = ""
if "icon" not in resource_info:
resource_info["icon"] = ""
if "handles" not in resource_info:
resource_info["handles"] = []
if "init_param_schema" not in resource_info:
resource_info["init_param_schema"] = {}
resource_info["registry_type"] = "resource" resource_info["registry_type"] = "resource"
self.resource_type_registry.update(data) self.resource_type_registry.update(data)
logger.debug( logger.debug(
@@ -194,6 +200,10 @@ class Registry:
device_config["description"] = "" device_config["description"] = ""
if "icon" not in device_config: if "icon" not in device_config:
device_config["icon"] = "" device_config["icon"] = ""
if "handles" not in device_config:
device_config["handles"] = []
if "init_param_schema" not in device_config:
device_config["init_param_schema"] = {}
device_config["registry_type"] = "device" device_config["registry_type"] = "device"
if "class" in device_config: if "class" in device_config:
# 处理状态类型 # 处理状态类型