Compare commits

...

2 Commits

Author SHA1 Message Date
zhangshixiang
470d7283e4 修改消息转换 2026-01-19 15:15:38 +08:00
zhangshixiang
03f7f44c77 去除“屏蔽开机初始化” 2026-01-19 15:14:20 +08:00
2 changed files with 39 additions and 14 deletions

View File

@@ -442,7 +442,7 @@ class PRCXI9300TubeRack(TubeRack):
# 清理临时数据
del self._temp_ordering
def load_state(self, state: Dict[str, Any]) -> None:
"""从给定的状态加载工作台信息。"""
# super().load_state(state)
@@ -1160,8 +1160,7 @@ class PRCXI9300Backend(LiquidHandlerBackend):
protocol_name = f"protocol_{time.time()}"
self.protocol_name = protocol_name
self.steps_todo_list = []
matrices = self.api_client.matrix_by_id("5de524d0-3f95-406c-86dd-f83626ebc7cb")["WorkTablets"]
if not len(self.matrix_id):
self.matrix_id = str(uuid.uuid4())
@@ -1224,17 +1223,17 @@ class PRCXI9300Backend(LiquidHandlerBackend):
print("PRCXI9300 error code cleared.")
self.api_client.call("IAutomation", "Stop")
# 执行重置
# print("Starting PRCXI9300 reset...")
# self.api_client.call("IAutomation", "Reset")
print("Starting PRCXI9300 reset...")
self.api_client.call("IAutomation", "Reset")
# # 检查重置状态并等待完成
# while not self.is_reset_ok:
# print("Waiting for PRCXI9300 to reset...")
# if hasattr(self, '_ros_node') and self._ros_node is not None:
# await self._ros_node.sleep(1)
# else:
# await asyncio.sleep(1)
# print("PRCXI9300 reset successfully.")
# 检查重置状态并等待完成
while not self.is_reset_ok:
print("Waiting for PRCXI9300 to reset...")
if hasattr(self, '_ros_node') and self._ros_node is not None:
await self._ros_node.sleep(1)
else:
await asyncio.sleep(1)
print("PRCXI9300 reset successfully.")
self.api_client.update_clamp_jaw_position(self.matrix_id, self.plate_positions)

View File

@@ -374,9 +374,35 @@ def convert_to_ros_msg(ros_msg_type: Union[Type, Any], obj: Any) -> Any:
setattr(ros_msg, key, []) # FIXME
elif "array.array" in str(type(attr)):
if attr.typecode == "f" or attr.typecode == "d":
# 如果是单个值,转换为列表
if value is None:
value = []
elif not isinstance(value, Iterable) or isinstance(value, (str, bytes)):
value = [value]
setattr(ros_msg, key, [float(i) for i in value])
else:
setattr(ros_msg, key, value)
# 对于整数数组,需要确保是序列且每个值在有效范围内
if value is None:
value = []
elif not isinstance(value, Iterable) or isinstance(value, (str, bytes)):
# 如果是单个值,转换为列表
value = [value]
# 确保每个整数值在有效范围内(-2147483648 到 2147483647
converted_value = []
for i in value:
if i is None:
continue # 跳过 None 值
if isinstance(i, (int, float)):
int_val = int(i)
# 确保在 int32 范围内
if int_val < -2147483648:
int_val = -2147483648
elif int_val > 2147483647:
int_val = 2147483647
converted_value.append(int_val)
else:
converted_value.append(i)
setattr(ros_msg, key, converted_value)
else:
nested_ros_msg = convert_to_ros_msg(type(attr)(), value)
setattr(ros_msg, key, nested_ros_msg)