diff --git a/UI/TrendManage/ActualTrendWidget.py b/UI/TrendManage/ActualTrendWidget.py index 2500ea5..e2c20ce 100644 --- a/UI/TrendManage/ActualTrendWidget.py +++ b/UI/TrendManage/ActualTrendWidget.py @@ -91,12 +91,17 @@ class ActualTrend(QtWidgets.QMainWindow): self._dynamic_ax.plot(pos_list, value_list, 'bo-', linewidth=2) # self._dynamic_ax.set_xlim(0,10) self._dynamic_ax.set_ylim(minY, maxY) + # print(id(self._dynamic_ax)) self._dynamic_ax.figure.canvas.draw() def closeEvent(self, event): # 判断是否点击了窗口的关闭按钮 if event.type() == event.Close: self._timer.stop() + self.hide() + + def showEvent(self, event): + self._timer.start() if __name__ == "__main__": qapp = QtWidgets.QApplication(sys.argv) diff --git a/UI/VarManages/ModbusModel.py b/UI/VarManages/ModbusModel.py index d1cfd60..fa80619 100644 --- a/UI/VarManages/ModbusModel.py +++ b/UI/VarManages/ModbusModel.py @@ -230,10 +230,17 @@ class ModBusTCPSlaveModel(VarTableModel): class VarButtonDelegate(QItemDelegate): """该类用于向单元格中添加按钮 任务表格""" + trendWidgetDict = {} def __init__(self, parent=None): super(VarButtonDelegate, self).__init__(parent) + def trendWidget(self, varName): + if varName not in self.trendWidgetDict: + trendWidget = ActualTrend(varName = varName) + self.trendWidgetDict[varName] = trendWidget + return self.trendWidgetDict[varName] + def paint(self, painter, option, index): if not self.parent().indexWidget(index): button1 = QPushButton( @@ -442,7 +449,7 @@ class VarButtonDelegate(QItemDelegate): if model.table.parent._isPopenOpen: sender = self.sender() name = str(model.datas[sender.index[0]][3]) - trend = ActualTrend(varName = name) + trend = self.trendWidget(varName = name) trend.show() class ModbusTypeBox(QItemDelegate): diff --git a/model/ProjectModel/ProjectManage.py b/model/ProjectModel/ProjectManage.py index 53bbc69..2ab20c3 100644 --- a/model/ProjectModel/ProjectManage.py +++ b/model/ProjectModel/ProjectManage.py @@ -346,14 +346,14 @@ class ProjectManage(object): zipf.extractall('project') - project = Project() - projectList = [] + projectList = [] for n in zipProjects: jsonPath = os.path.join('project', n, 'config', 'config.json') with open(jsonPath, 'r') as f: data = json.load(f) proType = data['ProjectType'] des = data['description'] + project = Project() project.createProject(n, proType, des) projectList.append(n) diff --git a/model/ProjectModel/VarManage.py b/model/ProjectModel/VarManage.py index 4fad67b..06c3579 100644 --- a/model/ProjectModel/VarManage.py +++ b/model/ProjectModel/VarManage.py @@ -44,9 +44,8 @@ class ModbusVarManage(object): maxIndex = index # print(IDIndex, slaveIndex, nameIndex, desIndex, typeIndex, addrIndex, minIndex, maxIndex) if IDIndex == None or slaveIndex == None or nameIndex == None or desIndex == None or typeIndex == None or addrIndex == None or minIndex == None or maxIndex == None: - # print('表头错误') + print('表头错误') return '表头错误' - for index, row in enumerate(list(ws.iter_rows())[1:]): try: l = [str(x.value) for x in row] @@ -57,14 +56,14 @@ class ModbusVarManage(object): slaveID = l[slaveIndex] min = l[minIndex] max = l[maxIndex] - ModBusVarModel = ModBusVar() - if ModBusVarModel.getByName(varName): - ModBusVarModel.update(varType = varType, description = des, address = address, slaveID = slaveID, min = min, max = max, order = 'int').where(ModBusVarModel.varName == varName) + if ModBusVar.getByName(varName): + ModBusVar.update(varType = varType, description = des, address = address, slaveID = slaveID, min = min, max = max, order = 'int').where(ModBusVar.varName == varName).execute() else: + ModBusVarModel = ModBusVar() ModBusVarModel.createVar(varName = varName, varType = varType, des = des, address = address, slaveID = slaveID, min = min, max = max, order = 'int') except Exception as e: print(e) - return '第{}行导入出错'.format(index + 1) + print('第{}行导入出错'.format(index + 1)) @classmethod def exportModbusVar(self, excelPath): diff --git a/requirements.txt b/requirements.txt index b7a8aac..a9a1808 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,7 @@ redis msgpack-python pythonnet influxdb_client -PyQtWebEngine \ No newline at end of file +PyQtWebEngine +pythonnet +pyecharts +pyDes \ No newline at end of file