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:
90
aio/aio.py
90
aio/aio.py
@ -12,7 +12,7 @@ customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark
|
||||
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
|
||||
customtkinter.set_widget_scaling(1.1) # widget dimensions and text size
|
||||
customtkinter.set_window_scaling(1.1) # window geometry dimensions
|
||||
socket.setdefaulttimeout(10)
|
||||
socket.setdefaulttimeout(1)
|
||||
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
@ -26,6 +26,7 @@ class App(customtkinter.CTk):
|
||||
# self.iconbitmap('./icon.ico')
|
||||
self.geometry("1180x550+30+30")
|
||||
self.protocol("WM_DELETE_WINDOW", self.func_end_call_back)
|
||||
self.config(bg='#E9E9E9')
|
||||
|
||||
self.grid_rowconfigure(4, weight=1)
|
||||
self.grid_columnconfigure((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), weight=1)
|
||||
@ -33,34 +34,34 @@ class App(customtkinter.CTk):
|
||||
|
||||
# =====================================================================
|
||||
# create frame sidebar(left)
|
||||
self.frame_func = customtkinter.CTkFrame(self, width=120, corner_radius=0)
|
||||
self.frame_func = customtkinter.CTkFrame(self, width=120, corner_radius=0, fg_color='#E9E9E9')
|
||||
self.frame_func.grid(row=0, column=0, rowspan=7, sticky='nsew')
|
||||
# create AIO logo
|
||||
self.label_logo = customtkinter.CTkLabel(self.frame_func, text="Rokae AIO", height=60, font=customtkinter.CTkFont(family="Segoe Script Bold", size=24, weight="bold"), text_color="DarkSlateGray")
|
||||
self.label_logo = customtkinter.CTkLabel(self.frame_func, text="Rokae AIO", height=60, font=customtkinter.CTkFont(family="Segoe Script Bold", size=24, weight="bold"), text_color="#4F4F4F")
|
||||
self.label_logo.grid(row=0, column=0, padx=15, pady=15)
|
||||
# create start button
|
||||
self.btn_start = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='开始运行', font=self.my_font, command=lambda: self.thread_it(self.func_start_callback))
|
||||
self.btn_start = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='开始运行', fg_color='#4F4F4F', font=self.my_font, command=lambda: self.thread_it(self.func_start_callback))
|
||||
self.btn_start.grid(row=1, column=0, sticky='new', padx=10, pady=10, ipadx=5, ipady=5)
|
||||
# create param check button
|
||||
self.btn_check = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='检查参数', font=self.my_font, command=lambda: self.thread_it(self.func_check_callback))
|
||||
self.btn_check = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='检查参数', fg_color='#4F4F4F', font=self.my_font, command=lambda: self.thread_it(self.func_check_callback))
|
||||
self.btn_check.grid(row=2, column=0, sticky='new', padx=10, pady=10, ipadx=5, ipady=5)
|
||||
# create start button
|
||||
self.btn_log = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='保存日志', font=self.my_font, command=lambda: self.thread_it(self.func_log_callback))
|
||||
self.btn_log = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='保存日志', fg_color='#4F4F4F', font=self.my_font, command=lambda: self.thread_it(self.func_log_callback))
|
||||
self.btn_log.grid(row=3, column=0, sticky='new', padx=10, pady=10, ipadx=5, ipady=5)
|
||||
# create start button
|
||||
self.btn_end = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='结束运行', font=self.my_font, command=self.func_end_call_back)
|
||||
self.btn_end = customtkinter.CTkButton(self.frame_func, corner_radius=10, text='结束运行', fg_color='#4F4F4F', font=self.my_font, command=self.func_end_call_back)
|
||||
self.btn_end.grid(row=4, column=0, sticky='new', padx=10, pady=10, ipadx=5, ipady=5)
|
||||
# create version info
|
||||
self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.1.4\nDate: 06/06/2024", font=self.my_font, text_color="DarkCyan")
|
||||
self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.1.4\nDate: 06/06/2024", font=self.my_font, text_color="#4F4F4F")
|
||||
self.frame_func.rowconfigure(6, weight=1)
|
||||
self.label_version.grid(row=6, column=0, padx=20, pady=20, sticky='s')
|
||||
|
||||
# =====================================================================
|
||||
# create frame
|
||||
self.frame_param = customtkinter.CTkFrame(self, corner_radius=10)
|
||||
self.frame_param.grid(row=0, column=1, rowspan=3, columnspan=13, sticky='new', ipadx=20, ipady=10, padx=10, pady=(10, 5))
|
||||
self.frame_param = customtkinter.CTkFrame(self, corner_radius=5, fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD')
|
||||
self.frame_param.grid(row=0, column=1, rowspan=3, columnspan=13, sticky='new', ipadx=20, ipady=10, padx=10, pady=(5, 10))
|
||||
# create main menu
|
||||
self.menu_main = customtkinter.CTkOptionMenu(self.frame_param, values=["INIT", "brake", "current", "iso"], font=self.my_font, command=self.func_main_callback)
|
||||
self.menu_main = customtkinter.CTkOptionMenu(self.frame_param, values=["INIT", "brake", "current", "iso"], font=self.my_font, text_color='yellow', button_color='red', fg_color='green', command=self.func_main_callback)
|
||||
self.menu_main.grid(row=0, column=1, sticky='we', padx=(20, 10), pady=(10, 5))
|
||||
self.menu_main.set("Start Here!")
|
||||
# create sub menu
|
||||
@ -104,31 +105,31 @@ class App(customtkinter.CTk):
|
||||
# create axis related
|
||||
self.label_axis = customtkinter.CTkLabel(self.frame_param, text="AXIS", font=self.my_font)
|
||||
self.label_axis.grid(row=2, column=2, sticky='e', pady=(5, 5))
|
||||
self.option_axis = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_axis = customtkinter.CTkOptionMenu(self.frame_param, button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_axis.grid(row=2, column=3, padx=(5, 10), pady=(5, 5), sticky='w')
|
||||
self.option_axis.configure(state='disabled')
|
||||
# create vel related
|
||||
self.label_vel = customtkinter.CTkLabel(self.frame_param, text="Vel", font=self.my_font)
|
||||
self.label_vel.grid(row=2, column=4, sticky='e', pady=(5, 5))
|
||||
self.option_vel = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_vel = customtkinter.CTkOptionMenu(self.frame_param, button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_vel.grid(row=2, column=5, padx=(5, 10), pady=(5, 5), sticky='w')
|
||||
self.option_vel.configure(state='disabled')
|
||||
# create trq related
|
||||
self.label_trq = customtkinter.CTkLabel(self.frame_param, text="Trq", font=self.my_font)
|
||||
self.label_trq.grid(row=2, column=6, sticky='e', pady=(5, 5))
|
||||
self.option_trq = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_trq = customtkinter.CTkOptionMenu(self.frame_param, button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_trq.grid(row=2, column=7, padx=(5, 10), pady=(5, 5), sticky='w')
|
||||
self.option_trq.configure(state='disabled')
|
||||
# create trqH related
|
||||
self.label_trqh = customtkinter.CTkLabel(self.frame_param, text="TrqH", font=self.my_font)
|
||||
self.label_trqh.grid(row=2, column=8, sticky='e', pady=(5, 5))
|
||||
self.option_trqh = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_trqh = customtkinter.CTkOptionMenu(self.frame_param, button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_trqh.grid(row=2, column=9, padx=(5, 10), pady=(5, 5), sticky='w')
|
||||
self.option_trqh.configure(state='disabled')
|
||||
# create STO related
|
||||
self.label_sto = customtkinter.CTkLabel(self.frame_param, text="STO", font=self.my_font)
|
||||
self.label_sto.grid(row=2, column=10, sticky='e', pady=(5, 5))
|
||||
self.option_sto = customtkinter.CTkOptionMenu(self.frame_param, values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_sto = customtkinter.CTkOptionMenu(self.frame_param, button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
self.option_sto.grid(row=2, column=11, padx=(5, 10), pady=(5, 5), sticky='w')
|
||||
self.option_sto.configure(state='disabled')
|
||||
# create rc1
|
||||
@ -169,7 +170,7 @@ class App(customtkinter.CTk):
|
||||
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")
|
||||
self.textbox = customtkinter.CTkTextbox(self, wrap='none', font=customtkinter.CTkFont(family="consolas", size=14), text_color="blue", fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD', border_spacing=5)
|
||||
self.textbox.grid(row=4, column=1, rowspan=3, columnspan=13, ipadx=10, ipady=10, padx=10, pady=(5, 10), sticky='nsew')
|
||||
self.textbox.configure(state='disabled')
|
||||
# =====================================================================
|
||||
@ -235,16 +236,13 @@ class App(customtkinter.CTk):
|
||||
self.initialization()
|
||||
|
||||
if func_name == 'brake':
|
||||
self.menu_sub = customtkinter.CTkOptionMenu(self.frame_param, values=["industrial", "cobot"], font=self.my_font, command=self.func_sub_callback)
|
||||
self.menu_sub.grid(row=1, column=1, sticky='we', padx=(20, 10), pady=(5, 5))
|
||||
self.menu_sub.set("--select--")
|
||||
|
||||
self.label_path.configure(text="Path", text_color='red')
|
||||
self.label_av.configure(text="AV", text_color='red')
|
||||
self.label_rr.configure(text="RR", text_color='red')
|
||||
self.label_axis.configure(text="AXIS", text_color='red')
|
||||
self.label_vel.configure(text="Vel", text_color='red')
|
||||
self.label_trq.configure(text="Trq", text_color='red')
|
||||
self.label_sto.configure(text="STO", text_color='red')
|
||||
|
||||
self.entry_path.configure(state="normal")
|
||||
self.entry_av.configure(state="normal")
|
||||
@ -252,6 +250,7 @@ class App(customtkinter.CTk):
|
||||
self.option_axis.configure(state="normal")
|
||||
self.option_vel.configure(state="normal")
|
||||
self.option_trq.configure(state="normal")
|
||||
self.option_sto.configure(state="normal")
|
||||
|
||||
elif func_name == 'current':
|
||||
self.menu_sub = customtkinter.CTkOptionMenu(self.frame_param, values=["max", "avg", "cycle"], font=self.my_font, command=self.func_sub_callback)
|
||||
@ -284,17 +283,12 @@ class App(customtkinter.CTk):
|
||||
else:
|
||||
self.initialization()
|
||||
self.menu_main.set("Start Here!")
|
||||
self.menu_main.configure(text_color='yellow')
|
||||
|
||||
def func_sub_callback(self, func_name):
|
||||
if func_name == "industrial":
|
||||
self.label_rpm.configure(text="RPM", text_color='red')
|
||||
self.entry_rpm.configure(state="normal")
|
||||
elif func_name == "cobot":
|
||||
if func_name == "max":
|
||||
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.entry_rpm.configure(placeholder_text='额定转速', state="disabled")
|
||||
self.label_dur.configure(text="Dur", text_color='black')
|
||||
self.entry_dur.configure(state="disabled")
|
||||
self.label_vel.configure(text="Vel", text_color='black')
|
||||
@ -303,7 +297,7 @@ class App(customtkinter.CTk):
|
||||
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.entry_rpm.configure(placeholder_text='额定转速', state="disabled")
|
||||
self.label_dur.configure(text="Dur", text_color='black')
|
||||
self.entry_dur.configure(state="disabled")
|
||||
self.label_vel.configure(text="Vel", text_color='black')
|
||||
@ -312,30 +306,30 @@ class App(customtkinter.CTk):
|
||||
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.entry_rpm.configure(state="normal", placeholder_text='额定转速')
|
||||
self.label_dur.configure(text="Dur", text_color='blue')
|
||||
self.entry_dur.configure(state="normal", placeholder_text='scenario')
|
||||
self.entry_dur.configure(state="normal", placeholder_text='周期')
|
||||
self.label_vel.configure(text="Vel", text_color='red')
|
||||
self.option_vel.configure(state="normal")
|
||||
self.label_trq.configure(text="Trq", text_color='red')
|
||||
self.option_trq.configure(state="normal")
|
||||
|
||||
def write2textbox(self, text, wait=0, exitcode=0):
|
||||
def write2textbox(self, text, wait=0, exitcode=0, color='blue'):
|
||||
self.textbox.tag_add(color, 'insert', 'end')
|
||||
self.textbox.tag_config(tagName=color, foreground=color)
|
||||
|
||||
if wait != 0:
|
||||
self.textbox.configure(text_color='blue')
|
||||
self.textbox.insert(index='end', text=text)
|
||||
self.textbox.insert(index='end', text=text, tags=color)
|
||||
self.textbox.update()
|
||||
self.textbox.see('end')
|
||||
elif exitcode != 0:
|
||||
self.textbox.configure(text_color='red')
|
||||
self.textbox.insert(index='end', text=text + '\n')
|
||||
self.textbox.insert(index='end', text=text + '\n', tags=color)
|
||||
self.textbox.update()
|
||||
self.textbox.see('end')
|
||||
self.textbox.configure(state='disabled')
|
||||
raise Exception(f"Error code: {exitcode}")
|
||||
else:
|
||||
self.textbox.configure(text_color='blue')
|
||||
self.textbox.insert(index='end', text=text + '\n')
|
||||
self.textbox.insert(index='end', text=text + '\n', tags=color)
|
||||
self.textbox.update()
|
||||
self.textbox.see('end')
|
||||
|
||||
@ -349,7 +343,7 @@ class App(customtkinter.CTk):
|
||||
_ = float(item)
|
||||
except Exception as Err:
|
||||
tkinter.messagebox.showerror(title="参数错误", message="请检查对应参数是否填写正确!", )
|
||||
self.write2textbox(f"错误信息:{Err}\n参数数据缺失,或者数据类型错误,更正后重新运行...", 0, 3)
|
||||
self.write2textbox(f"错误信息:{Err}\n参数数据缺失,或者数据类型错误,更正后重新运行...\n", 0, 3, 'red')
|
||||
return True
|
||||
|
||||
def check_param(self):
|
||||
@ -361,24 +355,18 @@ class App(customtkinter.CTk):
|
||||
axis = self.option_axis.get()
|
||||
vel = self.option_vel.get()
|
||||
trq = self.option_trq.get()
|
||||
sto = self.option_sto.get()
|
||||
sub_func = self.menu_sub.get()
|
||||
|
||||
c1 = exists(path)
|
||||
c2 = self.is_float('required', av, rr)
|
||||
c3 = rpm = 1
|
||||
# c3 = rpm = 1
|
||||
c3 = True if len({vel, trq, sto}) == 3 else False
|
||||
c4 = sub_func in ['industrial', 'cobot']
|
||||
c5 = True if vel != trq else False
|
||||
|
||||
if self.menu_sub.get() == 'industrial':
|
||||
rpm = self.entry_rpm.get().strip('- ')
|
||||
c3 = rpm.isdigit()
|
||||
elif self.menu_sub.get() == 'cobot':
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
|
||||
if c1 and c2 and c3 and c4 and c5:
|
||||
return 1, path, float(av), float(rr), int(rpm), int(axis), int(vel), int(trq)
|
||||
return 1, path, float(av), float(rr), int(sto), int(axis), int(vel), int(trq)
|
||||
else:
|
||||
return 0, 0
|
||||
# =======================================================
|
||||
@ -440,7 +428,7 @@ class App(customtkinter.CTk):
|
||||
func_dict = {1: brake.main, 2: current.main, 3: iso.main}
|
||||
|
||||
if flag == 1:
|
||||
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)
|
||||
func_dict[flag](path=args[0], av=args[1], rr=args[2], sto=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], rpm=args[7], w2t=self.write2textbox)
|
||||
|
Reference in New Issue
Block a user