action建立连接(主食了开始测量之后的逻辑),add_trasition(调用run_add()函数)加转点。

This commit is contained in:
2026-06-06 18:08:22 +08:00
parent 00091172ee
commit 1e17816a89
10 changed files with 1427 additions and 59 deletions

View File

@@ -24,27 +24,6 @@ import globals.create_link as create_link
class DeviceAutomation:
# def __init__(self, device_id=None):
# # 如果没有提供设备ID则自动获取
# if device_id is None:
# self.device_id = driver_utils.get_device_id()
# else:
# self.device_id = device_id
# # 初始化权限
# if driver_utils.grant_appium_permissions(self.device_id):
# logging.info(f"设备 {self.device_id} 授予Appium权限成功")
# else:
# logging.warning(f"设备 {self.device_id} 授予Appium权限失败")
# # 确保Appium服务器正在运行,不在运行则启动
# if not driver_utils.check_server_status(4723):
# driver_utils.start_appium_server()
# # 初始化Appium驱动和页面对象
# self.init_driver()
# # 创建测试结果目录
# self.results_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_results')
def __init__(self, driver=None, wait=None, device_id=None):
self.driver = driver
self.wait = wait
@@ -213,9 +192,7 @@ class DeviceAutomation:
return False
task_count = 0
max_tasks = 1 # 最大任务数量,防止无限循环
# while task_count < max_tasks:
# 获取测量任务
logging.info(f"设备 {self.device_id} 获取测量任务 (第{task_count + 1}次)")
# task_data = apis.get_measurement_task()
@@ -243,15 +220,9 @@ class DeviceAutomation:
logging.info(f"设备 {self.device_id} 当前要处理的项目名称:{global_variable.GLOBAL_CURRENT_PROJECT_NAME}")
# 执行测量操作
# logging.info(f"设备 {self.device_id} 开始执行测量操作")
if not self.measure_tabbar_page.measure_tabbar_page_manager():
logging.error(f"设备 {self.device_id} 测量操作执行失败")
# # 返回到测量页面
# self.driver.back()
# self.check_and_click_confirm_popup_appium()
# continue # 继续下一个任务
logging.info(f"设备 {self.device_id} 测量页面操作执行成功")
@@ -259,41 +230,33 @@ class DeviceAutomation:
logging.info(f"设备 {self.device_id} 开始执行断面里程配置")
if not self.section_mileage_config_page.section_mileage_config_page_manager():
logging.error(f"设备 {self.device_id} 断面里程配置执行失败")
# continue # 继续下一个任务
# 任务完成后短暂等待
logging.info(f"设备 {self.device_id}{task_count}个任务完成")
task_count += 1
# # +++++++++++++white+++++++++++++++++
# logging.info(f"设备 {self.device_id} 已完成{task_count}个任务,结束打数据流程")
# if task_count == 0:
# logging.error(f"没有完成打数据的线路,结束任务")
# # 执行打数据加转点
# if not self.check_station.run():
# logging.error(f"设备 {self.device_id} 打数据加转点执行失败")
# return False
# 执行打数据加转点
if not self.check_station.run():
logging.error(f"设备 {self.device_id} 打数据加转点执行失败")
return False
# # 执行上传配置管理,传入当前断点名称
# breakpoint_name = global_variable.GLOBAL_CURRENT_PROJECT_NAME
# line_num = global_variable.GLOBAL_LINE_NUM
# if self.upload_config_page.upload_config_page_manager(self.results_dir, breakpoint_name, line_num):
# logging.info(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传成功")
# upload_success_count += 1
# else:
# logging.error(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传失败")
# for i in range(3):
# if self.upload_config_page.upload_config_page_manager(self.results_dir, breakpoint_name, line_num):
# logging.info(f"设备 {self.device_id} 断点 '{breakpoint_name}' 重试上传成功")
# upload_success_count += 1
# break
# else:
# logging.error(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传失败,第 {i+1} 次重试")
# 执行上传配置管理,传入当前断点名称
breakpoint_name = global_variable.GLOBAL_CURRENT_PROJECT_NAME
line_num = global_variable.GLOBAL_LINE_NUM
if self.upload_config_page.upload_config_page_manager(self.results_dir, breakpoint_name, line_num):
logging.info(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传成功")
upload_success_count += 1
else:
logging.error(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传失败")
for i in range(3):
if self.upload_config_page.upload_config_page_manager(self.results_dir, breakpoint_name, line_num):
logging.info(f"设备 {self.device_id} 断点 '{breakpoint_name}' 重试上传成功")
upload_success_count += 1
break
else:
logging.error(f"设备 {self.device_id} 断点 '{breakpoint_name}' 上传失败,第 {i+1} 次重试")
return task_count > 0
# return task_count > 0
except Exception as e:
logging.error(f"设备 {self.device_id} 处理应用状态时出错: {str(e)}")
@@ -314,6 +277,15 @@ if __name__ == "__main__":
logging.info(f"设备 {automation.device_id} 自动化流程执行成功")
else:
logging.error(f"设备 {automation.device_id} 自动化流程执行失败")
# 保持脚本运行,不关闭连接
logging.info("自动化流程执行完成,保持连接状态...")
logging.info("按 Ctrl+C 退出并关闭连接")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
logging.info("用户中断,准备关闭连接...")
except Exception as e:
logging.error(f"设备执行出错: {str(e)}")
finally: