basically done

This commit is contained in:
2025-01-17 13:20:49 +08:00
parent 26f01635df
commit ea05c9bd41
23 changed files with 70 additions and 240170 deletions

View File

@@ -11,7 +11,7 @@ from common import clibs
def check_files(rawdata_dirs, result_files, w2t):
msg_wrong = "需要有四个文件和若干个数据文件夹,可参考如下确认:\n"
msg_wrong += "1. reach33_XXXXXXX.xlsx\n2. reach66_XXXXXXX.xlsx\n3. reach100_XXXXXXX.xlsx\n4. *.cfg\n"
msg_wrong += "- reach33_load33_speed33\nreach33_load33_speed66\n......\nreach100_load100_speed66\nreach100_load100_speed100\n"
msg_wrong += "- reach33_load33_speed33\n- reach33_load33_speed66\n...\n- reach100_load100_speed66\n- reach100_load100_speed100\n"
if len(result_files) != 4 or len(rawdata_dirs) == 0:
w2t(msg_wrong, "red", "InitFileError")
@@ -167,31 +167,14 @@ def single_file_process(data_file, wb, count, av, rr, vel, trq, estop, w2t):
def data_process(result_file, rawdata_dirs, av, rr, vel, trq, estop, w2t):
filename = result_file.split("/")[-1]
clibs.stop = True
w2t(f"正在打开文件 {filename} 需要 1min 左右......\n", "blue")
t_excel = clibs.GetThreadResult(openpyxl.load_workbook, args=(result_file, ))
t_excel.daemon = True
t_excel.start()
t_progress = threading.Thread(target=clibs.tl_prg, args=("Processing......", ))
t_progress.daemon = True
t_progress.start()
wb = t_excel.get_result()
w2t(f"正在打开文件 {filename},这可能需要一些时间......\n", "blue")
wb = openpyxl.load_workbook(result_file)
prefix = filename.split('_')[0]
for rawdata_dir in rawdata_dirs:
if rawdata_dir.split("/")[-1].split('_')[0] == prefix:
now_doing_msg(rawdata_dir, 'start', w2t)
_, data_files = clibs.traversal_files(rawdata_dir, w2t)
# 数据文件串行处理模式---------------------------------
# count = 1
# for data_file in data_files:
# now_doing_msg(data_file, 'start', w2t)
# single_file_process(data_file, wb_result, count, av, rr, vel, trq, estop, w2t)
# count += 1
# now_doing_msg(data_file, 'done', w2t)
# ---------------------------------------------------
# 数据文件并行处理模式---------------------------------
threads = [
threading.Thread(target=single_file_process, args=(data_files[0], wb, 1, av, rr, vel, trq, estop, w2t)),
threading.Thread(target=single_file_process, args=(data_files[1], wb, 2, av, rr, vel, trq, estop, w2t)),
@@ -199,17 +182,11 @@ def data_process(result_file, rawdata_dirs, av, rr, vel, trq, estop, w2t):
]
[t.start() for t in threads]
[t.join() for t in threads]
# ---------------------------------------------------
now_doing_msg(rawdata_dir, 'done', w2t)
w2t(f"正在保存文件 {filename} 需要 1min 左右......\n\n", "blue")
t_excel = threading.Thread(target=wb.save, args=(result_file, ))
t_excel.daemon = True
t_excel.start()
t_excel.join()
w2t(f"正在保存文件 {filename},这可能需要一些时间......\n\n", "blue")
wb.save(result_file)
wb.close()
clibs.stop = False
t_progress.join()
def main():
@@ -224,8 +201,13 @@ def main():
config_file, result_files = check_files(rawdata_dirs, result_files, w2t)
av, rr = get_configs(config_file, w2t)
clibs.stop = True
t_progress = threading.Thread(target=clibs.tl_prg, args=("Processing......", ))
t_progress.daemon = True
t_progress.start()
for result_file in result_files:
data_process(result_file, rawdata_dirs, av, rr, vel, trq, estop, w2t)
clibs.stop = False
w2t("-"*60 + "\n全部处理完毕\n")
time_end = time.time()