优化界面 完善逻辑

This commit is contained in:
2025-03-30 18:55:39 +08:00
parent a9a6db23fd
commit 676eb49679
10 changed files with 59 additions and 42 deletions

View File

@ -186,6 +186,9 @@ class DoBrakeTest(QThread):
self.logger("INFO", "brake", "-" * 90, "purple")
speed_max = 0
for rounds in range(1, 4):
if clibs.stop_flag:
self.logger("ERROR", "do_brake", "后台数据清零完成,现在可以重新运行其他程序。", "green")
count += 1
_ = 3 if count % 3 == 0 else count % 3
this_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
@ -356,9 +359,6 @@ class DoBrakeTest(QThread):
clibs.running[self.idx] = 1
if clibs.status["hmi"] != 1 or clibs.status["md"] != 1 or clibs.status["ec"] != 1:
self.logger("ERROR", "do_brake", "processing: 需要在网络设置中连接HMIModbus通信以及外部通信", "red")
t = threading.Thread(target=clibs.running_detection, args=(self.idx, ))
t.daemon = True
t.start()
data_dirs, data_files = clibs.traversal_files(self.dir_path)
config_file, prj_file, result_dirs, avs = self.initialization(data_dirs, data_files)

View File

@ -183,6 +183,9 @@ class DoCurrentTest(QThread):
clibs.c_md.r_clear_alarm()
for condition in conditions:
if clibs.stop_flag:
self.logger("ERROR", "do_current", "后台数据清零完成,现在可以重新运行其他程序。", "green")
number = conditions.index(condition)
# for testing
# if number < 12:

View File

@ -64,7 +64,7 @@ class LoggerHandler(QThread):
@db_lock
def logger(self, level, module, content, color="black", flag="both"):
global cursor
global cursor, stop_flag
if "move.monitor" in content:
return
@ -80,21 +80,16 @@ class LoggerHandler(QThread):
cursor.execute(f"INSERT INTO logs (level, module, content) VALUES (?, ?, ?)", (level, module, content))
if level.upper() == "ERROR":
stop_flag = False
raise Exception()
def running_detection(idx):
while True:
time.sleep(INTERVAL*2)
if not running[idx]:
raise Exception("")
# PREFIX = "resources/assets" # for pyinstaller
PREFIX = "assets" # for local testing
PREFIX = "resources/assets" # for pyinstaller
# PREFIX = "assets" # for local testing
log_path = f"{PREFIX}/logs"
lock = threading.Lock()
running = [0, 0, 0, 0, 0, 0, 0] # 制动数据/转矩数据/激光数据/精度数据/制动自动化/转矩自动化/耐久数据采集
stop_flag = False
functions = ["制动数据处理", "转矩数据处理", "激光数据处理", "精度数据处理", "制动自动化测试", "转矩自动化测试", "耐久数据采集"]
levels = ["DEBUG", "INFO", "WARNING", "ERROR"]
ip_addr, ssh_port, socket_port, xService_port, external_port, modbus_port, upgrade_port = "", 22, 5050, 6666, 8080, 502, 4567

View File

@ -167,7 +167,7 @@ class DoFactoryTest(QThread):
# 保留数据并处理输出
self.gen_results(params, start_time, end_time)
else:
self.change_curve_state(False)
clibs.stop_flag = False
self.logger("INFO", "factory", "后台数据清零完成,现在可以重新运行其他程序。", "green")
def gen_results(self, params, start_time, end_time):