download.py 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from ui.own.frame_theme import MyFrame
  4. from utils.qt import QtWidgets, QtCore, Qt, QtGui
  5. class Download(MyFrame):
  6. def setupUi(self, Download):
  7. self.reg = QtCore.QRegExp('^[a-zA-Z0-9_-]{16,16}$')
  8. self.validator = QtGui.QRegExpValidator(self)
  9. self.validator.setRegExp(self.reg)
  10. self.download = MyFrame(Download)
  11. self.download_layout = QtWidgets.QHBoxLayout(self.download)
  12. self.download_layout.setContentsMargins(0, 0, 0, 0)
  13. self.download_layout.setSpacing(0)
  14. self.message = QtWidgets.QWidget()
  15. self.message_layout = QtWidgets.QVBoxLayout(self.message)
  16. self.message_layout.setContentsMargins(0, 0, 0, 0)
  17. self.message_layout.setSpacing(0)
  18. self.message_widget = QtWidgets.QGroupBox("追溯信息")
  19. self.message_box_layout = QtWidgets.QVBoxLayout(self.message_widget)
  20. self.message_table = QtWidgets.QTableWidget(self.message_widget)
  21. self.message_table.setColumnCount(3)
  22. self.message_table.setShowGrid(True)
  23. self.message_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
  24. self.message_table.verticalHeader().setVisible(False)
  25. self.message_table.verticalHeader().setHighlightSections(True)
  26. self.message_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  27. self.message_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  28. self.message_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
  29. # self.message_table.horizontalHeader().setDefaultAlignment(Qt.AlignmentFlag.AlignCenter)
  30. self.message_table.setHorizontalHeaderLabels(["序号", "参数名称", "值"])
  31. self.message_table.setRowCount(6)
  32. item = QtWidgets.QTableWidgetItem("1")
  33. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  34. self.message_table.setItem(0, 0, item)
  35. item = QtWidgets.QTableWidgetItem("Bootloader软件版本")
  36. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  37. self.message_table.setItem(0, 1, item)
  38. item = QtWidgets.QTableWidgetItem("")
  39. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  40. self.message_table.setItem(0, 2, item)
  41. item = QtWidgets.QTableWidgetItem("2")
  42. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  43. self.message_table.setItem(1, 0, item)
  44. item = QtWidgets.QTableWidgetItem("应用程序软件版本号")
  45. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  46. self.message_table.setItem(1, 1, item)
  47. item = QtWidgets.QTableWidgetItem("")
  48. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  49. self.message_table.setItem(1, 2, item)
  50. item = QtWidgets.QTableWidgetItem("3")
  51. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  52. self.message_table.setItem(2, 0, item)
  53. item = QtWidgets.QTableWidgetItem("算法软件版本号")
  54. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  55. self.message_table.setItem(2, 1, item)
  56. item = QtWidgets.QTableWidgetItem("")
  57. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  58. self.message_table.setItem(2, 2, item)
  59. item = QtWidgets.QTableWidgetItem("4")
  60. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  61. self.message_table.setItem(3, 0, item)
  62. item = QtWidgets.QTableWidgetItem("硬件版本号")
  63. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  64. self.message_table.setItem(3, 1, item)
  65. item = QtWidgets.QTableWidgetItem("")
  66. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  67. self.message_table.setItem(3, 2, item)
  68. item = QtWidgets.QTableWidgetItem("5")
  69. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  70. self.message_table.setItem(4, 0, item)
  71. item = QtWidgets.QTableWidgetItem("BMS序列号")
  72. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  73. self.message_table.setItem(4, 1, item)
  74. item = QtWidgets.QTableWidgetItem("")
  75. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  76. self.message_table.setItem(4, 2, item)
  77. item = QtWidgets.QTableWidgetItem("6")
  78. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  79. self.message_table.setItem(5, 0, item)
  80. item = QtWidgets.QTableWidgetItem("电池编码")
  81. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  82. self.message_table.setItem(5, 1, item)
  83. item = QtWidgets.QTableWidgetItem("")
  84. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  85. self.message_table.setItem(5, 2, item)
  86. self.message_box_layout.addWidget(self.message_table)
  87. self.btn_read_version = QtWidgets.QPushButton("读取版本信息")
  88. self.message_box_layout.addWidget(self.btn_read_version)
  89. self.message_layout.addWidget(self.message_widget)
  90. # spacerItem3 = QtWidgets.QSpacerItem(40, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
  91. # self.message_layout.addItem(spacerItem3)
  92. self.second_widget = MyFrame()
  93. self.second_widget_layout = QtWidgets.QGridLayout(self.second_widget)
  94. self.lb_sblx = QtWidgets.QLabel("设备类型")
  95. self.second_widget_layout.addWidget(self.lb_sblx, 0, 0, 1, 1)
  96. self.cb_sblx = QtWidgets.QComboBox()
  97. self.cb_sblx.addItem("总控(BAU)")
  98. self.cb_sblx.addItem("主控(BCU)")
  99. self.cb_sblx.addItem("从控(CMU)")
  100. self.second_widget_layout.addWidget(self.cb_sblx, 0, 1, 1, 1)
  101. self.lb_bau = QtWidgets.QLabel("BAU")
  102. self.second_widget_layout.addWidget(self.lb_bau, 1, 0, 1, 1)
  103. self.cb_bau = QtWidgets.QComboBox()
  104. self.second_widget_layout.addWidget(self.cb_bau, 1, 1, 1, 1)
  105. self.lb_bcu = QtWidgets.QLabel("BCU")
  106. self.second_widget_layout.addWidget(self.lb_bcu, 2, 0, 1, 1)
  107. self.cb_bcu = QtWidgets.QComboBox()
  108. self.second_widget_layout.addWidget(self.cb_bcu, 2, 1, 1, 1)
  109. self.lb_cmu = QtWidgets.QLabel("CMU")
  110. self.second_widget_layout.addWidget(self.lb_cmu, 3, 0, 1, 1)
  111. self.cb_cmu = QtWidgets.QComboBox()
  112. self.second_widget_layout.addWidget(self.cb_cmu, 3, 1, 1, 1)
  113. self.message_layout.addWidget(self.second_widget)
  114. # spacerItem2 = QtWidgets.QSpacerItem(40, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
  115. # self.message_layout.addItem(spacerItem2)
  116. self.third_widget = MyFrame()
  117. self.third_widget_layout = QtWidgets.QGridLayout(self.third_widget)
  118. self.lb_cxwj = QtWidgets.QLabel("程序文件:")
  119. self.third_widget_layout.addWidget(self.lb_cxwj, 0, 0, 1, 1)
  120. self.edt_filename = QtWidgets.QLineEdit()
  121. self.edt_filename.setReadOnly(True)
  122. self.third_widget_layout.addWidget(self.edt_filename, 0, 1, 1, 3)
  123. self.btn_chose = QtWidgets.QPushButton("选择...")
  124. self.third_widget_layout.addWidget(self.btn_chose, 0, 4, 1, 1)
  125. self.btn_start_up = QtWidgets.QPushButton("开始升级")
  126. self.third_widget_layout.addWidget(self.btn_start_up, 1, 0, 1, 1)
  127. self.btn_stop_up = QtWidgets.QPushButton("中止")
  128. self.third_widget_layout.addWidget(self.btn_stop_up, 1, 2, 1, 1)
  129. self.btn_restart_up = QtWidgets.QPushButton("复位强制升级")
  130. self.third_widget_layout.addWidget(self.btn_restart_up, 1, 4, 1, 1)
  131. self.message_layout.addWidget(self.third_widget)
  132. self.message_layout.addStretch()
  133. self.download_layout.addWidget(self.message, 1)
  134. self.right_widget = QtWidgets.QWidget()
  135. self.right_widget_layout = QtWidgets.QVBoxLayout(self.right_widget)
  136. self.first_frame = MyFrame(self.right_widget)
  137. self.first_frame_layout = QtWidgets.QGridLayout(self.first_frame)
  138. self.lb_bms_sn = QtWidgets.QLabel("BMS序列号")
  139. self.first_frame_layout.addWidget(self.lb_bms_sn, 0, 0, 1, 1)
  140. self.btn_bms_sn = QtWidgets.QPushButton("录入")
  141. self.first_frame_layout.addWidget(self.btn_bms_sn, 1, 0, 1, 1)
  142. self.edt_bms_sn = QtWidgets.QLineEdit(self.first_frame)
  143. self.edt_bms_sn.setValidator(self.validator)
  144. self.first_frame_layout.addWidget(self.edt_bms_sn, 0, 1, 2, 4)
  145. self.right_widget_layout.addWidget(self.first_frame)
  146. self.second_frame = MyFrame(self.right_widget)
  147. self.second_frame_layout = QtWidgets.QGridLayout(self.second_frame)
  148. self.lb_battery_sn = QtWidgets.QLabel("电池编码")
  149. self.second_frame_layout.addWidget(self.lb_battery_sn, 0, 0, 1, 1)
  150. self.btn_battery_sn = QtWidgets.QPushButton("录入")
  151. self.second_frame_layout.addWidget(self.btn_battery_sn, 1, 0, 1, 1)
  152. self.edt_battery_sn = QtWidgets.QLineEdit(self.first_frame)
  153. self.edt_battery_sn.setValidator(self.validator)
  154. self.second_frame_layout.addWidget(self.edt_battery_sn, 0, 1, 2, 4)
  155. self.right_widget_layout.addWidget(self.second_frame)
  156. spacerItem1 = QtWidgets.QSpacerItem(40, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
  157. self.right_widget_layout.addItem(spacerItem1)
  158. self.download_layout.addWidget(self.right_widget, 1)
  159. QtCore.QMetaObject.connectSlotsByName(Download)