diff --git a/aio/brake.py b/aio/brake.py index bdfce1d..9aacb3f 100644 --- a/aio/brake.py +++ b/aio/brake.py @@ -94,31 +94,30 @@ def check_files(raw_data_dirs, result_files, w2t): prefix = [] for result_file in result_files: 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('\\') del wd[-1] wd = '\\'.join(wd) msg = f"""请关闭所有相关数据文件,并检查工作目录 {wd} 下,有且只允许有类似如下三个文件: - 1. load33_自研_制动性能测试.xlsx - 2. load66_自研_制动性能测试.xlsx - 3. load100_自研_制动性能测试.xlsx""" + 1. reach33_自研_制动性能测试.xlsx + 2. reach66_自研_制动性能测试.xlsx + 3. reach100_自研_制动性能测试.xlsx""" w2t(msg, 0, 3) for raw_data_dir in raw_data_dirs: components = raw_data_dir.split('\\')[-1].split('_') sorted(components) - if components[0] not in ['load33', 'load66', 'load100'] or \ - components[1] not in ['speed33', 'speed66', 'speed100'] or \ - components[2] not in ['reach33', 'reach66', 'reach100']: - msg = f"报错信息:数据目录 {raw_data_dir} 命名不合规,请参考如下形式\n" \ - f"命名规则:\n 1. loadAA_speedBB_reachCC\n 2. loadAA_reachBB_speedCC\n" \ - f"规则解释:AA/BB/CC 指的是负载/速度/臂展的比例\n" \ - f"load66_speed100_reach33:66% 负载,100% 速度以及 33% 臂展情况下的测试结果文件夹" + if components[0] not in ['reach33', 'reach66', 'reach100'] or \ + components[1] not in ['load33', 'load66', 'load100'] or \ + components[2] not in ['speed33', 'speed66', 'speed100']: + msg = f"""报错信息:数据目录 {raw_data_dir} 命名不合规,请参考如下形式: +命名规则:reachAA_loadBB_speedCC +规则解释:AA/BB/CC 指的是负载/速度/臂展的比例,例如reach66_load100_speed33:66%臂展,100%负载以及33%速度情况下的测试结果文件夹""" w2t(msg, 0, 4) _, raw_data_files = traversal_files(raw_data_dir, w2t) if len(raw_data_files) != 3: - msg = f"数据目录 {raw_data_dir} 下数据文件个数错误,每个数据目录下有且只能有三个以 .data 为后缀的数据文件" + msg = f"数据目录 {raw_data_dir} 下数据文件个数错误,每个数据目录下有且只能有三个以 .data/csv 为后缀的数据文件" w2t(msg, 0, 5) 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')): @@ -165,7 +164,7 @@ def single_file_process(data_file, wb_result, count, av, rr, axis, vel, trq, w2t sep = ',' 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) ws_result = wb_result[result_sheet_name] @@ -209,9 +208,9 @@ def find_result_sheet_name(conditions, count): # 参数:臂展和速度的列表 # 返回值:结果文件对应的sheet name # 33%臂展_33%速度_正1 - reach = conditions[0].removeprefix('reach') - speed = conditions[1].removeprefix('speed') - result_sheet_name = f"{reach}%臂展_{speed}%速度_正{count}" + load = conditions[0].removeprefix('load') + speed = conditions[2].removeprefix('speed') + result_sheet_name = f"{load}%负载_{speed}%速度_正{count}" 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 row_max = row_start = df.index[-1]