[modfiy] prepare for new method of processing brake data
This commit is contained in:
		
							
								
								
									
										33
									
								
								aio/brake.py
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								aio/brake.py
									
									
									
									
									
								
							| @@ -94,31 +94,30 @@ def check_files(raw_data_dirs, result_files, w2t): | |||||||
|     prefix = [] |     prefix = [] | ||||||
|     for result_file in result_files: |     for result_file in result_files: | ||||||
|         prefix.append(result_file.split('\\')[-1].split('_')[0]) |         prefix.append(result_file.split('\\')[-1].split('_')[0]) | ||||||
|     if not sorted(prefix) == sorted(['load33', 'load66', 'load100']): |     if not sorted(prefix) == sorted(['reach33', 'reach66', 'reach100']): | ||||||
|         wd = result_files[0].split('\\') |         wd = result_files[0].split('\\') | ||||||
|         del wd[-1] |         del wd[-1] | ||||||
|         wd = '\\'.join(wd) |         wd = '\\'.join(wd) | ||||||
|         msg = f"""请关闭所有相关数据文件,并检查工作目录 {wd} 下,有且只允许有类似如下三个文件: |         msg = f"""请关闭所有相关数据文件,并检查工作目录 {wd} 下,有且只允许有类似如下三个文件: | ||||||
|               1. load33_自研_制动性能测试.xlsx |               1. reach33_自研_制动性能测试.xlsx | ||||||
|               2. load66_自研_制动性能测试.xlsx |               2. reach66_自研_制动性能测试.xlsx | ||||||
|               3. load100_自研_制动性能测试.xlsx""" |               3. reach100_自研_制动性能测试.xlsx""" | ||||||
|         w2t(msg, 0, 3) |         w2t(msg, 0, 3) | ||||||
|  |  | ||||||
|     for raw_data_dir in raw_data_dirs: |     for raw_data_dir in raw_data_dirs: | ||||||
|         components = raw_data_dir.split('\\')[-1].split('_') |         components = raw_data_dir.split('\\')[-1].split('_') | ||||||
|         sorted(components) |         sorted(components) | ||||||
|         if components[0] not in ['load33', 'load66', 'load100'] or \ |         if components[0] not in ['reach33', 'reach66', 'reach100'] or \ | ||||||
|                 components[1] not in ['speed33', 'speed66', 'speed100'] or \ |                 components[1] not in ['load33', 'load66', 'load100'] or \ | ||||||
|                 components[2] not in ['reach33', 'reach66', 'reach100']: |                 components[2] not in ['speed33', 'speed66', 'speed100']: | ||||||
|             msg = f"报错信息:数据目录 {raw_data_dir} 命名不合规,请参考如下形式\n" \ |             msg = f"""报错信息:数据目录 {raw_data_dir} 命名不合规,请参考如下形式: | ||||||
|                   f"命名规则:\n    1. loadAA_speedBB_reachCC\n    2. loadAA_reachBB_speedCC\n" \ | 命名规则:reachAA_loadBB_speedCC | ||||||
|                   f"规则解释:AA/BB/CC 指的是负载/速度/臂展的比例\n" \ | 规则解释:AA/BB/CC 指的是负载/速度/臂展的比例,例如reach66_load100_speed33:66%臂展,100%负载以及33%速度情况下的测试结果文件夹""" | ||||||
|                   f"load66_speed100_reach33:66% 负载,100% 速度以及 33% 臂展情况下的测试结果文件夹" |  | ||||||
|             w2t(msg, 0, 4) |             w2t(msg, 0, 4) | ||||||
|  |  | ||||||
|         _, raw_data_files = traversal_files(raw_data_dir, w2t) |         _, raw_data_files = traversal_files(raw_data_dir, w2t) | ||||||
|         if len(raw_data_files) != 3: |         if len(raw_data_files) != 3: | ||||||
|             msg = f"数据目录 {raw_data_dir} 下数据文件个数错误,每个数据目录下有且只能有三个以 .data 为后缀的数据文件" |             msg = f"数据目录 {raw_data_dir} 下数据文件个数错误,每个数据目录下有且只能有三个以 .data/csv 为后缀的数据文件" | ||||||
|             w2t(msg, 0, 5) |             w2t(msg, 0, 5) | ||||||
|         for raw_data_file in raw_data_files: |         for raw_data_file in raw_data_files: | ||||||
|             if not (raw_data_file.split('\\')[-1].endswith('.data') or raw_data_file.split('\\')[-1].endswith('.csv')): |             if not (raw_data_file.split('\\')[-1].endswith('.data') or raw_data_file.split('\\')[-1].endswith('.csv')): | ||||||
| @@ -165,7 +164,7 @@ def single_file_process(data_file, wb_result, count, av, rr, axis, vel, trq, w2t | |||||||
|         sep = ',' |         sep = ',' | ||||||
|         df = read_csv(data_file, sep=sep, encoding='gbk', header=8) |         df = read_csv(data_file, sep=sep, encoding='gbk', header=8) | ||||||
|  |  | ||||||
|     conditions = sorted(data_file.split('\\')[-2].split('_')[1:]) |     conditions = sorted(data_file.split('\\')[-2].split('_'))  # ['loadxx', 'reachxx', 'speedxx'] | ||||||
|     result_sheet_name = find_result_sheet_name(conditions, count) |     result_sheet_name = find_result_sheet_name(conditions, count) | ||||||
|     ws_result = wb_result[result_sheet_name] |     ws_result = wb_result[result_sheet_name] | ||||||
|  |  | ||||||
| @@ -209,9 +208,9 @@ def find_result_sheet_name(conditions, count): | |||||||
|     # 参数:臂展和速度的列表 |     # 参数:臂展和速度的列表 | ||||||
|     # 返回值:结果文件对应的sheet name |     # 返回值:结果文件对应的sheet name | ||||||
|     # 33%臂展_33%速度_正1 |     # 33%臂展_33%速度_正1 | ||||||
|     reach = conditions[0].removeprefix('reach') |     load = conditions[0].removeprefix('load') | ||||||
|     speed = conditions[1].removeprefix('speed') |     speed = conditions[2].removeprefix('speed') | ||||||
|     result_sheet_name = f"{reach}%臂展_{speed}%速度_正{count}" |     result_sheet_name = f"{load}%负载_{speed}%速度_正{count}" | ||||||
|  |  | ||||||
|     return result_sheet_name |     return result_sheet_name | ||||||
|  |  | ||||||
| @@ -220,7 +219,7 @@ def find_row_start(data_file, df, conditions, av, rr, axis, vel, w2t, rpm): | |||||||
|     # 功能:查找数据文件中有效数据的行号,也即最后一个速度下降的点位 |     # 功能:查找数据文件中有效数据的行号,也即最后一个速度下降的点位 | ||||||
|     # 参数:如上 |     # 参数:如上 | ||||||
|     # 返回值:速度下降点位,最后的数据点位 |     # 返回值:速度下降点位,最后的数据点位 | ||||||
|     ratio = float(conditions[1].removeprefix('speed'))/100 |     ratio = float(conditions[2].removeprefix('speed'))/100 | ||||||
|     speed_max = av * ratio * rr / 6 |     speed_max = av * ratio * rr / 6 | ||||||
|     row_max = row_start = df.index[-1] |     row_max = row_start = df.index[-1] | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user