mirror of
https://github.com/deepmodeling/Uni-Lab-OS
synced 2026-04-27 01:23:31 +00:00
feat: 更新Neware电池测试系统驱动及电芯组装工作站相关文件
- 更新 neware_battery_test_system 驱动及设备配置 - 新增 generate_xml_content.py 工具脚本 - 更新 bioyond_cell_workstation 工作站实现 - 更新 coin_cell_assembly 扣式电池组装逻辑 - 更新相关注册表 YAML 配置:neware_battery_test_system、coin_cell_workstation、bioyond_cell
This commit is contained in:
@@ -1039,7 +1039,11 @@ class BioyondCellWorkstation(BioyondWorkstation):
|
||||
logger.warning(f"[create_orders_formulation] 第 {idx + 1} 个配方无有效物料,跳过")
|
||||
continue
|
||||
|
||||
item_mix_time = mix_time[idx] if idx < len(mix_time) else 0
|
||||
raw_mix_time = mix_time[idx] if idx < len(mix_time) else None
|
||||
try:
|
||||
item_mix_time = int(raw_mix_time) if raw_mix_time not in (None, "", "null") else 0
|
||||
except (ValueError, TypeError):
|
||||
item_mix_time = 0
|
||||
logger.info(f"[create_orders_formulation] 第 {idx + 1} 个配方: orderName={order_name}, "
|
||||
f"coinCellVolume={coin_cell_volume}, pouchCellVolume={pouch_cell_volume}, "
|
||||
f"conductivityVolume={conductivity_volume}, totalMass={total_mass}, "
|
||||
|
||||
@@ -161,7 +161,9 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
||||
logger.info("没有传入依华deck,检查启动json文件")
|
||||
super().__init__(deck=deck, *args, **kwargs,)
|
||||
self.debug_mode = debug_mode
|
||||
|
||||
self._modbus_address = address
|
||||
self._modbus_port = port
|
||||
|
||||
""" 连接初始化 """
|
||||
modbus_client = TCPClient(addr=address, port=port)
|
||||
logger.debug(f"创建 Modbus 客户端: {modbus_client}")
|
||||
@@ -178,9 +180,11 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
||||
raise ValueError('modbus tcp connection failed')
|
||||
self.nodes = BaseClient.load_csv(os.path.join(os.path.dirname(__file__), 'coin_cell_assembly_b.csv'))
|
||||
self.client = modbus_client.register_node_list(self.nodes)
|
||||
self._modbus_client_raw = modbus_client
|
||||
else:
|
||||
print("测试模式,跳过连接")
|
||||
self.nodes, self.client = None, None
|
||||
self._modbus_client_raw = None
|
||||
|
||||
""" 工站的配置 """
|
||||
|
||||
@@ -191,6 +195,32 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
||||
self.csv_export_file = None
|
||||
self.coin_num_N = 0 #已组装电池数量
|
||||
|
||||
def _ensure_modbus_connected(self) -> None:
|
||||
"""检查 Modbus TCP 连接是否存活,若已断开则自动重连(防止长时间空闲后连接超时)"""
|
||||
if self.debug_mode or self._modbus_client_raw is None:
|
||||
return
|
||||
raw_client = self._modbus_client_raw.client
|
||||
if raw_client.is_socket_open():
|
||||
return
|
||||
logger.warning("[Modbus] 检测到连接已断开,尝试重连...")
|
||||
try:
|
||||
raw_client.close()
|
||||
except Exception:
|
||||
pass
|
||||
count = 10
|
||||
while count > 0:
|
||||
count -= 1
|
||||
try:
|
||||
raw_client.connect()
|
||||
except Exception:
|
||||
pass
|
||||
if raw_client.is_socket_open():
|
||||
break
|
||||
time.sleep(2)
|
||||
if not raw_client.is_socket_open():
|
||||
raise RuntimeError(f"Modbus TCP 重连失败({self._modbus_address}:{self._modbus_port}),请检查设备连接")
|
||||
logger.info("[Modbus] 重连成功")
|
||||
|
||||
def post_init(self, ros_node: ROS2WorkstationNode):
|
||||
self._ros_node = ros_node
|
||||
|
||||
@@ -1056,6 +1086,7 @@ class CoinCellAssemblyWorkstation(WorkstationBase):
|
||||
|
||||
# 步骤0: 前置条件检查
|
||||
logger.info("\n【步骤 0/4】前置条件检查...")
|
||||
self._ensure_modbus_connected()
|
||||
try:
|
||||
# 检查 REG_UNILAB_INTERACT (应该为False,表示使用Unilab交互)
|
||||
unilab_interact_node = self.client.use_node('REG_UNILAB_INTERACT')
|
||||
|
||||
Reference in New Issue
Block a user