优化界面 完善逻辑

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

43
aio.py
View File

@ -187,15 +187,30 @@ class MainWindow(main_window.Ui_MainWindow):
self.run_program_thread(do_current.DoCurrentTest(self.le_unit_path.text(), self.cb_unit_tool.currentText()), 5, prog_done, None)
elif self.tw_funcs.currentIndex() == 2: # tab: 耐久采集 | func: 场景数据持久化
self.run_program_thread(factory_test.DoFactoryTest(self.le_durable_path.text(), self.le_durable_interval.text(), self.get_checkbox_states()), 6, prog_done, None)
else:
QMessageBox.warning(self, "运行错误", "当前无可运行的功能!")
def prog_stop(self):
if sum(clibs.running) == 0:
return
if clibs.stop_flag:
QMessageBox.warning(self, "停止运行", "当前程序正在停止中,请勿重复执行!")
return
idx = clibs.running.index(1)
clibs.running[idx] = 0
clibs.logger("INFO", "aio", f"{clibs.functions[idx]}程序已经停止涉及Excel文件读写时可能会损坏该文件", "red")
# QMessageBox.warning(self, "停止运行", "运行过程中不建议停止运行,可能会损坏文件,如果确实需要停止运行,可以直接关闭窗口!")
if idx in [0, 1, 2, 3]:
QMessageBox.warning(self, "停止运行", "数据处理功能不支持中途停止,可直接关闭窗口以强制终止程序的执行,但有文件损坏的风险!")
return
if idx in [4, 5, 6]:
try:
clibs.c_hr.execution("diagnosis.open", open=False, display_open=False)
clibs.c_hr.execution("diagnosis.set_params", display_pdo_params=[])
clibs.c_md.r_soft_estop(0)
except:
...
clibs.running[idx], clibs.stop_flag = 0, True
clibs.logger("INFO", "aio", f"{clibs.functions[idx]}程序正在停止中,需要一些时间清理后台数据,等待程序运行状态为 IDLE 时可重新运行其他程序!", "red")
def prog_reset(self):
self.tw_docs.setCurrentIndex(0)
@ -946,7 +961,7 @@ class MainWindow(main_window.Ui_MainWindow):
self.btn_ec_conn.setText("连接")
self.ec_state.setText(f'<img src="{clibs.PREFIX}/media/red.png" width="10" height="10" /><font face="consolas" size="4"><b>EC&nbsp;&nbsp;</b></font>')
# ============= Program running status =============
if sum(clibs.running) == 1:
if sum(clibs.running) == 1 or clibs.stop_flag:
self.run_state.setText(f'<img src="{clibs.PREFIX}/media/red.png" width="10" height="10" /><font face="consolas" size="4"><b>BUSY</b></font>')
else:
self.run_state.setText(f'<img src="{clibs.PREFIX}/media/green.png" width="10" height="10" /><font face="consolas" size="4"><b>IDLE</b></font>')
@ -954,6 +969,7 @@ class MainWindow(main_window.Ui_MainWindow):
def closeEvent(self, event):
idx = -1 if clibs.running.count(1) == 0 else clibs.running.index(1)
info_text = "当前无程序正在运行,可放心退出!" if idx == -1 else f"当前正在运行{clibs.functions[idx]},确认退出?"
info_text = "当前有程序正在停止中,确认退出?" if clibs.stop_flag else info_text
reply = QMessageBox.question(self, "退出", info_text)
if reply == QMessageBox.Yes:
os.chdir(clibs.log_path)
@ -1001,7 +1017,7 @@ class MainWindow(main_window.Ui_MainWindow):
if local_vers == server_vers:
self.update_label.setText(f'<img src="{clibs.PREFIX}/media/updated.png" width="14" height="14" style="vertical-align: middle;" /><span style="vertical-align: middle; font-size: 14px; font-weight: bold; color: #0D8A3D;"> Current is the latest version</span>')
elif local_vers > server_vers:
pass
self.update_label.setText(f'<img src="{clibs.PREFIX}/media/updated.png" width="14" height="14" style="vertical-align: middle;" /><span style="vertical-align: middle; font-size: 14px; font-weight: bold; color: #0D8A3D;"> Current is the latest version</span>')
elif local_vers < server_vers:
self.update_label.setText(f'''<a href="https://www.rustle.cc/aio.zip" style="text-decoration: none;"><img src="{clibs.PREFIX}/media/upgrade.png" width="14" height="14" style="vertical-align: middle;" /><span style="vertical-align: middle; font-size: 14px; font-weight: bold; color: #D81E06;"> v{server_vers.split('@')[0]} has been released, update ASAP!</span></a>''')
@ -1087,16 +1103,17 @@ class SplashScreen(QApplication):
self.splash.show()
self.splash.showMessage("正在加载资源.....", Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignHCenter, Qt.GlobalColor.white)
# self.t = QThread(self)
# self.run = InitWork()
# self.run.moveToThread(self.t)
# self.run.completed.connect(self.prog_done)
# self.action.connect(self.run.program)
# self.t.start()
# self.action.emit(1)
# with validation of server version
self.t = QThread(self)
self.run = InitWork()
self.run.moveToThread(self.t)
self.run.completed.connect(self.prog_done)
self.action.connect(self.run.program)
self.t.start()
self.action.emit(1)
# without validation of server version
self.prog_done("true")
# self.prog_done("true")
def prog_done(self, result):
if result == "false" or result == "":

View File

@ -6,8 +6,8 @@ VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(0, 4, 0, 0),
prodvers=(0, 4, 0, 0),
filevers=(0, 4, 0, 1),
prodvers=(0, 4, 0, 1),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
@ -31,12 +31,12 @@ VSVersionInfo(
'040904b0',
[StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'),
StringStruct('FileDescription', 'All in one automatic toolbox'),
StringStruct('FileVersion', '0.4.0.0 (2025-03-28)'),
StringStruct('FileVersion', '0.4.0.1 (2025-03-30)'),
StringStruct('InternalName', 'AIO.exe'),
StringStruct('LegalCopyright', '© 2024-2025 Manford Fan'),
StringStruct('OriginalFilename', 'AIO.exe'),
StringStruct('ProductName', 'AIO'),
StringStruct('ProductVersion', '0.4.0.0 (2025-03-28)')])
StringStruct('ProductVersion', '0.4.0.1 (2025-03-30)')])
]),
VarFileInfo([VarStruct('Translation', [1033, 1200])])
]

View File

@ -1 +1 @@
0.4.0.0@03/27/2025
0.4.0.1@03/30/2025

View File

@ -1,11 +1,13 @@
chardet==5.2.0
customtkinter==5.2.2
matplotlib==3.10.0
numpy==2.2.2
Pillow==11.1.0
pyinstaller==6.12.0
chardet==5.2.0
codes==0.1.5
numpy==2.2.4
openpyxl==3.1.5
pandas==2.2.3
paramiko==3.5.0
pdfplumber==0.11.5
Pillow==11.1.0
pymodbus==3.8.3
pyinstaller==6.12.0
paramiko==3.5.1
pdfplumber==0.11.6
pymodbus==3.8.6
PySide6==6.8.3

View File

@ -1 +1 @@
0.4.0.0@03/27/2025
0.4.0.1@03/30/2025

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):

View File

@ -79,7 +79,7 @@
## 三、注意事项
> **仅内网使用!!**
> **需要联网使用!!**
1. 仅适用于 xCore 2.3.0.7 及以上的版本
2. 仅适配了六轴工业/协作机型其他机型可能会存在使用上的问题具体可以找fanmingfu@rokae.com确认