Procházet zdrojové kódy

更新版本信息

leslie před 3 týdny
rodič
revize
c078515b70
3 změnil soubory, kde provedl 14 přidání a 96 odebrání
  1. 0 1
      ScanUtils/Dialog/Dialogadd.py
  2. 8 65
      ScanUtils/ScanInput.py
  3. 6 30
      ScanUtils/VersionSet.py

+ 0 - 1
ScanUtils/Dialog/Dialogadd.py

@@ -17,7 +17,6 @@ from PyQt5.QtCore import QStringListModel, QAbstractListModel, QModelIndex, QSiz
 
 
 class Dialogadd(QDialog):
-
     # 自定义消息
     dialogSignel = pyqtSignal(int, str)
 

+ 8 - 65
ScanUtils/ScanInput.py

@@ -27,13 +27,6 @@ from PyQt5.QtGui import *
 from PyQt5.QtWidgets import *
 
 
-# class WorkThread(QThread):
-#     sinOut = pyqtSignal(str)
-#     def run(self):
-#         while True:
-#             time.sleep(5)
-#             self.sinOut.emit("1111run")
-
 
 class ScanInput(QWidget):
 
@@ -62,16 +55,12 @@ class ScanInput(QWidget):
 
         QMessageBox.information(self, '提示', '请在英文输入法状态下进行扫码操作')
 
-        # 创建保存.txt的文件夹
-        # self.mkdirFile()
-
         # 线程传参
         self.autoSave = AutoSaveThread(self,directory,self.fileName)
         self.autoSave.start()
         self.my_signal.connect(self.autoSave.my_slot)
 
 
-
     def send_value(self, value):
         self.my_signal.emit(value)
 
@@ -90,17 +79,12 @@ class ScanInput(QWidget):
     # 打开文件
     def actOpenTriggered(self):
 
-
-        # 538614100080B2AE_2023年5月22日
-        # 当前应用所在的目录
-        # curPath = QCoreApplication.applicationDirPath()
         versionCode = self.ui.versionCode.text()
         deliveryDate = self.ui.Deliverydate.text()
         selectPath = self.directory
 
         QMessageBox.information(self, '提示', f'请选择以版本代码\'{versionCode}\'+发料日期\'{deliveryDate}\'为开头的.txt文件')
 
-        #     调用打开文件对话框打开一个文件
         QFileName = QFileDialog.getOpenFileName(self, "选取文件", selectPath,
                                                 "文本文件(*.txt)")
 
@@ -112,7 +96,6 @@ class ScanInput(QWidget):
             fileNameAll = QFileName[0].split("/")[-1].split(".")[0]
 
             self.fileName = fileName
-            # 将文件名传递给
             self.send_value(fileName)
 
 
@@ -128,28 +111,17 @@ class ScanInput(QWidget):
                         data = data.decode(encoding)
                         self.ui.plainTextEdit.setPlainText(data)
 
-                # f = open(QFileName[0], 'r',encoding='utf-8')
-                # with f:
-                #     data = f.read()
-                #     result = chardet.detect(data)
-                #     self.ui.plainTextEdit.setPlainText(data)
 
             else:
                 QMessageBox.critical(self,'错误',f'请选择以版本代码\'{versionCode}\'+发料日期\'{deliveryDate}\'为开头的.txt文件')
 
-    # 文件另存为
-    def actSaveAsTriggered(self):
 
+    def actSaveAsTriggered(self):
         desktopPath = Configuration().get_desktop()
-
-
         versionCode = self.ui.versionCode.text()
         Deliverydate = self.ui.Deliverydate.text()
         filenameStr = versionCode + "_" + Deliverydate + ".txt"
-
         filePathName = desktopPath + '\\' + folderName + '\\' + filenameStr
-
-
         aFileName = QFileDialog.getSaveFileName(self, "另存为", filePathName, "文本文档(*.txt)")
 
         text = self.ui.plainTextEdit.toPlainText()
@@ -175,14 +147,11 @@ class ScanInput(QWidget):
         directory = self.directory
 
         filePath = directory + "/" + fileName
-        # filePath = "test.txt"  # 指定文件路径
 
         try:
             with open(filePath, "w",encoding='utf-8') as f:
-            # with open(filePath, "w") as f:
                 text = self.ui.plainTextEdit.toPlainText()
                 f.write(text)
-                # 将文件标记为已保存
                 self.ui.plainTextEdit.document().setModified(False)
             QMessageBox.information(self, "Information", "保存成功")
         except Exception as e:
@@ -198,26 +167,13 @@ class ScanInput(QWidget):
 
 
 
-    # 创建保存文件的文件夹
-    # def mkdirFile(self):
-    #
-    #     desktopPath = Configuration().get_desktop()
-    #
-    #     folderNamePath = desktopPath + '\\' + folderName
-    #
-    #     if not os.path.exists(folderNamePath):
-    #         os.mkdir(folderNamePath)
-    #     else:
-    #         return True
 
 
 
     # 添加物料类别的界面 目前没用
     def openDialog(self):
         dialog = Dialogadd(self)
