[modify] AXIS is int, and add wb_data param in find_row_start() and modify accordingly; also the info of damage of result files
This commit is contained in:
@ -33,7 +33,7 @@ def get_threshold_step(excel_file, AXIS):
|
||||
conditions = sorted(excel_file.split('\\')[-2].split('_'))
|
||||
# 只有负载和速度是100%时,才会启用更敏感的step
|
||||
flg = 1 if conditions[0][-3:] == '100' and conditions[2][-3:] == '100' else 0
|
||||
if flg == 1 and AXIS == 'j2':
|
||||
if flg == 1 and AXIS == 2:
|
||||
threshold = 30
|
||||
step = 5
|
||||
else:
|
||||
@ -43,7 +43,7 @@ def get_threshold_step(excel_file, AXIS):
|
||||
return threshold, step
|
||||
|
||||
|
||||
def find_row_start(excel_file, ws_data, conditions, AV, RR, AXIS):
|
||||
def find_row_start(excel_file, wb_data, ws_data, conditions, AV, RR, AXIS):
|
||||
# 功能:查找数据文件中有效数据的行号,也即最后一个速度下降的点位
|
||||
# 参数:如上
|
||||
# 返回值:速度下降点位,最后的数据点位
|
||||
@ -57,16 +57,19 @@ def find_row_start(excel_file, ws_data, conditions, AV, RR, AXIS):
|
||||
if speed is None or int(speed) < 1:
|
||||
row_start -= 50
|
||||
continue
|
||||
|
||||
_ = []
|
||||
for i in range(row_start, row_start-step+1, -1):
|
||||
_.append(ws_data[f"A{i}"].value)
|
||||
speed_avg = abs(sum(_))/len(_)
|
||||
|
||||
if abs(speed_avg-speed_max) < threshold:
|
||||
row_start = row_start - 10
|
||||
break
|
||||
else:
|
||||
row_start -= step
|
||||
else:
|
||||
wb_data.close()
|
||||
os.remove(excel_file)
|
||||
msg = f"可能是{excel_file.replace('xlsx', 'data')},这个文件数据采集有问题,比如采集的时机不对,也有可能是程序步长设定问题,请检查......"
|
||||
warn_pause_exit(msg, 1, 9)
|
||||
@ -124,7 +127,7 @@ def single_file_process(data_file, wb_result, count, AV, RR, RC, AXIS):
|
||||
|
||||
wb_data = openpyxl.load_workbook(excel_file)
|
||||
ws_data = wb_data[sheet_name]
|
||||
row_max, row_start = find_row_start(excel_file, ws_data, conditions, AV, RR, AXIS)
|
||||
row_max, row_start = find_row_start(excel_file, wb_data, ws_data, conditions, AV, RR, AXIS)
|
||||
|
||||
copy_data_to_result(ws_data, ws_result, row_max, row_start)
|
||||
ws_result["C2"] = int(2)
|
||||
@ -308,7 +311,7 @@ def execution(args):
|
||||
print("全部处理完毕")
|
||||
delete_excel_files(raw_data_dirs)
|
||||
except Exception as Err:
|
||||
print("程序运行错误,请检查配置文件是否准确设定,以及数据文件组织是否正确!")
|
||||
print("程序运行错误,请检查配置文件是否准确设定,以及数据文件组织是否正确,也有可能是结果文件损坏,尝试重新复制一份,再运行!")
|
||||
delete_excel_files(raw_data_dirs)
|
||||
|
||||
time_end = time.time()
|
||||
|
Reference in New Issue
Block a user