2024-06-12
4. [openapi.py] 使用 int.to_bytes 和 int.from_bytes 替换 binascii 模块的功能 5. [aio.py] 修改了Data Process中初始化的动作,使得初始化时的状态统一成程序刚启动时的样子 6. [aio.py] 增加了tabview的点击行为函数,每次点击tab都会初始化 7. [aio.py] 增加了Automatic Test界面元素,包括如下,并完成了功能框架的搭建 - 标签:文件/角速度/减速比 - 按钮:急停及恢复 - 输入框:文件路径/角速度/减速比 - OptionMenu:负载 - 进度条
This commit is contained in:
parent
ff4b0cc04c
commit
295894a843
@ -251,6 +251,14 @@ v0.1.7.0(2024/06/29)
|
||||
2. [openapi.py] 修改了封包的规则,使之更加明晰,封包操作没有实现分包功能,目前看实际场景用不到
|
||||
3. [openapi.py] 定义 MAX_FRAME_SIZE 常量(1024),替换socket接收以及响应数据处理相关部分
|
||||
4. [openapi.py] 使用 int.to_bytes 和 int.from_bytes 替换 binascii 模块的功能
|
||||
5. [aio.py] 修改了Data Process中初始化的动作,使得初始化时的状态统一成程序刚启动时的样子
|
||||
6. [aio.py] 增加了tabview的点击行为函数,每次点击tab都会初始化
|
||||
7. [aio.py] 增加了Automatic Test界面元素,包括如下,并完成了功能框架的搭建
|
||||
- 标签:文件/角速度/减速比
|
||||
- 按钮:急停及恢复
|
||||
- 输入框:文件路径/角速度/减速比
|
||||
- OptionMenu:负载
|
||||
- 进度条
|
||||
|
||||
> **关于HMI接口**
|
||||
> - 封包解包顺序:帧长度二字节/包长度四字节/协议二字节/预留二字节,\x04\x00:\x00\x00\tR:\x02:\x00
|
||||
|
Binary file not shown.
298
aio/code/aio.py
298
aio/code/aio.py
@ -1,3 +1,4 @@
|
||||
import tkinter
|
||||
from os.path import exists
|
||||
from os import getcwd
|
||||
from threading import Thread
|
||||
@ -17,13 +18,13 @@ customtkinter.set_widget_scaling(1.1) # widget dimensions and text size
|
||||
customtkinter.set_window_scaling(1.1) # window geometry dimensions
|
||||
setdefaulttimeout(10)
|
||||
# global vars
|
||||
btns = {
|
||||
btns_func = {
|
||||
'start': {'btn': '', 'row': 1, 'text': '开始运行'},
|
||||
'check': {'btn': '', 'row': 2, 'text': '检查参数'},
|
||||
'log': {'btn': '', 'row': 3, 'text': '保存日志'},
|
||||
'end': {'btn': '', 'row': 4, 'text': '结束运行'},
|
||||
}
|
||||
widgits = {
|
||||
widgits_dp = {
|
||||
'path': {'label': '', 'entry': '', 'row': 1, 'col': 2, 'text': '数据文件夹路径'},
|
||||
'av': {'label': '', 'entry': '', 'row': 2, 'col': 2, 'text': '角速度'},
|
||||
'rc': {'label': '', 'entry': '', 'row': 2, 'col': 4, 'text': '额定电流'},
|
||||
@ -42,11 +43,36 @@ widgits = {
|
||||
'rc5': {'label': '', 'entry': '', 'row': 4, 'col': 10, 'text': '额定电流'},
|
||||
'rc6': {'label': '', 'entry': '', 'row': 4, 'col': 12, 'text': '额定电流'},
|
||||
}
|
||||
widgits_at = {
|
||||
'path': {'label': '', 'entry': '', 'row': 2, 'col': 2, 'text': '数据文件夹路径'},
|
||||
'loadsel': {'label': '', 'optionmenu': '', 'row': 2, 'col': 1, 'text': '负载信息'},
|
||||
'av1': {'label': '', 'entry': '', 'row': 3, 'col': 2, 'text': '角速度'},
|
||||
'av2': {'label': '', 'entry': '', 'row': 3, 'col': 4, 'text': '角速度'},
|
||||
'av3': {'label': '', 'entry': '', 'row': 3, 'col': 6, 'text': '角速度'},
|
||||
'av4': {'label': '', 'entry': '', 'row': 3, 'col': 8, 'text': '角速度'},
|
||||
'av5': {'label': '', 'entry': '', 'row': 3, 'col': 10, 'text': '角速度'},
|
||||
'av6': {'label': '', 'entry': '', 'row': 3, 'col': 12, 'text': '角速度'},
|
||||
'rc1': {'label': '', 'entry': '', 'row': 4, 'col': 2, 'text': '额定电流'},
|
||||
'rc2': {'label': '', 'entry': '', 'row': 4, 'col': 4, 'text': '额定电流'},
|
||||
'rc3': {'label': '', 'entry': '', 'row': 4, 'col': 6, 'text': '额定电流'},
|
||||
'rc4': {'label': '', 'entry': '', 'row': 4, 'col': 8, 'text': '额定电流'},
|
||||
'rc5': {'label': '', 'entry': '', 'row': 4, 'col': 10, 'text': '额定电流'},
|
||||
'rc6': {'label': '', 'entry': '', 'row': 4, 'col': 12, 'text': '额定电流'},
|
||||
'rr1': {'label': '', 'entry': '', 'row': 5, 'col': 2, 'text': '额定转速'},
|
||||
'rr2': {'label': '', 'entry': '', 'row': 5, 'col': 4, 'text': '额定转速'},
|
||||
'rr3': {'label': '', 'entry': '', 'row': 5, 'col': 6, 'text': '额定转速'},
|
||||
'rr4': {'label': '', 'entry': '', 'row': 5, 'col': 8, 'text': '额定转速'},
|
||||
'rr5': {'label': '', 'entry': '', 'row': 5, 'col': 10, 'text': '额定转速'},
|
||||
'rr6': {'label': '', 'entry': '', 'row': 5, 'col': 12, 'text': '额定转速'},
|
||||
}
|
||||
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.net_detect = Thread(target=self.detect_network)
|
||||
self.net_detect.daemon = True
|
||||
self.net_detect.start()
|
||||
self.my_font = customtkinter.CTkFont(family="Consolas", size=16, weight="bold")
|
||||
self.w_param = 84
|
||||
# =====================================================================
|
||||
@ -56,7 +82,7 @@ class App(customtkinter.CTk):
|
||||
self.geometry("1200x550+30+30")
|
||||
self.protocol("WM_DELETE_WINDOW", self.func_end_callback)
|
||||
self.config(bg='#E9E9E9')
|
||||
self.grid_rowconfigure(5, weight=1)
|
||||
self.grid_rowconfigure(6, weight=1)
|
||||
self.grid_columnconfigure((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), weight=1)
|
||||
self.minsize(1200, 550)
|
||||
# =====================================================================
|
||||
@ -67,54 +93,90 @@ class App(customtkinter.CTk):
|
||||
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 buttons
|
||||
for func in btns:
|
||||
btns[func]['btn'] = customtkinter.CTkButton(self.frame_func, corner_radius=10, text=btns[func]['text'], fg_color='#4F4F4F', font=self.my_font)
|
||||
btns[func]['btn'].grid(row=btns[func]['row'], column=0, sticky='new', padx=10, pady=10, ipadx=5, ipady=5)
|
||||
btns['start']['btn'].configure(command=lambda: self.thread_it(self.func_start_callback))
|
||||
btns['check']['btn'].configure(command=lambda: self.thread_it(self.func_check_callback))
|
||||
btns['log']['btn'].configure(command=lambda: self.thread_it(self.func_log_callback))
|
||||
btns['end']['btn'].configure(command=lambda: self.thread_it(self.func_end_callback))
|
||||
for func in btns_func:
|
||||
btns_func[func]['btn'] = customtkinter.CTkButton(self.frame_func, corner_radius=10, text=btns_func[func]['text'], fg_color='#4F4F4F', font=self.my_font)
|
||||
btns_func[func]['btn'].grid(row=btns_func[func]['row'], column=0, sticky='new', padx=10, pady=10, ipadx=5, ipady=5)
|
||||
btns_func['start']['btn'].configure(command=lambda: self.thread_it(self.func_start_callback))
|
||||
btns_func['check']['btn'].configure(command=lambda: self.thread_it(self.func_check_callback))
|
||||
btns_func['log']['btn'].configure(command=lambda: self.thread_it(self.func_log_callback))
|
||||
btns_func['end']['btn'].configure(command=lambda: self.thread_it(self.func_end_callback))
|
||||
# create version info
|
||||
self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.1.6.3\nDate: 06/18/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 tabviews
|
||||
self.tabview = customtkinter.CTkTabview(self, width=10000, height=100, anchor='w', fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD')
|
||||
self.tabview = customtkinter.CTkTabview(self, width=10000, height=100, anchor='w', fg_color='#E9E9E9', border_width=2, border_color='#CDCDCD', command=self.tabview_click)
|
||||
self.tabview.grid(row=0, column=1, padx=10, pady=5, sticky="nsew")
|
||||
self.tabview.add("Data Process")
|
||||
self.tabview.add("Automatic Test")
|
||||
# create main menu
|
||||
# create main menu for data process
|
||||
self.menu_main_dp = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), values=["init", "brake", "current", "iso", "wavelogger"], font=self.my_font, text_color='yellow', button_color='red', fg_color='green', command=self.func_main_callback)
|
||||
self.menu_main_dp.grid(row=1, column=1, sticky='we', padx=5, pady=5)
|
||||
self.menu_main_dp.set("Start Here!")
|
||||
# create sub menu
|
||||
# create sub menu for data process
|
||||
self.menu_sub_dp = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'))
|
||||
# =====================================================================
|
||||
# create widgits
|
||||
for widgit in widgits:
|
||||
# create main menu for automatic test
|
||||
self.menu_main_at = customtkinter.CTkOptionMenu(self.tabview.tab('Automatic Test'), values=["init", "brake", "current"], font=self.my_font, text_color='yellow', button_color='red', fg_color='green', command=self.func_main_callback)
|
||||
self.menu_main_at.grid(row=1, column=1, sticky='we', padx=5, pady=5)
|
||||
self.menu_main_at.set("Start Here!")
|
||||
# For data process tab START =====================================================================
|
||||
# create widgits_dp
|
||||
for widgit in widgits_dp:
|
||||
if widgit == 'path':
|
||||
widgits[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f'{widgit.upper()}', font=self.my_font)
|
||||
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=5)
|
||||
widgits[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Data Process'), width=670, placeholder_text=widgits[widgit]['text'], font=self.my_font)
|
||||
widgits[widgit]['entry'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, columnspan=11, padx=(5, 10), pady=5, sticky='we')
|
||||
widgits[widgit]['entry'].configure(state='disabled')
|
||||
widgits_dp[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f'{widgit.upper()}', font=self.my_font)
|
||||
widgits_dp[widgit]['label'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col'], sticky='e', pady=5)
|
||||
widgits_dp[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Data Process'), width=670, placeholder_text=widgits_dp[widgit]['text'], font=self.my_font)
|
||||
widgits_dp[widgit]['entry'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col']+1, columnspan=11, padx=(5, 10), pady=5, sticky='we')
|
||||
widgits_dp[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['av', 'rc', 'rpm', 'rr', 'dur', 'rc1', 'rc2', 'rc3', 'rc4', 'rc5', 'rc6']:
|
||||
widgits[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f"{widgit.upper()}", font=self.my_font)
|
||||
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=5)
|
||||
widgits[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Data Process'), width=self.w_param, placeholder_text=f"{widgits[widgit]['text']}", font=self.my_font)
|
||||
widgits[widgit]['entry'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, padx=(5, 10), pady=5, sticky='w')
|
||||
widgits[widgit]['entry'].configure(state='disabled')
|
||||
widgits_dp[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f"{widgit.upper()}", font=self.my_font)
|
||||
widgits_dp[widgit]['label'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col'], sticky='e', pady=5)
|
||||
widgits_dp[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Data Process'), width=self.w_param, placeholder_text=f"{widgits_dp[widgit]['text']}", font=self.my_font)
|
||||
widgits_dp[widgit]['entry'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col']+1, padx=(5, 10), pady=5, sticky='w')
|
||||
widgits_dp[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['axis', 'vel', 'trq', 'trqh', 'estop']:
|
||||
widgits[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f"{widgit.upper()}", font=self.my_font)
|
||||
widgits[widgit]['label'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col'], sticky='e', pady=5)
|
||||
widgits[widgit]['optionmenu'] = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
widgits[widgit]['optionmenu'].grid(row=widgits[widgit]['row'], column=widgits[widgit]['col']+1, padx=(5, 10), pady=5, sticky='w')
|
||||
widgits[widgit]['optionmenu'].configure(state='disabled')
|
||||
# =====================================================================
|
||||
widgits_dp[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Data Process'), text=f"{widgit.upper()}", font=self.my_font)
|
||||
widgits_dp[widgit]['label'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col'], sticky='e', pady=5)
|
||||
widgits_dp[widgit]['optionmenu'] = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), button_color='#708090', fg_color='#778899', values=["1", "2", "3", "4", "5", "6", "7"], width=self.w_param, font=self.my_font)
|
||||
widgits_dp[widgit]['optionmenu'].grid(row=widgits_dp[widgit]['row'], column=widgits_dp[widgit]['col']+1, padx=(5, 10), pady=5, sticky='w')
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='disabled')
|
||||
# For data process tab END =====================================================================
|
||||
# For automatic test tab START =====================================================================
|
||||
# create buttons
|
||||
self.seg_button = customtkinter.CTkSegmentedButton(self.tabview.tab('Automatic Test'), font=self.my_font, command=lambda value='机器状态': self.thread_it(self.segmented_button_callback()))
|
||||
self.seg_button.grid(row=1, column=2, columnspan=12, padx=(20, 10), pady=(10, 10), sticky="ew")
|
||||
self.seg_button.configure(values=["无效功能", "触发急停", "停止运动", "继续运动", "零点位姿", "机器状态", "告警信息"])
|
||||
self.seg_button.set("无效功能")
|
||||
# self.seg_button.configure(state="disabled")
|
||||
|
||||
self.progressbar = customtkinter.CTkProgressBar(self.tabview.tab('Automatic Test'))
|
||||
self.progressbar.grid(row=5, column=1, padx=5, pady=5, sticky="ew")
|
||||
self.progressbar.configure(mode="determinnate")
|
||||
self.progressbar.start()
|
||||
# create widgits_at
|
||||
for widgit in widgits_at:
|
||||
if widgit == 'path':
|
||||
widgits_at[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Automatic Test'), text=f'{widgit.upper()}', font=self.my_font)
|
||||
widgits_at[widgit]['label'].grid(row=widgits_at[widgit]['row'], column=widgits_at[widgit]['col'], sticky='e', pady=5)
|
||||
widgits_at[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Automatic Test'), width=670, placeholder_text=widgits_at[widgit]['text'], font=self.my_font)
|
||||
widgits_at[widgit]['entry'].grid(row=widgits_at[widgit]['row'], column=widgits_at[widgit]['col']+1, columnspan=11, padx=(5, 10), pady=5, sticky='we')
|
||||
widgits_at[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['av1', 'av2', 'av3', 'av4', 'av5', 'av6', 'rc1', 'rc2', 'rc3', 'rc4', 'rc5', 'rc6', 'rr1', 'rr2', 'rr3', 'rr4', 'rr5', 'rr6']:
|
||||
widgits_at[widgit]['label'] = customtkinter.CTkLabel(self.tabview.tab('Automatic Test'), text=f"{widgit.upper()}", font=self.my_font)
|
||||
widgits_at[widgit]['label'].grid(row=widgits_at[widgit]['row'], column=widgits_at[widgit]['col'], sticky='e', pady=5)
|
||||
widgits_at[widgit]['entry'] = customtkinter.CTkEntry(self.tabview.tab('Automatic Test'), width=self.w_param, placeholder_text=f"{widgits_at[widgit]['text']}", font=self.my_font)
|
||||
widgits_at[widgit]['entry'].grid(row=widgits_at[widgit]['row'], column=widgits_at[widgit]['col']+1, padx=(5, 10), pady=5, sticky='w')
|
||||
widgits_at[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['loadsel', ]:
|
||||
widgits_at[widgit]['optionmenu'] = customtkinter.CTkOptionMenu(self.tabview.tab('Automatic Test'), button_color='#708090', fg_color='#778899', values=["tool33", "tool66", "tool100"], width=self.w_param, font=self.my_font)
|
||||
widgits_at[widgit]['optionmenu'].grid(row=widgits_at[widgit]['row'], column=widgits_at[widgit]['col'], padx=5, pady=5, sticky='we')
|
||||
widgits_at[widgit]['optionmenu'].set(widgits_at[widgit]['text'])
|
||||
widgits_at[widgit]['optionmenu'].configure(state='disabled')
|
||||
# For automatic test tab END =====================================================================
|
||||
# create textbox
|
||||
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=5, column=1, rowspan=2, columnspan=13, ipadx=10, ipady=10, padx=10, pady=(5, 10), sticky='nsew')
|
||||
self.textbox.grid(row=6, column=1, columnspan=13, ipadx=10, ipady=10, padx=10, pady=(5, 10), sticky='nsew')
|
||||
self.textbox.configure(state='disabled')
|
||||
# =====================================================================
|
||||
# version check
|
||||
@ -127,6 +189,27 @@ class App(customtkinter.CTk):
|
||||
tkinter.messagebox.showwarning(title="版本更新", message=msg)
|
||||
except:
|
||||
tkinter.messagebox.showwarning(title="版本更新", message="连接服务器失败,无法确认当前是否是最新版本......")
|
||||
# functions below ↓ ----------------------------------------------------------------------------------------
|
||||
|
||||
def segmented_button_callback(self):
|
||||
value = self.seg_button.get()
|
||||
print(f"segment button is triggered: {value}")
|
||||
match value:
|
||||
case '触发急停':
|
||||
pass
|
||||
case '停止运动':
|
||||
pass
|
||||
case '继续运动':
|
||||
pass
|
||||
case '零点位姿':
|
||||
pass
|
||||
case '机器状态':
|
||||
pass
|
||||
case '告警信息':
|
||||
pass
|
||||
|
||||
def detect_network(self):
|
||||
pass
|
||||
|
||||
def thread_it(self, func, *args):
|
||||
""" 将函数打包进线程 """
|
||||
@ -134,78 +217,107 @@ class App(customtkinter.CTk):
|
||||
self.myThread.daemon = True # 主线程退出就直接让子线程跟随退出,不论是否运行完成。
|
||||
self.myThread.start()
|
||||
|
||||
def tabview_click(self):
|
||||
self.initialization()
|
||||
tab_name = self.tabview.get()
|
||||
if tab_name == 'Data Process':
|
||||
self.menu_main_dp.set("Start Here!")
|
||||
elif tab_name == 'Automatic Test':
|
||||
self.menu_main_at.set("Start Here!")
|
||||
|
||||
def initialization(self):
|
||||
for widgit in widgits:
|
||||
tab_name = self.tabview.get()
|
||||
if tab_name == 'Data Process':
|
||||
for widgit in widgits_dp:
|
||||
if widgit in ['path', 'av', 'rc', 'rpm', 'rr', 'dur', 'rc1', 'rc2', 'rc3', 'rc4', 'rc5', 'rc6']:
|
||||
widgits[widgit]['label'].configure(text=f'{widgit.upper()}', text_color='black')
|
||||
widgits[widgit]['entry'].configure(placeholder_text=widgits[widgit]['text'], state='disabled')
|
||||
widgits_dp[widgit]['label'].configure(text=f'{widgit.upper()}', text_color='black')
|
||||
widgits_dp[widgit]['entry'].delete(0, tkinter.END)
|
||||
widgits_dp[widgit]['entry'].configure(placeholder_text=widgits_dp[widgit]['text'], state='normal')
|
||||
widgits_dp[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['axis', 'vel', 'trq', 'trqh', 'estop']:
|
||||
widgits[widgit]['label'].configure(text=f'{widgit.upper()}', text_color="black")
|
||||
widgits[widgit]['optionmenu'].configure(state='disabled')
|
||||
widgits_dp[widgit]['label'].configure(text=f'{widgit.upper()}', text_color="black")
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='normal')
|
||||
widgits_dp[widgit]['optionmenu'].set('1')
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='disabled')
|
||||
|
||||
self.menu_sub_dp.grid_forget()
|
||||
self.textbox.delete(index1='1.0', index2='end')
|
||||
self.textbox.configure(state='disabled')
|
||||
elif tab_name == 'Automatic Test':
|
||||
for widgit in widgits_at:
|
||||
if widgit in ['path', 'av1', 'av2', 'av3', 'av4', 'av5', 'av6', 'rc1', 'rc2', 'rc3', 'rc4', 'rc5', 'rc6', 'rr1', 'rr2', 'rr3', 'rr4', 'rr5', 'rr6']:
|
||||
widgits_at[widgit]['label'].configure(text=f'{widgit.upper()}', text_color='black')
|
||||
widgits_at[widgit]['entry'].delete(0, tkinter.END)
|
||||
widgits_at[widgit]['entry'].configure(placeholder_text=widgits_at[widgit]['text'], state='normal')
|
||||
widgits_at[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['loadsel']:
|
||||
widgits_at[widgit]['optionmenu'].configure(state='normal')
|
||||
widgits_at[widgit]['optionmenu'].set(widgits_at[widgit]['text'])
|
||||
widgits_at[widgit]['optionmenu'].configure(state='disabled')
|
||||
self.seg_button.set("无效按钮")
|
||||
|
||||
def func_main_callback(self, func_name):
|
||||
self.initialization()
|
||||
|
||||
tab_name = self.tabview.get()
|
||||
if tab_name == 'Data Process':
|
||||
if func_name == 'brake':
|
||||
for widgit in widgits:
|
||||
for widgit in widgits_dp:
|
||||
if widgit in ['path', 'av', 'rr']:
|
||||
widgits[widgit]['label'].configure(text_color='red')
|
||||
widgits[widgit]['entry'].configure(state='normal')
|
||||
widgits_dp[widgit]['label'].configure(text_color='red')
|
||||
widgits_dp[widgit]['entry'].configure(state='normal')
|
||||
elif widgit in ['axis', 'vel', 'trq', 'estop']:
|
||||
widgits[widgit]['label'].configure(text_color="red")
|
||||
widgits[widgit]['optionmenu'].configure(state='normal')
|
||||
widgits_dp[widgit]['label'].configure(text_color="red")
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='normal')
|
||||
elif func_name == 'current':
|
||||
self.menu_sub_dp = customtkinter.CTkOptionMenu(self.tabview.tab('Data Process'), values=["max", "avg", "cycle"], font=self.my_font, button_color='red', fg_color='green', command=self.func_sub_callback)
|
||||
self.menu_sub_dp.grid(row=2, column=1, sticky='we', padx=5, pady=5)
|
||||
self.menu_sub_dp.set("--select--")
|
||||
self.menu_sub_dp.configure(text_color='yellow')
|
||||
|
||||
for widgit in widgits:
|
||||
for widgit in widgits_dp:
|
||||
if widgit in ['path', 'rc', 'rc1', 'rc2', 'rc3', 'rc4', 'rc5', 'rc6']:
|
||||
color = 'blue' if widgit == 'rc' else 'red'
|
||||
widgits[widgit]['label'].configure(text_color=color)
|
||||
widgits[widgit]['entry'].configure(state='normal')
|
||||
widgits_dp[widgit]['label'].configure(text_color=color)
|
||||
widgits_dp[widgit]['entry'].configure(state='normal')
|
||||
elif widgit in ['trqh',]:
|
||||
widgits[widgit]['label'].configure(text_color="red")
|
||||
widgits[widgit]['optionmenu'].configure(state='normal')
|
||||
widgits_dp[widgit]['label'].configure(text_color="red")
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='normal')
|
||||
elif func_name == 'iso' or func_name == 'wavelogger':
|
||||
for widgit in widgits:
|
||||
for widgit in widgits_dp:
|
||||
if widgit in ['path',]:
|
||||
widgits[widgit]['label'].configure(text_color='red')
|
||||
widgits[widgit]['entry'].configure(state='normal')
|
||||
widgits_dp[widgit]['label'].configure(text_color='red')
|
||||
widgits_dp[widgit]['entry'].configure(state='normal')
|
||||
else:
|
||||
self.initialization()
|
||||
self.menu_main_dp.set("Start Here!")
|
||||
elif tab_name == 'Automatic Test':
|
||||
pass
|
||||
|
||||
def func_sub_callback(self, func_name):
|
||||
if func_name == "max":
|
||||
for widgit in widgits:
|
||||
for widgit in widgits_dp:
|
||||
if widgit in ['rpm', 'dur']:
|
||||
widgits[widgit]['label'].configure(text_color='black')
|
||||
widgits[widgit]['entry'].configure(state='disabled')
|
||||
widgits_dp[widgit]['label'].configure(text_color='black')
|
||||
widgits_dp[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['vel', 'trq']:
|
||||
widgits[widgit]['label'].configure(text_color='black')
|
||||
widgits[widgit]['optionmenu'].configure(state='disabled')
|
||||
widgits_dp[widgit]['label'].configure(text_color='black')
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='disabled')
|
||||
elif func_name == 'avg':
|
||||
for widgit in widgits:
|
||||
for widgit in widgits_dp:
|
||||
if widgit in ['rpm', 'dur']:
|
||||
widgits[widgit]['label'].configure(text_color='black')
|
||||
widgits[widgit]['entry'].configure(state='disabled')
|
||||
widgits_dp[widgit]['label'].configure(text_color='black')
|
||||
widgits_dp[widgit]['entry'].configure(state='disabled')
|
||||
elif widgit in ['vel', 'trq']:
|
||||
widgits[widgit]['label'].configure(text_color='black')
|
||||
widgits[widgit]['optionmenu'].configure(state='disabled')
|
||||
widgits_dp[widgit]['label'].configure(text_color='black')
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='disabled')
|
||||
elif func_name == 'cycle':
|
||||
for widgit in widgits:
|
||||
for widgit in widgits_dp:
|
||||
if widgit in ['rpm', 'dur']:
|
||||
widgits[widgit]['label'].configure(text_color='blue')
|
||||
widgits[widgit]['entry'].configure(state='normal')
|
||||
widgits_dp[widgit]['label'].configure(text_color='blue')
|
||||
widgits_dp[widgit]['entry'].configure(state='normal')
|
||||
elif widgit in ['vel', 'trq']:
|
||||
widgits[widgit]['label'].configure(text_color="red")
|
||||
widgits[widgit]['optionmenu'].configure(state='normal')
|
||||
widgits_dp[widgit]['label'].configure(text_color="red")
|
||||
widgits_dp[widgit]['optionmenu'].configure(state='normal')
|
||||
|
||||
def write2textbox(self, text, wait=0, exitcode=0, color='blue'):
|
||||
self.textbox.tag_add(color, 'insert', 'end')
|
||||
@ -240,15 +352,17 @@ class App(customtkinter.CTk):
|
||||
return True
|
||||
|
||||
def check_param(self):
|
||||
tab_name = self.tabview.get()
|
||||
if tab_name == 'Data Process':
|
||||
func_name = self.menu_main_dp.get()
|
||||
if func_name == 'brake':
|
||||
path = widgits['path']['entry'].get().strip()
|
||||
av = widgits['av']['entry'].get().strip('- ')
|
||||
rr = widgits['rr']['entry'].get().strip('- ')
|
||||
axis = widgits['axis']['optionmenu'].get()
|
||||
vel = widgits['vel']['optionmenu'].get()
|
||||
trq = widgits['trq']['optionmenu'].get()
|
||||
estop = widgits['estop']['optionmenu'].get()
|
||||
path = widgits_dp['path']['entry'].get().strip()
|
||||
av = widgits_dp['av']['entry'].get().strip('- ')
|
||||
rr = widgits_dp['rr']['entry'].get().strip('- ')
|
||||
axis = widgits_dp['axis']['optionmenu'].get()
|
||||
vel = widgits_dp['vel']['optionmenu'].get()
|
||||
trq = widgits_dp['trq']['optionmenu'].get()
|
||||
estop = widgits_dp['estop']['optionmenu'].get()
|
||||
|
||||
c1 = exists(path)
|
||||
c2 = self.is_float('required', av, rr)
|
||||
@ -260,19 +374,19 @@ class App(customtkinter.CTk):
|
||||
return 0, 0
|
||||
# =======================================================
|
||||
elif func_name == 'current':
|
||||
path = widgits['path']['entry'].get().strip()
|
||||
rc = widgits['rc']['entry'].get().strip('- ')
|
||||
rpm = widgits['rpm']['entry'].get().strip()
|
||||
dur = widgits['dur']['entry'].get().strip()
|
||||
rc1 = widgits['rc1']['entry'].get().strip()
|
||||
rc2 = widgits['rc2']['entry'].get().strip()
|
||||
rc3 = widgits['rc3']['entry'].get().strip()
|
||||
rc4 = widgits['rc4']['entry'].get().strip()
|
||||
rc5 = widgits['rc5']['entry'].get().strip()
|
||||
rc6 = widgits['rc6']['entry'].get().strip()
|
||||
vel = widgits['vel']['optionmenu'].get()
|
||||
trq = widgits['trq']['optionmenu'].get()
|
||||
trqh = widgits['trqh']['optionmenu'].get()
|
||||
path = widgits_dp['path']['entry'].get().strip()
|
||||
rc = widgits_dp['rc']['entry'].get().strip('- ')
|
||||
rpm = widgits_dp['rpm']['entry'].get().strip()
|
||||
dur = widgits_dp['dur']['entry'].get().strip()
|
||||
rc1 = widgits_dp['rc1']['entry'].get().strip()
|
||||
rc2 = widgits_dp['rc2']['entry'].get().strip()
|
||||
rc3 = widgits_dp['rc3']['entry'].get().strip()
|
||||
rc4 = widgits_dp['rc4']['entry'].get().strip()
|
||||
rc5 = widgits_dp['rc5']['entry'].get().strip()
|
||||
rc6 = widgits_dp['rc6']['entry'].get().strip()
|
||||
vel = widgits_dp['vel']['optionmenu'].get()
|
||||
trq = widgits_dp['trq']['optionmenu'].get()
|
||||
trqh = widgits_dp['trqh']['optionmenu'].get()
|
||||
sub = self.menu_sub_dp.get()
|
||||
|
||||
c1 = exists(path)
|
||||
@ -298,7 +412,7 @@ class App(customtkinter.CTk):
|
||||
return 0, 0
|
||||
# =======================================================
|
||||
elif func_name == 'iso':
|
||||
path = widgits['path']['entry'].get().strip()
|
||||
path = widgits_dp['path']['entry'].get().strip()
|
||||
c1 = exists(path)
|
||||
if c1:
|
||||
return 3, path
|
||||
@ -306,7 +420,7 @@ class App(customtkinter.CTk):
|
||||
return 0, 0
|
||||
# =======================================================
|
||||
elif func_name == 'wavelogger':
|
||||
path = widgits['path']['entry'].get().strip()
|
||||
path = widgits_dp['path']['entry'].get().strip()
|
||||
c1 = exists(path)
|
||||
if c1:
|
||||
return 4, path
|
||||
@ -315,6 +429,12 @@ class App(customtkinter.CTk):
|
||||
# =======================================================
|
||||
else:
|
||||
return 0, 0
|
||||
elif tab_name == 'Automatic Test':
|
||||
func_name = self.menu_main_at.get()
|
||||
if func_name == 'brake':
|
||||
pass
|
||||
elif func_name == 'current':
|
||||
pass
|
||||
|
||||
def func_start_callback(self):
|
||||
self.textbox.configure(state='normal')
|
||||
|
@ -3,8 +3,6 @@ import socket
|
||||
import threading
|
||||
import selectors
|
||||
import time
|
||||
import sys
|
||||
|
||||
|
||||
MAX_FRAME_SIZE = 1024
|
||||
|
||||
|
Reference in New Issue
Block a user