11. [openapi.py] 建联部分做容错处理,并将读写文件做自适应处理
12. [aio.py] 将读写文件做自适应处理,引入openapi模块并生成实例,做心跳检测,将socket超时时间修改为3s
This commit is contained in:
2024-06-24 19:22:56 +08:00
parent a4009eb17c
commit 6604f0ba06
4 changed files with 42 additions and 20 deletions

View File

@ -1,5 +1,5 @@
import tkinter
from os.path import exists
from os.path import exists, dirname
from os import getcwd
from threading import Thread
import tkinter.messagebox
@ -11,12 +11,13 @@ import data_process.brake as brake
import data_process.current as current
import data_process.iso as iso
import data_process.wavelogger as wavelogger
import automatic_test.openapi as openapi
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
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
setdefaulttimeout(10)
setdefaulttimeout(3)
# global vars
btns_func = {
'start': {'btn': '', 'row': 1, 'text': '开始运行'},
@ -146,7 +147,7 @@ class App(customtkinter.CTk):
self.seg_button.configure(values=["无效功能", "触发急停", "停止运动", "继续运动", "零点位姿", "机器状态", "告警信息"])
self.seg_button.set("无效功能")
# self.seg_button.configure(state="disabled")
# create progress bar
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")
@ -206,8 +207,9 @@ class App(customtkinter.CTk):
pass
def detect_network(self):
current_path = dirname(__file__)
while True:
with open('./automatic_test/templates/heartbeat', 'r', encoding='utf-8') as f_h:
with open(f'{current_path}/../assets/templates/heartbeat', 'r', encoding='utf-8') as f_h:
pb_color = 'green' if f_h.read().strip() == '1' else 'red'
self.progressbar.configure(progress_color=pb_color)
sleep(3)
@ -490,8 +492,9 @@ class App(customtkinter.CTk):
if __name__ == "__main__":
with open("./automatic_test/templates/heartbeat", "w", encoding='utf-8') as f_h:
f_h.write('0')
t_hr = Thread(target=openapi.HmiRequest)
t_hr.daemon = True
t_hr.start()
aio = App()
aio.net_detect = Thread(target=aio.detect_network)