- 减速比rr数据源修改为configs.xlsx
4. 在current工程main函数增加 VelSet 100语句
This commit is contained in:
parent
d35858e14e
commit
edda9defdd
@ -478,4 +478,5 @@ v0.1.9.2(2024/07/13)
|
||||
- 在find_point函数种,当无法找到正确点位时,继续执行,而不是直接终止执行
|
||||
- max功能计算逻辑矫正,应该是取绝对值的最大值
|
||||
- 整体梳理了trq/trqh的传递路径,现已修正完毕
|
||||
|
||||
- 减速比rr数据源修改为configs.xlsx
|
||||
4. 在current工程main函数增加 VelSet 100语句
|
||||
|
Binary file not shown.
Binary file not shown.
@ -158,7 +158,7 @@ def current_avg(data_files, rcs, trq, w2t):
|
||||
return current
|
||||
|
||||
|
||||
def current_cycle(dur, data_files, rcs, vel, trq, trqh, rpms, w2t):
|
||||
def current_cycle(dur, data_files, rcs, rrs, vel, trq, trqh, rpms, w2t):
|
||||
result = None
|
||||
hold = []
|
||||
single = []
|
||||
@ -194,9 +194,9 @@ def current_cycle(dur, data_files, rcs, vel, trq, trqh, rpms, w2t):
|
||||
pass
|
||||
|
||||
if dur == 0:
|
||||
p_single(wb, single, vel, trq, rpms, w2t)
|
||||
p_single(wb, single, vel, trq, rpms, rrs, w2t)
|
||||
else:
|
||||
p_scenario(wb, single, vel, trq, rpms, dur, w2t)
|
||||
p_scenario(wb, single, vel, trq, rpms, rrs, dur, w2t)
|
||||
|
||||
w2t(f"正在保存文件 {result},需要 10s 左右", 1, 0, 'orange')
|
||||
stop = 0
|
||||
@ -237,7 +237,7 @@ def find_point(data_file, pos, flag, df, _row_s, _row_e, w2t, exitcode, threshol
|
||||
w2t(f"[{pos}] {data_file}数据有误,需要检查,无法找到有效起始点或结束点...", 0, exitcode, 'red')
|
||||
|
||||
|
||||
def p_single(wb, single, vel, trq, rpms, w2t):
|
||||
def p_single(wb, single, vel, trq, rpms, rrs, w2t):
|
||||
# 1. 先找到第一个速度为零的点,数据从后往前找,一开始就是零的情况不予考虑
|
||||
# 2. 记录第一个点的位置,继续向前查找第二个速度为零的点,同理,一开始为零的点不予考虑
|
||||
# 3. 记录第二个点的位置,并将其中的数据拷贝至对应位置
|
||||
@ -251,7 +251,7 @@ def p_single(wb, single, vel, trq, rpms, w2t):
|
||||
set_option("display.precision", 2)
|
||||
if data_file.endswith('.data'):
|
||||
df = read_csv(data_file, sep='\t')
|
||||
rr = float(wb['统计'].cell(row=2, column=axis+1).value)
|
||||
rr = rrs[axis+1]
|
||||
addition = 180 / 3.1415926 * 60 / 360 * rr
|
||||
elif data_file.endswith('.csv'):
|
||||
df = read_csv(data_file, sep=',', encoding='gbk', header=8)
|
||||
@ -268,6 +268,7 @@ def p_single(wb, single, vel, trq, rpms, w2t):
|
||||
col_names = list(df.columns)
|
||||
df_1 = df[col_names[vel-1]].multiply(rpm*addition)
|
||||
df_2 = df[col_names[trq-1]].multiply(scale)
|
||||
print(df_1.abs().max())
|
||||
df = concat([df_1, df_2], axis=1)
|
||||
|
||||
_step = 5 if data_file.endswith('.csv') else 50
|
||||
@ -318,7 +319,7 @@ def p_single(wb, single, vel, trq, rpms, w2t):
|
||||
cell.value = None
|
||||
|
||||
|
||||
def p_scenario(wb, single, vel, trq, rpms, dur, w2t):
|
||||
def p_scenario(wb, single, vel, trq, rpms, rrs, dur, w2t):
|
||||
for data_file in single:
|
||||
cycle = 0.001
|
||||
axis = int(data_file.split('\\')[-1].split('_')[0].removeprefix('j'))
|
||||
@ -330,7 +331,7 @@ def p_scenario(wb, single, vel, trq, rpms, dur, w2t):
|
||||
set_option("display.precision", 2)
|
||||
if data_file.endswith('.data'):
|
||||
df = read_csv(data_file, sep='\t')
|
||||
rr = float(wb['统计'].cell(row=2, column=axis+1).value)
|
||||
rr = rrs[axis+1]
|
||||
addition = 180 / 3.1415926 * 60 / 360 * rr
|
||||
elif data_file.endswith('.csv'):
|
||||
df = read_csv(data_file, sep=',', encoding='gbk', header=8)
|
||||
@ -374,6 +375,7 @@ def get_configs(configfile, w2t):
|
||||
_wb = load_workbook(configfile, read_only=True)
|
||||
_ws = _wb['Target']
|
||||
rcs = []
|
||||
rrs = []
|
||||
rpms = []
|
||||
for i in range(2, 9):
|
||||
try:
|
||||
@ -386,18 +388,23 @@ def get_configs(configfile, w2t):
|
||||
except:
|
||||
rcs.append(0.0)
|
||||
|
||||
return rpms, rcs
|
||||
try:
|
||||
rrs.append(float(_ws.cell(row=2, column=i).value))
|
||||
except:
|
||||
rrs.append(0.0)
|
||||
|
||||
return rpms, rcs, rrs
|
||||
|
||||
|
||||
def main(path, sub, dur, vel, trq, trqh, w2t):
|
||||
data_files = initialization(path, sub, w2t)
|
||||
rpms, rcs = get_configs(path + '\\configs.xlsx', w2t)
|
||||
rpms, rcs, rrs = get_configs(path + '\\configs.xlsx', w2t)
|
||||
if sub == 'max':
|
||||
current_max(data_files, rcs, trq, w2t)
|
||||
elif sub == 'avg':
|
||||
current_avg(data_files, rcs, trq, w2t)
|
||||
elif sub == 'cycle':
|
||||
current_cycle(dur, data_files, rcs, vel, trq, trqh, rpms, w2t)
|
||||
current_cycle(dur, data_files, rcs, rrs, vel, trq, trqh, rpms, w2t)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user