w2tgit add .!

This commit is contained in:
gitea 2025-01-22 16:40:29 +08:00
parent 92bdf133f2
commit 6b6fa1ec71
11 changed files with 23 additions and 22 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ package/
code/common/__pycache__/ code/common/__pycache__/
code/data_process/__pycache__/ code/data_process/__pycache__/
code/automatic_test/__pycache__/ code/automatic_test/__pycache__/
code/durable_docs/__pycache__/

View File

@ -67,7 +67,7 @@ def initialization(path, sub, data_dirs, data_files, hr, w2t):
configs = json.load(f_config) configs = json.load(f_config)
except Exception as Err: except Exception as Err:
clibs.insert_logdb("ERROR", "current", f"get_config: 无法打开 {local_file},获取配置文件参数错误 {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"] 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": elif pon == "negative":
md.write_pon(0) md.write_pon(0)
else: else:
w2t("configs.xlsx 中 Target 页面 B5 单元格填写不正确,检查后重新运行...", "red", "DirectionError") w2t("configs.xlsx 中 Target 页面 B5 单元格填写不正确,检查后重新运行...\n", "red", "DirectionError")
for condition in result_dirs: for condition in result_dirs:
reach = condition.split("_")[0].removeprefix("reach") 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): for axis in range(1, 4):
if not clibs.running: if not clibs.running:
w2t("后台数据清零完成,现在可以重新运行之前停止的程序。", "red") w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red")
exit() exit()
# for single condition test # for single condition test
@ -239,7 +239,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t):
else: else:
time.sleep(1) time.sleep(1)
if (time.time() - t_start) > 3: if (time.time() - t_start) > 3:
w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序编写正确并正常执行...", "red", "ReadySignalTimeoutError") w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序编写正确并正常执行...\n", "red", "ReadySignalTimeoutError")
# 4. 找出最大速度传递给RL程序最后清除相关记录 # 4. 找出最大速度传递给RL程序最后清除相关记录
time.sleep(5) # 消除前 5s 的不稳定数据 time.sleep(5) # 消除前 5s 的不稳定数据
change_curve_state(hr, True) 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: else:
time.sleep(1) time.sleep(1)
else: else:
w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序配置正确并正常执行...", "red", "ReadySignalTimeoutError") w2t("3s 内未收到机器人的运行信号,需要确认 RL 程序配置正确并正常执行...\n", "red", "ReadySignalTimeoutError")
time.sleep(5+random.randint(1, 5)) # 排除从其他位姿到零点位姿,再到轴极限位姿的时间 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: while flag:
time.sleep(0.05) time.sleep(0.05)
if time.time() - start > 20: if time.time() - start > 20:
w2t("20s 内未触发急停,需排查......", "red", "BrakeTimeoutError") w2t("20s 内未触发急停,需排查......\n", "red", "BrakeTimeoutError")
try: try:
clibs.lock.acquire(True) clibs.lock.acquire(True)

View File

@ -174,7 +174,7 @@ def run_rl(path, prj_file, hr, md, sub, w2t):
for condition in conditions: for condition in conditions:
if not clibs.running: if not clibs.running:
w2t("后台数据清零完成,现在可以重新运行之前停止的程序。", "red") w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red")
exit() exit()
number = conditions.index(condition) number = conditions.index(condition)
@ -211,7 +211,7 @@ def run_rl(path, prj_file, hr, md, sub, w2t):
else: else:
time.sleep(1) time.sleep(1)
if (time.time() - t_start) > 3: if (time.time() - t_start) > 3:
w2t("3s 内未收到机器人的运行信号需要确认RL程序和工具通信是否正常执行...", "red", "ReadySignalTimeoutError") w2t("3s 内未收到机器人的运行信号需要确认RL程序和工具通信是否正常执行...\n", "red", "ReadySignalTimeoutError")
# 4. 执行采集 # 4. 执行采集
time.sleep(10) # 消除前 10s 的不稳定数据 time.sleep(10) # 消除前 10s 的不稳定数据

View File

@ -9,7 +9,7 @@ def traversal_files(_path, _w2t):
# 参数:路径 # 参数:路径
# 返回值:路径下的文件夹列表 路径下的文件列表 # 返回值:路径下的文件夹列表 路径下的文件列表
if not os.path.exists(_path): if not os.path.exists(_path):
_w2t(f"数据文件夹{_path}不存在,请确认后重试......", "red", "PathNotExistError") _w2t(f"数据文件夹{_path}不存在,请确认后重试......\n", "red", "PathNotExistError")
else: else:
dirs, files = [], [] dirs, files = [], []
for item in os.scandir(_path): for item in os.scandir(_path):

View File

