From 97ba8ffc51b2d9697bbd8cafa6e78ff65b7900ca Mon Sep 17 00:00:00 2001 From: gitea Date: Wed, 5 Jun 2024 21:27:11 +0800 Subject: [PATCH] [modify] support single axis cycle data process --- aio/aio.py | 197 +++++++++++++++++++++++++++++++++--------------- aio/current.py | 188 +++++++++++++++++++++++++++++++++++++++------ aio/layout.xlsx | Bin 10323 -> 10272 bytes 3 files changed, 300 insertions(+), 85 deletions(-) diff --git a/aio/aio.py b/aio/aio.py index 2e7d441..93e14eb 100644 --- a/aio/aio.py +++ b/aio/aio.py @@ -24,17 +24,12 @@ class App(customtkinter.CTk): # configure window self.title("AIO - All in one automatic toolbox") # self.iconbitmap('./icon.ico') - # screen_width = self.winfo_screenwidth() - # screen_height = self.winfo_screenheight() - # width = screen_width - 200 - # height = screen_height - 200 - # self.geometry(f"{width}x{height}+{100}+{100}") - self.geometry("1100x500+100+100") + self.geometry("1180x550+100+100") self.protocol("WM_DELETE_WINDOW", self.func_end_call_back) - self.grid_rowconfigure(3, weight=1) - self.grid_columnconfigure((1, 2, 3, 4, 5, 6, 7, 8, 9), weight=1) - self.minsize(1100, 500) + self.grid_rowconfigure(4, weight=1) + self.grid_columnconfigure((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), weight=1) + self.minsize(1180, 550) # ===================================================================== # create frame sidebar(left) @@ -62,8 +57,8 @@ class App(customtkinter.CTk): # ===================================================================== # create frame - self.frame_param = customtkinter.CTkFrame(self, height=240, corner_radius=10) - self.frame_param.grid(row=0, column=1, rowspan=3, columnspan=11, sticky='new', ipadx=20, ipady=10, padx=10, pady=(10, 5)) + self.frame_param = customtkinter.CTkFrame(self, corner_radius=10) + self.frame_param.grid(row=0, column=1, rowspan=3, columnspan=13, sticky='new', ipadx=20, ipady=10, padx=10, pady=(10, 5)) # create main menu self.menu_main = customtkinter.CTkOptionMenu(self.frame_param, values=["INIT", "brake", "current", "iso"], font=self.my_font, command=self.func_main_callback) self.menu_main.grid(row=0, column=1, sticky='we', padx=(20, 10), pady=(10, 5)) @@ -74,7 +69,7 @@ class App(customtkinter.CTk): self.label_path = customtkinter.CTkLabel(self.frame_param, text="Path", font=self.my_font) self.label_path.grid(row=0, column=2, sticky='e', pady=(10, 5)) self.entry_path = customtkinter.CTkEntry(self.frame_param, width=670, placeholder_text="数据文件夹路径", font=self.my_font) - self.entry_path.grid(row=0, column=3, columnspan=9, padx=(5, 10), pady=(10, 5), sticky='we') + self.entry_path.grid(row=0, column=3, columnspan=11, padx=(5, 10), pady=(10, 5), sticky='we') self.entry_path.configure(state='disabled') # create av related self.label_av = customtkinter.CTkLabel(self.frame_param, text="AV", font=self.my_font) @@ -124,10 +119,52 @@ class App(customtkinter.CTk): self.option_trq = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font) self.option_trq.grid(row=2, column=7, padx=(5, 10), pady=(5, 5), sticky='w') self.option_trq.configure(state='disabled') + # create trqH related + self.label_trqh = customtkinter.CTkLabel(self.frame_param, text="TrqH", font=self.my_font) + self.label_trqh.grid(row=2, column=8, sticky='e', pady=(5, 5)) + self.option_trqh = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font) + self.option_trqh.grid(row=2, column=9, padx=(5, 10), pady=(5, 5), sticky='w') + self.option_trqh.configure(state='disabled') + # create STO related + self.label_sto = customtkinter.CTkLabel(self.frame_param, text="STO", font=self.my_font) + self.label_sto.grid(row=2, column=10, sticky='e', pady=(5, 5)) + self.option_sto = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font) + self.option_sto.grid(row=2, column=11, padx=(5, 10), pady=(5, 5), sticky='w') + self.option_sto.configure(state='disabled') + # create rc1 + self.label_rc_1 = customtkinter.CTkLabel(self.frame_param, text="RC1", font=self.my_font) + self.label_rc_1.grid(row=3, column=2, sticky='e', pady=(5, 5)) + self.entry_rc_1 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font) + self.entry_rc_1.grid(row=3, column=3, padx=(5, 10), pady=(5, 5), sticky='w') + + self.label_rc_2 = customtkinter.CTkLabel(self.frame_param, text="RC2", font=self.my_font) + self.label_rc_2.grid(row=3, column=4, sticky='e', pady=(5, 5)) + self.entry_rc_2 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font) + self.entry_rc_2.grid(row=3, column=5, padx=(5, 10), pady=(5, 5), sticky='w') + + self.label_rc_3 = customtkinter.CTkLabel(self.frame_param, text="RC3", font=self.my_font) + self.label_rc_3.grid(row=3, column=6, sticky='e', pady=(5, 5)) + self.entry_rc_3 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font) + self.entry_rc_3.grid(row=3, column=7, padx=(5, 10), pady=(5, 5), sticky='w') + + self.label_rc_4 = customtkinter.CTkLabel(self.frame_param, text="RC4", font=self.my_font) + self.label_rc_4.grid(row=3, column=8, sticky='e', pady=(5, 5)) + self.entry_rc_4 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font) + self.entry_rc_4.grid(row=3, column=9, padx=(5, 10), pady=(5, 5), sticky='w') + + self.label_rc_5 = customtkinter.CTkLabel(self.frame_param, text="RC5", font=self.my_font) + self.label_rc_5.grid(row=3, column=10, sticky='e', pady=(5, 5)) + self.entry_rc_5 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font) + self.entry_rc_5.grid(row=3, column=11, padx=(5, 10), pady=(5, 5), sticky='w') + + self.label_rc_6 = customtkinter.CTkLabel(self.frame_param, text="RC6", font=self.my_font) + self.label_rc_6.grid(row=3, column=12, sticky='e', pady=(5, 5)) + self.entry_rc_6 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font) + self.entry_rc_6.grid(row=3, column=13, padx=(5, 10), pady=(5, 5), sticky='w') # ===================================================================== # create textbox - self.textbox = customtkinter.CTkTextbox(self, height=640, wrap='none', font=customtkinter.CTkFont(family="consolas", size=14), text_color="blue") - self.textbox.grid(row=3, column=1, rowspan=5, columnspan=15, ipadx=10, ipady=10, padx=10, pady=(5, 10), sticky='nsew') + self.textbox = customtkinter.CTkTextbox(self, wrap='none', font=customtkinter.CTkFont(family="consolas", size=14), text_color="blue") + self.textbox.grid(row=4, column=1, rowspan=3, columnspan=13, ipadx=10, ipady=10, padx=10, pady=(5, 10), sticky='nsew') self.textbox.configure(state='disabled') # ===================================================================== # version check @@ -157,6 +194,14 @@ class App(customtkinter.CTk): self.label_axis.configure(text="AXIS", text_color="black") self.label_vel.configure(text="Vel", text_color="black") self.label_trq.configure(text="Trq", text_color="black") + self.label_trqh.configure(text="TrqH", text_color="black") + self.label_sto.configure(text="STO", text_color="black") + self.label_rc_1.configure(text="RC1", text_color="black") + self.label_rc_2.configure(text="RC2", text_color="black") + self.label_rc_3.configure(text="RC3", text_color="black") + self.label_rc_4.configure(text="RC4", text_color="black") + self.label_rc_5.configure(text="RC5", text_color="black") + self.label_rc_6.configure(text="RC6", text_color="black") self.entry_path.configure(placeholder_text="数据文件夹路径", state="disabled") self.entry_av.configure(placeholder_text="角速度", state="disabled") @@ -167,6 +212,14 @@ class App(customtkinter.CTk): self.option_axis.configure(state="disabled") self.option_vel.configure(state="disabled") self.option_trq.configure(state="disabled") + self.option_trqh.configure(state="disabled") + self.option_sto.configure(state="disabled") + self.entry_rc_1.configure(placeholder_text="optional", state="disabled") + self.entry_rc_2.configure(placeholder_text="optional", state="disabled") + self.entry_rc_3.configure(placeholder_text="optional", state="disabled") + self.entry_rc_4.configure(placeholder_text="optional", state="disabled") + self.entry_rc_5.configure(placeholder_text="optional", state="disabled") + self.entry_rc_6.configure(placeholder_text="optional", state="disabled") self.menu_sub.grid_forget() self.textbox.delete(index1='1.0', index2='end') @@ -180,12 +233,12 @@ class App(customtkinter.CTk): self.menu_sub.grid(row=1, column=1, sticky='we', padx=(20, 10), pady=(5, 5)) self.menu_sub.set("--select--") - self.label_path.configure(text="*Path", text_color='red') - self.label_av.configure(text="*AV", text_color='red') - self.label_rr.configure(text="*RR", text_color='red') - self.label_axis.configure(text="*AXIS", text_color='red') - self.label_vel.configure(text="*Vel", text_color='red') - self.label_trq.configure(text="*Trq", text_color='red') + self.label_path.configure(text="Path", text_color='red') + self.label_av.configure(text="AV", text_color='red') + self.label_rr.configure(text="RR", text_color='red') + self.label_axis.configure(text="AXIS", text_color='red') + self.label_vel.configure(text="Vel", text_color='red') + self.label_trq.configure(text="Trq", text_color='red') self.entry_path.configure(state="normal") self.entry_av.configure(state="normal") @@ -199,22 +252,36 @@ class App(customtkinter.CTk): self.menu_sub.grid(row=1, column=1, sticky='we', padx=(20, 10), pady=(5, 5)) self.menu_sub.set("--select--") - self.label_path.configure(text="*Path", text_color='red') - self.label_rc.configure(text="*RC", text_color='red') - self.label_trq.configure(text="*Trq", text_color='red') + self.label_path.configure(text="Path", text_color='red') + self.label_rc.configure(text="RC", text_color='blue') + self.label_trqh.configure(text="TrqH", text_color='red') + self.label_rc_1.configure(text="RC1", text_color='red') + self.label_rc_2.configure(text="RC2", text_color='red') + self.label_rc_3.configure(text="RC3", text_color='red') + self.label_rc_4.configure(text="RC4", text_color='red') + self.label_rc_5.configure(text="RC5", text_color='red') + self.label_rc_6.configure(text="RC6", text_color='red') self.entry_path.configure(state="normal") - self.entry_rc.configure(state="normal") - self.option_trq.configure(state="normal") + self.entry_rc.configure(state="normal", placeholder_text="optional") + self.option_trqh.configure(state="normal") + self.entry_rc_1.configure(state="normal", placeholder_text="额定电流") + self.entry_rc_2.configure(state="normal", placeholder_text="额定电流") + self.entry_rc_3.configure(state="normal", placeholder_text="额定电流") + self.entry_rc_4.configure(state="normal", placeholder_text="额定电流") + self.entry_rc_5.configure(state="normal", placeholder_text="额定电流") + self.entry_rc_6.configure(state="normal", placeholder_text="额定电流") + elif func_name == 'iso': - self.label_path.configure(text="*Path", text_color='red') + self.label_path.configure(text="Path", text_color='red') self.entry_path.configure(state="normal") + else: self.initialization() self.menu_main.set("Start Here!") def func_sub_callback(self, func_name): if func_name == "industrial": - self.label_rpm.configure(text="*RPM", text_color='red') + self.label_rpm.configure(text="RPM", text_color='red') self.entry_rpm.configure(state="normal") elif func_name == "cobot": self.label_rpm.configure(text="RPM", text_color='black') @@ -224,16 +291,22 @@ class App(customtkinter.CTk): self.entry_dur.configure(state="disabled") self.label_vel.configure(text="Vel", text_color='black') self.option_vel.configure(state="disabled") + self.label_trq.configure(text="Trq", text_color='black') + self.option_trq.configure(state="disabled") elif func_name == 'avg': self.label_dur.configure(text="Dur", text_color='black') self.entry_dur.configure(state="disabled") self.label_vel.configure(text="Vel", text_color='black') self.option_vel.configure(state="disabled") + self.label_trq.configure(text="Trq", text_color='black') + self.option_trq.configure(state="disabled") elif func_name == 'cycle': - self.label_dur.configure(text="*Dur", text_color='red') - self.entry_dur.configure(state="normal") - self.label_vel.configure(text="*Vel", text_color='red') + self.label_dur.configure(text="Dur", text_color='blue') + self.entry_dur.configure(state="normal", placeholder_text='scenario') + self.label_vel.configure(text="Vel", text_color='red') self.option_vel.configure(state="normal") + self.label_trq.configure(text="Trq", text_color='red') + self.option_trq.configure(state="normal") def write2textbox(self, text, wait=0, exitcode=0): @@ -247,6 +320,7 @@ class App(customtkinter.CTk): self.textbox.insert(index='end', text=text + '\n') self.textbox.update() self.textbox.see('end') + self.textbox.configure(state='disabled') raise Exception(f"Error code: {exitcode}") else: self.textbox.configure(text_color='blue') @@ -254,6 +328,19 @@ class App(customtkinter.CTk): self.textbox.update() self.textbox.see('end') + def is_float(self, flag, *args): + for item in args: + try: + if flag == 'optional': + item = 0 if item == '' else item + _ = float(item) + elif flag == 'required': + _ = float(item) + except Exception as Err: + self.write2textbox(str(Err)) + self.write2textbox("参数数据缺失,或者数据类型错误,更正后重新运行...", 0, 3) + return True + def check_param(self): func_name = self.menu_main.get() if func_name == 'brake': @@ -266,12 +353,7 @@ class App(customtkinter.CTk): sub_func = self.menu_sub.get() c1 = exists(path) - try: - _a = float(av) - _b = float(rr) - c2 = True - except: - c2 = False + c2 = self.is_float(av, rr) c3 = rpm = 1 c4 = sub_func in ['industrial', 'cobot'] c5 = True if vel != trq else False @@ -295,35 +377,32 @@ class App(customtkinter.CTk): dur = self.entry_dur.get() vel = self.option_vel.get() trq = self.option_trq.get() + trqh = self.option_trqh.get() sub = self.menu_sub.get() + rc1 = self.entry_rc_1.get() + rc2 = self.entry_rc_2.get() + rc3 = self.entry_rc_3.get() + rc4 = self.entry_rc_4.get() + rc5 = self.entry_rc_5.get() + rc6 = self.entry_rc_6.get() + c1 = exists(path) c2 = sub in ['max', 'avg', 'cycle'] + c3 = self.is_float('optional', rc) + _ = [rc1, rc2, rc3, rc4, rc5, rc6] + c4 = self.is_float('required', *_) - rcs = rc.split() - for _ in rcs: - try: - _t = float(_) - except: - c3 = False - break - else: - c3 = True - - c4 = c5 = True + c5 = c6 = True if sub == 'cycle': - try: - _ = float(dur) - c4 = True - except: - c4 = False c5 = True if vel != trq else False + c6 = self.is_float('optional', dur) - if c1 and c2 and c3 and c4 and c5: + if c1 and c2 and c3 and c4 and c5 and c6: rcs = [] - for x in rc.split(): + for x in _: rcs.append(float(x)) - dur = 0 if sub != 'cycle' else dur - return 2, path, sub, rcs, int(vel), int(trq), float(dur) + dur = 0 if sub != 'cycle' or dur == '' else dur + return 2, path, sub, rcs, int(vel), int(trq), int(trqh), float(dur) else: return 0, 0 # ======================================================= @@ -348,7 +427,7 @@ class App(customtkinter.CTk): func_dict[flag](path=args[0], av=args[1], rr=args[2], rpm=args[3], axis=args[4], vel=args[5], trq=args[6], w2t=self.write2textbox) elif flag == 2: # tkinter.messagebox.showinfo(title="TBD", message="功能待实现......") - func_dict[flag](path=args[0], sub=args[1], rc=args[2], vel=args[3], trq=args[4], dur=args[5], w2t=self.write2textbox) + func_dict[flag](path=args[0], sub=args[1], rcs=args[2], vel=args[3], trq=args[4], trqh=args[5], dur=args[6], w2t=self.write2textbox) elif flag == 3: func_dict[flag](path=args[0], w2t=self.write2textbox) else: @@ -382,12 +461,8 @@ class App(customtkinter.CTk): def func_end_call_back(self): if tkinter.messagebox.askyesno(title="关闭程序", message="相关数据可能未保存,正在运行程序时有概率会损坏数据文件,确定要终止程序运行吗?"): self.destroy() - else: - pass - pass if __name__ == "__main__": - aio = App() aio.mainloop() diff --git a/aio/current.py b/aio/current.py index 9d38c7d..b93240d 100644 --- a/aio/current.py +++ b/aio/current.py @@ -3,6 +3,37 @@ from os import scandir from os.path import exists from sys import argv from pandas import read_csv +from re import match +from threading import Thread +from time import sleep + +class GetThreadResult(Thread): + def __init__(self, func, args=()): + super(GetThreadResult, self).__init__() + self.func = func + self.args = args + self.result = 0 + + def run(self): + sleep(1) + self.result = self.func(*self.args) + + def get_result(self): + Thread.join(self) # 等待线程执行完毕 + try: + return self.result + except Exception as Err: + return None + + +def w2t_local(msg, wait, w2t): + while True: + global stop + if stop == 0 and wait != 0: + sleep(1) + w2t(msg, wait) + else: + break def traversal_files(path, w2t): @@ -27,16 +58,18 @@ def traversal_files(path, w2t): def initialization(path, sub, w2t): _, data_files = traversal_files(path, w2t) count = 0 + for data_file in data_files: + filename = data_file.split('\\')[-1] if sub != 'cycle': - if not (data_file.endswith('.data') or data_file.endswith('.csv')): - msg = f"所有文件必须以 .data 结尾,请检查后重新运行。" + if not (match('j[1-7].*\\.data', filename) or match('j[1-7].*\\.csv', filename)): + msg = f"所有文件必须以 jx_ 开头,以 .data/csv 结尾(x取值1-7),请检查后重新运行。" w2t(msg, 0, 2) else: - if data_file.endswith('.xlsx'): + if filename.endswith('.xlsx'): count += 1 - elif not (data_file.endswith('.data') or data_file.endswith('.csv')): - msg = f"所有文件必须以 .data 结尾,请检查后重新运行。" + elif not (match('j[1-7].*\\.data', filename) or match('j[1-7].*\\.csv', filename)): + msg = f"所有文件必须以 jx_ 开头,以 .data/csv 结尾(x取值1-7),请检查后重新运行。" w2t(msg, 0, 3) if sub == 'cycle' and count != 1: @@ -45,7 +78,7 @@ def initialization(path, sub, w2t): return data_files -def current_max(data_files, rc, trq, w2t): +def current_max(data_files, rcs, trqh, w2t): current = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0} for data_file in data_files: if data_file.endswith('.data'): @@ -54,9 +87,9 @@ def current_max(data_files, rc, trq, w2t): df = read_csv(data_file, sep=',', encoding='gbk', header=8) axis = int(data_file.split('\\')[-1].split('_')[0].removeprefix('j')) - rca = rc[axis-1] + rca = rcs[axis-1] - col = df.columns.values[trq-1] + col = df.columns.values[trqh-1] c_max = df[col].max() scale = 1 if data_file.endswith('.csv') else 1000 @@ -68,7 +101,7 @@ def current_max(data_files, rc, trq, w2t): return current -def current_avg(data_files, rc, trq, w2t): +def current_avg(data_files, rcs, trqh, w2t): current = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0} for data_file in data_files: if data_file.endswith('.data'): @@ -77,9 +110,9 @@ def current_avg(data_files, rc, trq, w2t): df = read_csv(data_file, sep=',', encoding='gbk', header=8) axis = int(data_file.split('\\')[-1].split('_')[0].removeprefix('j')) - rca = rc[axis-1] + rca = rcs[axis-1] - col = df.columns.values[trq - 1] + col = df.columns.values[trqh - 1] c_std = df[col].std() c_avg = df[col].mean() @@ -92,46 +125,153 @@ def current_avg(data_files, rc, trq, w2t): return current -def current_cycle(dur, data_files, rc, vel, trq, w2t): +def current_cycle(dur, data_files, rcs, vel, trq, trqh, w2t): result = None hold = [] single = [] for data_file in data_files: + filename = data_file.split('\\')[-1] if data_file.endswith('.xlsx'): result = data_file - elif (data_file.endswith('.csv') or data_file.endswith('.data')) and data_file.startswith('hold', 3, 10): + elif match('j[1-7]_hold_.*\\.data', filename) or match('j[1-7]_hold_.*\\.csv', filename): hold.append(data_file) else: single.append(data_file) + w2t(f"正在打开文件 {result},需要 10s 左右", 1) + + global stop + stop = 0 + t_excel = GetThreadResult(load_workbook, args=(result, )) + t_wait = Thread(target=w2t_local, args=('.', 1, w2t)) + t_excel.start() + t_wait.start() + t_excel.join() + wb = t_excel.get_result() + stop = 1 + sleep(1.1) + w2t('') + if hold != []: - avg = current_avg(hold, rc, trq, w2t) - wb = load_workbook(result) - for k, v in avg.items(): + avg = current_avg(hold, rcs, trqh, w2t) + for axis, cur_value in avg.items(): try: - shtname = f"J{k}" - wb[shtname]["J4"].value = v + shtname = f"J{axis}" + wb[shtname]["J4"].value = float(cur_value) except: pass + if dur == 0: + p_single(wb, single, vel, trq, w2t) + else: + p_scenario() + + w2t(f"正在保存文件 {result},需要 10s 左右", 1) + stop = 0 + t_excel = Thread(target=wb.save, args=(result, )) + t_wait = Thread(target=w2t_local, args=('.', 1, w2t)) + t_excel.start() + t_wait.start() + t_excel.join() + stop = 1 + sleep(1.1) + w2t('\n') + w2t("----------------------------------------------------------") + w2t("全部处理完毕") + + +def p_single(wb, single, vel, trq, w2t): + # 1. 先找到第一个速度为零的点,数据从后往前找,一开始就是零的情况不予考虑 + # 2. 记录第一个点的位置,继续向前查找第二个速度为零的点,同理,一开始为零的点不予考虑 + # 3. 记录第二个点的位置,并将其中的数据拷贝至对应位置 for data_file in single: axis = int(data_file.split('\\')[-1].split('_')[0].removeprefix('j')) - rcs = rc[axis-1] - pass + shtname = f"J{axis}" + ws = wb[shtname] + + if data_file.endswith('.data'): + df = read_csv(data_file, sep='\t') + elif data_file.endswith('.csv'): + df = read_csv(data_file, sep=',', encoding='gbk', header=8) + + # 过滤尾部无效数据 + _row_e = df.index[-1] + _row_s = _row_e - 200 + while _row_e > 200: + speed_avg = df.iloc[_row_s:_row_e, vel-1].abs().mean() + if speed_avg > 2: + _row_e -= 50 + _row_s -= 50 + continue + else: + break + else: + w2t("数据有误,需要检查,无法找到第一个有效起始点...", 0, 1) + + # 找到第一个起始点 row_end,继续找到有数据的部分 + row_end = _row_e - 100 + _row_e -= 200 + _row_s -= 200 + while _row_e > 200: + speed_avg = df.iloc[_row_s:_row_e, vel-1].abs().mean() + if speed_avg < 2: + _row_e -= 50 + _row_s -= 50 + continue + else: + break + else: + w2t("数据有误,需要检查,无法找到第二个有效起始点...", 0, 2) + + # 目前已经有一点的速度值了,继续往前搜寻下一个速度为零的点 + _row_e -= 200 + _row_s -= 200 + while _row_e > 200: + speed_avg = df.iloc[_row_s:_row_e, vel-1].abs().mean() + if speed_avg > 2: + _row_e -= 50 + _row_s -= 50 + continue + else: + break + else: + w2t("数据有误,需要检查,无法找到第三个有效起始点...", 0, 3) + + row_start = _row_s + 180 + data = [] + for row in range(row_start, row_end): + data.append(df.iloc[row, vel-1]) + data.append(df.iloc[row, trq-1]) + + i = 0 + for row in ws.iter_rows(min_row=2, min_col=2, max_row=15000, max_col=3): + for cell in row: + try: + cell.value = data[i] + i += 1 + except: + cell.value = None + + +def p_scenario(): + pass + + # ======================================= -def main(path, sub, rc, vel, trq, dur, w2t): +def main(path, sub, rcs, vel, trq, trqh, dur, w2t): data_files = initialization(path, sub, w2t) if sub == 'max': - current_max(data_files, rc, trq, w2t) + current_max(data_files, rcs, trqh, w2t) elif sub == 'avg': - current_avg(data_files, rc, trq, w2t) + current_avg(data_files, rcs, trqh, w2t) elif sub == 'cycle': - current_cycle(dur, data_files, rc, vel, trq, w2t) + current_cycle(dur, data_files, rcs, vel, trq, trqh, w2t) else: pass if __name__ == '__main__': + stop = 0 main(*argv[1:]) diff --git a/aio/layout.xlsx b/aio/layout.xlsx index 7af97d87e4a52d64c4328d08f8d04beae515c7b0..ac11973f023dda75e940e1c125d2a20351ceae76 100644 GIT binary patch delta 4972 zcmZ`-cTm&awoM2SdXwG>p;s{=@PR}L9R%qmpzulWNN+!S@1a)-y-5pAK>p}T@Zn*_rAIF-ko>PA8YpPbJjY0&;Do4p4NM+*OUP!(wADbm&fFQxd7+a-1ITu zp%>JB7bqPi=8W>)NUH`(Q`MnwC|wIP1lG;*`qCxej)Uz*=8uB|#UY#Kd7VSj@w&Op zI6FeVM<|i3#q6yLtIF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