-        # 连接【子窗口内置消息和主窗口的槽函数】
-        # dialog.datetime.dateChanged.connect(self.slot_inner)
-        # 连接【子窗口自定义消息和主窗口槽函数】
+
         dialog.dialogSignel.connect(self.slot_emit)
         dialog.show()
 
@@ -225,8 +181,7 @@ class ScanInput(QWidget):
         self.autoSave.stop()
 
     def closeEventOld(self, event):
-        # # desktopPath = Configuration().get_desktop()
-        #
+
         versionCode = self.ui.versionCode.text()
 
         deliveryDate = self.ui.Deliverydate.text()
@@ -244,20 +199,17 @@ class ScanInput(QWidget):
 
             txt = self.ui.plainTextEdit.toPlainText()
 
-
-
             file = open(filePathName, 'w',encoding="utf-8")
 
             file.write(txt)
 
             file.close()
 
-            #关闭线程
-            self.autoSave.terminate()  # 结束此进程
+            self.autoSave.terminate()
 
-            self.autoSave.wait()  # 等待结束完成
+            self.autoSave.wait()
 
-            if self.autoSave.isFinished():  # 如果当前线程已经完成工作,则删除
+            if self.autoSave.isFinished():
 
                 del self.autoSave
 
@@ -265,14 +217,13 @@ class ScanInput(QWidget):
 
         else:
             event.ignore()
-            # QMessageBox.information(self, "消息", "谢谢!")
+
 
 
     def closeEvent(self, event):
-        # 判断文本编辑器是否已经保存
         if self.ui.plainTextEdit.document().isModified():
 
-            # 文件名称
+
             fileName = self.fileName
             directory = self.directory
             msg_box = QMessageBox(QMessageBox.Question, "提示", f"是否需要将文件{fileName}保存在{directory}文件夹中")
@@ -300,7 +251,6 @@ class ScanInput(QWidget):
             event.accept()
 
 
-# 自动保存 线程任务
 class AutoSaveThread(QThread):
 
     # 初始化传参
@@ -331,18 +281,11 @@ class AutoSaveThread(QThread):
         # 定时
         if self.inputDiog.ui.plainTextEdit.toPlainText():
 
-            # desktopPath = Configuration().get_desktop()
-
-            # versionCode = self.versionCode
-            # deliveryDate = self.deliveryDate
             #
             filePath = self.directory
 
             filenameStr = self.fileName
 
-            #
-            # filenameStr = versionCode+"_"+deliveryDate + ".txt"
-            # filePathName = filePath + '\\' + folderName + '\\' + filenameStr
             filePathName = filePath + '/'  + filenameStr
 
             txt = self.inputDiog.ui.plainTextEdit.toPlainText()

+ 6 - 30
ScanUtils/VersionSet.py

@@ -16,11 +16,8 @@ softwareIconPath = r'D:\PycharmProjects\Scan\ScanUtils\pic\scan.png'
 # softwareIconPath = r':pic/scan.png'
 
 folderName = 'material'
-VERSION = '2.5'
+VERSION = '2.7'
 
-# class MySlot(QObject):
-#     def get(self,msg):
-#         print("信息" + msg)
 
 
 
@@ -29,8 +26,6 @@ class VersionSet(QWidget):
     #自定义信号
     mySignal = pyqtSignal(str)
 
-    # def run1(self):
-    #     self.mySignal.emit('Hello PyQt5')
 
     def __init__(self, parent = None, closeToDlg = None):
         '''构造函数'''
@@ -56,7 +51,7 @@ class VersionSet(QWidget):
     def getParamDict(self, newRule = True):
         paramDict = {}
         if newRule:#新规则2023年4月20日
-            paramDict['芯片主版本'] = (('HX02', 2), ('HX03', 3), ('HX05', 4))#4位
+            paramDict['芯片主版本'] = (('HX01', 1), ('HX02', 2), ('HX03', 3), ('HX05', 4), ('HX10', 5))#4位
             paramDict['芯片次版本'] = (('第1版(A)', 1), ('第2版(B)', 2), ('第3版(C)', 3), ('第4版(D)', 4), ('第5版(E)', 5), ('第6版(F)', 6))#4位
 
             paramDict['数字电容容值'] = (('无电容', 0), ('1uF', 1), ('4.7uF', 2), ('10uF', 3), ('22uF', 4), ('33uF', 5), ('47uF', 6), ('68uF', 7), ('100uF', 8))#4位
@@ -64,13 +59,13 @@ class VersionSet(QWidget):
             paramDict['数字电容品牌'] = (('试验品牌', 0), ('AVX', 1), ('Vishay', 2), ('Sunlord', 3), ('火炬', 4), ('湘江', 5), ('振华', 6), ('丰华', 7), ('国巨', 8), ('三星', 9))
             paramDict['电容耐压'] = (('16V', 0), ('20V', 1), ('25V', 2))#3位
 
