mirror of
https://github.com/deepmodeling/Uni-Lab-OS
synced 2026-03-26 01:13:11 +00:00
refactor: 14个协议编译器去重精简,删除死代码
- 统一debug_print为共享import,移除14个本地定义 - 移除重复工具函数(find_connected_stirrer, get_vessel_liquid_volume等) - 精简装饰性日志(emoji分隔线、进度提示),保留关键决策点 - 删除evacuateandrefill_protocol_old.py死代码 - 涉及文件:add, adjustph, clean_vessel, dissolve, dry, evacuateandrefill, evaporate, filter, pump, recrystallize, reset_handling, run_column, stir, wash_solid Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,99 +2,18 @@ import traceback
|
||||
import numpy as np
|
||||
import networkx as nx
|
||||
import asyncio
|
||||
import time as time_module # 🔧 重命名time模块
|
||||
import time as time_module # 重命名time模块
|
||||
from typing import List, Dict, Any
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from unilabos.compile.utils.vessel_parser import get_vessel
|
||||
from .utils.logger_util import debug_print
|
||||
from .utils.vessel_parser import get_vessel
|
||||
from .utils.resource_helper import get_resource_liquid_volume
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def debug_print(message):
|
||||
"""强制输出调试信息"""
|
||||
output = f"[TRANSFER] {message}"
|
||||
logger.info(output)
|
||||
|
||||
|
||||
def get_vessel_liquid_volume(G: nx.DiGraph, vessel: str) -> float:
|
||||
"""
|
||||
从容器节点的数据中获取液体体积
|
||||
"""
|
||||
debug_print(f"🔍 开始读取容器 '{vessel}' 的液体体积...")
|
||||
|
||||
if vessel not in G.nodes():
|
||||
logger.error(f"❌ 容器 '{vessel}' 不存在于系统图中")
|
||||
debug_print(f" - 系统中的容器: {list(G.nodes())}")
|
||||
return 0.0
|
||||
|
||||
vessel_data = G.nodes[vessel].get('data', {})
|
||||
debug_print(f"📋 容器 '{vessel}' 的数据结构: {vessel_data}")
|
||||
|
||||
total_volume = 0.0
|
||||
|
||||
# 方法1:检查 'liquid' 字段(列表格式)
|
||||
debug_print("🔍 方法1: 检查 'liquid' 字段...")
|
||||
if 'liquid' in vessel_data:
|
||||
liquids = vessel_data['liquid']
|
||||
debug_print(f" - liquid 字段类型: {type(liquids)}")
|
||||
debug_print(f" - liquid 字段内容: {liquids}")
|
||||
|
||||
if isinstance(liquids, list):
|
||||
debug_print(f" - liquid 是列表,包含 {len(liquids)} 个元素")
|
||||
for i, liquid in enumerate(liquids):
|
||||
debug_print(f" 液体 {i + 1}: {liquid}")
|
||||
if isinstance(liquid, dict):
|
||||
volume_keys = ['liquid_volume', 'volume', 'amount', 'quantity']
|
||||
for key in volume_keys:
|
||||
if key in liquid:
|
||||
try:
|
||||
vol = float(liquid[key])
|
||||
total_volume += vol
|
||||
debug_print(f" ✅ 从 '{key}' 读取体积: {vol}mL")
|
||||
break
|
||||
except (ValueError, TypeError) as e:
|
||||
logger.warning(f" ⚠️ 无法转换 '{key}': {liquid[key]} -> {str(e)}")
|
||||
continue
|
||||
else:
|
||||
debug_print(f" - liquid 不是列表: {type(liquids)}")
|
||||
else:
|
||||
debug_print(" - 没有 'liquid' 字段")
|
||||
|
||||
# 方法2:检查直接的体积字段
|
||||
debug_print("🔍 方法2: 检查直接体积字段...")
|
||||
volume_keys = ['total_volume', 'volume', 'liquid_volume', 'amount', 'current_volume']
|
||||
for key in volume_keys:
|
||||
if key in vessel_data:
|
||||
try:
|
||||
vol = float(vessel_data[key])
|
||||
total_volume = max(total_volume, vol) # 取最大值
|
||||
debug_print(f" ✅ 从容器数据 '{key}' 读取体积: {vol}mL")
|
||||
break
|
||||
except (ValueError, TypeError) as e:
|
||||
logger.warning(f" ⚠️ 无法转换 '{key}': {vessel_data[key]} -> {str(e)}")
|
||||
continue
|
||||
|
||||
# 方法3:检查 'state' 或 'status' 字段
|
||||
debug_print("🔍 方法3: 检查 'state' 字段...")
|
||||
if 'state' in vessel_data and isinstance(vessel_data['state'], dict):
|
||||
state = vessel_data['state']
|
||||
debug_print(f" - state 字段内容: {state}")
|
||||
if 'volume' in state:
|
||||
try:
|
||||
vol = float(state['volume'])
|
||||
total_volume = max(total_volume, vol)
|
||||
debug_print(f" ✅ 从容器状态读取体积: {vol}mL")
|
||||
except (ValueError, TypeError) as e:
|
||||
logger.warning(f" ⚠️ 无法转换 state.volume: {state['volume']} -> {str(e)}")
|
||||
else:
|
||||
debug_print(" - 没有 'state' 字段或不是字典")
|
||||
|
||||
debug_print(f"📊 容器 '{vessel}' 最终检测体积: {total_volume}mL")
|
||||
return total_volume
|
||||
|
||||
|
||||
def is_integrated_pump(node_class: str, node_name: str = "") -> bool:
|
||||
"""
|
||||
判断是否为泵阀一体设备
|
||||
@@ -515,188 +434,132 @@ def generate_pump_protocol_with_rinsing(
|
||||
to_vessel_id, _ = get_vessel(to_vessel)
|
||||
|
||||
with generate_pump_protocol_with_rinsing._lock:
|
||||
debug_print("=" * 60)
|
||||
debug_print(f"PUMP_TRANSFER: 🚀 开始生成协议 (同步版本)")
|
||||
debug_print(f" 📍 路径: {from_vessel_id} -> {to_vessel_id}")
|
||||
debug_print(f" 🕐 时间戳: {time_module.time()}")
|
||||
debug_print(f" 🔒 获得执行锁")
|
||||
debug_print("=" * 60)
|
||||
debug_print(f"PUMP_TRANSFER: {from_vessel_id} -> {to_vessel_id}, volume={volume}, flowrate={flowrate}")
|
||||
|
||||
# 短暂延迟,避免快速重复调用
|
||||
time_module.sleep(0.01)
|
||||
|
||||
debug_print("🔍 步骤1: 开始体积处理...")
|
||||
|
||||
# 1. 处理体积参数
|
||||
final_volume = volume
|
||||
debug_print(f"📋 初始设置: final_volume = {final_volume}")
|
||||
debug_print(f"初始体积: {final_volume}")
|
||||
|
||||
# 🔧 修复:如果volume为0(ROS2传入的空值),从容器读取实际体积
|
||||
# 如果volume为0,从容器读取实际体积
|
||||
if volume == 0.0:
|
||||
debug_print("🎯 检测到 volume=0.0,开始自动体积检测...")
|
||||
|
||||
# 直接从源容器读取实际体积
|
||||
actual_volume = get_vessel_liquid_volume(G, from_vessel_id)
|
||||
debug_print(f"📖 从容器 '{from_vessel_id}' 读取到体积: {actual_volume}mL")
|
||||
actual_volume = get_resource_liquid_volume(G.nodes.get(from_vessel_id, {}))
|
||||
|
||||
if actual_volume > 0:
|
||||
final_volume = actual_volume
|
||||
debug_print(f"✅ 成功设置体积为: {final_volume}mL")
|
||||
debug_print(f"从容器读取体积: {final_volume}mL")
|
||||
else:
|
||||
final_volume = 10.0 # 如果读取失败,使用默认值
|
||||
logger.warning(f"⚠️ 无法从容器读取体积,使用默认值: {final_volume}mL")
|
||||
final_volume = 10.0
|
||||
logger.warning(f"无法从容器读取体积,使用默认值: {final_volume}mL")
|
||||
else:
|
||||
debug_print(f"📌 体积非零,直接使用: {final_volume}mL")
|
||||
debug_print(f"使用指定体积: {final_volume}mL")
|
||||
|
||||
# 处理 amount 参数
|
||||
if amount and amount.strip():
|
||||
debug_print(f"🔍 检测到 amount 参数: '{amount}',开始解析...")
|
||||
parsed_volume = _parse_amount_to_volume(amount)
|
||||
debug_print(f"📖 从 amount 解析得到体积: {parsed_volume}mL")
|
||||
|
||||
if parsed_volume > 0:
|
||||
final_volume = parsed_volume
|
||||
debug_print(f"✅ 使用从 amount 解析的体积: {final_volume}mL")
|
||||
elif parsed_volume == 0.0 and amount.lower().strip() == "all":
|
||||
debug_print("🎯 检测到 amount='all',从容器读取全部体积...")
|
||||
actual_volume = get_vessel_liquid_volume(G, from_vessel_id)
|
||||
actual_volume = get_resource_liquid_volume(G.nodes.get(from_vessel_id, {}))
|
||||
if actual_volume > 0:
|
||||
final_volume = actual_volume
|
||||
debug_print(f"✅ amount='all',设置体积为: {final_volume}mL")
|
||||
|
||||
# 最终体积验证
|
||||
debug_print(f"🔍 步骤2: 最终体积验证...")
|
||||
if final_volume <= 0:
|
||||
logger.error(f"❌ 体积无效: {final_volume}mL")
|
||||
logger.error(f"体积无效: {final_volume}mL")
|
||||
final_volume = 10.0
|
||||
logger.warning(f"⚠️ 强制设置为默认值: {final_volume}mL")
|
||||
logger.warning(f"强制设置为默认值: {final_volume}mL")
|
||||
|
||||
debug_print(f"✅ 最终确定体积: {final_volume}mL")
|
||||
debug_print(f"最终体积: {final_volume}mL")
|
||||
|
||||
# 2. 处理流速参数
|
||||
debug_print(f"🔍 步骤3: 处理流速参数...")
|
||||
debug_print(f" - 原始 flowrate: {flowrate}")
|
||||
debug_print(f" - 原始 transfer_flowrate: {transfer_flowrate}")
|
||||
|
||||
final_flowrate = flowrate if flowrate > 0 else 2.5
|
||||
final_transfer_flowrate = transfer_flowrate if transfer_flowrate > 0 else 0.5
|
||||
|
||||
if flowrate <= 0:
|
||||
logger.warning(f"⚠️ flowrate <= 0,修正为: {final_flowrate}mL/s")
|
||||
logger.warning(f"flowrate <= 0,修正为: {final_flowrate}mL/s")
|
||||
if transfer_flowrate <= 0:
|
||||
logger.warning(f"⚠️ transfer_flowrate <= 0,修正为: {final_transfer_flowrate}mL/s")
|
||||
|
||||
debug_print(f"✅ 修正后流速: flowrate={final_flowrate}mL/s, transfer_flowrate={final_transfer_flowrate}mL/s")
|
||||
logger.warning(f"transfer_flowrate <= 0,修正为: {final_transfer_flowrate}mL/s")
|
||||
|
||||
# 3. 根据时间计算流速
|
||||
if time > 0 and final_volume > 0:
|
||||
debug_print(f"🔍 步骤4: 根据时间计算流速...")
|
||||
calculated_flowrate = final_volume / time
|
||||
debug_print(f" - 计算得到流速: {calculated_flowrate}mL/s")
|
||||
|
||||
if flowrate <= 0 or flowrate == 2.5:
|
||||
final_flowrate = min(calculated_flowrate, 10.0)
|
||||
debug_print(f" - 调整 flowrate 为: {final_flowrate}mL/s")
|
||||
if transfer_flowrate <= 0 or transfer_flowrate == 0.5:
|
||||
final_transfer_flowrate = min(calculated_flowrate, 5.0)
|
||||
debug_print(f" - 调整 transfer_flowrate 为: {final_transfer_flowrate}mL/s")
|
||||
|
||||
# 4. 根据速度规格调整
|
||||
if rate_spec:
|
||||
debug_print(f"🔍 步骤5: 根据速度规格调整...")
|
||||
debug_print(f" - 速度规格: '{rate_spec}'")
|
||||
|
||||
if rate_spec == "dropwise":
|
||||
final_flowrate = min(final_flowrate, 0.1)
|
||||
final_transfer_flowrate = min(final_transfer_flowrate, 0.1)
|
||||
debug_print(f" - dropwise模式,流速调整为: {final_flowrate}mL/s")
|
||||
elif rate_spec == "slowly":
|
||||
final_flowrate = min(final_flowrate, 0.5)
|
||||
final_transfer_flowrate = min(final_transfer_flowrate, 0.3)
|
||||
debug_print(f" - slowly模式,流速调整为: {final_flowrate}mL/s")
|
||||
elif rate_spec == "quickly":
|
||||
final_flowrate = max(final_flowrate, 5.0)
|
||||
final_transfer_flowrate = max(final_transfer_flowrate, 2.0)
|
||||
debug_print(f" - quickly模式,流速调整为: {final_flowrate}mL/s")
|
||||
debug_print(f"速度规格 '{rate_spec}' 应用后: flowrate={final_flowrate}, transfer={final_transfer_flowrate}")
|
||||
|
||||
# 5. 处理冲洗参数
|
||||
debug_print(f"🔍 步骤6: 处理冲洗参数...")
|
||||
final_rinsing_solvent = rinsing_solvent
|
||||
final_rinsing_volume = rinsing_volume if rinsing_volume > 0 else 5.0
|
||||
final_rinsing_repeats = rinsing_repeats if rinsing_repeats > 0 else 2
|
||||
|
||||
if rinsing_volume <= 0:
|
||||
logger.warning(f"⚠️ rinsing_volume <= 0,修正为: {final_rinsing_volume}mL")
|
||||
logger.warning(f"rinsing_volume <= 0,修正为: {final_rinsing_volume}mL")
|
||||
if rinsing_repeats <= 0:
|
||||
logger.warning(f"⚠️ rinsing_repeats <= 0,修正为: {final_rinsing_repeats}次")
|
||||
logger.warning(f"rinsing_repeats <= 0,修正为: {final_rinsing_repeats}次")
|
||||
|
||||
# 根据物理属性调整冲洗参数
|
||||
if viscous or solid:
|
||||
final_rinsing_repeats = max(final_rinsing_repeats, 3)
|
||||
final_rinsing_volume = max(final_rinsing_volume, 10.0)
|
||||
debug_print(f"🧪 粘稠/固体物质,调整冲洗参数:{final_rinsing_repeats}次,{final_rinsing_volume}mL")
|
||||
|
||||
# 参数总结
|
||||
debug_print("📊 最终参数总结:")
|
||||
debug_print(f" - 体积: {final_volume}mL")
|
||||
debug_print(f" - 流速: {final_flowrate}mL/s")
|
||||
debug_print(f" - 转移流速: {final_transfer_flowrate}mL/s")
|
||||
debug_print(f" - 冲洗溶剂: '{final_rinsing_solvent}'")
|
||||
debug_print(f" - 冲洗体积: {final_rinsing_volume}mL")
|
||||
debug_print(f" - 冲洗次数: {final_rinsing_repeats}次")
|
||||
debug_print(f"最终参数: volume={final_volume}mL, flowrate={final_flowrate}mL/s, "
|
||||
f"transfer_flowrate={final_transfer_flowrate}mL/s, "
|
||||
f"rinsing={final_rinsing_solvent}/{final_rinsing_volume}mL/{final_rinsing_repeats}次")
|
||||
|
||||
# ========== 执行基础转移 ==========
|
||||
|
||||
debug_print("🔧 步骤7: 开始执行基础转移...")
|
||||
|
||||
try:
|
||||
debug_print(f" - 调用 generate_pump_protocol...")
|
||||
debug_print(
|
||||
f" - 参数: G, '{from_vessel_id}', '{to_vessel_id}', {final_volume}, {final_flowrate}, {final_transfer_flowrate}")
|
||||
|
||||
pump_action_sequence = generate_pump_protocol(
|
||||
G, from_vessel_id, to_vessel_id, final_volume,
|
||||
final_flowrate, final_transfer_flowrate
|
||||
)
|
||||
|
||||
debug_print(f" - generate_pump_protocol 返回结果:")
|
||||
debug_print(f" - 动作序列长度: {len(pump_action_sequence)}")
|
||||
debug_print(f" - 动作序列是否为空: {len(pump_action_sequence) == 0}")
|
||||
debug_print(f"基础转移生成了 {len(pump_action_sequence)} 个动作")
|
||||
|
||||
if not pump_action_sequence:
|
||||
debug_print("❌ 基础转移协议生成为空,可能是路径问题")
|
||||
debug_print(f" - 源容器存在: {from_vessel_id in G.nodes()}")
|
||||
debug_print(f" - 目标容器存在: {to_vessel_id in G.nodes()}")
|
||||
debug_print("基础转移协议生成为空,可能是路径问题")
|
||||
|
||||
if from_vessel_id in G.nodes() and to_vessel_id in G.nodes():
|
||||
try:
|
||||
path = nx.shortest_path(G, source=from_vessel_id, target=to_vessel_id)
|
||||
debug_print(f" - 路径存在: {path}")
|
||||
debug_print(f"路径存在: {path}")
|
||||
except Exception as path_error:
|
||||
debug_print(f" - 无法找到路径: {str(path_error)}")
|
||||
debug_print(f"无法找到路径: {str(path_error)}")
|
||||
|
||||
return [
|
||||
{
|
||||
"device_id": "system",
|
||||
"action_name": "log_message",
|
||||
"action_kwargs": {
|
||||
"message": f"⚠️ 路径问题,无法转移: {final_volume}mL 从 {from_vessel_id} 到 {to_vessel_id}"
|
||||
"message": f"路径问题,无法转移: {final_volume}mL 从 {from_vessel_id} 到 {to_vessel_id}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
debug_print(f"✅ 基础转移生成了 {len(pump_action_sequence)} 个动作")
|
||||
|
||||
# 打印前几个动作用于调试
|
||||
if len(pump_action_sequence) > 0:
|
||||
debug_print("🔍 前几个动作预览:")
|
||||
for i, action in enumerate(pump_action_sequence[:3]):
|
||||
debug_print(f" 动作 {i + 1}: {action}")
|
||||
if len(pump_action_sequence) > 3:
|
||||
debug_print(f" ... 还有 {len(pump_action_sequence) - 3} 个动作")
|
||||
|
||||
except Exception as e:
|
||||
debug_print(f"❌ 基础转移失败: {str(e)}")
|
||||
debug_print(f"基础转移失败: {str(e)}")
|
||||
import traceback
|
||||
debug_print(f"详细错误: {traceback.format_exc()}")
|
||||
return [
|
||||
@@ -704,111 +567,82 @@ def generate_pump_protocol_with_rinsing(
|
||||
"device_id": "system",
|
||||
"action_name": "log_message",
|
||||
"action_kwargs": {
|
||||
"message": f"❌ 转移失败: {final_volume}mL 从 {from_vessel_id} 到 {to_vessel_id}, 错误: {str(e)}"
|
||||
"message": f"转移失败: {final_volume}mL 从 {from_vessel_id} 到 {to_vessel_id}, 错误: {str(e)}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
# ========== 执行冲洗操作 ==========
|
||||
|
||||
debug_print("🔧 步骤8: 检查冲洗操作...")
|
||||
|
||||
if final_rinsing_solvent and final_rinsing_solvent.strip() and final_rinsing_repeats > 0:
|
||||
debug_print(f"🧽 开始冲洗操作,溶剂: '{final_rinsing_solvent}'")
|
||||
debug_print(f"开始冲洗操作,溶剂: '{final_rinsing_solvent}'")
|
||||
|
||||
try:
|
||||
if final_rinsing_solvent.strip() != "air":
|
||||
debug_print(" - 执行液体冲洗...")
|
||||
rinsing_actions = _generate_rinsing_sequence(
|
||||
G, from_vessel_id, to_vessel_id, final_rinsing_solvent,
|
||||
final_rinsing_volume, final_rinsing_repeats,
|
||||
final_flowrate, final_transfer_flowrate
|
||||
)
|
||||
pump_action_sequence.extend(rinsing_actions)
|
||||
debug_print(f" - 添加了 {len(rinsing_actions)} 个冲洗动作")
|
||||
else:
|
||||
debug_print(" - 执行空气冲洗...")
|
||||
air_rinsing_actions = _generate_air_rinsing_sequence(
|
||||
G, from_vessel_id, to_vessel_id, final_rinsing_volume, final_rinsing_repeats,
|
||||
final_flowrate, final_transfer_flowrate
|
||||
)
|
||||
pump_action_sequence.extend(air_rinsing_actions)
|
||||
debug_print(f" - 添加了 {len(air_rinsing_actions)} 个空气冲洗动作")
|
||||
except Exception as e:
|
||||
debug_print(f"⚠️ 冲洗操作失败: {str(e)},跳过冲洗")
|
||||
debug_print(f"冲洗操作失败: {str(e)},跳过冲洗")
|
||||
else:
|
||||
debug_print(f"⏭️ 跳过冲洗操作")
|
||||
debug_print(f" - 溶剂: '{final_rinsing_solvent}'")
|
||||
debug_print(f" - 次数: {final_rinsing_repeats}")
|
||||
debug_print(f" - 条件满足: {bool(final_rinsing_solvent and final_rinsing_solvent.strip() and final_rinsing_repeats > 0)}")
|
||||
debug_print(f"跳过冲洗操作 (solvent='{final_rinsing_solvent}', repeats={final_rinsing_repeats})")
|
||||
|
||||
# ========== 最终结果 ==========
|
||||
|
||||
debug_print("=" * 60)
|
||||
debug_print(f"🎉 PUMP_TRANSFER: 协议生成完成")
|
||||
debug_print(f" 📊 总动作数: {len(pump_action_sequence)}")
|
||||
debug_print(f" 📋 最终体积: {final_volume}mL")
|
||||
debug_print(f" 🚀 执行路径: {from_vessel_id} -> {to_vessel_id}")
|
||||
debug_print(f"PUMP_TRANSFER 完成: {from_vessel_id} -> {to_vessel_id}, "
|
||||
f"volume={final_volume}mL, 动作数={len(pump_action_sequence)}")
|
||||
|
||||
# 最终验证
|
||||
if len(pump_action_sequence) == 0:
|
||||
debug_print("🚨 协议生成结果为空!这是异常情况")
|
||||
debug_print("协议生成结果为空!")
|
||||
return [
|
||||
{
|
||||
"device_id": "system",
|
||||
"action_name": "log_message",
|
||||
"action_kwargs": {
|
||||
"message": f"🚨 协议生成失败: 无法生成任何动作序列"
|
||||
"message": "协议生成失败: 无法生成任何动作序列"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
debug_print("=" * 60)
|
||||
return pump_action_sequence
|
||||
|
||||
|
||||
def _parse_amount_to_volume(amount: str) -> float:
|
||||
"""解析 amount 字符串为体积"""
|
||||
debug_print(f"🔍 解析 amount: '{amount}'")
|
||||
|
||||
if not amount:
|
||||
debug_print(" - amount 为空,返回 0.0")
|
||||
return 0.0
|
||||
|
||||
amount = amount.lower().strip()
|
||||
debug_print(f" - 处理后的 amount: '{amount}'")
|
||||
|
||||
# 处理特殊关键词
|
||||
if amount == "all":
|
||||
debug_print(" - 检测到 'all',返回 0.0(需要后续处理)")
|
||||
return 0.0 # 返回0.0,让调用者处理
|
||||
|
||||
# 提取数字
|
||||
import re
|
||||
numbers = re.findall(r'[\d.]+', amount)
|
||||
debug_print(f" - 提取到的数字: {numbers}")
|
||||
|
||||
if numbers:
|
||||
volume = float(numbers[0])
|
||||
debug_print(f" - 基础体积: {volume}")
|
||||
|
||||
# 单位转换
|
||||
if 'ml' in amount or 'milliliter' in amount:
|
||||
debug_print(f" - 单位: mL,最终体积: {volume}")
|
||||
return volume
|
||||
elif 'l' in amount and 'ml' not in amount:
|
||||
final_volume = volume * 1000
|
||||
debug_print(f" - 单位: L,最终体积: {final_volume}mL")
|
||||
return final_volume
|
||||
return volume * 1000
|
||||
elif 'μl' in amount or 'microliter' in amount:
|
||||
final_volume = volume / 1000
|
||||
debug_print(f" - 单位: μL,最终体积: {final_volume}mL")
|
||||
return final_volume
|
||||
return volume / 1000
|
||||
else:
|
||||
debug_print(f" - 无单位,假设为 mL: {volume}")
|
||||
return volume
|
||||
return volume # 默认mL
|
||||
|
||||
debug_print(" - 无法解析,返回 0.0")
|
||||
return 0.0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user