|
@@ -0,0 +1,658 @@
|
|
|
+import time
|
|
|
+
|
|
|
+from PyQt5.QtCore import *
|
|
|
+from PyQt5.QtGui import *
|
|
|
+from PyQt5.QtWidgets import *
|
|
|
+
|
|
|
+from ScanUtils import CRC8
|
|
|
+
|
|
|
+
|
|
|
+from ScanUtils.ui.VersionSet import Ui_Form
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+softwareIconPath = r'./pic/scan.png'
|
|
|
+
|
|
|
+# class MySlot(QObject):
|
|
|
+# def get(self,msg):
|
|
|
+# print("信息" + msg)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+class VersionSet(QWidget):
|
|
|
+
|
|
|
+ #自定义信号
|
|
|
+ mySignal = pyqtSignal(str)
|
|
|
+
|
|
|
+ # def run1(self):
|
|
|
+ # self.mySignal.emit('Hello PyQt5')
|
|
|
+
|
|
|
+ def __init__(self, parent = None, closeToDlg = None):
|
|
|
+ '''构造函数'''
|
|
|
+ super(VersionSet, self).__init__(parent)
|
|
|
+ self.ui = Ui_Form()
|
|
|
+ self.ui.setupUi(self)
|
|
|
+
|
|
|
+ self.setWindowIcon(QIcon(softwareIconPath))
|
|
|
+
|
|
|
+ self.setWindowTitle("生产物料扫码记录")
|
|
|
+
|
|
|
+ self.setWindowFlags(self.windowFlags() | Qt.CustomizeWindowHint)#QtCore.Qt.WindowStaysOnTopHint顶层显示
|
|
|
+ #禁用最小化
|
|
|
+ # self.setWindowFlags(self.windowFlags() & ~Qt.WindowMinimizeButtonHint)
|
|
|
+ #禁用最大化
|
|
|
+ # self.setWindowFlags(self.windowFlags() & ~Qt.WindowMaximizeButtonHint)
|
|
|
+ #禁止拉伸窗口大小
|
|
|
+ # self.setFixedSize(self.width(), self.height())
|
|
|
+ self.closeToDlg = closeToDlg
|
|
|
+ self.widgetInit()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ # 设置参数
|
|
|
+ def getParamDict(self, newRule = True):
|
|
|
+ paramDict = {}
|
|
|
+ if newRule:#新规则2023年4月20日
|
|
|
+ paramDict['芯片主版本'] = (('HX02', 2), ('HX03', 3))#4位
|
|
|
+ paramDict['芯片次版本'] = (('第1版(A)', 1), ('第2版(B)', 2), ('第3版(C)', 3), ('第4版(D)', 4), ('第5版(E)', 5))#4位
|
|
|
+
|
|
|
+ paramDict['数字电容容值'] = (('无电容', 0), ('1uF', 1), ('4.7uF', 2), ('10uF', 3), ('22uF', 4), ('33uF', 5), ('47uF', 6), ('68uF', 7), ('100uF', 8))#4位
|
|
|
+ # 2022年9月28日由3位扩展到5位
|
|
|
+ paramDict['数字电容品牌'] = (('试验品牌', 0), ('AVX', 1), ('Vishay', 2), ('Sunlord', 3), ('火炬', 4), ('湘江', 5), ('振华', 6), ('丰华', 7), ('国巨', 8))
|
|
|
+ paramDict['电容耐压'] = (('16V', 0), ('20V', 1), ('25V', 2))#3位
|
|
|
+
|
|
|
+ paramDict['起爆电容容值'] = (('无电容', 0), ('33uF', 1), ('47uF', 2), ('68uF', 3), ('100uF', 4), ('220uF', 5))#3位
|
|
|
+ paramDict['起爆电容品牌'] = (('试验品牌', 0), ('AVX', 1), ('Vishay', 2), ('Sunlord', 3))#3位
|
|
|
+
|
|
|
+ paramDict['引火件形式'] = (('无', 0), ('焊接刚性药头', 1), ('贴片刚性药头', 2), ('贴片发热电阻', 3), ('碗状电阻器', 4))#3位
|
|
|
+ paramDict['桥丝规格'] = (('16um(7.9~8.6欧)', 0), ('2欧姆', 1))#5位
|
|
|
+ paramDict['脚线焊接方式'] = (('无孔焊接', 0), ('有孔焊接', 1), ('铭威铆接', 2), ('创德铆接', 3))#4位
|
|
|
+ paramDict['PCB供应商'] = (('丰达兴', 0), ('闽威', 1))
|
|
|
+ else:#旧规则
|
|
|
+ paramDict['芯片主版本'] = (('HX02', 2), ('HX03', 3)) # 4位
|
|
|
+ paramDict['芯片次版本'] = (('第1版(A)', 1), ('第2版(B)', 2), ('第3版(C)', 3), ('第4版(D)', 4), ('第5版(E)', 5)) # 4位
|
|
|
+
|
|
|
+ paramDict['数字电容容值'] = (
|
|
|
+ ('无电容', 0), ('1uF', 1), ('4.7uF', 2), ('10uF', 3), ('22uF', 4), ('33uF', 5), ('47uF', 6), ('68uF', 7),
|
|
|
+ ('100uF', 8)) # 4位
|
|
|
+ # 2022年9月28日由3位扩展到5位
|
|
|
+ paramDict['数字电容品牌'] = (
|
|
|
+ ('AVX', 1), ('Vishay', 2), ('Sunlord', 3), ('火炬', 4), ('湘江', 5), ('振华', 6), ('丰华', 7), ('国巨', 8))
|
|
|
+ paramDict['数字电容耐压'] = (('16V', 0), ('20V', 1), ('25V', 2)) # 3位
|
|
|
+
|
|
|
+ paramDict['起爆电容容值'] = (('无电容', 0), ('33uF', 1), ('47uF', 2), ('68uF', 3), ('100uF', 4)) # 3位
|
|
|
+ paramDict['起爆电容品牌'] = (('AVX', 1), ('Vishay', 2), ('Sunlord', 3)) # 3位
|
|
|
+ paramDict['起爆电容耐压'] = (('16V', 0), ('20V', 1), ('25V', 2)) # 3位
|
|
|
+
|
|
|
+ paramDict['引火件形式'] = (('无', 0), ('焊接刚性药头', 1), ('贴片刚性药头', 2), ('贴片发热电阻', 3), ('碗状电阻器', 4)) # 3位
|
|
|
+ paramDict['桥丝规格'] = (('16um(7.9~8.6欧)', 0), ('2欧姆', 1)) # 5位
|
|
|
+ paramDict['脚线焊接方式'] = (('焊接(有孔)', 1), ('铆接', 2), ('焊接(无孔)', 3)) # 4位
|
|
|
+
|
|
|
+ return paramDict
|
|
|
+
|
|
|
+ # 初始化:
|
|
|
+ def widgetInit(self):
|
|
|
+ paramDict = self.getParamDict(True)
|
|
|
+
|
|
|
+ for item in paramDict['芯片主版本']:
|
|
|
+ self.ui.chipVer_1.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['芯片次版本']:
|
|
|
+ self.ui.chipVer_2.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['数字电容容值']:
|
|
|
+ self.ui.workCapValue.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['数字电容品牌']:
|
|
|
+ self.ui.workCapVender.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['起爆电容容值']:
|
|
|
+ self.ui.blastCapValue.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['起爆电容品牌']:
|
|
|
+ self.ui.blastCapVender.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['电容耐压']:
|
|
|
+ self.ui.capVoltage.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['引火件形式']:
|
|
|
+ self.ui.bridgeType.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['桥丝规格']:
|
|
|
+ self.ui.bridgeValue.addItem(item[0])
|
|
|
+
|
|
|
+ for item in paramDict['PCB供应商']:
|
|
|
+ self.ui.pcbVender.addItem(item[0])
|
|
|
+
|
|
|
+ for item in range(32):
|
|
|
+ self.ui.pcbVer.addItem(str(item).zfill(2))#5位
|
|
|
+
|
|
|
+ for item in paramDict['脚线焊接方式']:
|
|
|
+ self.ui.lineType.addItem(item[0])
|
|
|
+
|
|
|
+ self.setDefault()
|
|
|
+
|
|
|
+ self.updateStatus()
|
|
|
+
|
|
|
+ self.ui.chipVer_1.activated.connect(self.updateStatus)
|
|
|
+ self.ui.chipVer_2.activated.connect(self.updateStatus)
|
|
|
+
|
|
|
+ self.ui.workCapValue.activated.connect(self.updateStatus)
|
|
|
+ self.ui.workCapVender.activated.connect(self.updateStatus)
|
|
|
+
|
|
|
+ self.ui.blastCapValue.activated.connect(self.updateStatus)
|
|
|
+ self.ui.blastCapVender.activated.connect(self.updateStatus)
|
|
|
+
|
|
|
+ self.ui.capVoltage.activated.connect(self.updateStatus)
|
|
|
+
|
|
|
+ self.ui.bridgeType.activated.connect(self.updateStatus)
|
|
|
+ self.ui.bridgeValue.activated.connect(self.updateStatus)
|
|
|
+
|
|
|
+ self.ui.pcbVender.activated.connect(self.updateStatus)
|
|
|
+ self.ui.pcbVer.activated.connect(self.updateStatus)
|
|
|
+ self.ui.lineType.activated.connect(self.updateStatus)
|
|
|
+
|
|
|
+ self.ui.productDate.dateChanged.connect(self.updateStatus)
|
|
|
+
|
|
|
+ # self.ui.copy.clicked.connect(self.copySolf)
|
|
|
+ self.ui.commit.clicked.connect(self.open_ScanInput)
|
|
|
+ # self.ui.read.clicked.connect(self.readSolf
|
|
|
+ # self.ui.write.clicked.connect(self.writeSolf)
|
|
|
+ # self.ui.analyst.clicked.connect(self.analystSolf).
|
|
|
+
|
|
|
+ # 打开窗口
|
|
|
+ def open_ScanInput(self):
|
|
|
+ versionCode= self.ui.versionCode.text()
|
|
|
+ productDate = self.ui.productDate.text()
|
|
|
+ from ScanUtils.ScanInput import ScanInput
|
|
|
+ self.ScanInput_ui = ScanInput(versionCode,productDate)
|
|
|
+
|
|
|
+ #self.ScanInput_ui.ui.versionCode.setText(versionCode)
|
|
|
+ # self.ScanInput_ui.ui.Deliverydate.setText(productDate)
|
|
|
+
|
|
|
+ self.ScanInput_ui.show()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ def setDefault(self):
|
|
|
+ self.ui.workCapValue.setCurrentIndex(4)#默认22uF
|
|
|
+ self.ui.workCapVender.setCurrentIndex(6)#默认振华
|
|
|
+ self.ui.blastCapValue.setCurrentIndex(1)#默认33uF
|
|
|
+ self.ui.blastCapVender.setCurrentIndex(2)#默认Vishay
|
|
|
+ self.ui.chipVer_1.setCurrentIndex(1)
|
|
|
+ self.ui.chipVer_2.setCurrentIndex(4)
|
|
|
+ self.ui.bridgeType.setCurrentIndex(4)
|
|
|
+ self.ui.lineType.setCurrentIndex(0)
|
|
|
+ self.ui.productDate.setDate(QDate.currentDate())
|
|
|
+
|
|
|
+ def paramStr2Value(self, content, paramList):
|
|
|
+ for item in paramList:
|
|
|
+ if content == item[0]:
|
|
|
+ return item[1]
|
|
|
+ return None
|
|
|
+ def paramValue2Str(self, value, paramList):
|
|
|
+ for item in paramList:
|
|
|
+ if value == item[1]:
|
|
|
+ return item[0]
|
|
|
+ return None
|
|
|
+
|
|
|
+ # 版本号
|
|
|
+ def getCurrentParam(self):
|
|
|
+ paramDict = self.getParamDict(True)
|
|
|
+
|
|
|
+ chipVer_1 = self.paramStr2Value(self.ui.chipVer_1.currentText(), paramDict['芯片主版本'])
|
|
|
+
|
|
|
+ chipVer_2 = self.paramStr2Value(self.ui.chipVer_2.currentText(), paramDict['芯片次版本'])
|
|
|
+
|
|
|
+ workCapVender = self.paramStr2Value(self.ui.workCapVender.currentText(), paramDict['数字电容品牌'])
|
|
|
+
|
|
|
+ workCapValue = self.paramStr2Value(self.ui.workCapValue.currentText(), paramDict['数字电容容值'])
|
|
|
+
|
|
|
+ blastCapVender = self.paramStr2Value(self.ui.blastCapVender.currentText(), paramDict['起爆电容品牌'])
|
|
|
+
|
|
|
+ blastCapValue = self.paramStr2Value(self.ui.blastCapValue.currentText(), paramDict['起爆电容容值'])
|
|
|
+
|
|
|
+ capVoltage = self.paramStr2Value(self.ui.capVoltage.currentText(), paramDict['电容耐压'])
|
|
|
+
|
|
|
+ bridgeType = self.paramStr2Value(self.ui.bridgeType.currentText(), paramDict['引火件形式'])
|
|
|
+
|
|
|
+ bridgeValue = self.paramStr2Value(self.ui.bridgeValue.currentText(), paramDict['桥丝规格'])
|
|
|
+
|
|
|
+ pcbVender = self.paramStr2Value(self.ui.pcbVender.currentText(), paramDict['PCB供应商'])
|
|
|
+
|
|
|
+
|
|
|
+ pcbVer = int(self.ui.pcbVer.currentText())
|
|
|
+
|
|
|
+ lineType = self.paramStr2Value(self.ui.lineType.currentText(), paramDict['脚线焊接方式'])
|
|
|
+
|
|
|
+ productDate = self.ui.productDate.date()#发料日期
|
|
|
+
|
|
|
+ U64Value = chipVer_1 & 0x0F #芯片主版本号共4位,bit0-3
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (chipVer_2 & 0x0F) << 4#芯片次版本号共4位,bit4-7
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (workCapVender & 0x1F) << 8 #数字电容品牌共5位 ,bit8-12
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (workCapValue & 0x0F) << 13 #数字电容容量共4位 ,bit13-16
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (blastCapVender & 0x07) << 17 #起爆电容品牌共3位 ,bit17-19
|
|
|
+
|
|
|
+ U64Value |= (blastCapValue & 0x07) << 20 #起爆电容容量共3位 ,bit20-22
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (capVoltage & 0x07) << 23 #电容耐压共3位 ,bit23-25
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (bridgeType & 0x07) << 26 #引火件形式共3位 ,bit26-28
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (bridgeValue & 0x1F) << 29 #桥丝规格共5位 ,bit29-33
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (pcbVer & 0x1F) << 34 #PCB版本流水号共5位 ,bit34-38
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (pcbVender & 0x03) << 39 #PCB供应商共2位 ,bit39-40
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (lineType & 0x07) << 41 #脚线焊接方式共3位 ,bit41-43
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (((productDate.year()-2020)*12 + (productDate.month()-1)) & 0x7F) << 44 # 发料日期中的年月共7位 ,bit44-50
|
|
|
+
|
|
|
+
|
|
|
+ U64Value |= (productDate.day() & 0x1F) << 51 # 发料日期中的日共5位 ,bit51-55
|
|
|
+
|
|
|
+ # print(hex(U64Value))
|
|
|
+
|
|
|
+
|
|
|
+ Bytes_0 = U64Value & 0xFF
|
|
|
+ Bytes_1 = (U64Value >> 8) & 0xFF
|
|
|
+ Bytes_2 = (U64Value >> 16) & 0xFF
|
|
|
+ Bytes_3 = (U64Value >> 24) & 0xFF
|
|
|
+ Bytes_4 = (U64Value >> 32) & 0xFF
|
|
|
+ Bytes_5 = (U64Value >> 40) & 0xFF
|
|
|
+ Bytes_6 = (U64Value >> 48) & 0xFF
|
|
|
+
|
|
|
+ hexStr = '%02X%02X%02X%02X%02X%02X%02X' % (Bytes_0, Bytes_1, Bytes_2, Bytes_3, Bytes_4, Bytes_5, Bytes_6)
|
|
|
+ hexStr += '%02X' % ((~CRC8.getCrc8(bytearray.fromhex(hexStr))) & 0xFF)
|
|
|
+
|
|
|
+ return hexStr
|
|
|
+
|
|
|
+ def updateStatus(self, param= None):
|
|
|
+ status = True
|
|
|
+ if self.ui.workCapValue.currentText() == "无电容":
|
|
|
+ status = False
|
|
|
+ self.ui.workCapVender.setEnabled(status)
|
|
|
+
|
|
|
+ status = True
|
|
|
+ if self.ui.blastCapValue.currentText() == "无电容":
|
|
|
+ status = False
|
|
|
+ self.ui.blastCapVender.setEnabled(status)
|
|
|
+
|
|
|
+ self.ui.versionCode.setText(self.getCurrentParam())
|
|
|
+
|
|
|
+
|
|
|
+ def showVersion(self, hexStr):
|
|
|
+ if len(hexStr) == 16 and hexStr[12:14] == "00":
|
|
|
+ self.showVersionForOldRule(hexStr)
|
|
|
+ else:
|
|
|
+ self.showVersionForNewRule(hexStr)
|
|
|
+
|
|
|
+ def showVersionForOldRule(self, hexStr):
|
|
|
+ result, infos = self.getVersionInfosForOldRule(hexStr)
|
|
|
+ if not result:
|
|
|
+ QMessageBox.critical(self, '错误', '{0}'.format(infos))
|
|
|
+ return
|
|
|
+
|
|
|
+ contents = []
|
|
|
+ key = '延期模块版本代码'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '芯片主版本'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+ key = '芯片次版本'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+
|
|
|
+ key = '数字电容品牌'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '数字电容容值'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '数字电容耐压'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '起爆电容品牌'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '起爆电容容值'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '起爆电容耐压'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '引火件形式'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '桥丝规格'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = 'PCB版本流水号'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '脚线焊接方式'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ QMessageBox.information(self, '信息(旧规则)', '\n'.join(contents))
|
|
|
+
|
|
|
+ def getVersionInfosForOldRule(self, versionHexStr):
|
|
|
+ if not versionHexStr or len(versionHexStr) != 16:
|
|
|
+ return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
|
|
|
+ try:
|
|
|
+ verBytes = bytearray.fromhex(versionHexStr)
|
|
|
+ except Exception as e:
|
|
|
+ return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
|
|
|
+
|
|
|
+ crc8 = (~CRC8.getCrc8(verBytes[:-1])) & 0xFF
|
|
|
+ if crc8 != verBytes[-1]:
|
|
|
+ return False, '{0}\n校验值错误'.format(versionHexStr)
|
|
|
+
|
|
|
+ U64Value = 0
|
|
|
+ U64Value |= verBytes[6]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[5]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[4]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[3]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[2]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[1]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[0]&0xFF
|
|
|
+
|
|
|
+ paramDict = self.getParamDict(False)
|
|
|
+
|
|
|
+ infos = {}
|
|
|
+ infos['延期模块版本代码'] = versionHexStr
|
|
|
+
|
|
|
+ key = '芯片主版本'
|
|
|
+ value = U64Value & 0x0F
|
|
|
+ chipVer_1 = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if chipVer_1 == None:
|
|
|
+ chipVer_1 = '未知({0})'.format(value)
|
|
|
+ infos[key] = chipVer_1
|
|
|
+
|
|
|
+ key = '芯片次版本'
|
|
|
+ value = (U64Value >> 4) & 0x0F
|
|
|
+ chipVer_2 = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if chipVer_2 == None:
|
|
|
+ chipVer_2 = '未知({0})'.format(value)
|
|
|
+ infos[key] = chipVer_2
|
|
|
+
|
|
|
+ key = '数字电容品牌'
|
|
|
+ value = (((U64Value >> 46) & 0x03)<<3) + ((U64Value >> 8) & 0x07)#2022年9月28日由3位扩展到5位
|
|
|
+
|
|
|
+ workCapVender = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if workCapVender == None:
|
|
|
+ workCapVender = '未知({0})'.format(value)
|
|
|
+ infos[key] = workCapVender
|
|
|
+
|
|
|
+ key = '数字电容容值'
|
|
|
+ value = (U64Value >> 11) & 0x0F
|
|
|
+ workCapValue = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if workCapValue == None:
|
|
|
+ workCapValue = '未知({0})'.format(value)
|
|
|
+ infos[key] = workCapValue
|
|
|
+
|
|
|
+ key = '数字电容耐压'
|
|
|
+ value = (U64Value >> 15) & 0x07
|
|
|
+ workCapVoltage = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if workCapVoltage == None:
|
|
|
+ workCapVoltage = '未知({0})'.format(value)
|
|
|
+ infos[key] = workCapVoltage
|
|
|
+
|
|
|
+ key = '起爆电容品牌'
|
|
|
+ value = (U64Value >> 18) & 0x07
|
|
|
+ blastVender = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if blastVender == None:
|
|
|
+ blastVender = '未知({0})'.format(value)
|
|
|
+ infos[key] = blastVender
|
|
|
+
|
|
|
+ key = '起爆电容容值'
|
|
|
+ value = (U64Value >> 21) & 0x07
|
|
|
+ blastCapValue = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if blastCapValue == None:
|
|
|
+ blastCapValue = '未知({0})'.format(value)
|
|
|
+ infos[key] = blastCapValue
|
|
|
+
|
|
|
+ key = '起爆电容耐压'
|
|
|
+ value = (U64Value >> 24) & 0x07
|
|
|
+ blastCapVoltage = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if blastCapVoltage == None:
|
|
|
+ blastCapVoltage = '未知({0})'.format(value)
|
|
|
+ infos[key] = blastCapVoltage
|
|
|
+
|
|
|
+ key = '引火件形式'
|
|
|
+ value = (U64Value >> 27) & 0x07
|
|
|
+ bridgeType = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if bridgeType == None:
|
|
|
+ bridgeType = '未知({0})'.format(value)
|
|
|
+ infos[key] = bridgeType
|
|
|
+
|
|
|
+ key = '桥丝规格'
|
|
|
+ value = (U64Value >> 30) & 0x1F
|
|
|
+ bridgeValue = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if bridgeValue == None:
|
|
|
+ bridgeValue = '未知({0})'.format(value)
|
|
|
+ infos[key] = bridgeValue
|
|
|
+
|
|
|
+ infos['PCB版本流水号'] = str((U64Value >> 35) & 0x7F).zfill(2)
|
|
|
+
|
|
|
+ key = '脚线焊接方式'
|
|
|
+ value = (U64Value >> 42) & 0x0F
|
|
|
+ lineType = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if lineType == None:
|
|
|
+ lineType = '未知({0})'.format(value)
|
|
|
+ infos[key] = lineType
|
|
|
+
|
|
|
+ return True, infos
|
|
|
+
|
|
|
+
|
|
|
+ def showVersionForNewRule(self, hexStr):
|
|
|
+ result, infos = self.getVersionInfosForNewRule(hexStr)
|
|
|
+ if not result:
|
|
|
+ QMessageBox.critical(self, '错误', '{0}'.format(infos))
|
|
|
+ return
|
|
|
+
|
|
|
+ contents = []
|
|
|
+ key = '延期模块版本代码'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '芯片主版本'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+ key = '芯片次版本'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+
|
|
|
+ key = '数字电容品牌'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '数字电容容值'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '起爆电容品牌'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '起爆电容容值'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '电容耐压'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '引火件形式'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '桥丝规格'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = 'PCB供应商'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = 'PCB版本流水号'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '脚线焊接方式'
|
|
|
+ contents.append("{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ key = '发料日期'
|
|
|
+ contents.append("\n{0}:{1}".format(key, infos[key]))
|
|
|
+
|
|
|
+ QMessageBox.information(self, '信息', '\n'.join(contents))
|
|
|
+
|
|
|
+ def getVersionInfosForNewRule(self, versionHexStr):
|
|
|
+ if not versionHexStr or len(versionHexStr) != 16:
|
|
|
+ return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
|
|
|
+ try:
|
|
|
+ verBytes = bytearray.fromhex(versionHexStr)
|
|
|
+ except Exception as e:
|
|
|
+ return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
|
|
|
+
|
|
|
+ crc8 = (~CRC8.getCrc8(verBytes[:-1])) & 0xFF
|
|
|
+ if crc8 != verBytes[-1]:
|
|
|
+ return False, '{0}\n校验值错误'.format(versionHexStr)
|
|
|
+
|
|
|
+ U64Value = 0
|
|
|
+ U64Value |= verBytes[6]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[5]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[4]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[3]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[2]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[1]&0xFF
|
|
|
+ U64Value <<= 8
|
|
|
+ U64Value |= verBytes[0]&0xFF
|
|
|
+
|
|
|
+ infos = {}
|
|
|
+ infos['延期模块版本代码'] = versionHexStr
|
|
|
+
|
|
|
+ paramDict = self.getParamDict(True)
|
|
|
+
|
|
|
+ key = '芯片主版本'#芯片主版本号共4位,bit0-3
|
|
|
+ value = U64Value & 0x0F
|
|
|
+ chipVer_1 = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if chipVer_1 == None:
|
|
|
+ chipVer_1 = '未知({0})'.format(value)
|
|
|
+ infos[key] = chipVer_1
|
|
|
+
|
|
|
+ key = '芯片次版本'#芯片次版本号共4位,bit4-7
|
|
|
+ value = (U64Value >> 4) & 0x0F
|
|
|
+ chipVer_2 = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if chipVer_2 == None:
|
|
|
+ chipVer_2 = '未知({0})'.format(value)
|
|
|
+ infos[key] = chipVer_2
|
|
|
+
|
|
|
+ key = '数字电容品牌'#数字电容品牌共5位 ,bit8-12
|
|
|
+ value = (U64Value >> 8) & 0x1F
|
|
|
+
|
|
|
+ workCapVender = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if workCapVender == None:
|
|
|
+ workCapVender = '未知({0})'.format(value)
|
|
|
+ infos[key] = workCapVender
|
|
|
+
|
|
|
+ key = '数字电容容值'#数字电容容量共4位 ,bit13-16
|
|
|
+ value = (U64Value >> 13) & 0x0F
|
|
|
+ workCapValue = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if workCapValue == None:
|
|
|
+ workCapValue = '未知({0})'.format(value)
|
|
|
+ infos[key] = workCapValue
|
|
|
+
|
|
|
+ key = '起爆电容品牌'#起爆电容品牌共3位 ,bit17-19
|
|
|
+ value = (U64Value >> 17) & 0x07
|
|
|
+ blastVender = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if blastVender == None:
|
|
|
+ blastVender = '未知({0})'.format(value)
|
|
|
+ infos[key] = blastVender
|
|
|
+
|
|
|
+ key = '起爆电容容值'#起爆电容容量共3位 ,bit20-22
|
|
|
+ value = (U64Value >> 20) & 0x07
|
|
|
+ blastCapValue = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if blastCapValue == None:
|
|
|
+ blastCapValue = '未知({0})'.format(value)
|
|
|
+ infos[key] = blastCapValue
|
|
|
+
|
|
|
+ key = '电容耐压'#电容耐压共3位 ,bit23-25
|
|
|
+ value = (U64Value >> 23) & 0x07
|
|
|
+ blastCapVoltage = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if blastCapVoltage == None:
|
|
|
+ blastCapVoltage = '未知({0})'.format(value)
|
|
|
+ infos[key] = blastCapVoltage
|
|
|
+
|
|
|
+ key = '引火件形式'#引火件形式共3位 ,bit26-28
|
|
|
+ value = (U64Value >> 26) & 0x07
|
|
|
+ bridgeType = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if bridgeType == None:
|
|
|
+ bridgeType = '未知({0})'.format(value)
|
|
|
+ infos[key] = bridgeType
|
|
|
+
|
|
|
+ key = '桥丝规格'#桥丝规格共5位 ,bit29-33
|
|
|
+ value = (U64Value >> 29) & 0x1F
|
|
|
+ bridgeValue = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if bridgeValue == None:
|
|
|
+ bridgeValue = '未知({0})'.format(value)
|
|
|
+ infos[key] = bridgeValue
|
|
|
+
|
|
|
+ infos['PCB版本流水号'] = str((U64Value >> 34) & 0x1F).zfill(2)#PCB版本流水号共5位 ,bit34-38
|
|
|
+
|
|
|
+ key = 'PCB供应商'# PCB供应商共2位 ,bit39-40
|
|
|
+ value = (U64Value >> 39) & 0x03
|
|
|
+ bridgeValue = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if bridgeValue == None:
|
|
|
+ bridgeValue = '未知({0})'.format(value)
|
|
|
+ infos[key] = bridgeValue
|
|
|
+
|
|
|
+ key = '脚线焊接方式'#脚线焊接方式共3位 ,bit41-43
|
|
|
+ value = (U64Value >> 41) & 0x07
|
|
|
+ lineType = self.paramValue2Str(value, paramDict[key])
|
|
|
+ if lineType == None:
|
|
|
+ lineType = '未知({0})'.format(value)
|
|
|
+ infos[key] = lineType
|
|
|
+
|
|
|
+ # 发料日期中的年月共7位 ,bit44-50
|
|
|
+ # 发料日期中的日共5位 ,bit51-55
|
|
|
+ yearAndMonth = (U64Value >> 44) & 0x7F
|
|
|
+ yaer = yearAndMonth//12
|
|
|
+ month = 1+ (yearAndMonth%12)
|
|
|
+ day = (U64Value >> 51) & 0x1F
|
|
|
+ infos['发料日期'] = "%04d年%d月%d日"%(2020+yaer, month, day)
|
|
|
+
|
|
|
+ return True, infos
|
|
|
+
|
|
|
+ def closeEvent(self, QCloseEvent):
|
|
|
+ if self.closeToDlg != None:
|
|
|
+ self.closeToDlg.show()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ import sys
|
|
|
+ app = QApplication(sys.argv)
|
|
|
+ ui = VersionSet()
|
|
|
+ ui.show()
|
|
|
+ sys.exit(app.exec_())
|