diff --git a/rokae/aio/aio.py b/rokae/aio/aio.py index decad7a..65758fb 100644 --- a/rokae/aio/aio.py +++ b/rokae/aio/aio.py @@ -128,8 +128,6 @@ class App(customtkinter.CTk): cur_vers = self.label_version.cget("text").replace('\n', ' @ ').replace("Vers: ", '').replace("Date: ", '') try: new_vers = urlopen("https://www.rustle.cc/vers").read().decode('utf-8') - print(f"{cur_vers}") - print(f"{new_vers}") if cur_vers.strip() != new_vers.strip(): msg = f"""当前版本:{cur_vers}\n更新版本:{new_vers}\n\n请及时更新 https://pan.rustle.cc/s/jRfM""" tkinter.messagebox.showwarning(title="版本更新", message=msg) @@ -214,11 +212,17 @@ class App(customtkinter.CTk): elif func_name == 'avg': pass - def write2textbox(self, text, wait=0): + def write2textbox(self, text, wait=0, exitcode=0): if wait != 0: self.textbox.insert(index='end', text=text) self.textbox.update() self.textbox.see('end') + elif exitcode != 0: + self.textbox.configure(text_color='red') + self.textbox.insert(index='end', text=text + '\n') + self.textbox.update() + self.textbox.see('end') + raise Exception(f"Error code: {exitcode}") else: self.textbox.insert(index='end', text=text + '\n') self.textbox.update() @@ -249,8 +253,10 @@ class App(customtkinter.CTk): else: pass - flag = 1 if c1 and c2 and c3 and c4 and c5 else 0 - return flag, path, int(av), int(rr), int(rpm), int(axis), int(vel), int(trq) + if c1 and c2 and c3 and c4 and c5: + return 1, path, int(av), int(rr), int(rpm), int(axis), int(vel), int(trq) + else: + return 0, 0 elif func_name == 'current': path = self.entry_path.get() @@ -267,8 +273,10 @@ class App(customtkinter.CTk): except ValueError: c3 = False - flag = 2 if c1 and c2 and c3 else 0 - return flag, path, float(rc), int(vel), int(trq), sub_func + if c1 and c2 and c3: + return 2, path, float(rc), int(vel), int(trq), sub_func + else: + return 0, 0 else: return 0, 0 @@ -283,7 +291,8 @@ class App(customtkinter.CTk): if flag == 1: 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: - func_dict[flag](path=args[0], rc=args[1], sub_func=args[2]) + tkinter.messagebox.showinfo(title="TBD", message="功能待实现......") + # func_dict[flag](path=args[0], rc=args[1], sub_func=args[2]) else: tkinter.messagebox.showerror(title="参数错误", message="请检查对应参数是否填写正确!", ) diff --git a/rokae/aio/brake.py b/rokae/aio/brake.py index 25338b0..e7b836b 100644 --- a/rokae/aio/brake.py +++ b/rokae/aio/brake.py @@ -89,7 +89,7 @@ def check_files(raw_data_dirs, result_files, w2t): msg = "结果文件数目错误,结果文件有且只有三个,请确认!" for result_file in result_files: w2t(result_file) - w2t(msg) + w2t(msg, 0, 2) prefix = [] for result_file in result_files: @@ -102,7 +102,7 @@ def check_files(raw_data_dirs, result_files, w2t): 1. load33_自研_制动性能测试.xlsx 2. load66_自研_制动性能测试.xlsx 3. load100_自研_制动性能测试.xlsx""" - w2t(msg) + w2t(msg, 0, 3) for raw_data_dir in raw_data_dirs: components = raw_data_dir.split('\\')[-1].split('_') @@ -114,16 +114,16 @@ def check_files(raw_data_dirs, result_files, w2t): f"命名规则:\n 1. loadAA_speedBB_reachCC\n 2. loadAA_reachBB_speedCC\n" \ f"规则解释:AA/BB/CC 指的是负载/速度/臂展的比例\n" \ f"load66_speed100_reach33:66% 负载,100% 速度以及 33% 臂展情况下的测试结果文件夹" - w2t(msg) + 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 为后缀的数据文件" - w2t(msg) + 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')): msg = f"数据文件 {raw_data_file} 后缀错误,每个数据目录下有且只能有三个以 .data/csv 为后缀的数据文件" - w2t(msg) + w2t(msg, 0, 6) w2t("数据目录合规性检查结束,未发现问题......") @@ -273,7 +273,7 @@ def traversal_files(path, w2t): # 返回值:路径下的文件夹列表 路径下的文件列表 if not exists(path): msg = f'数据文件夹{path}不存在,请确认后重试......' - w2t(msg) + w2t(msg, 0, 1) else: dirs = [] files = [] @@ -291,16 +291,15 @@ def main(path, av, rr, rpm, axis, vel, trq, w2t): # 参数:initialization函数的返回值 # 返回值:- time_start = time() - raw_data_dirs, result_files = traversal_files(path, w2t) - check_files(raw_data_dirs, result_files, w2t) - prefix = [] for raw_data_dir in raw_data_dirs: prefix.append(raw_data_dir.split('\\')[-1].split("_")[0]) try: # threads = [] + check_files(raw_data_dirs, result_files, w2t) + for result_file in result_files: if result_file.split('\\')[-1].split('_')[0] not in set(prefix): continue @@ -318,7 +317,7 @@ def main(path, av, rr, rpm, axis, vel, trq, w2t): w2t("全部处理完毕") time_end = time() time_total = time_end - time_start - msg = f"数据处理时间:{time_total // 3600:02.0f} h {time_total % 3600 // 60:02.0f} min {time_total % 60:02.0f} s" + msg = f"数据处理时间:{time_total // 3600:02.0f} h {time_total % 3600 // 60:02.0f} m {time_total % 60:02.0f} s" w2t(msg) diff --git a/rokae/aio/readme.txt b/rokae/aio/readme.txt index 792683b..b7c0108 100644 --- a/rokae/aio/readme.txt +++ b/rokae/aio/readme.txt @@ -121,3 +121,6 @@ v0.1.1(2024/05/30) 2. 修改了无效数据下的动作 3. textbox只在开始和结束时改变状态,而不是每次写入都更改 4. 调整了brake的结构 +5. 重新在write2textbox中添加exitcode参数,并补齐相关逻辑和修改brake中的调用方式 +6. 修复参数检查无效的情况 +7. 屏蔽电流相关的功能