mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 21:11:12 +00:00
feat(反应站): 添加反应器子设备支持
- 在设备注册表中添加反应器子设备配置 - 实现BioyondReactor类用于处理反应器数据 - 更新反应站主设备以支持子设备数据同步 - 在测试配置中添加5个反应器实例
This commit is contained in:
@@ -5,10 +5,16 @@
|
|||||||
"name": "reaction_station_bioyond",
|
"name": "reaction_station_bioyond",
|
||||||
"parent": null,
|
"parent": null,
|
||||||
"children": [
|
"children": [
|
||||||
"Bioyond_Deck"
|
"Bioyond_Deck",
|
||||||
|
"reactor_1",
|
||||||
|
"reactor_2",
|
||||||
|
"reactor_3",
|
||||||
|
"reactor_4",
|
||||||
|
"reactor_5"
|
||||||
],
|
],
|
||||||
"type": "device",
|
"type": "device",
|
||||||
"class": "reaction_station.bioyond",
|
"class": "reaction_station.bioyond",
|
||||||
|
"position": {"x": 0, "y": 3800, "z": 0},
|
||||||
"config": {
|
"config": {
|
||||||
"config": {
|
"config": {
|
||||||
"api_key": "DE9BDDA0",
|
"api_key": "DE9BDDA0",
|
||||||
@@ -64,6 +70,61 @@
|
|||||||
},
|
},
|
||||||
"data": {}
|
"data": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "reactor_1",
|
||||||
|
"name": "reactor_1",
|
||||||
|
"children": [],
|
||||||
|
"parent": "reaction_station_bioyond",
|
||||||
|
"type": "device",
|
||||||
|
"class": "reaction_station.reactor",
|
||||||
|
"position": {"x": 1150, "y": 380, "z": 0},
|
||||||
|
"config": {},
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "reactor_2",
|
||||||
|
"name": "reactor_2",
|
||||||
|
"children": [],
|
||||||
|
"parent": "reaction_station_bioyond",
|
||||||
|
"type": "device",
|
||||||
|
"class": "reaction_station.reactor",
|
||||||
|
"position": {"x": 1365, "y": 380, "z": 0},
|
||||||
|
"config": {},
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "reactor_3",
|
||||||
|
"name": "reactor_3",
|
||||||
|
"children": [],
|
||||||
|
"parent": "reaction_station_bioyond",
|
||||||
|
"type": "device",
|
||||||
|
"class": "reaction_station.reactor",
|
||||||
|
"position": {"x": 1580, "y": 380, "z": 0},
|
||||||
|
"config": {},
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "reactor_4",
|
||||||
|
"name": "reactor_4",
|
||||||
|
"children": [],
|
||||||
|
"parent": "reaction_station_bioyond",
|
||||||
|
"type": "device",
|
||||||
|
"class": "reaction_station.reactor",
|
||||||
|
"position": {"x": 1790, "y": 380, "z": 0},
|
||||||
|
"config": {},
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "reactor_5",
|
||||||
|
"name": "reactor_5",
|
||||||
|
"children": [],
|
||||||
|
"parent": "reaction_station_bioyond",
|
||||||
|
"type": "device",
|
||||||
|
"class": "reaction_station.reactor",
|
||||||
|
"position": {"x": 2010, "y": 380, "z": 0},
|
||||||
|
"config": {},
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "Bioyond_Deck",
|
"id": "Bioyond_Deck",
|
||||||
"name": "Bioyond_Deck",
|
"name": "Bioyond_Deck",
|
||||||
|
|||||||
@@ -14,6 +14,37 @@ from unilabos.devices.workstation.bioyond_studio.config import (
|
|||||||
from unilabos.devices.workstation.bioyond_studio.config import API_CONFIG
|
from unilabos.devices.workstation.bioyond_studio.config import API_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
class BioyondReactor:
|
||||||
|
def __init__(self, config: dict = None, deck=None, protocol_type=None, **kwargs):
|
||||||
|
self.in_temperature = 0.0
|
||||||
|
self.out_temperature = 0.0
|
||||||
|
self.pt100_temperature = 0.0
|
||||||
|
self.sensor_average_temperature = 0.0
|
||||||
|
self.target_temperature = 0.0
|
||||||
|
self.setting_temperature = 0.0
|
||||||
|
self.viscosity = 0.0
|
||||||
|
self.average_viscosity = 0.0
|
||||||
|
self.speed = 0.0
|
||||||
|
self.force = 0.0
|
||||||
|
|
||||||
|
def update_metrics(self, payload: Dict[str, Any]):
|
||||||
|
def _f(v):
|
||||||
|
try:
|
||||||
|
return float(v)
|
||||||
|
except Exception:
|
||||||
|
return 0.0
|
||||||
|
self.target_temperature = _f(payload.get("targetTemperature"))
|
||||||
|
self.setting_temperature = _f(payload.get("settingTemperature"))
|
||||||
|
self.in_temperature = _f(payload.get("inTemperature"))
|
||||||
|
self.out_temperature = _f(payload.get("outTemperature"))
|
||||||
|
self.pt100_temperature = _f(payload.get("pt100Temperature"))
|
||||||
|
self.sensor_average_temperature = _f(payload.get("sensorAverageTemperature"))
|
||||||
|
self.speed = _f(payload.get("speed"))
|
||||||
|
self.force = _f(payload.get("force"))
|
||||||
|
self.viscosity = _f(payload.get("viscosity"))
|
||||||
|
self.average_viscosity = _f(payload.get("averageViscosity"))
|
||||||
|
|
||||||
|
|
||||||
class BioyondReactionStation(BioyondWorkstation):
|
class BioyondReactionStation(BioyondWorkstation):
|
||||||
"""Bioyond反应站类
|
"""Bioyond反应站类
|
||||||
|
|
||||||
@@ -52,6 +83,8 @@ class BioyondReactionStation(BioyondWorkstation):
|
|||||||
self.speed = 0.0
|
self.speed = 0.0
|
||||||
self.force = 0.0
|
self.force = 0.0
|
||||||
|
|
||||||
|
self._frame_to_reactor_id = {1: "reactor_1", 2: "reactor_2", 3: "reactor_3", 4: "reactor_4", 5: "reactor_5"}
|
||||||
|
|
||||||
# ==================== 工作流方法 ====================
|
# ==================== 工作流方法 ====================
|
||||||
|
|
||||||
def reactor_taken_out(self):
|
def reactor_taken_out(self):
|
||||||
@@ -558,6 +591,21 @@ class BioyondReactionStation(BioyondWorkstation):
|
|||||||
pub = self._ros_node._property_publishers.get(name)
|
pub = self._ros_node._property_publishers.get(name)
|
||||||
if pub:
|
if pub:
|
||||||
pub.publish_property()
|
pub.publish_property()
|
||||||
|
frame = data.get("frameCode")
|
||||||
|
reactor_id = None
|
||||||
|
try:
|
||||||
|
reactor_id = self._frame_to_reactor_id.get(int(frame))
|
||||||
|
except Exception:
|
||||||
|
reactor_id = None
|
||||||
|
if reactor_id and hasattr(self._ros_node, "sub_devices"):
|
||||||
|
child = self._ros_node.sub_devices.get(reactor_id)
|
||||||
|
if child and hasattr(child, "driver_instance"):
|
||||||
|
child.driver_instance.update_metrics(data)
|
||||||
|
pubs = getattr(child.ros_node_instance, "_property_publishers", {})
|
||||||
|
for name in props:
|
||||||
|
p = pubs.get(name)
|
||||||
|
if p:
|
||||||
|
p.publish_property()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
event = {
|
event = {
|
||||||
@@ -575,6 +623,7 @@ class BioyondReactionStation(BioyondWorkstation):
|
|||||||
"averageViscosity": data.get("averageViscosity"),
|
"averageViscosity": data.get("averageViscosity"),
|
||||||
"request_time": report_request.request_time,
|
"request_time": report_request.request_time,
|
||||||
"timestamp": datetime.now().isoformat(),
|
"timestamp": datetime.now().isoformat(),
|
||||||
|
"reactor_id": self._frame_to_reactor_id.get(int(data.get("frameCode", 0))) if str(data.get("frameCode", "")).isdigit() else None,
|
||||||
}
|
}
|
||||||
|
|
||||||
base_dir = Path(__file__).resolve().parents[3] / "unilabos_data"
|
base_dir = Path(__file__).resolve().parents[3] / "unilabos_data"
|
||||||
|
|||||||
@@ -565,3 +565,58 @@ reaction_station.bioyond:
|
|||||||
- workstation_status
|
- workstation_status
|
||||||
type: object
|
type: object
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
reaction_station.reactor:
|
||||||
|
category:
|
||||||
|
- reactor
|
||||||
|
- reaction_station_bioyond
|
||||||
|
class:
|
||||||
|
action_value_mappings: {}
|
||||||
|
module: unilabos.devices.workstation.bioyond_studio.reaction_station:BioyondReactor
|
||||||
|
status_types:
|
||||||
|
average_viscosity: float
|
||||||
|
force: float
|
||||||
|
in_temperature: float
|
||||||
|
out_temperature: float
|
||||||
|
pt100_temperature: float
|
||||||
|
sensor_average_temperature: float
|
||||||
|
setting_temperature: float
|
||||||
|
speed: float
|
||||||
|
target_temperature: float
|
||||||
|
viscosity: float
|
||||||
|
type: python
|
||||||
|
config_info: []
|
||||||
|
description: 反应站子设备-反应器
|
||||||
|
handles: []
|
||||||
|
icon: reaction_station.webp
|
||||||
|
init_param_schema:
|
||||||
|
config:
|
||||||
|
properties:
|
||||||
|
config:
|
||||||
|
type: object
|
||||||
|
required: []
|
||||||
|
type: object
|
||||||
|
data:
|
||||||
|
properties:
|
||||||
|
average_viscosity:
|
||||||
|
type: number
|
||||||
|
force:
|
||||||
|
type: number
|
||||||
|
in_temperature:
|
||||||
|
type: number
|
||||||
|
out_temperature:
|
||||||
|
type: number
|
||||||
|
pt100_temperature:
|
||||||
|
type: number
|
||||||
|
sensor_average_temperature:
|
||||||
|
type: number
|
||||||
|
setting_temperature:
|
||||||
|
type: number
|
||||||
|
speed:
|
||||||
|
type: number
|
||||||
|
target_temperature:
|
||||||
|
type: number
|
||||||
|
viscosity:
|
||||||
|
type: number
|
||||||
|
required: []
|
||||||
|
type: object
|
||||||
|
version: 1.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user