mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-06 15:05:13 +00:00
优化了全protocol的运行时间,除了pumptransfer相关的还没
This commit is contained in:
@@ -3,7 +3,7 @@ import logging
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
class VirtualColumn:
|
||||
"""Virtual column device for RunColumn protocol"""
|
||||
"""Virtual column device for RunColumn protocol 🏛️"""
|
||||
|
||||
def __init__(self, device_id: str = None, config: Dict[str, Any] = None, **kwargs):
|
||||
# 处理可能的不同调用方式
|
||||
@@ -25,45 +25,77 @@ class VirtualColumn:
|
||||
self._column_length = self.config.get('column_length') or kwargs.get('column_length', 25.0)
|
||||
self._column_diameter = self.config.get('column_diameter') or kwargs.get('column_diameter', 2.0)
|
||||
|
||||
print(f"=== VirtualColumn {self.device_id} created with max_flow_rate={self._max_flow_rate}, length={self._column_length}cm ===")
|
||||
print(f"🏛️ === 虚拟色谱柱 {self.device_id} 已创建 === ✨")
|
||||
print(f"📏 柱参数: 流速={self._max_flow_rate}mL/min | 长度={self._column_length}cm | 直径={self._column_diameter}cm 🔬")
|
||||
|
||||
async def initialize(self) -> bool:
|
||||
"""Initialize virtual column"""
|
||||
self.logger.info(f"Initializing virtual column {self.device_id}")
|
||||
"""Initialize virtual column 🚀"""
|
||||
self.logger.info(f"🔧 初始化虚拟色谱柱 {self.device_id} ✨")
|
||||
|
||||
self.data.update({
|
||||
"status": "Idle",
|
||||
"column_state": "Ready",
|
||||
"column_state": "Ready",
|
||||
"current_flow_rate": 0.0,
|
||||
"max_flow_rate": self._max_flow_rate,
|
||||
"column_length": self._column_length,
|
||||
"column_diameter": self._column_diameter,
|
||||
"processed_volume": 0.0,
|
||||
"progress": 0.0,
|
||||
"current_status": "Ready"
|
||||
"current_status": "Ready for separation"
|
||||
})
|
||||
|
||||
self.logger.info(f"✅ 色谱柱 {self.device_id} 初始化完成 🏛️")
|
||||
self.logger.info(f"📊 设备规格: 最大流速 {self._max_flow_rate}mL/min | 柱长 {self._column_length}cm 📏")
|
||||
return True
|
||||
|
||||
async def cleanup(self) -> bool:
|
||||
"""Cleanup virtual column"""
|
||||
self.logger.info(f"Cleaning up virtual column {self.device_id}")
|
||||
"""Cleanup virtual column 🧹"""
|
||||
self.logger.info(f"🧹 清理虚拟色谱柱 {self.device_id} 🔚")
|
||||
|
||||
self.data.update({
|
||||
"status": "Offline",
|
||||
"column_state": "Offline",
|
||||
"current_status": "System offline"
|
||||
})
|
||||
|
||||
self.logger.info(f"✅ 色谱柱 {self.device_id} 清理完成 💤")
|
||||
return True
|
||||
|
||||
async def run_column(self, from_vessel: str, to_vessel: str, column: str) -> bool:
|
||||
"""Execute column chromatography run - matches RunColumn action"""
|
||||
self.logger.info(f"Running column separation: {from_vessel} -> {to_vessel} using {column}")
|
||||
async def run_column(self, from_vessel: str, to_vessel: str, column: str, **kwargs) -> bool:
|
||||
"""Execute column chromatography run - matches RunColumn action 🏛️"""
|
||||
|
||||
# 提取额外参数
|
||||
rf = kwargs.get('rf', '0.3')
|
||||
solvent1 = kwargs.get('solvent1', 'ethyl_acetate')
|
||||
solvent2 = kwargs.get('solvent2', 'hexane')
|
||||
ratio = kwargs.get('ratio', '30:70')
|
||||
|
||||
self.logger.info(f"🏛️ 开始柱层析分离: {from_vessel} → {to_vessel} 🚰")
|
||||
self.logger.info(f" 🧪 使用色谱柱: {column}")
|
||||
self.logger.info(f" 🎯 Rf值: {rf}")
|
||||
self.logger.info(f" 🧪 洗脱溶剂: {solvent1}:{solvent2} ({ratio}) 💧")
|
||||
|
||||
# 更新设备状态
|
||||
self.data.update({
|
||||
"status": "Running",
|
||||
"column_state": "Separating",
|
||||
"current_status": "Column separation in progress",
|
||||
"current_status": "🏛️ Column separation in progress",
|
||||
"progress": 0.0,
|
||||
"processed_volume": 0.0
|
||||
"processed_volume": 0.0,
|
||||
"current_from_vessel": from_vessel,
|
||||
"current_to_vessel": to_vessel,
|
||||
"current_column": column,
|
||||
"current_rf": rf,
|
||||
"current_solvents": f"{solvent1}:{solvent2} ({ratio})"
|
||||
})
|
||||
|
||||
# 模拟柱层析分离过程
|
||||
# 假设处理时间基于流速和柱子长度
|
||||
separation_time = (self._column_length * 2) / self._max_flow_rate # 简化计算
|
||||
base_time = (self._column_length * 2) / self._max_flow_rate # 简化计算
|
||||
separation_time = max(base_time, 20.0) # 最少20秒
|
||||
|
||||
self.logger.info(f"⏱️ 预计分离时间: {separation_time:.1f}秒 ⌛")
|
||||
self.logger.info(f"📏 柱参数: 长度 {self._column_length}cm | 流速 {self._max_flow_rate}mL/min 🌊")
|
||||
|
||||
steps = 20 # 分20个步骤模拟分离过程
|
||||
step_time = separation_time / steps
|
||||
@@ -74,34 +106,65 @@ class VirtualColumn:
|
||||
progress = (i + 1) / steps * 100
|
||||
volume_processed = (i + 1) * 5.0 # 假设每步处理5mL
|
||||
|
||||
# 不同阶段的状态描述
|
||||
if progress <= 25:
|
||||
phase = "🌊 样品上柱阶段"
|
||||
phase_emoji = "📥"
|
||||
elif progress <= 50:
|
||||
phase = "🧪 洗脱开始"
|
||||
phase_emoji = "💧"
|
||||
elif progress <= 75:
|
||||
phase = "⚗️ 成分分离中"
|
||||
phase_emoji = "🔄"
|
||||
else:
|
||||
phase = "🎯 收集产物"
|
||||
phase_emoji = "📤"
|
||||
|
||||
# 更新状态
|
||||
status_msg = f"{phase_emoji} {phase}: {progress:.1f}% | 💧 已处理: {volume_processed:.1f}mL"
|
||||
|
||||
self.data.update({
|
||||
"progress": progress,
|
||||
"processed_volume": volume_processed,
|
||||
"current_status": f"Column separation: {progress:.1f}% - Processing {volume_processed:.1f}mL"
|
||||
"current_status": status_msg,
|
||||
"current_phase": phase
|
||||
})
|
||||
|
||||
self.logger.info(f"Column separation progress: {progress:.1f}%")
|
||||
# 进度日志(每25%打印一次)
|
||||
if progress >= 25 and (i + 1) % 5 == 0: # 每5步(25%)打印一次
|
||||
self.logger.info(f"📊 分离进度: {progress:.0f}% | {phase} | 💧 {volume_processed:.1f}mL 完成 ✨")
|
||||
|
||||
# 分离完成
|
||||
final_status = f"✅ 柱层析分离完成: {from_vessel} → {to_vessel} | 💧 共处理 {volume_processed:.1f}mL"
|
||||
|
||||
self.data.update({
|
||||
"status": "Idle",
|
||||
"column_state": "Ready",
|
||||
"current_status": "Column separation completed",
|
||||
"progress": 100.0
|
||||
"current_status": final_status,
|
||||
"progress": 100.0,
|
||||
"final_volume": volume_processed
|
||||
})
|
||||
|
||||
self.logger.info(f"Column separation completed: {from_vessel} -> {to_vessel}")
|
||||
self.logger.info(f"🎉 柱层析分离完成! ✨")
|
||||
self.logger.info(f"📊 分离结果:")
|
||||
self.logger.info(f" 🥽 源容器: {from_vessel}")
|
||||
self.logger.info(f" 🥽 目标容器: {to_vessel}")
|
||||
self.logger.info(f" 🏛️ 使用色谱柱: {column}")
|
||||
self.logger.info(f" 💧 处理体积: {volume_processed:.1f}mL")
|
||||
self.logger.info(f" 🧪 洗脱条件: {solvent1}:{solvent2} ({ratio})")
|
||||
self.logger.info(f" 🎯 Rf值: {rf}")
|
||||
self.logger.info(f" ⏱️ 总耗时: {separation_time:.1f}秒 🏁")
|
||||
|
||||
return True
|
||||
|
||||
# 状态属性
|
||||
@property
|
||||
def status(self) -> str:
|
||||
return self.data.get("status", "Unknown")
|
||||
return self.data.get("status", "❓ Unknown")
|
||||
|
||||
@property
|
||||
def column_state(self) -> str:
|
||||
return self.data.get("column_state", "Unknown")
|
||||
return self.data.get("column_state", "❓ Unknown")
|
||||
|
||||
@property
|
||||
def current_flow_rate(self) -> float:
|
||||
@@ -129,4 +192,12 @@ class VirtualColumn:
|
||||
|
||||
@property
|
||||
def current_status(self) -> str:
|
||||
return self.data.get("current_status", "Ready")
|
||||
return self.data.get("current_status", "📋 Ready")
|
||||
|
||||
@property
|
||||
def current_phase(self) -> str:
|
||||
return self.data.get("current_phase", "🏠 待机中")
|
||||
|
||||
@property
|
||||
def final_volume(self) -> float:
|
||||
return self.data.get("final_volume", 0.0)
|
||||
Reference in New Issue
Block a user