diff --git a/aio.py b/aio.py index 9ceec6a..fff4f0b 100644 --- a/aio.py +++ b/aio.py @@ -14,7 +14,7 @@ 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 +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 import codes.common.clibs as clibs @@ -25,12 +25,6 @@ from codes.autotest import do_current, do_brake from codes.durable import factory_test -class MultiWindows: - login_window = None - reset_window = None - main_window = None - - class ContentDialog(QDialog): def __init__(self, content, parent=None): super().__init__(parent) @@ -111,6 +105,7 @@ class MainWindow(main_window.Ui_MainWindow): header.setSectionResizeMode(i, QHeaderView.ResizeMode.ResizeToContents) # ========================= clibs ========================= self.setup_statusbar() + self.setWindowIcon(QIcon(f"{clibs.PREFIX}/media/icon.ico")) # ========================= styleSheet ========================= tws = [self.tw_funcs, self.tw_docs] for tw in tws: @@ -199,6 +194,7 @@ class MainWindow(main_window.Ui_MainWindow): QMessageBox.warning(self, "停止运行", "运行过程中不建议停止运行,可能会损坏文件,如果确实需要停止运行,可以直接关闭窗口!") def prog_reset(self): + self.tw_docs.setCurrentIndex(0) self.pte_output.clear() def file_browser(self): @@ -296,6 +292,7 @@ class MainWindow(main_window.Ui_MainWindow): item = QTreeWidgetItem(self.treew_log) for i in range(self.treew_log.columnCount()): item.setText(i, str(record[i])) + item.setTextAlignment(i, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter) self.treew_log.addTopLevelItem(item) color_map = {"DEBUG": QColor(220, 220, 220), "INFO": QColor(144, 238, 144), "WARNING": QColor(255, 240, 210), "ERROR": QColor(255, 220, 220)} brush = QBrush(color_map[record[2].upper()]) @@ -319,11 +316,11 @@ class MainWindow(main_window.Ui_MainWindow): @clibs.db_lock def do_pre(): if self.is_searching is False: - first_id = self.treew_log.topLevelItem(0).text(0) - end = int(first_id)-1 if int(first_id)-1 > 0 else None - start = int(first_id)-100 if int(first_id)-100 > 0 else 0 + first_id = int(self.treew_log.topLevelItem(0).text(0)) + end = first_id-1 if first_id-1 > 0 else None if end is None: return + start = end-100 if end-100 > 0 else 1 clibs.cursor.execute(f"SELECT * FROM logs WHERE id BETWEEN {start} AND {end}") records = clibs.cursor.fetchall() @@ -400,7 +397,7 @@ class MainWindow(main_window.Ui_MainWindow): line_number = self.treew_log.topLevelItemCount() last_id = int(self.treew_log.topLevelItem(line_number-1).text(0)) start = last_id + 1 if last_id % 100 == 0 else last_id - last_id % 100 + 1 - end = int(last_id) + 100 + end = int(start) + 100 if int(start) <= len_records: clibs.cursor.execute(f"select * from logs where id between {start} and {end}") records = clibs.cursor.fetchall() @@ -677,7 +674,7 @@ class MainWindow(main_window.Ui_MainWindow): clibs.search_records = clibs.cursor.fetchall() len_records = len(clibs.search_records) pages_all = len_records // 100 if len_records % 100 == 0 else len_records // 100 + 1 - remainder = len_records % 100 + remainder = len_records % 100 if len_records % 100 != 0 else 100 records = clibs.search_records[-1 * remainder:] return pages_all, records @@ -739,7 +736,7 @@ class MainWindow(main_window.Ui_MainWindow): def md_conn(self): if clibs.status["hmi"] == 0: - QMessageBox.warning(self, "告警", "操作Modbus连接之前,需要先打开HMI连接!") + QMessageBox.warning(self, "告警", "操作 Modbus 连接之前,需要先打开 HMI 连接!") return self.btn_md_conn.setDisabled(True) @@ -751,7 +748,7 @@ class MainWindow(main_window.Ui_MainWindow): def ec_conn(self): if clibs.status["hmi"] == 0: - QMessageBox.warning(self, "告警", "操作外部通信连接之前,需要先打开HMI连接!") + QMessageBox.warning(self, "告警", "操作 EC 连接之前,需要先打开 HMI 连接!") return self.btn_ec_conn.setDisabled(True) @@ -792,7 +789,7 @@ class MainWindow(main_window.Ui_MainWindow): clibs.c_hr.logger("DEBUG", "aio", f"hmi: xService请求发送成功 {cmd_json}") if clibs.status["hmi"] == 0: - QMessageBox.critical(self, "错误", "使用该功能之前,需要先打开HMI连接!") + QMessageBox.critical(self, "错误", "使用该功能之前,需要先打开 HMI 连接!") return if self.pte_hmi_send.toPlainText() == "": return @@ -847,7 +844,7 @@ class MainWindow(main_window.Ui_MainWindow): def ec_send(self): if clibs.status["ec"] == 0: - QMessageBox.critical(self, "错误", "使用该功能之前,需要先打开MD连接!") + QMessageBox.critical(self, "错误", "使用该功能之前,需要先打开 EC 连接!") return if self.pte_ec_send.toPlainText() == "": return @@ -866,7 +863,7 @@ class MainWindow(main_window.Ui_MainWindow): cmd = self.cb_hmi_cmd.currentText() self.pte_hmi_send.clear() self.pte_him_recv.clear() - with open(f"assets/files/protocols/hmi/{cmd}.json", mode="r", encoding="utf-8") as f_hmi: + with open(f"{clibs.PREFIX}/files/protocols/hmi/{cmd}.json", mode="r", encoding="utf-8") as f_hmi: hmi_dict = json.load(f_hmi) t = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") hmi_dict["id"] = "@".join([cmd, t]) @@ -877,7 +874,7 @@ class MainWindow(main_window.Ui_MainWindow): self.pte_md_send.clear() self.pte_md_recv.clear() self.pte_md_send.appendPlainText(cmd) - with open(f"assets/files/protocols/md/{cmd}.txt", mode="r", encoding="utf-8") as f_md: + with open(f"{clibs.PREFIX}/files/protocols/md/{cmd}.txt", mode="r", encoding="utf-8") as f_md: c_send = f_md.read() self.pte_md_send.appendPlainText(c_send) @@ -885,16 +882,16 @@ class MainWindow(main_window.Ui_MainWindow): cmd = self.cb_ec_cmd.currentText() self.pte_ec_send.clear() self.pte_ec_recv.clear() - with open(f"assets/files/protocols/ec/{cmd}.txt", mode="r", encoding="utf-8") as f_md: + with open(f"{clibs.PREFIX}/files/protocols/ec/{cmd}.txt", mode="r", encoding="utf-8") as f_md: c_send = f_md.read() self.pte_ec_send.appendPlainText(c_send) def check_interval(self): try: interval = float(self.le_durable_interval.text()) - interval = 300 if interval < 300 else int(interval) + interval = clibs.CYCLE if interval < clibs.CYCLE else int(interval) except Exception: - interval = 300 + interval = clibs.CYCLE self.le_durable_interval.setText(str(interval)) def state_detection(self): @@ -934,11 +931,11 @@ class MainWindow(main_window.Ui_MainWindow): event.ignore() def setup_statusbar(self): - with open(f"assets/files/version/local_vers", mode="r", encoding="utf-8") as f_local: + with open(f"{clibs.PREFIX}/files/version/local_vers", mode="r", encoding="utf-8") as f_local: local_vers = f_local.read().strip() l_version, update = local_vers.split("@") vers_info = f" v{l_version} Update@{update}" - with open(f"assets/files/version/server_vers", mode="r", encoding="utf-8") as f_server: + with open(f"{clibs.PREFIX}/files/version/server_vers", mode="r", encoding="utf-8") as f_server: server_vers = f_server.read().strip() update_label = QLabel() @@ -946,11 +943,11 @@ class MainWindow(main_window.Ui_MainWindow): self.statusbar.addWidget(version_label, 0) self.statusbar.addPermanentWidget(update_label, 0) # 添加到右侧 if local_vers == server_vers: - update_label.setText(' 当前是最新版本,继续保持! ') + update_label.setText(f' 当前是最新版本,继续保持! ') elif local_vers > server_vers: pass elif local_vers < server_vers: - update_label.setText(f''' v{server_vers.split('@')[0]}已经发布,尽快更新至最新版本! ''') + update_label.setText(f''' v{server_vers.split('@')[0]}已经发布,尽快更新至最新版本! ''') version_label.setText(f' {vers_info}') update_label.setOpenExternalLinks(True) # 允许超链接在浏览器中打开 @@ -971,7 +968,7 @@ class InitWork(QThread): req = request.Request(url_vers, headers=headers) response = request.urlopen(req, timeout=clibs.INTERVAL * 10) server_vers = response.read().decode("utf-8").strip() - with open("assets/files/version/server_vers", mode="w", encoding="utf-8") as f_server: + with open(f"{clibs.PREFIX}/files/version/server_vers", mode="w", encoding="utf-8") as f_server: f_server.write(server_vers) self.completed.emit("true") except Exception as err: @@ -988,7 +985,7 @@ class SplashScreen(QApplication): super().__init__(argv) self.window = None - pixmap = QPixmap("./assets/media/splash.png") + pixmap = QPixmap(f"{clibs.PREFIX}/media/splash.png") self.splash = QSplashScreen(pixmap, Qt.WindowType.WindowStaysOnTopHint) scaled_pixmap = pixmap.scaled(800, 400, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation) self.splash.setPixmap(scaled_pixmap) diff --git a/assets/files/projects/autotest.xml b/assets/files/projects/autotest.xml deleted file mode 100644 index 483b9af..0000000 --- a/assets/files/projects/autotest.xml +++ /dev/null @@ -1,842 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assets/files/projects/configs.xlsx b/assets/files/projects/configs.xlsx index 4520560..675b2f6 100644 Binary files a/assets/files/projects/configs.xlsx and b/assets/files/projects/configs.xlsx differ diff --git a/assets/files/protocols/ec/io_state.txt b/assets/files/protocols/ec/io_state.txt new file mode 100644 index 0000000..bf64c35 --- /dev/null +++ b/assets/files/protocols/ec/io_state.txt @@ -0,0 +1 @@ +io_state:DO4_0,DI4_1 \ No newline at end of file diff --git a/assets/files/protocols/ec/set_do.txt b/assets/files/protocols/ec/set_do.txt deleted file mode 100644 index e2e2db5..0000000 --- a/assets/files/protocols/ec/set_do.txt +++ /dev/null @@ -1 +0,0 @@ -set_do:DO4_0,true \ No newline at end of file diff --git a/assets/files/protocols/ec/setdo.txt b/assets/files/protocols/ec/setdo.txt new file mode 100644 index 0000000..bda6b77 --- /dev/null +++ b/assets/files/protocols/ec/setdo.txt @@ -0,0 +1 @@ +setdo:DO4_0,true \ No newline at end of file diff --git a/assets/files/version/file_version_info.txt b/assets/files/version/file_version_info.txt index aa27a6e..612df88 100644 --- a/assets/files/version/file_version_info.txt +++ b/assets/files/version/file_version_info.txt @@ -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, 3, 1, 6), - prodvers=(0, 3, 1, 6), + filevers=(0, 4, 0, 0), + prodvers=(0, 4, 0, 0), # 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.3.1.6 (2025-03-21)'), + StringStruct('FileVersion', '0.4.0.0 (2025-03-28)'), StringStruct('InternalName', 'AIO.exe'), StringStruct('LegalCopyright', '© 2024-2025 Manford Fan'), StringStruct('OriginalFilename', 'AIO.exe'), StringStruct('ProductName', 'AIO'), - StringStruct('ProductVersion', '0.3.1.6 (2025-03-21)')]) + StringStruct('ProductVersion', '0.4.0.0 (2025-03-28)')]) ]), VarFileInfo([VarStruct('Translation', [1033, 1200])]) ] diff --git a/assets/files/version/local_vers b/assets/files/version/local_vers index 245a459..ec3409f 100644 --- a/assets/files/version/local_vers +++ b/assets/files/version/local_vers @@ -1 +1 @@ -0.3.1.6@03/21/2025 \ No newline at end of file +0.4.0.0@03/27/2025 \ No newline at end of file diff --git a/assets/files/version/server_vers b/assets/files/version/server_vers index bd78cb6..ec3409f 100644 --- a/assets/files/version/server_vers +++ b/assets/files/version/server_vers @@ -1 +1 @@ -0.3.1.7@03/24/2025 \ No newline at end of file +0.4.0.0@03/27/2025 \ No newline at end of file diff --git a/codes/autotest/do_brake.py b/codes/autotest/do_brake.py index eeecf6d..4f3f8d0 100644 --- a/codes/autotest/do_brake.py +++ b/codes/autotest/do_brake.py @@ -159,13 +159,12 @@ class DoBrakeTest(QThread): prj_name = ".".join(prj_file.split("/")[-1].split(".")[:-1]) wb = openpyxl.load_workbook(config_file, read_only=True) ws = wb["Target"] - write_diagnosis = float(ws.cell(row=2, column=2).value) - get_init_speed = float(ws.cell(row=3, column=2).value) - single_brake = str(ws.cell(row=4, column=2).value) - pon = ws.cell(row=5, column=2).value - io_name = ws.cell(row=6, column=2).value.upper().strip() + get_init_speed = float(ws.cell(row=2, column=2).value) + single_brake = str(ws.cell(row=3, column=2).value).strip() + pon = ws.cell(row=4, column=2).value + io_name = ws.cell(row=5, column=2).value.upper().strip() wb.close() - msg = f"基本参数配置:write_diagnosis(废弃) = {write_diagnosis}, get_init_speed = {get_init_speed}, single_brake = {single_brake}, pon = {pon}" + msg = f"基本参数配置:get_init_speed = {get_init_speed}, single_brake = {single_brake}, pon = {pon}, IO = {io_name}" self.logger("INFO", "do_brake", msg) if pon == "positive": @@ -195,7 +194,7 @@ class DoBrakeTest(QThread): continue clibs.c_md.write_axis(axis) - self.logger("INFO", "brake-processing", "-" * 90, "purple", flag="signal") + self.logger("INFO", "brake", "-" * 90, "purple", flag="signal") speed_max = 0 for rounds in range(1, 4): count += 1 @@ -309,9 +308,9 @@ class DoBrakeTest(QThread): if clibs.c_md.w_program_state == 1: break else: - time.sleep(5) + time.sleep(2) if time.time() - t_start > 60: - self.logger("ERROR", "do_brake","60s 内程序未能正常执行,需检查...", "red", "RlProgramStartTimeout") + self.logger("ERROR", "do_brake", "60s 内程序未能正常执行,需检查...", "red", "RlProgramStartTimeout") for i in range(16): if clibs.c_md.read_ready_to_go() == 1: @@ -360,7 +359,7 @@ class DoBrakeTest(QThread): break else: - time.sleep(50) # why? + time.sleep(clibs.INTERVAL*2) self.change_curve_state(False) msg = f"
{self.tool.removeprefix('tool')}%负载的制动性能测试执行完毕,如需采集其他负载,须切换负载类型,并更换其他负载,重新执行" self.logger("INFO", "do_brake", msg, "green") diff --git a/codes/common/clibs.py b/codes/common/clibs.py index 6ef9471..fc690fe 100644 --- a/codes/common/clibs.py +++ b/codes/common/clibs.py @@ -81,23 +81,18 @@ def handle_exception(func): return wrapper -log_path = f"assets/logs" +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] # 制动数据/转矩数据/激光数据/精度数据/制动自动化/转矩自动化/耐久数据采集 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 username, password = "luoshi", "luoshi2019" -INTERVAL, RADIAN, MAX_FRAME_SIZE, MAX_LOG_NUMBER = 1, 57.3, 1024, 10 +INTERVAL, RADIAN, MAX_FRAME_SIZE, MAX_LOG_NUMBER, CYCLE = 1, 57.3, 1024, 10, 300 c_md, c_hr, c_ec, c_pd, conn, cursor, search_records = None, None, None, None, None, None, None status = {"mysql": 0, "hmi": 0, "md": 0, "ec": 0} c_joint_vel, c_servo_trq, c_sensor_trq, c_estimate_trans_trq, c_safety_estop = 1, 2, 3, 4, 3 # 各个指标所在列 init_logdb() - -# ============== ↓↓↓DEBUG CODE↓↓↓ ============== -for i in range(100): - logger("DEBUG", "clibs", 'running123', flag="cursor") - logger("INFO", "aio", 'running234', flag="cursor") - logger("WARNING", "openapi", 'running345', flag="cursor") - logger("ERROR", "brake", 'running456', flag="cursor") diff --git a/codes/common/openapi.py b/codes/common/openapi.py index ff5259a..c6003b9 100644 --- a/codes/common/openapi.py +++ b/codes/common/openapi.py @@ -745,7 +745,7 @@ class HmiRequest(QThread): def execution(self, command, **kwargs): req = None try: - with open(f"assets/files/protocols/hmi/{command}.json", encoding="utf-8", mode="r") as f_json: + with open(f"{clibs.PREFIX}/files/protocols/hmi/{command}.json", encoding="utf-8", mode="r") as f_json: req = json.load(f_json) t = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") req["id"] = f"{command}@{t}" @@ -768,12 +768,14 @@ class HmiRequest(QThread): cmd = json.dumps(req, separators=(",", ":")) try: self.c.send(self.package(cmd)) + time.sleep(clibs.INTERVAL/4) self.logger("DEBUG", "openapi", f"hmi: 老协议请求发送成功 {cmd}") except Exception as err: self.logger("ERROR", "openapi", f"hmi: 老协议请求发送失败 {cmd},报错信息 {err}", "red", "CommandSendFailed") elif flag == 1: try: self.c_xs.send(self.package_xs(req)) + time.sleep(clibs.INTERVAL/4) self.logger("DEBUG", "openapi", f"hmi: xService请求发送成功 {req}") except Exception as Err: self.logger("ERROR", "openapi", f"hr: xService请求发送失败 {req} 报错信息 {Err}", "red", "CommandSendFailed") @@ -1804,9 +1806,9 @@ class ExternalCommunication(QThread): if clibs.status["ec"]: try: self.c.close() - self.logger("INFO", "openapi", f"ec: 关闭 EC 连接成功", "green") + self.logger("INFO", "openapi", f"ec: 关闭外部通信连接成功", "green") except Exception as err: - self.logger("ERROR", "openapi", f"ec: 关闭 EC 连接失败:{err}", "red", "EcCloseFailed") + self.logger("ERROR", "openapi", f"ec: 关闭外部通信连接失败:{err}", "red", "EcCloseFailed") def s_string(self, directive): order = "".join([directive, self.suffix]) @@ -2057,7 +2059,7 @@ class ExternalCommunication(QThread): self.s_string(directive) time.sleep(clibs.INTERVAL) result = self.r_string(directive).strip() - self.logger("INFO", "openapi", f"ec: 执行{description}指令是 {directive},返回值为 {result}{more_desc}") + self.logger("DEBUG", "openapi", f"ec: 执行{description}指令是 {directive},返回值为 {result}{more_desc}") return result @@ -2167,9 +2169,9 @@ class RobotInit(object): interactive_data = f"/home/luoshi/bin/controller/interactive_data/{robot_type}" config_files = [ - f"assets/files/projects/fieldbus_device.json", - f"assets/files/projects/registers.json", - f"assets/files/projects/registers.xml" + f"{clibs.PREFIX}/files/projects/fieldbus_device.json", + f"{clibs.PREFIX}/files/projects/registers.json", + f"{clibs.PREFIX}/files/projects/registers.xml" ] for config_file in config_files: filename = config_file.split("/")[-1] @@ -2197,10 +2199,10 @@ class RobotInit(object): os.remove(io_device_file_local_tmp) except: ... - clibs.c_hr.execution("io_device.load_cfg") - clibs.c_hr.execution("modbus.load_cfg") clibs.c_hr.execution("fieldbus_device.load_cfg") clibs.c_hr.execution("fieldbus_device.set_params", device_name="autotest", enable=True) + clibs.c_hr.execution("io_device.load_cfg") + clibs.c_hr.execution("modbus.load_cfg") def robot_init(self): pd = PreDos(clibs.ip_addr, clibs.ssh_port, clibs.username, clibs.password) diff --git a/codes/durable/factory_test.py b/codes/durable/factory_test.py index 8d7f461..7b0e435 100644 --- a/codes/durable/factory_test.py +++ b/codes/durable/factory_test.py @@ -19,7 +19,7 @@ class DoFactoryTest(QThread): def __init__(self, dir_path, interval, procs, /): super().__init__() self.dir_path = dir_path - self.interval = int(interval) if interval != "" else 300 + self.interval = int(interval) if interval != "" else clibs.CYCLE self.procs = procs self.idx = 6 self.curves = [] @@ -99,6 +99,7 @@ class DoFactoryTest(QThread): self.change_curve_state(False) clibs.c_md.r_soft_estop(0) clibs.c_md.r_soft_estop(1) + clibs.c_md.r_reset_estop() clibs.c_md.r_clear_alarm() clibs.c_md.write_act(False) time.sleep(1) # 让曲线彻底关闭 diff --git a/codes/ui/main_window.py b/codes/ui/main_window.py index b591b20..7b49c7b 100644 --- a/codes/ui/main_window.py +++ b/codes/ui/main_window.py @@ -38,9 +38,6 @@ class Ui_MainWindow(QMainWindow): font.setFamilies([u"Consolas"]) font.setPointSize(14) MainWindow.setFont(font) - icon = QIcon() - icon.addFile(u"../assets/media/icon.ico", QSize(), QIcon.Mode.Normal, QIcon.State.Off) - MainWindow.setWindowIcon(icon) MainWindow.setStyleSheet(u"background-color: rgb(233, 233, 233);") MainWindow.setDocumentMode(False) self.centralwidget = QWidget(MainWindow) @@ -290,7 +287,7 @@ class Ui_MainWindow(QMainWindow): self.sa_durable.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents") - self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 212, 78)) + self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 158, 78)) self.horizontalLayout_9 = QHBoxLayout(self.scrollAreaWidgetContents) self.horizontalLayout_9.setObjectName(u"horizontalLayout_9") self.verticalLayout_5 = QVBoxLayout() @@ -652,6 +649,7 @@ class Ui_MainWindow(QMainWindow): self.cb_ec_cmd.addItem("") self.cb_ec_cmd.addItem("") self.cb_ec_cmd.addItem("") + self.cb_ec_cmd.addItem("") self.cb_ec_cmd.setObjectName(u"cb_ec_cmd") self.cb_ec_cmd.setMinimumSize(QSize(240, 0)) self.cb_ec_cmd.setFont(font4) @@ -881,7 +879,7 @@ class Ui_MainWindow(QMainWindow): self.label.setText(QCoreApplication.translate("MainWindow", u"Rokae AIO", None)) self.btn_start.setText(QCoreApplication.translate("MainWindow", u"\u5f00\u59cb\u6267\u884c", None)) self.btn_stop.setText(QCoreApplication.translate("MainWindow", u"\u505c\u6b62\u6267\u884c", None)) - self.btn_reset.setText(QCoreApplication.translate("MainWindow", u"\u72b6\u6001\u91cd\u7f6e", None)) + self.btn_reset.setText(QCoreApplication.translate("MainWindow", u"\u8f93\u51fa\u91cd\u7f6e", None)) self.cb_data_func.setItemText(0, QCoreApplication.translate("MainWindow", u"\u5236\u52a8", None)) self.cb_data_func.setItemText(1, QCoreApplication.translate("MainWindow", u"\u8f6c\u77e9", None)) self.cb_data_func.setItemText(2, QCoreApplication.translate("MainWindow", u"\u6fc0\u5149", None)) @@ -951,12 +949,13 @@ class Ui_MainWindow(QMainWindow): self.label_18.setText("") self.cb_ec_cmd.setItemText(0, QCoreApplication.translate("MainWindow", u"motor_on", None)) self.cb_ec_cmd.setItemText(1, QCoreApplication.translate("MainWindow", u"motor_off", None)) - self.cb_ec_cmd.setItemText(2, QCoreApplication.translate("MainWindow", u"set_do", None)) + self.cb_ec_cmd.setItemText(2, QCoreApplication.translate("MainWindow", u"setdo", None)) self.cb_ec_cmd.setItemText(3, QCoreApplication.translate("MainWindow", u"switch_mode_auto", None)) self.cb_ec_cmd.setItemText(4, QCoreApplication.translate("MainWindow", u"switch_mode_manual", None)) self.cb_ec_cmd.setItemText(5, QCoreApplication.translate("MainWindow", u"operating_mode", None)) - self.cb_ec_cmd.setItemText(6, QCoreApplication.translate("MainWindow", u"motor_on_state", None)) - self.cb_ec_cmd.setItemText(7, QCoreApplication.translate("MainWindow", u"robot_running_state", None)) + self.cb_ec_cmd.setItemText(6, QCoreApplication.translate("MainWindow", u"io_state", None)) + self.cb_ec_cmd.setItemText(7, QCoreApplication.translate("MainWindow", u"motor_on_state", None)) + self.cb_ec_cmd.setItemText(8, QCoreApplication.translate("MainWindow", u"robot_running_state", None)) self.btn_ec_send.setText(QCoreApplication.translate("MainWindow", u"\u53d1\u9001", None)) self.pushButton.setText(QCoreApplication.translate("MainWindow", u"HMI", None)) diff --git a/readme.md b/readme.md index 689079b..24e49f8 100644 --- a/readme.md +++ b/readme.md @@ -103,7 +103,7 @@ 打包时,只需要修改 clibs.py 中的 PREFIX 即可,调试时再修改回来,第三方库依赖详见 `assets/files/version/requirements.txt` 文件 ``` -pyinstaller --noconfirm --onedir --windowed --optimize 2 --contents-directory . --upx-dir "D:/Syncthing/common/A_Program/upx-4.2.4-win64/" --add-data "../.venv/Lib/site-packages/customtkinter;customtkinter/" --add-data "../assets:assets" --version-file ../assets/files/version/file_version_info.txt -i ../assets/media/icon.ico ../code/aio.py -p ../code/common/clibs.py -p ../code/commom/openapi.py -p ../code/data_process/brake.py -p ../code/data_process/iso.py -p ../code/data_process/current.py -p ../code/data_process/wavelogger.py -p ../code/automatic_test/do_current.py -p ../code/automatic_test/do_brake.py -p ../code/durable_docs/factory_test.py -p ../code/durable_docs/create_plot.py --exclude-module=scipy +pyinstaller --noconfirm --onedir --windowed --optimize 2 --add-data "../assets:assets" --contents-directory=resources --clean --upx-dir "D:/Syncthing/common/A_Program/upx-4.2.4-win64/" --name=aio --version-file=../assets/files/version/file_version_info.txt --icon=../assets/media/icon.ico --exclude-module=scipy ../aio.py ``` ### 2. tabview 组件字体修改 diff --git a/test.py b/test.py deleted file mode 100644 index f701f83..0000000 --- a/test.py +++ /dev/null @@ -1,119 +0,0 @@ -def test(flag: int, **kwargs): - print(f"flag = {flag}") - print(f"kwargs = {kwargs}") - -test(11, a=1,b="b") - -import time - -# import common.openapi as openapi -# -# hr = openapi.HmiRequest("10.2.21.252", 5050, 6666) -# for _ in range(3): -# hr.execution("controller.heart") -# time.sleep(1) -# -# hr.close() - - - -# import pymysql -# -# conn = pymysql.connect(host='10.2.20.216', user='root', password='Rokae_123457', port=13306, charset='utf8') -# cursor = conn.cursor() -# cursor.execute("SET autocommit = 1;") -# cursor.execute("use fanmingfu;") -# cursor.execute("insert into 20250315153551_log (module, level, content) values (%s, %s, %s)", ("aioaaaaaa", "debug", "testing information")) -# logger("ERROR", "clibs", f"数据文件夹{dir_path}不存在,请确认后重试......\n", signal, "red", "PathNotExistError", idx) - -# level = "ERROR" -# module = "clibs" -# content = "{'data': {'name': 'xCore'}, 'id': 'controller.heart-1742374255.8898985'}" -# tb_name = "20250319162718_log" -# cursor.execute(f"INSERT INTO {tb_name} (level, module, content) VALUES (%s, %s, %s)", (level, module, content)) - -# conn.commit() -# ============================================ -# def tttt(flag, signal, cursor, **data): -# if flag == "signal": -# print(f"data = {data['signals']}") -# elif flag == "cursor": -# print(f"data = {data['cursors']}") -# elif flag == "both": -# print(f"data = {data}") -# print(f"data = {data['signals']}") -# print(f"data = {data['cursors']}") -# -# -# tttt("both", 1, 1, signals=123, cursors=456) - -# ============================================ - -# import sys -# from time import sleep -# from PySide6.QtCore import * -# from PySide6.QtGui import * -# from PySide6.QtWidgets import * -# -# -# class MyWindow(QMainWindow): -# range_number = Signal(int) -# -# def __init__(self) -> None: -# super().__init__() -# self.setWindowTitle("QThread学习") -# self.resize(800, 600) -# self.setup_ui() -# self.setup_thread() -# -# def setup_ui(self): -# self.mylistwidget = QListWidget(self) -# self.mylistwidget.resize(500, 500) -# self.mylistwidget.move(20, 20) -# -# self.additem_button = QPushButton(self) -# self.additem_button.resize(150, 30) -# self.additem_button.setText("填充QListWidget") -# self.additem_button.move(530, 20) -# -# def setup_thread(self): -# self.thread1 = QThread(self) # 创建一个线程 -# self.range_thread = WorkThread() # 实例化线程类 -# self.range_thread.moveToThread(self.thread1) # 将类移动到线程中运行 -# # 线程数据传回信号,用add_item函数处理 -# self.range_thread.range_requested.connect(self.add_item) -# self.additem_button.clicked.connect(self.start_thread) -# self.range_number.connect(self.range_thread.range_proc) -# # self.additem_button.clicked.connect(self.range_thread.range_proc) # 连接到线程类的函数 -# -# def start_thread(self): -# self.thread1.start() -# range_number = 30 -# self.range_number.emit(range_number) # 发射信号让线程接收需要range多少 -# -# def add_item(self, requested_number): # 线程传回参数 -# text = f"第{requested_number}项————Item" -# item = QListWidgetItem() -# item.setIcon(QPixmap()) -# item.setText(text) -# self.mylistwidget.addItem(item) -# -# -# class WorkThread(QObject): -# range_requested = Signal(int) # 括号里是传出的参数的类型 -# -# def __init__(self): -# super().__init__() -# -# def range_proc(self, number): # number即为从主线程接收的参数 -# print(number) -# for i in range(number): -# self.range_requested.emit(i) # 发射信号 -# sleep(0.5) -# -# -# if __name__ == "__main__": -# app = QApplication(sys.argv) -# window = MyWindow() -# window.show() -# app.exec() \ No newline at end of file diff --git a/ui/login.ui b/ui/login.ui deleted file mode 100644 index 2f976bc..0000000 --- a/ui/login.ui +++ /dev/null @@ -1,249 +0,0 @@ - - - Form - - - Qt::WindowModality::WindowModal - - - - 0 - 0 - 500 - 270 - - - - - 0 - 0 - - - - - 500 - 270 - - - - - 500 - 270 - - - - - Consolas - 14 - - - - 登录 - - - - ../assets/media/icon.ico../assets/media/icon.ico - - - - - 41 - 41 - 411 - 211 - - - - - 2 - - - - - 2 - - - - - - Consolas - 14 - - - - 用户名 - - - - - - - - Consolas - 14 - - - - - - - - - - 2 - - - - - - Consolas - 14 - - - - 密 码 - - - - - - - - Consolas - 14 - - - - QLineEdit::EchoMode::Password - - - - - - - - - - 0 - 0 - - - - - Consolas - 12 - - - - - - - - - - - 2 - - - - - - Consolas - 14 - - - - 登录 - - - - - - - - Consolas - 14 - - - - 重置 - - - - - - - - - - - - btn_login - clicked() - Form - user_login() - - - 85 - 130 - - - 34 - 112 - - - - - le_password - returnPressed() - Form - user_login() - - - 178 - 82 - - - 11 - 70 - - - - - le_username - returnPressed() - Form - user_login() - - - 169 - 42 - - - 10 - 33 - - - - - btn_reset - clicked() - Form - reset_password() - - - 311 - 138 - - - 367 - 113 - - - - - - user_login() - reset_password() - - diff --git a/ui/main.ui b/ui/main.ui index 5c4ed7d..5def571 100644 --- a/ui/main.ui +++ b/ui/main.ui @@ -34,10 +34,6 @@ Rokae AIO - - - ../assets/media/icon.ico../assets/media/icon.ico - background-color: rgb(233, 233, 233); @@ -184,7 +180,7 @@ - 状态重置 + 输出重置 false @@ -587,7 +583,7 @@ 0 0 - 212 + 158 78 @@ -1263,7 +1259,7 @@ - set_do + setdo @@ -1281,6 +1277,11 @@ operating_mode + + + io_state + + motor_on_state diff --git a/ui/reset.ui b/ui/reset.ui deleted file mode 100644 index 2f34e7d..0000000 --- a/ui/reset.ui +++ /dev/null @@ -1,271 +0,0 @@ - - - Form - - - Qt::WindowModality::WindowModal - - - - 0 - 0 - 500 - 270 - - - - - 0 - 0 - - - - - 500 - 270 - - - - - 500 - 270 - - - - - Consolas - 14 - - - - 重置密码 - - - - ../assets/media/icon.ico../assets/media/icon.ico - - - - - 40 - 27 - 411 - 211 - - - - - - - - - - Consolas - 14 - - - - 用户名 - - - - - - - - Consolas - 14 - - - - - - - - - - - - - Consolas - 14 - - - - 旧密码 - - - - - - - - Consolas - 14 - - - - QLineEdit::EchoMode::Password - - - - - - - - - - - - Consolas - 14 - - - - 新密码 - - - - - - - - Consolas - 14 - - - - QLineEdit::EchoMode::Password - - - - - - - - - - - - Consolas - 14 - - - - 确 认 - - - - - - - - Consolas - 14 - - - - QLineEdit::EchoMode::Password - - - - - - - - - - 0 - 0 - - - - - Consolas - 12 - - - - - - - - - - - - - - Consolas - 14 - - - - 确定 - - - - - - - - Consolas - 14 - - - - 取消 - - - - - - - - - - le_username - le_old_password - le_new_password_1 - le_new_password_2 - - - - - btn_reset - clicked() - Form - reset_password() - - - 85 - 175 - - - 22 - 149 - - - - - btn_cancel - clicked() - Form - reset_cancel() - - - 295 - 177 - - - 386 - 148 - - - - - - reset_password() - reset_cancel() - -