mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-04 05:15:10 +00:00
Compare commits
2 Commits
6f600b4fc7
...
470d7283e4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
470d7283e4 | ||
|
|
03f7f44c77 |
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user