diff --git a/.gitignore b/.gitignore index b25b9b9..9e02d55 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ package/ code/common/__pycache__/ code/data_process/__pycache__/ code/automatic_test/__pycache__/ +code/durable_docs/__pycache__/ \ No newline at end of file diff --git a/code/automatic_test/do_brake.py b/code/automatic_test/do_brake.py index 5e8c78c..20e110d 100644 --- a/code/automatic_test/do_brake.py +++ b/code/automatic_test/do_brake.py @@ -67,7 +67,7 @@ def initialization(path, sub, data_dirs, data_files, hr, w2t): configs = json.load(f_config) except Exception as Err: clibs.insert_logdb("ERROR", "current", f"get_config: 无法打开 {local_file},获取配置文件参数错误 {Err}") - w2t(f"无法打开 {local_file}", color="red", desc="OpenFileError") + w2t(f"无法打开 {local_file}\n", color="red", desc="OpenFileError") # 最大角速度,额定电流,减速比,额定转速 version = configs["VERSION"] @@ -158,7 +158,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t): elif pon == "negative": md.write_pon(0) else: - w2t("configs.xlsx 中 Target 页面 B5 单元格填写不正确,检查后重新运行...", "red", "DirectionError") + w2t("configs.xlsx 中 Target 页面 B5 单元格填写不正确,检查后重新运行...\n", "red", "DirectionError") for condition in result_dirs: reach = condition.split("_")[0].removeprefix("reach") @@ -175,7 +175,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t): for axis in range(1, 4): if not clibs.running: - w2t("后台数据清零完成,现在可以重新运行之前停止的程序。", "red") + w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red") exit() # for single condition test @@ -239,7 +239,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t): else: time.sleep(1) if (time.time() - t_start) > 3: - w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序编写正确并正常执行...", "red", "ReadySignalTimeoutError") + w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序编写正确并正常执行...\n", "red", "ReadySignalTimeoutError") # 4. 找出最大速度,传递给RL程序,最后清除相关记录 time.sleep(5) # 消除前 5s 的不稳定数据 change_curve_state(hr, True) @@ -298,7 +298,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t): else: time.sleep(1) else: - w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序配置正确并正常执行...", "red", "ReadySignalTimeoutError") + w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序配置正确并正常执行...\n", "red", "ReadySignalTimeoutError") time.sleep(5+random.randint(1, 5)) # 排除从其他位姿到零点位姿,再到轴极限位姿的时间 @@ -308,7 +308,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t): while flag: time.sleep(0.05) if time.time() - start > 20: - w2t("20s 内未触发急停,需排查......", "red", "BrakeTimeoutError") + w2t("20s 内未触发急停,需排查......\n", "red", "BrakeTimeoutError") try: clibs.lock.acquire(True) diff --git a/code/automatic_test/do_current.py b/code/automatic_test/do_current.py index 91911cf..e2cd2d7 100644 --- a/code/automatic_test/do_current.py +++ b/code/automatic_test/do_current.py @@ -174,7 +174,7 @@ def run_rl(path, prj_file, hr, md, sub, w2t): for condition in conditions: if not clibs.running: - w2t("后台数据清零完成,现在可以重新运行之前停止的程序。", "red") + w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red") exit() number = conditions.index(condition) @@ -211,7 +211,7 @@ def run_rl(path, prj_file, hr, md, sub, w2t): else: time.sleep(1) if (time.time() - t_start) > 3: - w2t("3s 内未收到机器人的运行信号,需要确认RL程序和工具通信是否正常执行...", "red", "ReadySignalTimeoutError") + w2t("3s 内未收到机器人的运行信号,需要确认RL程序和工具通信是否正常执行...\n", "red", "ReadySignalTimeoutError") # 4. 执行采集 time.sleep(10) # 消除前 10s 的不稳定数据 diff --git a/code/common/clibs.py b/code/common/clibs.py index 55b6086..e0f67f0 100644 --- a/code/common/clibs.py +++ b/code/common/clibs.py @@ -9,7 +9,7 @@ def traversal_files(_path, _w2t): # 参数:路径 # 返回值:路径下的文件夹列表 路径下的文件列表 if not os.path.exists(_path): - _w2t(f"数据文件夹{_path}不存在,请确认后重试......", "red", "PathNotExistError") + _w2t(f"数据文件夹{_path}不存在,请确认后重试......\n", "red", "PathNotExistError") else: dirs, files = [], [] for item in os.scandir(_path): diff --git a/code/common/openapi.py b/code/common/openapi.py index e481422..b4f562c 100644 --- a/code/common/openapi.py +++ b/code/common/openapi.py @@ -746,7 +746,7 @@ class HmiRequest(object): req = json.load(f_json) except Exception as Err: clibs.insert_logdb("ERROR", "openapi", f"hr-execution: 暂不支持 {command} 功能,或确认该功能存在... {Err}") - clibs.w2t(f"hr-execution: 暂不支持 {command} 功能,或确认该功能存在... {Err}", "red", "CommandError") + clibs.w2t(f"hr-execution: 暂不支持 {command} 功能,或确认该功能存在... {Err}\n", "red", "CommandError") if p_flag == 0: # for old protocols match command: @@ -2155,7 +2155,7 @@ class PreDos(object): self.__ssh.connect(hostname=self.ip, port=self.port, username=self.username, password=self.password) self.__sftp = self.__ssh.open_sftp() except Exception as Err: - msg = f"predos: SSH 无法连接到 {self.ip}:{self.port},需检查网络连通性或者登录信息是否正确 {Err}" + msg = f"predos: SSH 无法连接到 {self.ip}:{self.port},需检查网络连通性或者登录信息是否正确 {Err}\n" clibs.insert_logdb("ERROR", "openapi", msg) clibs.w2t(msg, "red", f"SSHError: cannot connected to {self.ip}:{self.port}") diff --git a/code/data_process/brake.py b/code/data_process/brake.py index 8e19f53..db65dc6 100644 --- a/code/data_process/brake.py +++ b/code/data_process/brake.py @@ -69,7 +69,7 @@ def get_configs(config_file, w2t): p_dir = config_file.split('/')[-2] if not re.match("^[jJ][123]$", p_dir): - w2t("被处理的根文件夹命名必须是 [Jj][123] 的格式", "red", "DirNameError") + w2t("被处理的根文件夹命名必须是 [Jj][123] 的格式\n", "red", "DirNameError") axis = int(p_dir[-1]) rrs = [abs(_) for _ in configs["TRANSMISSION"]["REDUCTION_RATIO_NUMERATOR"]] # 减速比,rr for reduction ratio diff --git a/code/data_process/current.py b/code/data_process/current.py index 36e4e57..7142fd4 100644 --- a/code/data_process/current.py +++ b/code/data_process/current.py @@ -64,11 +64,11 @@ def current_max(data_files, rts, trq, w2t, insert_logdb): if not cur: continue else: - w2t(f"{axis}轴数据:") + w2t(f"{axis}轴最大转矩数据:") for value in cur: w2t(f"{value:.4f} ") w2t("\n") - w2t("\n【MAX】数据处理完毕......") + w2t("\n【MAX】最大转矩数据处理完毕......\n") insert_logdb("INFO", "current", f"MAX: 获取最大转矩值结束 current_max = {current}") return current @@ -106,11 +106,11 @@ def current_avg(data_files, rts, trqh, w2t, insert_logdb): if not cur: continue else: - w2t(f"{axis}轴数据:") + w2t(f"{axis}轴平均转矩数据:") for value in cur: w2t(f"{value:.4f} ") w2t("\n") - w2t("\n【AVG】数据处理完毕......\n") + w2t("\n【AVG】平均转矩数据处理完毕......\n") insert_logdb("INFO", "current", f"AVG: 获取平均转矩值结束 current_avg = {current}") return current @@ -176,7 +176,7 @@ def find_point(data_file, df, flag, row_s, row_e, threshold, step, end_point, sk insert_logdb("WARNING", "current", f"【lt】{axis} 轴第 {seq} 次查找数据可能有异常,row_s = {row_s}, row_e = {row_e}!") return row_s, row_e else: - w2t(f"{data_file} 数据有误,需要检查,无法找到第 {seq} 个有效点...", "red", "AnchorNotFound") + w2t(f"{data_file} 数据有误,需要检查,无法找到第 {seq} 个有效点...\n", "red", "AnchorNotFound") elif flag == "gt": while row_e > end_point: speed_avg = df.iloc[row_s:row_e].abs().mean() @@ -194,7 +194,7 @@ def find_point(data_file, df, flag, row_s, row_e, threshold, step, end_point, sk insert_logdb("WARNING", "current", f"【gt】{axis} 轴第 {seq} 次查找数据可能有异常,row_s = {row_s}, row_e = {row_e}!") return row_s, row_e else: - w2t(f"{data_file} 数据有误,需要检查,无法找到第 {seq} 个有效点...", "red", "AnchorNotFound") + w2t(f"{data_file} 数据有误,需要检查,无法找到第 {seq} 个有效点...\n", "red", "AnchorNotFound") def get_row_number(threshold, flag, df, row_s, row_e, axis, insert_logdb): @@ -345,7 +345,7 @@ def p_scenario(wb, scenario, vel, trq, sensor, rrs, dur_time, w2t): row_start = 3000 row_end = row_start + int(dur_time/cycle) if row_end > df.index[-1]: - w2t(f"位置超限:{data_file} 共有 {df.index[-1]} 条数据,无法取到第 {row_end} 条数据,需要确认场景周期时间...", "red", "DataOverLimit") + w2t(f"位置超限:{data_file} 共有 {df.index[-1]} 条数据,无法取到第 {row_end} 条数据,需要确认场景周期时间...\n", "red", "DataOverLimit") data, first_c, second_c, third_c, fourth_c = [], vel-1, trq-1, sensor-1, sensor for row in range(row_start, row_end+1): diff --git a/code/data_process/iso.py b/code/data_process/iso.py index 6db2cc5..867999e 100644 --- a/code/data_process/iso.py +++ b/code/data_process/iso.py @@ -147,7 +147,7 @@ def main(): ws.cell(row=i, column=7).value = None except Exception as Err: clibs.insert_logdb("ERROR", "iso", f"main: 无法打开文件 {filename}") - w2t(f"发生错误:{Err}", "red", "FileOpenError") + w2t(f"发生错误:{Err}\n", "red", "FileOpenError") p_files = [] for file in files: @@ -172,7 +172,7 @@ def main(): wb.close() if len(p_files) == 0: - w2t(f"目录 {path} 下没有需要处理的文件,需要确认......", "red") + w2t(f"目录 {path} 下没有需要处理的文件,需要确认......\n", "red") else: os.remove(tmpfile) w2t("------------------------------------------\n") diff --git a/code/durable_docs/__pycache__/create_plot.cpython-312.pyc b/code/durable_docs/__pycache__/create_plot.cpython-312.pyc deleted file mode 100644 index 8840f59..0000000 Binary files a/code/durable_docs/__pycache__/create_plot.cpython-312.pyc and /dev/null differ diff --git a/code/durable_docs/__pycache__/factory_test.cpython-312.pyc b/code/durable_docs/__pycache__/factory_test.cpython-312.pyc deleted file mode 100644 index 3565786..0000000 Binary files a/code/durable_docs/__pycache__/factory_test.cpython-312.pyc and /dev/null differ diff --git a/code/durable_docs/factory_test.py b/code/durable_docs/factory_test.py index de40068..6425998 100644 --- a/code/durable_docs/factory_test.py +++ b/code/durable_docs/factory_test.py @@ -141,7 +141,7 @@ def run_rl(path, params, curves, hr, md, w2t): count = 0 while clibs.running: if not clibs.running: - w2t("后台数据清零完成,现在可以重新运行之前停止的程序。", "red") + w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red") exit() this_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))