diff --git a/UI/Main/Main.py b/UI/Main/Main.py index e9fb236..6f99d4b 100644 --- a/UI/Main/Main.py +++ b/UI/Main/Main.py @@ -217,7 +217,7 @@ class MainWindow(QMainWindow): widget.deleteLater() def exButtonClicked(self, index): - print(Globals.getValue('currentPro')) + # print(Globals.getValue('currentPro')) if Globals.getValue('currentPro') == -1 and index not in [0, 3]: return -1 @@ -245,8 +245,8 @@ class MainWindow(QMainWindow): def initProcedureDB(self): if Globals.getValue('currentPro') == -1: return - self.procedureManagerWidget.initDB() - self.procedureManagerWidget.initUI() + # self.procedureManagerWidget.initDB() + # self.procedureManagerWidget.initUI() self.exButtonClicked(5) def showControlSystem(self): diff --git a/UI/ProcedureManager/ProcedureManager.py b/UI/ProcedureManager/ProcedureManager.py index c528e2c..48e5efe 100644 --- a/UI/ProcedureManager/ProcedureManager.py +++ b/UI/ProcedureManager/ProcedureManager.py @@ -7,7 +7,8 @@ from PyQt5.QtWidgets import (QApplication, QMainWindow, QTableView, QToolButton, QLabel, QCheckBox, QSpinBox, QMenu, QFileDialog, QTabWidget, QTabBar, QListWidget, QListWidgetItem, QDialog, QLineEdit, QFormLayout, QDialogButtonBox, QMessageBox, - QHeaderView, QToolBar, QAction, QStatusBar, QSplitter, QAbstractItemView, QFrame) + QHeaderView, QToolBar, QAction, QStatusBar, QSplitter, QAbstractItemView, QFrame, + QProgressDialog) from docx import Document from docx.shared import Pt, RGBColor from docx.enum.text import WD_PARAGRAPH_ALIGNMENT @@ -630,68 +631,169 @@ class ProcedureManager(QMainWindow): self.loadProcedures(categoryId) def importProcedure(self): - filePath, _ = QFileDialog.getOpenFileName( + """导入规程 - 支持多文件选择""" + filePaths, _ = QFileDialog.getOpenFileNames( self, "选择规程文件", "", "Excel文件 (*.xlsx *.xls)" ) - if not filePath: + if not filePaths: return - try: - parsedData = ExcelParser.parseProcedure(filePath) + currentItem = self.categoryList.currentItem() + categoryId = currentItem.data(Qt.UserRole) if currentItem else None + + # 统计导入结果 + totalFiles = len(filePaths) + successCount = 0 + skipCount = 0 + errorCount = 0 + errorDetails = [] + + # 批量导入确认 + if totalFiles > 1: + reply = QMessageBox.question( + self, "批量导入确认", + f"您选择了 {totalFiles} 个文件进行导入。\n\n" + f"导入过程中如果遇到同名规程,将会逐个询问是否覆盖。\n" + f"是否继续批量导入?", + QMessageBox.Yes | QMessageBox.No + ) + if reply != QMessageBox.Yes: + return + + # 创建进度对话框 + progress = None + if totalFiles > 1: + progress = QProgressDialog("正在导入规程...", "取消", 0, totalFiles, self) + progress.setWindowModality(Qt.WindowModal) + progress.setMinimumDuration(0) + progress.show() + + # 逐个处理文件 + for index, filePath in enumerate(filePaths): + if progress: + progress.setValue(index) + progress.setLabelText(f"正在导入: {os.path.basename(filePath)}") + + # 检查是否取消 + if progress.wasCanceled(): + break - currentItem = self.categoryList.currentItem() - categoryId = currentItem.data(Qt.UserRole) if currentItem else None + try: + result = self.importSingleProcedure(filePath, categoryId, totalFiles > 1) + + if result == "success": + successCount += 1 + elif result == "skip": + skipCount += 1 + elif result == "cancel": + # 用户取消了整个导入过程 + break + + except Exception as e: + errorCount += 1 + fileName = os.path.basename(filePath) + errorDetails.append(f"{fileName}: {str(e)}") + print(f"导入文件 {fileName} 时发生错误: {str(e)}") + + # 关闭进度对话框 + if progress: + progress.close() + + # 刷新规程列表 + if successCount > 0: + self.loadProcedures(categoryId) + + # 显示导入结果 + self.showImportResults(totalFiles, successCount, skipCount, errorCount, errorDetails) + + def importSingleProcedure(self, filePath, categoryId, isBatchMode=False): + """导入单个规程文件 + + Args: + filePath: 文件路径 + categoryId: 分类ID + isBatchMode: 是否为批量模式 + Returns: + str: "success", "skip", "cancel", "error" + """ + try: + parsedData = ExcelParser.parseProcedure(filePath) procInfo = parsedData["规程信息"] procedureName = procInfo["规程名称"] procedureNumber = procInfo["规程编号"] + fileName = os.path.basename(filePath) # 检查是否存在同名规程 existingProcedure = self.db.getProcedureByNameAndNumber(procedureName, procedureNumber) - if existingProcedure: # 存在同名规程,询问是否覆盖 existingId, existingName, existingNumber, existingType, existingCategoryId = existingProcedure - reply = QMessageBox.question( - self, - "发现同名规程", - f"发现同名规程:\n" - f"规程名称:{existingName}\n" - f"规程编号:{existingNumber}\n" - f"规程类型:{existingType}\n\n" - f"是否要覆盖这个规程?\n" - f"覆盖后原规程内容将丢失。", - QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel - ) - - if reply == QMessageBox.Cancel: - return - elif reply == QMessageBox.Yes: - # 覆盖现有规程 - success = self.db.updateProcedureById( - existingId, - categoryId, - procedureName, - procedureNumber, - procInfo["规程类型"], - parsedData, - "" + if isBatchMode: + # 批量模式下的对话框包含更多选项 + msgBox = QMessageBox(self) + msgBox.setWindowTitle("发现同名规程") + msgBox.setText(f"文件: {fileName}\n\n" + f"发现同名规程:\n" + f"规程名称:{existingName}\n" + f"规程编号:{existingNumber}\n" + f"规程类型:{existingType}\n\n" + f"请选择操作:") + + overwriteBtn = msgBox.addButton("覆盖", QMessageBox.YesRole) + skipBtn = msgBox.addButton("跳过", QMessageBox.NoRole) + cancelBtn = msgBox.addButton("取消全部", QMessageBox.RejectRole) + + msgBox.exec_() + clickedBtn = msgBox.clickedButton() + + if clickedBtn == cancelBtn: + return "cancel" + elif clickedBtn == skipBtn: + return "skip" + elif clickedBtn == overwriteBtn: + # 覆盖现有规程 + success = self.db.updateProcedureById( + existingId, categoryId, procedureName, procedureNumber, + procInfo["规程类型"], parsedData, "" + ) + if success: + return "success" + else: + raise Exception("无法覆盖规程,请检查数据库连接") + else: + # 单文件模式的原有逻辑 + reply = QMessageBox.question( + self, "发现同名规程", + f"发现同名规程:\n" + f"规程名称:{existingName}\n" + f"规程编号:{existingNumber}\n" + f"规程类型:{existingType}\n\n" + f"是否要覆盖这个规程?\n" + f"覆盖后原规程内容将丢失。", + QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel ) - if success: - self.statusBar.showMessage(f"成功覆盖规程: {procedureName}", 5000) - self.loadProcedures(categoryId) + if reply == QMessageBox.Cancel: + return "cancel" + elif reply == QMessageBox.Yes: + # 覆盖现有规程 + success = self.db.updateProcedureById( + existingId, categoryId, procedureName, procedureNumber, + procInfo["规程类型"], parsedData, "" + ) + if success: + self.statusBar.showMessage(f"成功覆盖规程: {procedureName}", 5000) + return "success" + else: + raise Exception("无法覆盖规程,请检查数据库连接") else: - QMessageBox.warning(self, "覆盖失败", "无法覆盖规程,请检查数据库连接") - return - else: - # 用户选择不覆盖 - return + return "skip" # 不存在同名规程,正常添加 procId = self.db.addProcedure( @@ -704,13 +806,46 @@ class ProcedureManager(QMainWindow): ) if procId: - self.statusBar.showMessage(f"成功导入规程: {procedureName}", 5000) - self.loadProcedures(categoryId) + if not isBatchMode: + self.statusBar.showMessage(f"成功导入规程: {procedureName}", 5000) + return "success" else: - QMessageBox.warning(self, "导入失败", "无法导入规程,请检查数据库连接") - + raise Exception("无法导入规程,请检查数据库连接") + except Exception as e: - QMessageBox.critical(self, "导入错误", f"导入规程时发生错误:\n{str(e)}") + if not isBatchMode: + QMessageBox.critical(self, "导入错误", f"导入规程时发生错误:\n{str(e)}") + raise e + + def showImportResults(self, totalFiles, successCount, skipCount, errorCount, errorDetails): + """显示导入结果统计""" + if totalFiles == 1: + # 单文件导入,使用原有的消息显示方式 + return + + # 多文件导入结果统计 + resultMsg = f"批量导入完成!\n\n" + resultMsg += f"总文件数: {totalFiles}\n" + resultMsg += f"成功导入: {successCount}\n" + resultMsg += f"跳过文件: {skipCount}\n" + resultMsg += f"导入失败: {errorCount}\n" + + if errorCount > 0: + resultMsg += f"\n失败详情:\n" + for detail in errorDetails[:5]: # 最多显示5个错误 + resultMsg += f"• {detail}\n" + if len(errorDetails) > 5: + resultMsg += f"• ... 还有 {len(errorDetails) - 5} 个错误\n" + + # 根据结果选择消息类型 + if errorCount == 0: + if successCount > 0: + QMessageBox.information(self, "导入成功", resultMsg) + self.statusBar.showMessage(f"批量导入完成: 成功 {successCount} 个", 5000) + else: + QMessageBox.information(self, "导入完成", resultMsg) + else: + QMessageBox.warning(self, "导入完成(有错误)", resultMsg) def addCategory(self): dialog = AddCategoryDialog(self) diff --git a/UI/ProcedureManager/StepExecutor.py b/UI/ProcedureManager/StepExecutor.py index e25237a..2ae5958 100644 --- a/UI/ProcedureManager/StepExecutor.py +++ b/UI/ProcedureManager/StepExecutor.py @@ -174,6 +174,18 @@ class StepExecutor(QWidget): self.actualElapsedTime = 0 # 实际已用时间 self.lastStepStartTime = None # 上一步开始时间 + # 等待操作相关状态 + self.isWaiting = False # 是否正在等待 + self.waitingStepId = None # 正在等待的步骤ID + self.waitStartTime = None # 等待开始时间 + self.waitDuration = 0 # 等待持续时间 + + # 设置操作超时相关状态 + self.isSettingTimeout = False # 是否正在设置操作超时等待 + self.settingStepId = None # 正在超时等待的设置步骤ID + self.settingResult = None # 设置操作的结果 + self.settingStartTime = None # 设置超时开始时间 + def initTimers(self): """初始化定时器""" self.timer = QTimer() @@ -182,6 +194,16 @@ class StepExecutor(QWidget): self.countdownTimer = QTimer() self.countdownTimer.timeout.connect(self.updateCountdown) + # 添加等待操作专用定时器 + self.waitTimer = QTimer() + self.waitTimer.setSingleShot(True) # 单次触发 + self.waitTimer.timeout.connect(self.onWaitCompleted) + + # 添加设置操作超时专用定时器 + self.setTimer = QTimer() + self.setTimer.setSingleShot(True) # 单次触发 + self.setTimer.timeout.connect(self.onSetTimeoutCompleted) + def initUi(self, testSteps): """初始化用户界面""" layout = QVBoxLayout() @@ -608,6 +630,27 @@ class StepExecutor(QWidget): """停止自动执行""" self.isRunning = False self.timer.stop() + + # 停止等待定时器(如果正在等待) + if self.waitTimer.isActive(): + self.waitTimer.stop() + if self.isWaiting: + print(f"停止执行,中断等待操作 (步骤 {self.waitingStepId})") + self.isWaiting = False + self.waitingStepId = None + self.waitStartTime = None + self.waitDuration = 0 + + # 停止设置操作超时定时器(如果正在超时等待) + if self.setTimer.isActive(): + self.setTimer.stop() + if self.isSettingTimeout: + print(f"停止执行,中断设置超时等待 (步骤 {self.settingStepId})") + self.isSettingTimeout = False + self.settingStepId = None + self.settingResult = None + self.settingStartTime = None + self.updateButtonStates(True, False, True, True, True) self.saveCurrentResults() @@ -650,7 +693,7 @@ class StepExecutor(QWidget): """处理轮次完成""" self.saveCurrentResults() - if self.remainingCycles > 1: + if self.remainingCycles > 1 or self.infiniteCycles: self.prepareNextCycle() else: self.finishExecution() @@ -758,6 +801,22 @@ class StepExecutor(QWidget): self.actualElapsedTime += stepExecutionTime print(f"步骤执行时间: {stepExecutionTime:.1f}秒, 累计已用时间: {self.actualElapsedTime:.1f}秒") + # 特殊处理等待操作 + if result == 'WAITING': + print(f"步骤 {stepInfo['stepId']} 进入等待状态,暂时不记录结果") + # 更新表格显示为等待中状态 + self.tableModel.updateStepResult(row, '等待中...', datetime.now()) + self.tableView.adjustRowHeight(row) + return result + + # 特殊处理设置操作超时等待 + if result == 'SETTING_TIMEOUT': + print(f"步骤 {stepInfo['stepId']} 进入设置超时等待状态,暂时不记录结果") + # 更新表格显示为设置超时等待中状态 + self.tableModel.updateStepResult(row, '成功设置触发条件,等待响应时间结果返回中...', datetime.now()) + self.tableView.adjustRowHeight(row) + return result + if result is None: print(f"警告:步骤 {stepInfo['stepId']} 返回了None结果,设置为False") result = '执行失败,未检测到关键字' @@ -834,47 +893,104 @@ class StepExecutor(QWidget): return None def performSetOperation(self, stepId, description, keyword, stepType = None): - """执行设置操作""" + """执行设置操作 - 支持非阻塞超时等待""" # print(f"执行设置操作 (步骤 {stepId}): {description}") + from datetime import datetime - # 简单匹配等号前变量名和等号后数值 - variablePattern = r'([^\s=]+)=([0-9]+(?:\.[0-9]+)?)' + # 优化的正则表达式:支持负值、小数、科学计数法 + # 匹配模式:变量名=数值(支持正负数、小数、科学计数法) + variablePattern = r'([^\s=]+)\s*=\s*([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)' matches = re.findall(variablePattern, description) if matches: # print(f"检测到 {len(matches)} 个需要设置的变量:") result = '' + hasTimeoutOperation = False + for varName, varValue in matches: varName = varName.strip() - # print(f" 变量: {varName} = {varValue}") - if stepType and 'Time' in stepType: - timeMatch = re.search(r'Time\s*=\s*(\d+)\s*ms', stepType, re.IGNORECASE) - if timeMatch: - timeoutMS = int(timeMatch.group(1)) + try: + # 转换为浮点数,支持各种数值格式 + numericValue = float(varValue) + # print(f" 变量: {varName} = {numericValue}") + + # 处理超时设置 + if stepType and 'Time' in stepType: + timeMatch = re.search(r'Time\s*=\s*(\d+)\s*ms', stepType, re.IGNORECASE) + if timeMatch: + timeoutMS = int(timeMatch.group(1)) + else: + timeoutMS = 2000 + + print(f"使用非阻塞超时设置: {timeoutMS}ms + 2秒") + success = self.protocolManager.writeVariableValue( + varName, numericValue, trigger=True, timeoutMS=timeoutMS + ) + + # 记录当前结果(不包含超时等待的最终结果) + if success: + result += f"{varName} = {numericValue} (设置中...)\n" + else: + result += f"{varName} 设置失败\n" + + # 如果有超时设置,需要非阻塞等待 + if success: + hasTimeoutOperation = True + # 设置超时等待状态 + self.isSettingTimeout = True + self.settingStepId = stepId + self.settingResult = result + self.settingStartTime = datetime.now() + + # 启动超时定时器 (timeoutMS + 2000ms) + totalWaitTime = timeoutMS + 1000 + self.setTimer.start(totalWaitTime) + + # 暂停主执行定时器 + if self.timer.isActive(): + self.timer.stop() + + # 更新状态显示 + self.updateStatusDisplay(f"等待时间响应结果返回中... ({totalWaitTime/1000:.1f}秒)", "orange") + + # 返回特殊标记,表示正在超时等待中 + return 'SETTING_TIMEOUT' else: - timeoutMS = 2000 - # print(timeoutMS) - success = self.protocolManager.writeVariableValue(varName, float(varValue), trigger = True, timeoutMS = timeoutMS) - time.sleep(timeoutMS/1000 + 2) - else: - success = self.protocolManager.writeVariableValue(varName, float(varValue)) - if success: - result += f"{varName} = {varValue}\n" - else: - result += f"{varName}强制失败\n" - return result + success = self.protocolManager.writeVariableValue(varName, numericValue) + + # 记录结果 + if success: + result += f"{varName} = {numericValue}\n" + else: + result += f"{varName} 设置失败\n" + + except ValueError as e: + # 数值转换失败 + result += f"{varName} 数值格式错误: {varValue}\n" + print(f"数值转换错误: {varValue} -> {str(e)}") + except Exception as e: + # 其他异常 + result += f"{varName} 执行异常: {str(e)}\n" + print(f"执行异常: {str(e)}") + + # 如果没有超时操作,直接返回结果 + if not hasTimeoutOperation: + return result + else: + # 如果有超时操作,已经在上面返回了 'SETTING_TIMEOUT' + return result else: - return '"强制失败,未检测到关键字"' + return '强制失败,未检测到有效的变量赋值格式' def performCheckOperation(self, stepId, description, keyword, stepType = None): """执行检查操作""" print(f"执行检查操作 (步骤 {stepId}): {description}") - # 支持多种比较符号的正则表达式 + # 支持多种比较符号的正则表达式,支持负值、小数、科学计数法 # 匹配格式:变量名 比较符号 数值 # 支持的比较符号:=, ==, >, <, >=, <=, !=, <> - variablePattern = r'([^\s=>|<|>=|<=|!=|<>)\s*([0-9]+(?:\.[0-9]+)?)' + variablePattern = r'([^\s=>|<|>=|<=|!=|<>)\s*([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)' matches = re.findall(variablePattern, description) if matches: @@ -957,20 +1073,169 @@ class StepExecutor(QWidget): return False def performWaitOperation(self, stepId, description, keyword, stepType): - """执行等待操作,等待时间取自描述字段中的数字(秒)""" + """执行等待操作,等待时间取自描述字段中的数字(秒)- 非阻塞版本""" print(f"执行等待操作 (步骤 {stepId}): {description}") - import re, time - # 只提取描述中的数字(支持小数),不再匹配"等待"字样 - match = re.search(r'([0-9]+(?:\.[0-9]+)?)', description) + import re + from datetime import datetime + + # 支持负值的数字匹配(虽然等待时间通常不会是负数,但保持一致性) + match = re.search(r'([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)', description) if match: seconds = float(match.group(1)) - print(f" 等待 {seconds} 秒...") - time.sleep(seconds) - return '执行成功' + if seconds <= 0: + print(f" 等待时间无效: {seconds} 秒,必须大于0") + return '等待时间无效,必须大于0秒' + + print(f" 开始非阻塞等待 {seconds} 秒...") + + # 设置等待状态 + self.isWaiting = True + self.waitingStepId = stepId + self.waitStartTime = datetime.now() + self.waitDuration = seconds + + # 启动等待定时器(转换为毫秒) + self.waitTimer.start(int(seconds * 1000)) + + # 暂停主执行定时器,避免继续执行下一步 + if self.timer.isActive(): + self.timer.stop() + + # 更新状态显示 + self.updateStatusDisplay(f"等待中... ({seconds}秒)", "orange") + + # 返回特殊标记,表示正在等待中 + return 'WAITING' else: print(" 未检测到等待时间") return '未检测到等待时间' + def onWaitCompleted(self): + """等待操作完成的回调函数""" + from datetime import datetime + + if not self.isWaiting: + return + + # 计算实际等待时间 + if self.waitStartTime: + actualWaitTime = (datetime.now() - self.waitStartTime).total_seconds() + print(f" 等待完成,实际等待时间: {actualWaitTime:.2f} 秒") + + # 重置等待状态 + self.isWaiting = False + waitingStepId = self.waitingStepId + self.waitingStepId = None + self.waitStartTime = None + self.waitDuration = 0 + + # 更新步骤结果为成功 + if waitingStepId: + # 找到对应的步骤行并更新结果 + for row in range(self.tableModel.rowCount()): + stepInfo = self.tableModel.getStepInfo(row) + if stepInfo and stepInfo.get('stepId') == waitingStepId: + # 更新步骤结果 + self.tableModel.updateStepResult(row, '等待完成', datetime.now()) + + # 更新步骤结果记录 + executionTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + stepResult = { + 'step_id': str(waitingStepId), + 'step_description': stepInfo.get('description', ''), + 'execution_time': executionTime, + 'result': '等待完成' + } + self.stepResults.append(stepResult) + + # 保存到数据库 + if hasattr(self, 'currentExecutionId'): + self.dbManager.updateStepResults(self.currentExecutionId, self.stepResults) + + # 更新表格行高 + self.tableView.adjustRowHeight(row) + break + + # 恢复执行流程 + if self.isRunning: + # 更新状态显示 + cycleNum = self.getCurrentCycleNumber() + self.updateStatusDisplay(f"执行中 - 第{cycleNum}轮", "green") + + # 重新启动主执行定时器 + stepInterval = int(self.stepIntervalSpin.value() * 1000) + self.timer.start(stepInterval) + else: + # 如果不是自动执行模式,更新状态为就绪 + self.updateStatusDisplay("就绪", "blue") + + def onSetTimeoutCompleted(self): + """设置操作超时完成的回调函数""" + from datetime import datetime + + if not self.isSettingTimeout: + return + + # 计算实际超时等待时间 + if self.settingStartTime: + actualWaitTime = (datetime.now() - self.settingStartTime).total_seconds() + print(f" 设置超时等待完成,实际等待时间: {actualWaitTime:.2f} 秒") + + # 获取保存的结果并更新为最终结果 + finalResult = self.settingResult + if finalResult: + # 将 "设置中..." 替换为 "设置完成" + finalResult = finalResult.replace("(设置中...)", "(触发成功)") + else: + finalResult = "设置超时等待完成" + + # 重置设置超时状态 + self.isSettingTimeout = False + settingStepId = self.settingStepId + self.settingStepId = None + self.settingResult = None + self.settingStartTime = None + + # 更新步骤结果 + if settingStepId: + # 找到对应的步骤行并更新结果 + for row in range(self.tableModel.rowCount()): + stepInfo = self.tableModel.getStepInfo(row) + if stepInfo and stepInfo.get('stepId') == settingStepId: + # 更新步骤结果 + self.tableModel.updateStepResult(row, finalResult, datetime.now()) + + # 更新步骤结果记录 + executionTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + stepResult = { + 'step_id': str(settingStepId), + 'step_description': stepInfo.get('description', ''), + 'execution_time': executionTime, + 'result': finalResult + } + self.stepResults.append(stepResult) + + # 保存到数据库 + if hasattr(self, 'currentExecutionId'): + self.dbManager.updateStepResults(self.currentExecutionId, self.stepResults) + + # 更新表格行高 + self.tableView.adjustRowHeight(row) + break + + # 恢复执行流程 + if self.isRunning: + # 更新状态显示 + cycleNum = self.getCurrentCycleNumber() + self.updateStatusDisplay(f"执行中 - 第{cycleNum}轮", "green") + + # 重新启动主执行定时器 + stepInterval = int(self.stepIntervalSpin.value() * 1000) + self.timer.start(stepInterval) + else: + # 如果不是自动执行模式,更新状态为就绪 + self.updateStatusDisplay("就绪", "blue") + def performDeltaTOperation(self, stepId, description, keyword, stepType): """执行接收操作""" result = self.protocolManager.recvDeltaT() @@ -989,6 +1254,22 @@ class StepExecutor(QWidget): if not fromAuto: self.stopAutoExecute() + # 重置等待状态 + if self.waitTimer.isActive(): + self.waitTimer.stop() + self.isWaiting = False + self.waitingStepId = None + self.waitStartTime = None + self.waitDuration = 0 + + # 重置设置操作超时状态 + if self.setTimer.isActive(): + self.setTimer.stop() + self.isSettingTimeout = False + self.settingStepId = None + self.settingResult = None + self.settingStartTime = None + self.cycleSpin.setValue(1) self.infiniteCheckbox.setChecked(False) self.isRunning = False @@ -1004,7 +1285,7 @@ class StepExecutor(QWidget): self.resetCountdown() # 重置后重新调整行高 - self.adjustAllRowHeights() + # self.adjustAllRowHeights() def onExportReportClicked(self): """导出报告点击事件""" diff --git a/bin.py b/bin.py index 8f6c747..f8d4e3d 100644 --- a/bin.py +++ b/bin.py @@ -15,7 +15,7 @@ logging.getLogger('modbus_tk').setLevel(logging.ERROR) if __name__ == '__main__': app = QApplication(sys.argv) - print(1111111) + # print(1111111) app.setStyle(QStyleFactory.create('Fusion')) app.setStyleSheet(CommonHelper.readQss('Static/Main.qss') + CommonHelper.readQss('Static/profibus.qss') diff --git a/model/ProjectModel/ProjectManage.py b/model/ProjectModel/ProjectManage.py index d64f69e..f7b8737 100644 --- a/model/ProjectModel/ProjectManage.py +++ b/model/ProjectModel/ProjectManage.py @@ -160,7 +160,8 @@ class ProjectManage(object): protocolManage = ProtocolManage() Globals.setValue('protocolManage', protocolManage) Globals.getValue('HistoryWidget').exchangeProject() - + Globals.getValue('MainWindow').procedureManagerWidget.initDB() + Globals.getValue('MainWindow').procedureManagerWidget.initUI() # 通知控制系统工程已切换 try: from control.ControlManager import getControlManager