diff --git a/aio.py b/aio.py
index d855c43..eb40b36 100644
--- a/aio.py
+++ b/aio.py
@@ -4,7 +4,6 @@ import os
import re
import sqlite3
import sys
-import threading
import time
from urllib import request
import os.path
@@ -12,11 +11,10 @@ import matplotlib
import matplotlib.pyplot as plt
import pandas
from matplotlib.widgets import Slider
-matplotlib.use('QtAgg')
from PySide6.QtCore import Qt, QThread, Signal, QObject, QTimer
from PySide6.QtGui import QTextCursor, QFont, QPixmap, QColor, QBrush, QIcon
-from PySide6.QtWidgets import QMessageBox, QCheckBox, QSplashScreen, QApplication, QFrame, QLabel, QTreeWidgetItem, QFileDialog, QHeaderView, QDialog, QVBoxLayout, QPlainTextEdit
+from PySide6.QtWidgets import QMessageBox, QCheckBox, QSplashScreen, QApplication, QLabel, QTreeWidgetItem, QFileDialog, QHeaderView, QDialog, QVBoxLayout, QPlainTextEdit
import codes.common.clibs as clibs
import codes.common.openapi as openapi
@@ -24,6 +22,7 @@ import codes.ui.main_window as main_window
from codes.analysis import brake, current, wavelogger, iso
from codes.autotest import do_current, do_brake
from codes.durable import factory_test
+matplotlib.use('QtAgg')
class ContentDialog(QDialog):
@@ -135,6 +134,10 @@ class MainWindow(main_window.Ui_MainWindow):
self.run = RunProg()
self.run.moveToThread(self.t)
self.run.completed.connect(prog_done)
+ try:
+ self.action.disconnect()
+ except TypeError:
+ pass
self.action.connect(self.run.program)
self.t.start()
self.action.emit((prog, idx, reserved))
@@ -447,7 +450,7 @@ class MainWindow(main_window.Ui_MainWindow):
self.run_program_thread(do_next, -98, self.prog_done_next, None)
def show_item_content(self, item, column):
- content = " | ".join([item.text(i) for i in range(self.treew_log.columnCount())])
+ content = "\n".join([item.text(i) for i in range(self.treew_log.columnCount())])
dialog = ContentDialog(content, self)
dialog.exec()
@@ -880,9 +883,9 @@ class MainWindow(main_window.Ui_MainWindow):
return
elif content[0].strip().startswith("ctrl"):
for item in content[1:]:
- addr = int(item.split(":")[0].strip())
- value = int(item.split(":")[1].strip())
try:
+ addr = int(item.split(":")[0].strip())
+ value = int(item.split(":")[1].strip())
clibs.c_md.c.write_register(addr, value)
time.sleep(clibs.INTERVAL/4)
except Exception as err:
@@ -893,20 +896,27 @@ class MainWindow(main_window.Ui_MainWindow):
else:
QMessageBox.critical(self, "格式错误", "非法的发送内容,自定义发送需参考已有的格式!")
+ def prog_done_ec_send(self, results):
+ flag, result, ret, error, idx, cmd = results
+ print(f"res = {results}")
+ if ret[1] == "error":
+ clibs.logger("ERROR", "openapi", f"{ret[0]}", "red")
+ else:
+ self.pte_ec_recv.appendPlainText(str(ret))
+
def ec_send(self):
+ def ec_send_thread():
+ return clibs.c_ec.sr_string(cmd)
+
if clibs.status["ec"] == 0:
QMessageBox.critical(self, "错误", "使用该功能之前,需要先打开 EC 连接!")
return
if self.pte_ec_send.toPlainText() == "":
return
- self.pte_ec_recv.clear()
cmd = self.pte_ec_send.toPlainText().strip()
- try:
- result = clibs.c_ec.sr_string(cmd)
- self.pte_ec_recv.appendPlainText(str(result))
- except Exception as err:
- self.pte_ec_recv.appendPlainText(f"操作失败:{err}")
+ self.pte_ec_recv.clear()
+ self.run_program_thread(ec_send_thread, -99, self.prog_done_ec_send, cmd)
def hmi_cb_change(self):
cmd = self.cb_hmi_cmd.currentText()
@@ -1103,17 +1113,20 @@ class SplashScreen(QApplication):
self.splash.show()
self.splash.showMessage("正在加载资源.....", Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignHCenter, Qt.GlobalColor.white)
- # 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")
+ with open(f"{clibs.PREFIX}/files/version/IS_VALIDATE", mode="r", encoding="utf-8") as f_validate:
+ is_validate = f_validate.read()
+ if is_validate == "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)
+ else:
+ # without validation of server version
+ self.prog_done("true")
def prog_done(self, result):
if result == "false" or result == "":
diff --git a/assets/files/version/IS_VALIDATE b/assets/files/version/IS_VALIDATE
new file mode 100644
index 0000000..56a6051
--- /dev/null
+++ b/assets/files/version/IS_VALIDATE
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/codes/common/clibs.py b/codes/common/clibs.py
index f8ed7f0..2c61bef 100644
--- a/codes/common/clibs.py
+++ b/codes/common/clibs.py
@@ -2,8 +2,6 @@ import os
import os.path
import threading
import sqlite3
-import time
-
from PySide6.QtCore import Signal, QThread
diff --git a/codes/common/openapi.py b/codes/common/openapi.py
index b329791..bd81a9f 100644
--- a/codes/common/openapi.py
+++ b/codes/common/openapi.py
@@ -1753,7 +1753,7 @@ class ExternalCommunication(QThread):
clibs.c_hr.execution("socket.set_params", enable=True, ip="0.0.0.0", port=str(self.port), suffix="\r", type=1)
# time.sleep(clibs.INTERVAL*2)
self.c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.c.settimeout(clibs.INTERVAL*5)
+ self.c.settimeout(clibs.INTERVAL*3)
try:
self.c.connect((self.ip, self.port))
self.logger("INFO", "openapi", f"ec: 外部通信连接成功...", "green")
@@ -1782,7 +1782,8 @@ class ExternalCommunication(QThread):
try:
char = self.c.recv(1).decode(encoding="unicode_escape")
except Exception as err:
- self.logger("ERROR", "openapi", f"ec: 获取请求指令 {directive} 的返回数据超时,需确认指令发送格式以及内容正确!具体报错信息如下 {err}", "red")
+ result = [f"ec: 获取请求指令 {directive} 的返回数据超时,需确认指令发送格式以及内容正确!具体报错信息如下 {err}", "error"]
+ return result
result = "".join([result, char])
return result
@@ -2033,6 +2034,7 @@ class PreDos(object):
self.ssh_port = ssh_port
self.username = username
self.password = password
+ self.logger = clibs.logger
def __ssh2server(self):
try:
@@ -2041,8 +2043,7 @@ class PreDos(object):
self.__ssh.connect(hostname=self.ip, port=self.ssh_port, username=self.username, password=self.password)
self.__sftp = self.__ssh.open_sftp()
except Exception as err:
- print(f"predos: SSH 无法连接到 {self.ip}:{self.ssh_port},需检查网络连通性或者登录信息是否正确 {err}")
- raise Exception("SshConnFailed")
+ self.logger("ERROR", "openapi", f"predos: SSH 无法连接到 {self.ip}:{self.ssh_port},需检查网络连通性或者登录信息是否正确 {err}", "red")
def push_prj_to_server(self, prj_file):
# prj_file:本地工程完整路径
diff --git a/ui/main.ui b/ui/main.ui
index 0792226..28872b5 100644
--- a/ui/main.ui
+++ b/ui/main.ui
@@ -9,8 +9,8 @@
0
0
- 1006
- 568
+ 1004
+ 563
@@ -1846,8 +1846,8 @@
curve_draw()
- 326
- 80
+ 700
+ 144
701
@@ -1862,8 +1862,8 @@
durable_cb_change()
- 326
- 80
+ 586
+ 142
546
@@ -1878,8 +1878,8 @@
pre_page()
- 326
- 266
+ 408
+ 523
307
@@ -1894,8 +1894,8 @@
realtime_page()
- 326
- 266
+ 489
+ 523
435
@@ -1910,8 +1910,8 @@
next_page()
- 326
- 266
+ 570
+ 523
520
@@ -1926,8 +1926,8 @@
search_keyword()
- 326
- 266
+ 731
+ 523
688
@@ -1942,8 +1942,8 @@
search_keyword()
- 326
- 266
+ 837
+ 521
932
@@ -1958,7 +1958,7 @@
hmi_cb_change()
- 475
+ 810
89
@@ -1974,7 +1974,7 @@
hmi_send()
- 335
+ 891
89
@@ -1990,8 +1990,8 @@
hmi_page()
- 326
- 80
+ 982
+ 85
744
@@ -2006,8 +2006,8 @@
md_page()
- 326
- 80
+ 982
+ 124
784
@@ -2022,8 +2022,8 @@
ec_page()
- 326
- 80
+ 982
+ 163
969
@@ -2038,8 +2038,8 @@
md_cb_change()
- 466
- 80
+ 808
+ 89
612
@@ -2054,8 +2054,8 @@
md_send()
- 326
- 80
+ 889
+ 89
795
@@ -2086,7 +2086,7 @@
hmi_conn()
- 335
+ 545
89
@@ -2102,8 +2102,8 @@
md_conn()
- 326
- 80
+ 545
+ 89
398
@@ -2123,7 +2123,7 @@
412
- -1
+ 0
@@ -2134,12 +2134,12 @@
check_interval()
- 326
- 80
+ 637
+ 109
821
- -3
+ 0
@@ -2155,7 +2155,7 @@
540
- -2
+ 0
@@ -2166,8 +2166,8 @@
hmi_conn()
- 385
- 89
+ 464
+ 87
216
@@ -2246,11 +2246,11 @@
file_browser()
- 326
- 80
+ 985
+ 75
- 1004
+ 1003
56
@@ -2262,11 +2262,11 @@
file_browser()
- 326
- 80
+ 983
+ 76
- 1004
+ 1003
88