电机电流单独测试逻辑优化

This commit is contained in:
2025-05-16 13:55:33 +08:00
parent b758733b59
commit 66df4edbed
7 changed files with 44 additions and 22 deletions

1
aio.py
View File

@ -807,7 +807,6 @@ class MainWindow(main_window.Ui_MainWindow):
def prog_done_ec_send(self, results): def prog_done_ec_send(self, results):
flag, result, ret, error, idx, cmd = results flag, result, ret, error, idx, cmd = results
print(f"res = {results}")
if ret[1] == "error": if ret[1] == "error":
clibs.logger("ERROR", "openapi", f"{ret[0]}", "red") clibs.logger("ERROR", "openapi", f"{ret[0]}", "red")
else: else:

Binary file not shown.

View File

@ -6,8 +6,8 @@ VSVersionInfo(
ffi=FixedFileInfo( ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0. # Set not needed items to zero 0.
filevers=(0, 4, 0, 4), filevers=(0, 4, 0, 6),
prodvers=(0, 4, 0, 4), prodvers=(0, 4, 0, 6),
# Contains a bitmask that specifies the valid bits 'flags'r # Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f, mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file. # Contains a bitmask that specifies the Boolean attributes of the file.
@ -31,12 +31,12 @@ VSVersionInfo(
'040904b0', '040904b0',
[StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'), [StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'),
StringStruct('FileDescription', 'All in one automatic toolbox'), StringStruct('FileDescription', 'All in one automatic toolbox'),
StringStruct('FileVersion', '0.4.0.4 (2025-04-21)'), StringStruct('FileVersion', '0.4.0.6 (2025-05-16)'),
StringStruct('InternalName', 'AIO.exe'), StringStruct('InternalName', 'AIO.exe'),
StringStruct('LegalCopyright', '© 2024-2025 Manford Fan'), StringStruct('LegalCopyright', '© 2024-2025 Manford Fan'),
StringStruct('OriginalFilename', 'AIO.exe'), StringStruct('OriginalFilename', 'AIO.exe'),
StringStruct('ProductName', 'AIO'), StringStruct('ProductName', 'AIO'),
StringStruct('ProductVersion', '0.4.0.4 (2025-04-21)')]) StringStruct('ProductVersion', '0.4.0.6 (2025-05-16)')])
]), ]),
VarFileInfo([VarStruct('Translation', [1033, 1200])]) VarFileInfo([VarStruct('Translation', [1033, 1200])])
] ]

View File

@ -1 +1 @@
0.4.0.4@04/21/2025 0.4.0.6@05/16/2025

View File

@ -1 +1 @@
0.4.0.4@04/21/2025 0.4.0.6@05/16/2025

View File

@ -1,3 +1,4 @@
import random
import threading import threading
import time import time
import os import os
@ -124,6 +125,7 @@ class DoBrakeTest(QThread):
else: else:
clibs.count = 0 clibs.count = 0
clibs.logger("WARNING", "do_brake", f"尝试三次后仍无法获取正确数据,本次数据无效,继续执行...", "red") clibs.logger("WARNING", "do_brake", f"尝试三次后仍无法获取正确数据,本次数据无效,继续执行...", "red")
return None
df1 = pandas.DataFrame.from_dict({"hw_joint_vel_feedback": d_vel}) df1 = pandas.DataFrame.from_dict({"hw_joint_vel_feedback": d_vel})
df2 = pandas.DataFrame.from_dict({"device_servo_trq_feedback": d_trq}) df2 = pandas.DataFrame.from_dict({"device_servo_trq_feedback": d_trq})
@ -314,9 +316,11 @@ class DoBrakeTest(QThread):
def exec_brake(): def exec_brake():
flag, start, data, record = True, time.time(), None, None flag, start, data, record = True, time.time(), None, None
while flag: while flag:
time.sleep(0.05) time.sleep(0.01*random.randint(1, 10))
# time.sleep(0.05)
if time.time() - start > 20: if time.time() - start > 20:
clibs.logger("ERROR", "do_brake", "20s 内未触发急停,需排查......", "red") clibs.logger("INFO", "do_brake", "20s 内未触发急停,需排查,当前先继续执行......", "red")
break
try: try:
clibs.lock.acquire(True) clibs.lock.acquire(True)
@ -337,10 +341,18 @@ class DoBrakeTest(QThread):
time.sleep(clibs.INTERVAL*2) # wait speed goes down to 0 time.sleep(clibs.INTERVAL*2) # wait speed goes down to 0
flag = False flag = False
break break
return time.time() return time.time(), flag
time.sleep(11) # 排除从其他位姿到零点位姿,再到轴极限位姿的时间 time.sleep(11) # 排除从其他位姿到零点位姿,再到轴极限位姿的时间
end_time = exec_brake() end_time, flag = exec_brake()
if flag is True: # 没有触发急停
if clibs.count < 3:
clibs.count += 1
continue
else:
clibs.count = 0
break
# 6. 保留数据并处理输出 # 6. 保留数据并处理输出
ret = self.gen_result_file(axis, end_time, reach, load, speed, speed_max, rounds) ret = self.gen_result_file(axis, end_time, reach, load, speed, speed_max, rounds)
if ret != "retry": if ret != "retry":

View File

