v0.1.5.0(2024/06/08)
1. [aio.py]: 主界面切换不同功能时保持placehold一致 2. [brake.py]: 由于制动采集模板和内容的更改,适配了新的数据,更新了算法 3. [layout.xlsx]: 添加了各个功能的流程图 4. [aio.py]: 重新调整界面配色 5. [aio.py]: 修改了write2textbox函数,定制化显示每一行的颜色,针对每一行可自定义输出内容颜色 6. [brake.py/iso.py/current.py]: 由于第 5 点的更改,同时修改了其他文件相关引用的部分
This commit is contained in:
@ -7,6 +7,8 @@ from re import match
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
from csv import reader
|
||||
|
||||
|
||||
class GetThreadResult(Thread):
|
||||
def __init__(self, func, args=()):
|
||||
super(GetThreadResult, self).__init__()
|
||||
@ -31,7 +33,7 @@ def w2t_local(msg, wait, w2t):
|
||||
global stop
|
||||
if stop == 0 and wait != 0:
|
||||
sleep(1)
|
||||
w2t(msg, wait)
|
||||
w2t(msg, wait, 0, 'orange')
|
||||
else:
|
||||
break
|
||||
|
||||
@ -42,7 +44,7 @@ def traversal_files(path, w2t):
|
||||
# 返回值:路径下的文件夹列表 路径下的文件列表
|
||||
if not exists(path):
|
||||
msg = f'数据文件夹{path}不存在,请确认后重试......'
|
||||
w2t(msg, 0, 8)
|
||||
w2t(msg, 0, 8, 'red')
|
||||
else:
|
||||
dirs = []
|
||||
files = []
|
||||
@ -64,16 +66,16 @@ def initialization(path, sub, w2t):
|
||||
if sub != 'cycle':
|
||||
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, 6)
|
||||
w2t(msg, 0, 6, 'red')
|
||||
else:
|
||||
if filename.endswith('.xlsx'):
|
||||
count += 1
|
||||
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, 7)
|
||||
w2t(msg, 0, 7, 'red')
|
||||
|
||||
if sub == 'cycle' and count != 1:
|
||||
w2t("未找到电机电流数据处理excel表格,确认后重新运行!", 0, 5)
|
||||
w2t("未找到电机电流数据处理excel表格,确认后重新运行!", 0, 5, 'red')
|
||||
|
||||
return data_files
|
||||
|
||||
@ -138,8 +140,7 @@ def current_cycle(dur, data_files, rcs, vel, trq, trqh, rpm, w2t):
|
||||
else:
|
||||
single.append(data_file)
|
||||
|
||||
w2t(f"正在打开文件 {result},需要 10s 左右", 1)
|
||||
|
||||
w2t(f"正在打开文件 {result},需要 10s 左右", 1, 0, 'orange')
|
||||
global stop
|
||||
stop = 0
|
||||
t_excel = GetThreadResult(load_workbook, args=(result, ))
|
||||
@ -166,7 +167,7 @@ def current_cycle(dur, data_files, rcs, vel, trq, trqh, rpm, w2t):
|
||||
else:
|
||||
p_scenario(wb, single, vel, trq, rpm, dur, w2t)
|
||||
|
||||
w2t(f"正在保存文件 {result},需要 10s 左右", 1)
|
||||
w2t(f"正在保存文件 {result},需要 10s 左右", 1, 0, 'orange')
|
||||
stop = 0
|
||||
t_excel = Thread(target=wb.save, args=(result, ))
|
||||
t_wait = Thread(target=w2t_local, args=('.', 1, w2t))
|
||||
@ -191,7 +192,7 @@ def find_point(flag, df, _row_s, _row_e, w2t, exitcode, threshold, step, end_poi
|
||||
else:
|
||||
return _row_s, _row_e
|
||||
else:
|
||||
w2t(f"数据有误,需要检查,无法找到第{exitcode}个有效点...", 0, exitcode)
|
||||
w2t(f"数据有误,需要检查,无法找到第{exitcode}个有效点...", 0, exitcode, 'red')
|
||||
elif flag == 'gt':
|
||||
while _row_e > end_point:
|
||||
speed_avg = df.iloc[_row_s:_row_e, 0].abs().mean()
|
||||
@ -202,7 +203,7 @@ def find_point(flag, df, _row_s, _row_e, w2t, exitcode, threshold, step, end_poi
|
||||
else:
|
||||
return _row_s, _row_e
|
||||
else:
|
||||
w2t(f"数据有误,需要检查,无法找到有效起始点或结束点...", 0, exitcode)
|
||||
w2t(f"数据有误,需要检查,无法找到有效起始点或结束点...", 0, exitcode, 'red')
|
||||
|
||||
|
||||
def p_single(wb, single, vel, trq, rpm, w2t):
|
||||
@ -262,7 +263,7 @@ def p_single(wb, single, vel, trq, rpm, w2t):
|
||||
_row_e -= _end_point
|
||||
_row_s -= _end_point
|
||||
_row_s, _row_e = find_point('lt', df, _row_s, _row_e, w2t, 4, threshold=2, step=_step, end_point=_end_point)
|
||||
#目前已经有一点的速度值了,继续往前搜寻下一个速度为零的点
|
||||
# 目前已经有一点的速度值了,继续往前搜寻下一个速度为零的点
|
||||
_row_e -= _end_point
|
||||
_row_s -= _end_point
|
||||
_row_s, _row_e = find_point('gt', df, _row_s, _row_e, w2t, 4, threshold=2, step=_step, end_point=_end_point)
|
||||
@ -316,7 +317,7 @@ def p_scenario(wb, single, vel, trq, rpm, dur, w2t):
|
||||
row_start = 300
|
||||
row_end = row_start + int(dur/cycle)
|
||||
if row_end > df.index[-1]:
|
||||
w2t(f"位置超限:{data_file} 共有 {df.index[-1]} 条数据,无法取到第 {row_end} 条数据...", 0, 9)
|
||||
w2t(f"位置超限:{data_file} 共有 {df.index[-1]} 条数据,无法取到第 {row_end} 条数据...", 0, 9, 'red')
|
||||
|
||||
data = []
|
||||
for row in range(row_start, row_end):
|
||||
|
Reference in New Issue
Block a user