优化界面 完善逻辑
This commit is contained in:
43
aio.py
43
aio.py
@ -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 </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 == "":
|
||||
|
Reference in New Issue
Block a user