-            paramDict['起爆电容容值'] = (('无电容', 0), ('33uF', 1), ('47uF', 2), ('68uF', 3), ('100uF', 4), ('220uF', 5))#3位
+            paramDict['起爆电容容值'] = (('无电容', 0), ('33uF', 1), ('47uF', 2), ('68uF', 3), ('100uF', 4), ('220uF', 5),('120uF', 6))#3位
             paramDict['起爆电容品牌'] = (('试验品牌', 0), ('AVX', 1), ('Vishay', 2), ('Sunlord', 3), ('永铭', 4), ('丰宾', 5), ('米朗', 6))#3位
 
             paramDict['引火件形式'] = (('无', 0), ('焊接刚性药头', 1), ('贴片刚性药头', 2), ('贴片发热电阻', 3), ('碗状电阻器', 4))#3位
-            paramDict['桥丝规格'] = (('16um(7.9~8.6欧)', 0), ('2欧姆', 1), ('8欧姆', 2), ('20um', 3), ('22um', 4), ('25um', 5), ('30um', 6),('试验规格', 7), ('40um', 8),('28um', 9))#5位
+            paramDict['桥丝规格'] = (('16um(7.9~8.6欧)', 0), ('2欧姆', 1), ('8欧姆', 2), ('20um', 3), ('22um', 4), ('25um', 5), ('30um', 6),('试验规格', 7), ('40um', 8),('28um', 9),('50um', 10))#5位
             paramDict['脚线焊接方式'] = (('无孔焊接', 0), ('有孔焊接', 1), ('铭威铆接', 2), ('创德铆接', 3))#4位
-            paramDict['PCB供应商'] = (('丰达兴', 0), ('闽威', 1), ('镓锐', 2), ('联宇宏', 3))
+            paramDict['PCB供应商'] = (('丰达兴', 0), ('欧拓', 1), ('镓锐', 2), ('联宇宏', 3))
         else:#旧规则
             paramDict['芯片主版本'] = (('HX02', 2), ('HX03', 3))  # 4位
             paramDict['芯片次版本'] = (('第1版(A)', 1), ('第2版(B)', 2), ('第3版(C)', 3), ('第4版(D)', 4), ('第5版(E)', 5))  # 4位
@@ -262,11 +257,6 @@ class VersionSet(QWidget):
             self.ui.dir.setText(filePathName)
         else:
             self.ui.dir.setText(directory)
-        # if directory:
-        #     file_name = 'new_file.txt'
-        #     file_path = os.path.join(directory, file_name)
-        #     with open(file_path, 'w') as f:        #         f.write('新文件内容')
-
 
     # 默认地址
     def setDirDefault(self):
@@ -419,14 +409,8 @@ class VersionSet(QWidget):
         U64Value |= (lineType & 0x07) << 41   #脚线焊接方式共3位 ,bit41-43
 
         U64Value |= (((productDate.year()-2020)*12 + (productDate.month()-1)) & 0x7F) << 44  # 发料日期中的年月共7位 ,bit44-50
-        # print(bin((((productDate.year()-2020)*12 + (productDate.month()-1)) & 0x7F) << 44))
-        # print(bin(U64Value))
 
         U64Value |= (productDate.day() & 0x1F) << 51  # 发料日期中的日共5位 ,bit51-55
-        # print(bin((productDate.day() & 0x1F) << 51))
-        # print(hex(U64Value))
-        # print("aaaaa")
-        # print(bin(U64Value))
 
 
         Bytes_0 = U64Value & 0xFF
@@ -436,16 +420,10 @@ class VersionSet(QWidget):
         Bytes_4 = (U64Value >> 32) & 0xFF
         Bytes_5 = (U64Value >> 40) & 0xFF
         Bytes_6 = (U64Value >> 48) & 0xFF
-        # print(Bytes_0,Bytes_1,Bytes_2)
 
         hexStr = '%02X%02X%02X%02X%02X%02X%02X' % (Bytes_0, Bytes_1, Bytes_2, Bytes_3, Bytes_4, Bytes_5, Bytes_6)
-        # # 53861410004043
-        # print(hexStr)
-        # print(bytearray.fromhex(hexStr))
 
-        # print(bin(CRC8.getCrc8(bytearray.fromhex(hexStr))))
         hexStr += '%02X' % ((~CRC8.getCrc8(bytearray.fromhex(hexStr))) & 0xFF)
-        # print(hexStr)
         data = bytearray([0x01])  # 示例数据,转换为字节数组
         # print((CRC8.getCrc8(data)))
         return hexStr
@@ -462,9 +440,7 @@ class VersionSet(QWidget):
         self.ui.blastCapVender.setEnabled(status)
 
         self.ui.versionCode.setText(self.getCurrentParam())
-        #
-        # versionCodeChange = self.ui.versionCode.text()
-        # self.versioncode = versionCodeChange
+
         self.set_fileName_Default()