VersionSet.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. import time
  2. from PyQt5.QtCore import *
  3. from PyQt5.QtGui import *
  4. from PyQt5.QtWidgets import *
  5. from ScanUtils import CRC8
  6. from ScanUtils.ui.VersionSet import Ui_Form
  7. softwareIconPath = r'./pic/scan.png'
  8. # class MySlot(QObject):
  9. # def get(self,msg):
  10. # print("信息" + msg)
  11. class VersionSet(QWidget):
  12. #自定义信号
  13. mySignal = pyqtSignal(str)
  14. # def run1(self):
  15. # self.mySignal.emit('Hello PyQt5')
  16. def __init__(self, parent = None, closeToDlg = None):
  17. '''构造函数'''
  18. super(VersionSet, self).__init__(parent)
  19. self.ui = Ui_Form()
  20. self.ui.setupUi(self)
  21. self.setWindowIcon(QIcon(softwareIconPath))
  22. self.setWindowTitle("生产物料扫码记录")
  23. self.setWindowFlags(self.windowFlags() | Qt.CustomizeWindowHint)#QtCore.Qt.WindowStaysOnTopHint顶层显示
  24. #禁用最小化
  25. # self.setWindowFlags(self.windowFlags() & ~Qt.WindowMinimizeButtonHint)
  26. #禁用最大化
  27. # self.setWindowFlags(self.windowFlags() & ~Qt.WindowMaximizeButtonHint)
  28. #禁止拉伸窗口大小
  29. # self.setFixedSize(self.width(), self.height())
  30. self.closeToDlg = closeToDlg
  31. self.widgetInit()
  32. # 设置参数
  33. def getParamDict(self, newRule = True):
  34. paramDict = {}
  35. if newRule:#新规则2023年4月20日
  36. paramDict['芯片主版本'] = (('HX02', 2), ('HX03', 3))#4位
  37. paramDict['芯片次版本'] = (('第1版(A)', 1), ('第2版(B)', 2), ('第3版(C)', 3), ('第4版(D)', 4), ('第5版(E)', 5))#4位
  38. paramDict['数字电容容值'] = (('无电容', 0), ('1uF', 1), ('4.7uF', 2), ('10uF', 3), ('22uF', 4), ('33uF', 5), ('47uF', 6), ('68uF', 7), ('100uF', 8))#4位
  39. # 2022年9月28日由3位扩展到5位
  40. paramDict['数字电容品牌'] = (('试验品牌', 0), ('AVX', 1), ('Vishay', 2), ('Sunlord', 3), ('火炬', 4), ('湘江', 5), ('振华', 6), ('丰华', 7), ('国巨', 8))
  41. paramDict['电容耐压'] = (('16V', 0), ('20V', 1), ('25V', 2))#3位
  42. paramDict['起爆电容容值'] = (('无电容', 0), ('33uF', 1), ('47uF', 2), ('68uF', 3), ('100uF', 4), ('220uF', 5))#3位
  43. paramDict['起爆电容品牌'] = (('试验品牌', 0), ('AVX', 1), ('Vishay', 2), ('Sunlord', 3))#3位
  44. paramDict['引火件形式'] = (('无', 0), ('焊接刚性药头', 1), ('贴片刚性药头', 2), ('贴片发热电阻', 3), ('碗状电阻器', 4))#3位
  45. paramDict['桥丝规格'] = (('16um(7.9~8.6欧)', 0), ('2欧姆', 1))#5位
  46. paramDict['脚线焊接方式'] = (('无孔焊接', 0), ('有孔焊接', 1), ('铭威铆接', 2), ('创德铆接', 3))#4位
  47. paramDict['PCB供应商'] = (('丰达兴', 0), ('闽威', 1))
  48. else:#旧规则
  49. paramDict['芯片主版本'] = (('HX02', 2), ('HX03', 3)) # 4位
  50. paramDict['芯片次版本'] = (('第1版(A)', 1), ('第2版(B)', 2), ('第3版(C)', 3), ('第4版(D)', 4), ('第5版(E)', 5)) # 4位
  51. paramDict['数字电容容值'] = (
  52. ('无电容', 0), ('1uF', 1), ('4.7uF', 2), ('10uF', 3), ('22uF', 4), ('33uF', 5), ('47uF', 6), ('68uF', 7),
  53. ('100uF', 8)) # 4位
  54. # 2022年9月28日由3位扩展到5位
  55. paramDict['数字电容品牌'] = (
  56. ('AVX', 1), ('Vishay', 2), ('Sunlord', 3), ('火炬', 4), ('湘江', 5), ('振华', 6), ('丰华', 7), ('国巨', 8))
  57. paramDict['数字电容耐压'] = (('16V', 0), ('20V', 1), ('25V', 2)) # 3位
  58. paramDict['起爆电容容值'] = (('无电容', 0), ('33uF', 1), ('47uF', 2), ('68uF', 3), ('100uF', 4)) # 3位
  59. paramDict['起爆电容品牌'] = (('AVX', 1), ('Vishay', 2), ('Sunlord', 3)) # 3位
  60. paramDict['起爆电容耐压'] = (('16V', 0), ('20V', 1), ('25V', 2)) # 3位
  61. paramDict['引火件形式'] = (('无', 0), ('焊接刚性药头', 1), ('贴片刚性药头', 2), ('贴片发热电阻', 3), ('碗状电阻器', 4)) # 3位
  62. paramDict['桥丝规格'] = (('16um(7.9~8.6欧)', 0), ('2欧姆', 1)) # 5位
  63. paramDict['脚线焊接方式'] = (('焊接(有孔)', 1), ('铆接', 2), ('焊接(无孔)', 3)) # 4位
  64. return paramDict
  65. # 初始化:
  66. def widgetInit(self):
  67. paramDict = self.getParamDict(True)
  68. for item in paramDict['芯片主版本']:
  69. self.ui.chipVer_1.addItem(item[0])
  70. for item in paramDict['芯片次版本']:
  71. self.ui.chipVer_2.addItem(item[0])
  72. for item in paramDict['数字电容容值']:
  73. self.ui.workCapValue.addItem(item[0])
  74. for item in paramDict['数字电容品牌']:
  75. self.ui.workCapVender.addItem(item[0])
  76. for item in paramDict['起爆电容容值']:
  77. self.ui.blastCapValue.addItem(item[0])
  78. for item in paramDict['起爆电容品牌']:
  79. self.ui.blastCapVender.addItem(item[0])
  80. for item in paramDict['电容耐压']:
  81. self.ui.capVoltage.addItem(item[0])
  82. for item in paramDict['引火件形式']:
  83. self.ui.bridgeType.addItem(item[0])
  84. for item in paramDict['桥丝规格']:
  85. self.ui.bridgeValue.addItem(item[0])
  86. for item in paramDict['PCB供应商']:
  87. self.ui.pcbVender.addItem(item[0])
  88. for item in range(32):
  89. self.ui.pcbVer.addItem(str(item).zfill(2))#5位
  90. for item in paramDict['脚线焊接方式']:
  91. self.ui.lineType.addItem(item[0])
  92. self.setDefault()
  93. self.updateStatus()
  94. self.ui.chipVer_1.activated.connect(self.updateStatus)
  95. self.ui.chipVer_2.activated.connect(self.updateStatus)
  96. self.ui.workCapValue.activated.connect(self.updateStatus)
  97. self.ui.workCapVender.activated.connect(self.updateStatus)
  98. self.ui.blastCapValue.activated.connect(self.updateStatus)
  99. self.ui.blastCapVender.activated.connect(self.updateStatus)
  100. self.ui.capVoltage.activated.connect(self.updateStatus)
  101. self.ui.bridgeType.activated.connect(self.updateStatus)
  102. self.ui.bridgeValue.activated.connect(self.updateStatus)
  103. self.ui.pcbVender.activated.connect(self.updateStatus)
  104. self.ui.pcbVer.activated.connect(self.updateStatus)
  105. self.ui.lineType.activated.connect(self.updateStatus)
  106. self.ui.productDate.dateChanged.connect(self.updateStatus)
  107. # self.ui.copy.clicked.connect(self.copySolf)
  108. self.ui.commit.clicked.connect(self.open_ScanInput)
  109. # self.ui.read.clicked.connect(self.readSolf
  110. # self.ui.write.clicked.connect(self.writeSolf)
  111. # self.ui.analyst.clicked.connect(self.analystSolf).
  112. # 打开窗口
  113. def open_ScanInput(self):
  114. versionCode= self.ui.versionCode.text()
  115. productDate = self.ui.productDate.text()
  116. from ScanUtils.ScanInput import ScanInput
  117. self.ScanInput_ui = ScanInput(versionCode,productDate)
  118. #self.ScanInput_ui.ui.versionCode.setText(versionCode)
  119. # self.ScanInput_ui.ui.Deliverydate.setText(productDate)
  120. self.ScanInput_ui.show()
  121. def setDefault(self):
  122. self.ui.workCapValue.setCurrentIndex(4)#默认22uF
  123. self.ui.workCapVender.setCurrentIndex(6)#默认振华
  124. self.ui.blastCapValue.setCurrentIndex(1)#默认33uF
  125. self.ui.blastCapVender.setCurrentIndex(2)#默认Vishay
  126. self.ui.chipVer_1.setCurrentIndex(1)
  127. self.ui.chipVer_2.setCurrentIndex(4)
  128. self.ui.bridgeType.setCurrentIndex(4)
  129. self.ui.lineType.setCurrentIndex(0)
  130. self.ui.productDate.setDate(QDate.currentDate())
  131. def paramStr2Value(self, content, paramList):
  132. for item in paramList:
  133. if content == item[0]:
  134. return item[1]
  135. return None
  136. def paramValue2Str(self, value, paramList):
  137. for item in paramList:
  138. if value == item[1]:
  139. return item[0]
  140. return None
  141. # 版本号
  142. def getCurrentParam(self):
  143. paramDict = self.getParamDict(True)
  144. chipVer_1 = self.paramStr2Value(self.ui.chipVer_1.currentText(), paramDict['芯片主版本'])
  145. chipVer_2 = self.paramStr2Value(self.ui.chipVer_2.currentText(), paramDict['芯片次版本'])
  146. workCapVender = self.paramStr2Value(self.ui.workCapVender.currentText(), paramDict['数字电容品牌'])
  147. workCapValue = self.paramStr2Value(self.ui.workCapValue.currentText(), paramDict['数字电容容值'])
  148. blastCapVender = self.paramStr2Value(self.ui.blastCapVender.currentText(), paramDict['起爆电容品牌'])
  149. blastCapValue = self.paramStr2Value(self.ui.blastCapValue.currentText(), paramDict['起爆电容容值'])
  150. capVoltage = self.paramStr2Value(self.ui.capVoltage.currentText(), paramDict['电容耐压'])
  151. bridgeType = self.paramStr2Value(self.ui.bridgeType.currentText(), paramDict['引火件形式'])
  152. bridgeValue = self.paramStr2Value(self.ui.bridgeValue.currentText(), paramDict['桥丝规格'])
  153. pcbVender = self.paramStr2Value(self.ui.pcbVender.currentText(), paramDict['PCB供应商'])
  154. pcbVer = int(self.ui.pcbVer.currentText())
  155. lineType = self.paramStr2Value(self.ui.lineType.currentText(), paramDict['脚线焊接方式'])
  156. productDate = self.ui.productDate.date()#发料日期
  157. U64Value = chipVer_1 & 0x0F #芯片主版本号共4位,bit0-3
  158. U64Value |= (chipVer_2 & 0x0F) << 4#芯片次版本号共4位,bit4-7
  159. U64Value |= (workCapVender & 0x1F) << 8 #数字电容品牌共5位 ,bit8-12
  160. U64Value |= (workCapValue & 0x0F) << 13 #数字电容容量共4位 ,bit13-16
  161. U64Value |= (blastCapVender & 0x07) << 17 #起爆电容品牌共3位 ,bit17-19
  162. U64Value |= (blastCapValue & 0x07) << 20 #起爆电容容量共3位 ,bit20-22
  163. U64Value |= (capVoltage & 0x07) << 23 #电容耐压共3位 ,bit23-25
  164. U64Value |= (bridgeType & 0x07) << 26 #引火件形式共3位 ,bit26-28
  165. U64Value |= (bridgeValue & 0x1F) << 29 #桥丝规格共5位 ,bit29-33
  166. U64Value |= (pcbVer & 0x1F) << 34 #PCB版本流水号共5位 ,bit34-38
  167. U64Value |= (pcbVender & 0x03) << 39 #PCB供应商共2位 ,bit39-40
  168. U64Value |= (lineType & 0x07) << 41 #脚线焊接方式共3位 ,bit41-43
  169. U64Value |= (((productDate.year()-2020)*12 + (productDate.month()-1)) & 0x7F) << 44 # 发料日期中的年月共7位 ,bit44-50
  170. U64Value |= (productDate.day() & 0x1F) << 51 # 发料日期中的日共5位 ,bit51-55
  171. # print(hex(U64Value))
  172. Bytes_0 = U64Value & 0xFF
  173. Bytes_1 = (U64Value >> 8) & 0xFF
  174. Bytes_2 = (U64Value >> 16) & 0xFF
  175. Bytes_3 = (U64Value >> 24) & 0xFF
  176. Bytes_4 = (U64Value >> 32) & 0xFF
  177. Bytes_5 = (U64Value >> 40) & 0xFF
  178. Bytes_6 = (U64Value >> 48) & 0xFF
  179. hexStr = '%02X%02X%02X%02X%02X%02X%02X' % (Bytes_0, Bytes_1, Bytes_2, Bytes_3, Bytes_4, Bytes_5, Bytes_6)
  180. hexStr += '%02X' % ((~CRC8.getCrc8(bytearray.fromhex(hexStr))) & 0xFF)
  181. return hexStr
  182. def updateStatus(self, param= None):
  183. status = True
  184. if self.ui.workCapValue.currentText() == "无电容":
  185. status = False
  186. self.ui.workCapVender.setEnabled(status)
  187. status = True
  188. if self.ui.blastCapValue.currentText() == "无电容":
  189. status = False
  190. self.ui.blastCapVender.setEnabled(status)
  191. self.ui.versionCode.setText(self.getCurrentParam())
  192. def showVersion(self, hexStr):
  193. if len(hexStr) == 16 and hexStr[12:14] == "00":
  194. self.showVersionForOldRule(hexStr)
  195. else:
  196. self.showVersionForNewRule(hexStr)
  197. def showVersionForOldRule(self, hexStr):
  198. result, infos = self.getVersionInfosForOldRule(hexStr)
  199. if not result:
  200. QMessageBox.critical(self, '错误', '{0}'.format(infos))
  201. return
  202. contents = []
  203. key = '延期模块版本代码'
  204. contents.append("{0}:{1}".format(key, infos[key]))
  205. key = '芯片主版本'
  206. contents.append("\n{0}:{1}".format(key, infos[key]))
  207. key = '芯片次版本'
  208. contents.append("{0}:{1}".format(key, infos[key]))
  209. key = '数字电容品牌'
  210. contents.append("\n{0}:{1}".format(key, infos[key]))
  211. key = '数字电容容值'
  212. contents.append("{0}:{1}".format(key, infos[key]))
  213. key = '数字电容耐压'
  214. contents.append("{0}:{1}".format(key, infos[key]))
  215. key = '起爆电容品牌'
  216. contents.append("\n{0}:{1}".format(key, infos[key]))
  217. key = '起爆电容容值'
  218. contents.append("{0}:{1}".format(key, infos[key]))
  219. key = '起爆电容耐压'
  220. contents.append("{0}:{1}".format(key, infos[key]))
  221. key = '引火件形式'
  222. contents.append("\n{0}:{1}".format(key, infos[key]))
  223. key = '桥丝规格'
  224. contents.append("{0}:{1}".format(key, infos[key]))
  225. key = 'PCB版本流水号'
  226. contents.append("\n{0}:{1}".format(key, infos[key]))
  227. key = '脚线焊接方式'
  228. contents.append("{0}:{1}".format(key, infos[key]))
  229. QMessageBox.information(self, '信息(旧规则)', '\n'.join(contents))
  230. def getVersionInfosForOldRule(self, versionHexStr):
  231. if not versionHexStr or len(versionHexStr) != 16:
  232. return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
  233. try:
  234. verBytes = bytearray.fromhex(versionHexStr)
  235. except Exception as e:
  236. return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
  237. crc8 = (~CRC8.getCrc8(verBytes[:-1])) & 0xFF
  238. if crc8 != verBytes[-1]:
  239. return False, '{0}\n校验值错误'.format(versionHexStr)
  240. U64Value = 0
  241. U64Value |= verBytes[6]&0xFF
  242. U64Value <<= 8
  243. U64Value |= verBytes[5]&0xFF
  244. U64Value <<= 8
  245. U64Value |= verBytes[4]&0xFF
  246. U64Value <<= 8
  247. U64Value |= verBytes[3]&0xFF
  248. U64Value <<= 8
  249. U64Value |= verBytes[2]&0xFF
  250. U64Value <<= 8
  251. U64Value |= verBytes[1]&0xFF
  252. U64Value <<= 8
  253. U64Value |= verBytes[0]&0xFF
  254. paramDict = self.getParamDict(False)
  255. infos = {}
  256. infos['延期模块版本代码'] = versionHexStr
  257. key = '芯片主版本'
  258. value = U64Value & 0x0F
  259. chipVer_1 = self.paramValue2Str(value, paramDict[key])
  260. if chipVer_1 == None:
  261. chipVer_1 = '未知({0})'.format(value)
  262. infos[key] = chipVer_1
  263. key = '芯片次版本'
  264. value = (U64Value >> 4) & 0x0F
  265. chipVer_2 = self.paramValue2Str(value, paramDict[key])
  266. if chipVer_2 == None:
  267. chipVer_2 = '未知({0})'.format(value)
  268. infos[key] = chipVer_2
  269. key = '数字电容品牌'
  270. value = (((U64Value >> 46) & 0x03)<<3) + ((U64Value >> 8) & 0x07)#2022年9月28日由3位扩展到5位
  271. workCapVender = self.paramValue2Str(value, paramDict[key])
  272. if workCapVender == None:
  273. workCapVender = '未知({0})'.format(value)
  274. infos[key] = workCapVender
  275. key = '数字电容容值'
  276. value = (U64Value >> 11) & 0x0F
  277. workCapValue = self.paramValue2Str(value, paramDict[key])
  278. if workCapValue == None:
  279. workCapValue = '未知({0})'.format(value)
  280. infos[key] = workCapValue
  281. key = '数字电容耐压'
  282. value = (U64Value >> 15) & 0x07
  283. workCapVoltage = self.paramValue2Str(value, paramDict[key])
  284. if workCapVoltage == None:
  285. workCapVoltage = '未知({0})'.format(value)
  286. infos[key] = workCapVoltage
  287. key = '起爆电容品牌'
  288. value = (U64Value >> 18) & 0x07
  289. blastVender = self.paramValue2Str(value, paramDict[key])
  290. if blastVender == None:
  291. blastVender = '未知({0})'.format(value)
  292. infos[key] = blastVender
  293. key = '起爆电容容值'
  294. value = (U64Value >> 21) & 0x07
  295. blastCapValue = self.paramValue2Str(value, paramDict[key])
  296. if blastCapValue == None:
  297. blastCapValue = '未知({0})'.format(value)
  298. infos[key] = blastCapValue
  299. key = '起爆电容耐压'
  300. value = (U64Value >> 24) & 0x07
  301. blastCapVoltage = self.paramValue2Str(value, paramDict[key])
  302. if blastCapVoltage == None:
  303. blastCapVoltage = '未知({0})'.format(value)
  304. infos[key] = blastCapVoltage
  305. key = '引火件形式'
  306. value = (U64Value >> 27) & 0x07
  307. bridgeType = self.paramValue2Str(value, paramDict[key])
  308. if bridgeType == None:
  309. bridgeType = '未知({0})'.format(value)
  310. infos[key] = bridgeType
  311. key = '桥丝规格'
  312. value = (U64Value >> 30) & 0x1F
  313. bridgeValue = self.paramValue2Str(value, paramDict[key])
  314. if bridgeValue == None:
  315. bridgeValue = '未知({0})'.format(value)
  316. infos[key] = bridgeValue
  317. infos['PCB版本流水号'] = str((U64Value >> 35) & 0x7F).zfill(2)
  318. key = '脚线焊接方式'
  319. value = (U64Value >> 42) & 0x0F
  320. lineType = self.paramValue2Str(value, paramDict[key])
  321. if lineType == None:
  322. lineType = '未知({0})'.format(value)
  323. infos[key] = lineType
  324. return True, infos
  325. def showVersionForNewRule(self, hexStr):
  326. result, infos = self.getVersionInfosForNewRule(hexStr)
  327. if not result:
  328. QMessageBox.critical(self, '错误', '{0}'.format(infos))
  329. return
  330. contents = []
  331. key = '延期模块版本代码'
  332. contents.append("{0}:{1}".format(key, infos[key]))
  333. key = '芯片主版本'
  334. contents.append("\n{0}:{1}".format(key, infos[key]))
  335. key = '芯片次版本'
  336. contents.append("{0}:{1}".format(key, infos[key]))
  337. key = '数字电容品牌'
  338. contents.append("\n{0}:{1}".format(key, infos[key]))
  339. key = '数字电容容值'
  340. contents.append("{0}:{1}".format(key, infos[key]))
  341. key = '起爆电容品牌'
  342. contents.append("\n{0}:{1}".format(key, infos[key]))
  343. key = '起爆电容容值'
  344. contents.append("{0}:{1}".format(key, infos[key]))
  345. key = '电容耐压'
  346. contents.append("\n{0}:{1}".format(key, infos[key]))
  347. key = '引火件形式'
  348. contents.append("\n{0}:{1}".format(key, infos[key]))
  349. key = '桥丝规格'
  350. contents.append("{0}:{1}".format(key, infos[key]))
  351. key = 'PCB供应商'
  352. contents.append("\n{0}:{1}".format(key, infos[key]))
  353. key = 'PCB版本流水号'
  354. contents.append("{0}:{1}".format(key, infos[key]))
  355. key = '脚线焊接方式'
  356. contents.append("{0}:{1}".format(key, infos[key]))
  357. key = '发料日期'
  358. contents.append("\n{0}:{1}".format(key, infos[key]))
  359. QMessageBox.information(self, '信息', '\n'.join(contents))
  360. def getVersionInfosForNewRule(self, versionHexStr):
  361. if not versionHexStr or len(versionHexStr) != 16:
  362. return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
  363. try:
  364. verBytes = bytearray.fromhex(versionHexStr)
  365. except Exception as e:
  366. return False, '{0}\n请输入16位16进制数'.format(versionHexStr)
  367. crc8 = (~CRC8.getCrc8(verBytes[:-1])) & 0xFF
  368. if crc8 != verBytes[-1]:
  369. return False, '{0}\n校验值错误'.format(versionHexStr)
  370. U64Value = 0
  371. U64Value |= verBytes[6]&0xFF
  372. U64Value <<= 8
  373. U64Value |= verBytes[5]&0xFF
  374. U64Value <<= 8
  375. U64Value |= verBytes[4]&0xFF
  376. U64Value <<= 8
  377. U64Value |= verBytes[3]&0xFF
  378. U64Value <<= 8
  379. U64Value |= verBytes[2]&0xFF
  380. U64Value <<= 8
  381. U64Value |= verBytes[1]&0xFF
  382. U64Value <<= 8
  383. U64Value |= verBytes[0]&0xFF
  384. infos = {}
  385. infos['延期模块版本代码'] = versionHexStr
  386. paramDict = self.getParamDict(True)
  387. key = '芯片主版本'#芯片主版本号共4位,bit0-3
  388. value = U64Value & 0x0F
  389. chipVer_1 = self.paramValue2Str(value, paramDict[key])
  390. if chipVer_1 == None:
  391. chipVer_1 = '未知({0})'.format(value)
  392. infos[key] = chipVer_1
  393. key = '芯片次版本'#芯片次版本号共4位,bit4-7
  394. value = (U64Value >> 4) & 0x0F
  395. chipVer_2 = self.paramValue2Str(value, paramDict[key])
  396. if chipVer_2 == None:
  397. chipVer_2 = '未知({0})'.format(value)
  398. infos[key] = chipVer_2
  399. key = '数字电容品牌'#数字电容品牌共5位 ,bit8-12
  400. value = (U64Value >> 8) & 0x1F
  401. workCapVender = self.paramValue2Str(value, paramDict[key])
  402. if workCapVender == None:
  403. workCapVender = '未知({0})'.format(value)
  404. infos[key] = workCapVender
  405. key = '数字电容容值'#数字电容容量共4位 ,bit13-16
  406. value = (U64Value >> 13) & 0x0F
  407. workCapValue = self.paramValue2Str(value, paramDict[key])
  408. if workCapValue == None:
  409. workCapValue = '未知({0})'.format(value)
  410. infos[key] = workCapValue
  411. key = '起爆电容品牌'#起爆电容品牌共3位 ,bit17-19
  412. value = (U64Value >> 17) & 0x07
  413. blastVender = self.paramValue2Str(value, paramDict[key])
  414. if blastVender == None:
  415. blastVender = '未知({0})'.format(value)
  416. infos[key] = blastVender
  417. key = '起爆电容容值'#起爆电容容量共3位 ,bit20-22
  418. value = (U64Value >> 20) & 0x07
  419. blastCapValue = self.paramValue2Str(value, paramDict[key])
  420. if blastCapValue == None:
  421. blastCapValue = '未知({0})'.format(value)
  422. infos[key] = blastCapValue
  423. key = '电容耐压'#电容耐压共3位 ,bit23-25
  424. value = (U64Value >> 23) & 0x07
  425. blastCapVoltage = self.paramValue2Str(value, paramDict[key])
  426. if blastCapVoltage == None:
  427. blastCapVoltage = '未知({0})'.format(value)
  428. infos[key] = blastCapVoltage
  429. key = '引火件形式'#引火件形式共3位 ,bit26-28
  430. value = (U64Value >> 26) & 0x07
  431. bridgeType = self.paramValue2Str(value, paramDict[key])
  432. if bridgeType == None:
  433. bridgeType = '未知({0})'.format(value)
  434. infos[key] = bridgeType
  435. key = '桥丝规格'#桥丝规格共5位 ,bit29-33
  436. value = (U64Value >> 29) & 0x1F
  437. bridgeValue = self.paramValue2Str(value, paramDict[key])
  438. if bridgeValue == None:
  439. bridgeValue = '未知({0})'.format(value)
  440. infos[key] = bridgeValue
  441. infos['PCB版本流水号'] = str((U64Value >> 34) & 0x1F).zfill(2)#PCB版本流水号共5位 ,bit34-38
  442. key = 'PCB供应商'# PCB供应商共2位 ,bit39-40
  443. value = (U64Value >> 39) & 0x03
  444. bridgeValue = self.paramValue2Str(value, paramDict[key])
  445. if bridgeValue == None:
  446. bridgeValue = '未知({0})'.format(value)
  447. infos[key] = bridgeValue
  448. key = '脚线焊接方式'#脚线焊接方式共3位 ,bit41-43
  449. value = (U64Value >> 41) & 0x07
  450. lineType = self.paramValue2Str(value, paramDict[key])
  451. if lineType == None:
  452. lineType = '未知({0})'.format(value)
  453. infos[key] = lineType
  454. # 发料日期中的年月共7位 ,bit44-50
  455. # 发料日期中的日共5位 ,bit51-55
  456. yearAndMonth = (U64Value >> 44) & 0x7F
  457. yaer = yearAndMonth//12
  458. month = 1+ (yearAndMonth%12)
  459. day = (U64Value >> 51) & 0x1F
  460. infos['发料日期'] = "%04d年%d月%d日"%(2020+yaer, month, day)
  461. return True, infos
  462. def closeEvent(self, QCloseEvent):
  463. if self.closeToDlg != None:
  464. self.closeToDlg.show()
  465. if __name__ == '__main__':
  466. import sys
  467. app = QApplication(sys.argv)
  468. ui = VersionSet()
  469. ui.show()
  470. sys.exit(app.exec_())