v0.1.4(2024/06/06)

1. AV/RR支持小数
2. 可处理电机电流单轴以及多轴数据,可根据需要进行参数设定处理不同轴的数据
3. 界面初始位置修改,以及删除所有entry的长度设定,因为设定无效
4. 修改了layout.xlsx布局,增加了duration/trqH/STO字段,以及额外的RC行,整体扩展了区域
5. 更改label/entry/optionmenu等控件的生成方式,使用循环实现,更加简洁和容易维护(暂未实现)
6. 支持工业/协作两条产品线的电机电流数据处理,包括单轴,场景,max/avg计算
This commit is contained in:
2024-06-06 19:04:55 +08:00
parent 97ba8ffc51
commit a0404c0003
4 changed files with 172 additions and 76 deletions

View File

@ -24,7 +24,7 @@ class App(customtkinter.CTk):
# configure window
self.title("AIO - All in one automatic toolbox")
# self.iconbitmap('./icon.ico')
self.geometry("1180x550+100+100")
self.geometry("1180x550+30+30")
self.protocol("WM_DELETE_WINDOW", self.func_end_call_back)
self.grid_rowconfigure(4, weight=1)
@ -136,31 +136,37 @@ class App(customtkinter.CTk):
self.label_rc_1.grid(row=3, column=2, sticky='e', pady=(5, 5))
self.entry_rc_1 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font)
self.entry_rc_1.grid(row=3, column=3, padx=(5, 10), pady=(5, 5), sticky='w')
self.entry_rc_1.configure(state='disabled')
self.label_rc_2 = customtkinter.CTkLabel(self.frame_param, text="RC2", font=self.my_font)
self.label_rc_2.grid(row=3, column=4, sticky='e', pady=(5, 5))
self.entry_rc_2 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font)
self.entry_rc_2.grid(row=3, column=5, padx=(5, 10), pady=(5, 5), sticky='w')
self.entry_rc_2.configure(state='disabled')
self.label_rc_3 = customtkinter.CTkLabel(self.frame_param, text="RC3", font=self.my_font)
self.label_rc_3.grid(row=3, column=6, sticky='e', pady=(5, 5))
self.entry_rc_3 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font)
self.entry_rc_3.grid(row=3, column=7, padx=(5, 10), pady=(5, 5), sticky='w')
self.entry_rc_3.configure(state='disabled')
self.label_rc_4 = customtkinter.CTkLabel(self.frame_param, text="RC4", font=self.my_font)
self.label_rc_4.grid(row=3, column=8, sticky='e', pady=(5, 5))
self.entry_rc_4 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font)
self.entry_rc_4.grid(row=3, column=9, padx=(5, 10), pady=(5, 5), sticky='w')
self.entry_rc_4.configure(state='disabled')
self.label_rc_5 = customtkinter.CTkLabel(self.frame_param, text="RC5", font=self.my_font)
self.label_rc_5.grid(row=3, column=10, sticky='e', pady=(5, 5))
self.entry_rc_5 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font)
self.entry_rc_5.grid(row=3, column=11, padx=(5, 10), pady=(5, 5), sticky='w')
self.entry_rc_5.configure(state='disabled')
self.label_rc_6 = customtkinter.CTkLabel(self.frame_param, text="RC6", font=self.my_font)
self.label_rc_6.grid(row=3, column=12, sticky='e', pady=(5, 5))
self.entry_rc_6 = customtkinter.CTkEntry(self.frame_param, width=self.w_param, placeholder_text=f"optional", font=self.my_font)
self.entry_rc_6.grid(row=3, column=13, padx=(5, 10), pady=(5, 5), sticky='w')
self.entry_rc_6.configure(state='disabled')
# =====================================================================
# create textbox
self.textbox = customtkinter.CTkTextbox(self, wrap='none', font=customtkinter.CTkFont(family="consolas", size=14), text_color="blue")
@ -287,6 +293,8 @@ class App(customtkinter.CTk):
self.label_rpm.configure(text="RPM", text_color='black')
self.entry_rpm.configure(state="disabled")
elif func_name == "max":
self.label_rpm.configure(text="RPM", text_color='black')
self.entry_rpm.configure(state="disabled", placeholder_text='额定转速')
self.label_dur.configure(text="Dur", text_color='black')
self.entry_dur.configure(state="disabled")
self.label_vel.configure(text="Vel", text_color='black')
@ -294,6 +302,8 @@ class App(customtkinter.CTk):
self.label_trq.configure(text="Trq", text_color='black')
self.option_trq.configure(state="disabled")
elif func_name == 'avg':
self.label_rpm.configure(text="RPM", text_color='black')
self.entry_rpm.configure(state="disabled", placeholder_text='额定转速')
self.label_dur.configure(text="Dur", text_color='black')
self.entry_dur.configure(state="disabled")
self.label_vel.configure(text="Vel", text_color='black')
@ -301,6 +311,8 @@ class App(customtkinter.CTk):
self.label_trq.configure(text="Trq", text_color='black')
self.option_trq.configure(state="disabled")
elif func_name == 'cycle':
self.label_rpm.configure(text="RPM", text_color='blue')
self.entry_rpm.configure(state="normal", placeholder_text='cycle')
self.label_dur.configure(text="Dur", text_color='blue')
self.entry_dur.configure(state="normal", placeholder_text='scenario')
self.label_vel.configure(text="Vel", text_color='red')
@ -308,7 +320,6 @@ class App(customtkinter.CTk):
self.label_trq.configure(text="Trq", text_color='red')
self.option_trq.configure(state="normal")
def write2textbox(self, text, wait=0, exitcode=0):
if wait != 0:
self.textbox.configure(text_color='blue')
@ -337,8 +348,8 @@ class App(customtkinter.CTk):
elif flag == 'required':
_ = float(item)
except Exception as Err:
self.write2textbox(str(Err))
self.write2textbox("参数数据缺失,或者数据类型错误,更正后重新运行...", 0, 3)
tkinter.messagebox.showerror(title="参数错误", message="请检查对应参数是否填写正确!", )
self.write2textbox(f"错误信息:{Err}\n参数数据缺失,或者数据类型错误,更正后重新运行...", 0, 3)
return True
def check_param(self):
@ -353,7 +364,7 @@ class App(customtkinter.CTk):
sub_func = self.menu_sub.get()
c1 = exists(path)
c2 = self.is_float(av, rr)
c2 = self.is_float('required', av, rr)
c3 = rpm = 1
c4 = sub_func in ['industrial', 'cobot']
c5 = True if vel != trq else False
@ -374,6 +385,7 @@ class App(customtkinter.CTk):
elif func_name == 'current':
path = self.entry_path.get()
rc = self.entry_rc.get()
rpm = self.entry_rpm.get()
dur = self.entry_dur.get()
vel = self.option_vel.get()
trq = self.option_trq.get()
@ -386,9 +398,10 @@ class App(customtkinter.CTk):
rc5 = self.entry_rc_5.get()
rc6 = self.entry_rc_6.get()
c1 = exists(path)
c2 = sub in ['max', 'avg', 'cycle']
c3 = self.is_float('optional', rc)
c0 = exists(path)
c1 = sub in ['max', 'avg', 'cycle']
c2 = self.is_float('optional', rc)
c3 = self.is_float('optional', rpm)
_ = [rc1, rc2, rc3, rc4, rc5, rc6]
c4 = self.is_float('required', *_)
@ -397,12 +410,15 @@ class App(customtkinter.CTk):
c5 = True if vel != trq else False
c6 = self.is_float('optional', dur)
if c1 and c2 and c3 and c4 and c5 and c6:
if c0 and c1 and c2 and c3 and c4 and c5 and c6:
rcs = []
for x in _:
rcs.append(float(x))
rc = 0 if rc == '' else rc
dur = 0 if sub != 'cycle' or dur == '' else dur
return 2, path, sub, rcs, int(vel), int(trq), int(trqh), float(dur)
rpm = 0 if sub != 'cycle' or rpm == '' else rpm
rcs.append(float(rc))
return 2, path, sub, rcs, int(vel), int(trq), int(trqh), float(dur), float(rpm)
else:
return 0, 0
# =======================================================
@ -427,7 +443,7 @@ class App(customtkinter.CTk):
func_dict[flag](path=args[0], av=args[1], rr=args[2], rpm=args[3], axis=args[4], vel=args[5], trq=args[6], w2t=self.write2textbox)
elif flag == 2:
# tkinter.messagebox.showinfo(title="TBD", message="功能待实现......")
func_dict[flag](path=args[0], sub=args[1], rcs=args[2], vel=args[3], trq=args[4], trqh=args[5], dur=args[6], w2t=self.write2textbox)
func_dict[flag](path=args[0], sub=args[1], rcs=args[2], vel=args[3], trq=args[4], trqh=args[5], dur=args[6], rpm=args[7], w2t=self.write2textbox)
elif flag == 3:
func_dict[flag](path=args[0], w2t=self.write2textbox)
else:
@ -436,11 +452,14 @@ class App(customtkinter.CTk):
self.textbox.configure(state='disabled')
def func_check_callback(self):
self.textbox.configure(state='normal')
self.textbox.delete(index1='1.0', index2='end')
flag, *args = self.check_param()
if flag:
tkinter.messagebox.showinfo(title="参数正确", message="所有参数形式上填写无误,可以开始运行!")
else:
tkinter.messagebox.showerror(title="参数错误", message="需要检查对应参数是否填写正确!", )
self.textbox.configure(state='disabled')
def func_log_callback(self):
content = self.textbox.get(index1='1.0', index2='end')
@ -453,7 +472,7 @@ class App(customtkinter.CTk):
tkinter.messagebox.showinfo(title="保存成功", message=f'{log_name}已被保存存至↓↓↓\n{getcwd()}')
except Exception as Err:
print(Err)
self.write2textbox(Err)
tkinter.messagebox.showerror(title="保存失败", message="未能保存本次日志或未能完整保存请准备好相关数据联系fanmingfu@rokae.com查看详细信息", )
else:
tkinter.messagebox.showwarning(title="未能保存", message="日志数据为空,不可保存!")