@ -746,7 +746,7 @@ class HmiRequest(object):
req = json.load(f_json) req = json.load(f_json)
except Exception as Err: except Exception as Err:
clibs.insert_logdb("ERROR", "openapi", f"hr-execution: 暂不支持 {command} 功能,或确认该功能存在... {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 if p_flag == 0: # for old protocols
match command: 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.__ssh.connect(hostname=self.ip, port=self.port, username=self.username, password=self.password)
self.__sftp = self.__ssh.open_sftp() self.__sftp = self.__ssh.open_sftp()
except Exception as Err: 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.insert_logdb("ERROR", "openapi", msg)
clibs.w2t(msg, "red", f"SSHError: cannot connected to {self.ip}:{self.port}") clibs.w2t(msg, "red", f"SSHError: cannot connected to {self.ip}:{self.port}")

View File

@ -69,7 +69,7 @@ def get_configs(config_file, w2t):
p_dir = config_file.split('/')[-2] p_dir = config_file.split('/')[-2]
if not re.match("^[jJ][123]$", p_dir): if not re.match("^[jJ][123]$", p_dir):
w2t("被处理的根文件夹命名必须是 [Jj][123] 的格式", "red", "DirNameError") w2t("被处理的根文件夹命名必须是 [Jj][123] 的格式\n", "red", "DirNameError")
axis = int(p_dir[-1]) axis = int(p_dir[-1])
rrs = [abs(_) for _ in configs["TRANSMISSION"]["REDUCTION_RATIO_NUMERATOR"]] # 减速比rr for reduction ratio rrs = [abs(_) for _ in configs["TRANSMISSION"]["REDUCTION_RATIO_NUMERATOR"]] # 减速比rr for reduction ratio

View File

@ -64,11 +64,11 @@ def current_max(data_files, rts, trq, w2t, insert_logdb):
if not cur: if not cur:
continue continue
else: else:
w2t(f"{axis}数据:") w2t(f"{axis}最大转矩数据:")
for value in cur: for value in cur:
w2t(f"{value:.4f} ") w2t(f"{value:.4f} ")
w2t("\n") w2t("\n")
w2t("\n【MAX】数据处理完毕......") w2t("\n【MAX】最大转矩数据处理完毕......\n")
insert_logdb("INFO", "current", f"MAX: 获取最大转矩值结束 current_max = {current}") insert_logdb("INFO", "current", f"MAX: 获取最大转矩值结束 current_max = {current}")
return current return current
@ -106,11 +106,11 @@ def current_avg(data_files, rts, trqh, w2t, insert_logdb):
if not cur: if not cur:
continue continue
else: else:
w2t(f"{axis}数据:") w2t(f"{axis}平均转矩数据:")
for value in cur: for value in cur:
w2t(f"{value:.4f} ") w2t(f"{value:.4f} ")
w2t("\n") w2t("\n")
w2t("\n【AVG】数据处理完毕......\n") w2t("\n【AVG】平均转矩数据处理完毕......\n")
insert_logdb("INFO", "current", f"AVG: 获取平均转矩值结束 current_avg = {current}") insert_logdb("INFO", "current", f"AVG: 获取平均转矩值结束 current_avg = {current}")
return 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}") insert_logdb("WARNING", "current", f"【lt】{axis} 轴第 {seq} 次查找数据可能有异常row_s = {row_s}, row_e = {row_e}")
return row_s, row_e return row_s, row_e
else: else:
w2t(f"{data_file} 数据有误,需要检查,无法找到第 {seq} 个有效点...", "red", "AnchorNotFound") w2t(f"{data_file} 数据有误,需要检查,无法找到第 {seq} 个有效点...\n", "red", "AnchorNotFound")
elif flag == "gt": elif flag == "gt":
while row_e > end_point: while row_e > end_point:
speed_avg = df.iloc[row_s:row_e].abs().mean() 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}") insert_logdb("WARNING", "current", f"【gt】{axis} 轴第 {seq} 次查找数据可能有异常row_s = {row_s}, row_e = {row_e}")
return row_s, row_e return row_s, row_e
else: 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): 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_start = 3000
row_end = row_start + int(dur_time/cycle) row_end = row_start + int(dur_time/cycle)
if row_end > df.index[-1]: 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 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): for row in range(row_start, row_end+1):

View File

@ -147,7 +147,7 @@ def main():
ws.cell(row=i, column=7).value = None ws.cell(row=i, column=7).value = None
except Exception as Err: except Exception as Err:
clibs.insert_logdb("ERROR", "iso", f"main: 无法打开文件 {filename}") clibs.insert_logdb("ERROR", "iso", f"main: 无法打开文件 {filename}")
w2t(f"发生错误:{Err}", "red", "FileOpenError") w2t(f"发生错误:{Err}\n", "red", "FileOpenError")
p_files = [] p_files = []
for file in files: for file in files:
@ -172,7 +172,7 @@ def main():
wb.close() wb.close()
if len(p_files) == 0: if len(p_files) == 0:
w2t(f"目录 {path} 下没有需要处理的文件,需要确认......", "red") w2t(f"目录 {path} 下没有需要处理的文件,需要确认......\n", "red")
else: else:
os.remove(tmpfile) os.remove(tmpfile)
w2t("------------------------------------------\n") w2t("------------------------------------------\n")

View File

@ -141,7 +141,7 @@ def run_rl(path, params, curves, hr, md, w2t):
count = 0 count = 0
while clibs.running: while clibs.running:
if not clibs.running: if not clibs.running:
w2t("后台数据清零完成,现在可以重新运行之前停止的程序。", "red") w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red")
exit() exit()
this_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) this_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))