@ -3,6 +3,7 @@ import threading
import time import time
import paramiko import paramiko
import pandas import pandas
import openpyxl
from PySide6.QtCore import Signal, QThread from PySide6.QtCore import Signal, QThread
from codes.common import clibs from codes.common import clibs
@ -16,9 +17,9 @@ class DoCurrentTest(QThread):
def initialization(self, data_dirs, data_files): def initialization(self, data_dirs, data_files):
def check_files(): def check_files():
msg = "初始路径下不允许有文件夹,初始路径下只能存在如下个文件,且文件为关闭状态,确认后重新运行!<br>" msg = "初始路径下不允许有文件夹,初始路径下只能存在如下个文件,且文件为关闭状态,确认后重新运行!<br>"
msg += "1. T_电机电流.xlsx<br>2. xxxx.zip" msg += "1. T_电机电流.xlsx<br>2. configs.xlsx<br>3. xxxx.zip"
if len(data_dirs) != 0 or len(data_files) != 2: if len(data_dirs) != 0 or len(data_files) != 3:
clibs.logger("ERROR", "do_current", msg, "red") clibs.logger("ERROR", "do_current", msg, "red")
prj_file, count = None, 0 prj_file, count = None, 0
@ -26,13 +27,16 @@ class DoCurrentTest(QThread):
filename = data_file.split("/")[-1] filename = data_file.split("/")[-1]
if filename == "T_电机电流.xlsx": if filename == "T_电机电流.xlsx":
count += 1 count += 1
elif filename == "configs.xlsx":
count += 1
config_file = data_file
elif filename.endswith(".zip"): elif filename.endswith(".zip"):
count += 1 count += 1
prj_file = data_file prj_file = data_file
else: else:
clibs.logger("ERROR", "do_current", msg, "red") clibs.logger("ERROR", "do_current", msg, "red")
if count != 2: if count != 3:
clibs.logger("ERROR", "do_current", msg, "red") clibs.logger("ERROR", "do_current", msg, "red")
if self.tool == "tool100": if self.tool == "tool100":
@ -45,7 +49,7 @@ class DoCurrentTest(QThread):
else: else:
clibs.logger("ERROR", "do_current", "负载选择错误,电机电流测试只能选择 tool100/inertia 规格!", "red") clibs.logger("ERROR", "do_current", "负载选择错误,电机电流测试只能选择 tool100/inertia 规格!", "red")
return prj_file return prj_file, config_file
def get_configs(): def get_configs():
robot_type = None robot_type = None
@ -157,7 +161,14 @@ class DoCurrentTest(QThread):
clibs.c_hr.execution("diagnosis.open", open=stat, display_open=stat) clibs.c_hr.execution("diagnosis.open", open=stat, display_open=stat)
clibs.c_hr.execution("diagnosis.set_params", display_pdo_params=display_pdo_params) clibs.c_hr.execution("diagnosis.set_params", display_pdo_params=display_pdo_params)
def run_rl(self, prj_file): def run_rl(self, prj_file, config_file):
wb = openpyxl.load_workbook(config_file, read_only=True)
ws = wb["Target"]
try:
single_current = int(str(ws.cell(row=6, column=2).value).strip())
except:
single_current = -1
wb.close()
prj_name = ".".join(prj_file.split("/")[-1].split(".")[:-1]) prj_name = ".".join(prj_file.split("/")[-1].split(".")[:-1])
c_regular = [ c_regular = [
"scenario(0, j1_p, j1_n, p_speed, p_tool, i_tool)", "scenario(0, j1_p, j1_n, p_speed, p_tool, i_tool)",
@ -199,9 +210,9 @@ class DoCurrentTest(QThread):
clibs.logger("ERROR", "do_current", "后台数据清零完成,现在可以重新运行其他程序。", "green") clibs.logger("ERROR", "do_current", "后台数据清零完成,现在可以重新运行其他程序。", "green")
number = conditions.index(condition) number = conditions.index(condition)
# for testing if single_current in range(0, 15) and single_current != number:
# if number < 12: continue
# continue
clibs.logger("INFO", "do_current", f"正在执行{disc[number]}测试......") clibs.logger("INFO", "do_current", f"正在执行{disc[number]}测试......")
# 1. 将act重置为False并修改将要执行的场景 # 1. 将act重置为False并修改将要执行的场景
@ -278,9 +289,9 @@ class DoCurrentTest(QThread):
clibs.logger("ERROR", "do_current", "processing: 需要在网络设置中连接HMI以及Modbus通信", "red") clibs.logger("ERROR", "do_current", "processing: 需要在网络设置中连接HMI以及Modbus通信", "red")
data_dirs, data_files = clibs.traversal_files(self.dir_path) data_dirs, data_files = clibs.traversal_files(self.dir_path)
prj_file = self.initialization(data_dirs, data_files) prj_file, config_file = self.initialization(data_dirs, data_files)
clibs.c_pd.push_prj_to_server(prj_file) clibs.c_pd.push_prj_to_server(prj_file)
self.run_rl(prj_file) self.run_rl(prj_file, config_file)
clibs.logger("INFO", "do_current", "-" * 60 + "<br>全部处理完毕<br>", "purple") clibs.logger("INFO", "do_current", "-" * 60 + "<br>全部处理完毕<br>", "purple")
time_total = time.time() - time_start time_total = time.time() - time_start