def SlotPushbutton_UseThisPara(self):
     """设置使用该参数列表"""
     if self.tableinfor_2Save!=self.tableinfor_2:#保存修改后的参数
         if self.currentfilepath is not None and self.currentfilepath['type'] == 0:
             FiveFileParser.updataTable(dict(self.tableinfor_2Save), 'MUBAN',
                                        self.currentfilepath['path'])
     self.Signal_UpdataParas.emit(dict(self.tableinfor_2Save))
     #创建数据表(包含参数,用一个data来存数据在数据库中的位置)
     #当前参数表对应的名字,不要后缀
     name="D"+os.path.split(self.currentfilepath['path'])[1].rstrip('.txt')+"时间"+time.strftime('%Y%m%d%M',time.localtime())
     #检测当前名字是否合适
     while os.path.exists("".join([os.path.join(self.AnotherSavingDir,name),'.d'])):
         name+='cp'
     #数据表路径
     path=os.path.join(self.AnotherSavingDir,''.join([name,'.d']))#数据表后缀变为‘.d’
     FiveFileParser.createTable(path)
     FiveFileParser.insertTable(dict(self.tableinfor_2Save), '参数',path,0)
     FiveFileParser.writeComments(path,'\nDataBaseDir*{}\nDataTable*{}'.format(self.AnotherSavingDir,name))
     QtWidgets.QMessageBox.information(self, '提示', '参数选择成功:'
                                       '数据表为:{}\n立即搜集数据'.format(name),
                                       QtWidgets.QMessageBox.Yes)
     self.Signal_SaveDirChanged_ForDB.emit(self.AnotherSavingDir,name)
     self.Signal_UseThisParaTable.emit(name)
     self.Siganl_ManagerWidget.emit('ShuJuBiao',''.join(name))
     self.log.info('Create DataTable:  {}.d'.format(name))
Exemple #2
0
 def CheckUsb(self):
     """检查USB"""
     path = self.FilesLists[0]
     usb = FiveFileParser.getcomments(path, ('usb', ))['usb']
     if usb != []:  #如果存在usb残留则删除记录
         FiveFileParser.removeComments(path, ['usb'])
     FiveFileParser.writeComments(path, ['usb*'])
     tempusb = 'None'  #暂存usb的路径
     usbPATH = '/media/pi'  #"/media/pi"#树莓派的Usb路径更改处
     if os.path.exists(usbPATH):
         if len(os.listdir(usbPATH)) != 0:
             for i in os.listdir(usbPATH):
                 if os.path.exists(os.path.join(usbPATH, i)):
                     tempusb = os.path.join(usbPATH, i)
                     self.usb = tempusb
                     break
     tempusb = self.Savepath if tempusb == 'None' else tempusb
     FiveFileParser.updateComments(path, {'usb': r'{}'.format(tempusb)})
Exemple #3
0
 def CheckFiles(self):
     """检查文件是否存在"""
     try:
         for index, files in enumerate(self.FilesLists):
             files = os.path.normpath(files)
             if not os.path.exists(files):
                 with open(files, "w") as f:
                     self.log.info("create file:{}".format(files))
                     if index == 0:  #"setting.txt"
                         FiveFileParser.writeComments(
                             files, [r'saving*{}'.format(files)])
                     if index == 1:
                         table = {
                             "省份名": "工厂名",
                         }
                         FiveFileParser.insertTable(table, 'regions', files,
                                                    0)
                     if index == 2:
                         table = {
                             "参数表名": "0",
                             "电厂": "0",
                             '阀门型号': "0",
                             '整定压力': "0",
                             '弹簧刚度': "0",
                             '密封面内径': "0",
                             '密封面外径': "0",
                             '整调螺母方数': "0",
                         }
                         FiveFileParser.insertTable(table, 'MUBAN0', files,
                                                    0)
             else:
                 if index == 0:  #"setting.txt"
                     FiveFileParser.updateComments(
                         files, {'usb': r'{}'.format(self.Savepath)})
         return True
     except Exception as e:
         return False