hard.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from ui.own.frame_theme import MyFrame
  4. from ui.own.palette_theme import set_edt_bg
  5. from utils.qt import QtWidgets, QtCore, Qt, QColor, QtGui
  6. class Hard(MyFrame):
  7. def setupUi(self, Hard):
  8. self.reg = QtCore.QRegExp('^[\-\+]?\d+(\.\d)?$')
  9. self.validator = QtGui.QRegExpValidator(self)
  10. self.validator.setRegExp(self.reg)
  11. self.reg = QtCore.QRegExp('^[\-\+]?\d+(\.\d\d\d)?$')
  12. self.validator_1 = QtGui.QRegExpValidator(self)
  13. self.validator_1.setRegExp(self.reg)
  14. self.reg = QtCore.QRegExp('^[1-9]\d*$')
  15. self.validator_2 = QtGui.QRegExpValidator(self)
  16. self.validator_2.setRegExp(self.reg)
  17. self.hard = MyFrame(Hard)
  18. self.hard_layout = QtWidgets.QHBoxLayout(self.hard)
  19. # self.hard_layout.setContentsMargins(5, 5, 5, 5)
  20. self.hard_layout.setSpacing(0)
  21. self.hard_left_groupbox = QtWidgets.QGroupBox(self.hard)
  22. self.hard_left_groupbox.setTitle("单体电压校准")
  23. self.hard_left_groupbox_layout = QtWidgets.QVBoxLayout(self.hard_left_groupbox)
  24. self.hard_left_top_widget = QtWidgets.QWidget()
  25. self.hard_left_top_layout = QtWidgets.QHBoxLayout(self.hard_left_top_widget)
  26. self.lb_cj = QtWidgets.QLabel("从机编号选择:")
  27. self.hard_left_top_layout.addWidget(self.lb_cj)
  28. self.cb_bmu_index = QtWidgets.QComboBox()
  29. for i in range(15):
  30. self.cb_bmu_index.addItem(str(i + 1))
  31. self.hard_left_top_layout.addWidget(self.cb_bmu_index)
  32. self.hard_left_top_layout.addStretch()
  33. self.hard_left_groupbox_layout.addWidget(self.hard_left_top_widget)
  34. self.hard_table = QtWidgets.QTableWidget(self.hard_left_groupbox)
  35. self.hard_table.setColumnCount(6)
  36. self.hard_table.verticalHeader().setVisible(False)
  37. self.hard_table.verticalHeader().setHighlightSections(True)
  38. self.hard_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  39. self.hard_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  40. self.hard_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
  41. self.hard_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
  42. # 设置只能选择行
  43. self.hard_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  44. self.hard_table.setHorizontalHeaderLabels(["序号", "参数名称", "电池真实值", "BMS上传值", "误差", "单位"])
  45. self.hard_table.setRowCount(72)
  46. for i in range(72):
  47. item = QtWidgets.QTableWidgetItem(str(i + 1))
  48. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  49. self.hard_table.setItem(i, 0, item)
  50. item = QtWidgets.QTableWidgetItem("mV")
  51. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  52. self.hard_table.setItem(i, 5, item)
  53. item = QtWidgets.QTableWidgetItem("C" + str(i + 1) + "单体电压")
  54. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  55. self.hard_table.setItem(i, 1, item)
  56. item = QtWidgets.QLineEdit()
  57. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  58. item.setValidator(self.validator_2)
  59. self.hard_table.setCellWidget(i, 2, item)
  60. item = QtWidgets.QTableWidgetItem("")
  61. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  62. self.hard_table.setItem(i, 3, item)
  63. item = QtWidgets.QTableWidgetItem("")
  64. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  65. self.hard_table.setItem(i, 4, item)
  66. # self.hard_table.item(0, 3).setText("2200")
  67. # self.hard_table.item(4, 3).setText("2200")
  68. # self.hard_table.item(8, 3).setText("2200")
  69. self.hard_left_groupbox_layout.addWidget(self.hard_table)
  70. self.set_widget = QtWidgets.QWidget()
  71. self.set_widget_layout = QtWidgets.QGridLayout(self.set_widget)
  72. self.lb_wctj = QtWidgets.QLabel("误差统计:最大值")
  73. self.set_widget_layout.addWidget(self.lb_wctj, 0, 0, 1, 2)
  74. self.edt_max = QtWidgets.QLineEdit(self.set_widget)
  75. self.edt_max.setText("0")
  76. self.edt_max.setAlignment(Qt.AlignCenter)
  77. self.edt_max.setReadOnly(True)
  78. set_edt_bg(self.edt_max, QColor(Qt.gray))
  79. self.set_widget_layout.addWidget(self.edt_max, 0, 2, 1, 1)
  80. self.lb_zxz = QtWidgets.QLabel("mV 最小值")
  81. self.set_widget_layout.addWidget(self.lb_zxz, 0, 3, 1, 1)
  82. self.edt_min = QtWidgets.QLineEdit(self.set_widget)
  83. self.edt_min.setText("0")
  84. self.edt_min.setAlignment(Qt.AlignCenter)
  85. self.edt_min.setReadOnly(True)
  86. set_edt_bg(self.edt_min, QColor(Qt.gray))
  87. self.set_widget_layout.addWidget(self.edt_min, 0, 4, 1, 1)
  88. self.lb_jz = QtWidgets.QLabel("mV 均值")
  89. self.set_widget_layout.addWidget(self.lb_jz, 0, 5, 1, 1)
  90. self.edt_avg = QtWidgets.QLineEdit(self.set_widget)
  91. self.edt_avg.setText("0")
  92. self.edt_avg.setAlignment(Qt.AlignCenter)
  93. self.edt_avg.setReadOnly(True)
  94. set_edt_bg(self.edt_avg, QColor(Qt.gray))
  95. self.set_widget_layout.addWidget(self.edt_avg, 0, 6, 1, 1)
  96. self.lb_bzz = QtWidgets.QLabel("mV 标准差")
  97. self.set_widget_layout.addWidget(self.lb_bzz, 0, 7, 1, 1)
  98. self.edt_bzc = QtWidgets.QLineEdit(self.set_widget)
  99. self.edt_bzc.setText("0")
  100. self.edt_bzc.setAlignment(Qt.AlignCenter)
  101. self.edt_bzc.setReadOnly(True)
  102. set_edt_bg(self.edt_bzc, QColor(Qt.gray))
  103. self.set_widget_layout.addWidget(self.edt_bzc, 0, 8, 1, 1)
  104. self.lb_dw = QtWidgets.QLabel("mV")
  105. self.set_widget_layout.addWidget(self.lb_dw, 0, 9, 1, 1)
  106. self.lb_dtjzz = QtWidgets.QLabel("单体校准值")
  107. self.set_widget_layout.addWidget(self.lb_dtjzz, 1, 0, 1, 1)
  108. self.edt_cell = QtWidgets.QLineEdit(self.set_widget)
  109. self.edt_cell.setText("0")
  110. self.edt_cell.setAlignment(Qt.AlignCenter)
  111. # self.edt_cell.setReadOnly(True)
  112. set_edt_bg(self.edt_cell, QColor(Qt.gray))
  113. self.set_widget_layout.addWidget(self.edt_cell, 1, 1, 1, 1)
  114. self.lb_dsw = QtWidgets.QLabel("mV")
  115. self.set_widget_layout.addWidget(self.lb_dsw, 1, 2, 1, 1)
  116. self.btn_hand = QtWidgets.QPushButton("单体校准")
  117. self.set_widget_layout.addWidget(self.btn_hand, 1, 4, 1, 2)
  118. self.btn_auto = QtWidgets.QPushButton("全部校准")
  119. self.set_widget_layout.addWidget(self.btn_auto, 1, 7, 1, 2)
  120. self.hard_left_groupbox_layout.addWidget(self.set_widget)
  121. self.hard_layout.addWidget(self.hard_left_groupbox, 1)
  122. self.hard_right_frame = MyFrame(self.hard)
  123. self.hard_right_frame_layout = QtWidgets.QVBoxLayout(self.hard_right_frame)
  124. self.rtc_groupbox = QtWidgets.QGroupBox("RTC时钟校准")
  125. self.rtc_groupbox_layout = QtWidgets.QHBoxLayout(self.rtc_groupbox)
  126. self.lb_rtc = QtWidgets.QLabel("RTC时钟")
  127. self.rtc_groupbox_layout.addWidget(self.lb_rtc)
  128. self.qline_rtc = QtWidgets.QLineEdit(self.rtc_groupbox)
  129. self.qline_rtc.setReadOnly(True)
  130. self.rtc_groupbox_layout.addWidget(self.qline_rtc)
  131. self.btn_rtc = QtWidgets.QPushButton("时钟校准")
  132. self.rtc_groupbox_layout.addWidget(self.btn_rtc)
  133. self.hard_right_frame_layout.addWidget(self.rtc_groupbox, 1)
  134. self.hard_right_cali_frame = MyFrame(self.hard_right_frame)
  135. self.hard_right_cali_frame_layout = QtWidgets.QHBoxLayout(self.hard_right_cali_frame)
  136. self.vol_groupbox = QtWidgets.QGroupBox("电压校准")
  137. self.vol_groupbox_layout = QtWidgets.QVBoxLayout(self.vol_groupbox)
  138. self.vol_table = QtWidgets.QTableWidget(self.vol_groupbox)
  139. self.vol_table.setColumnCount(4)
  140. self.vol_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
  141. self.vol_table.verticalHeader().setVisible(False)
  142. self.vol_table.verticalHeader().setHighlightSections(True)
  143. self.vol_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  144. self.vol_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  145. self.vol_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
  146. self.vol_table.setHorizontalHeaderLabels(["序号", "参数名称", "误差", "单位"])
  147. self.vol_table.setRowCount(3)
  148. item = QtWidgets.QTableWidgetItem("1")
  149. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  150. self.vol_table.setItem(0, 0, item)
  151. item = QtWidgets.QTableWidgetItem("总压")
  152. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  153. self.vol_table.setItem(0, 1, item)
  154. item = QtWidgets.QLineEdit()
  155. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  156. item.setValidator(self.validator)
  157. self.vol_table.setCellWidget(0, 2, item)
  158. item = QtWidgets.QTableWidgetItem("V")
  159. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  160. self.vol_table.setItem(0, 3, item)
  161. item = QtWidgets.QTableWidgetItem("2")
  162. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  163. self.vol_table.setItem(1, 0, item)
  164. item = QtWidgets.QTableWidgetItem("总压2")
  165. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  166. self.vol_table.setItem(1, 1, item)
  167. item = QtWidgets.QLineEdit()
  168. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  169. item.setValidator(self.validator)
  170. self.vol_table.setCellWidget(1, 2, item)
  171. item = QtWidgets.QTableWidgetItem("V")
  172. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  173. self.vol_table.setItem(1, 3, item)
  174. item = QtWidgets.QTableWidgetItem("3")
  175. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  176. self.vol_table.setItem(2, 0, item)
  177. item = QtWidgets.QTableWidgetItem("总压3")
  178. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  179. self.vol_table.setItem(2, 1, item)
  180. item = QtWidgets.QLineEdit()
  181. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  182. item.setValidator(self.validator)
  183. self.vol_table.setCellWidget(2, 2, item)
  184. item = QtWidgets.QTableWidgetItem("V")
  185. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  186. self.vol_table.setItem(2, 3, item)
  187. self.vol_groupbox_layout.addWidget(self.vol_table)
  188. self.vol_widget = QtWidgets.QWidget(self.vol_groupbox)
  189. self.vol_widget_layout = QtWidgets.QHBoxLayout(self.vol_widget)
  190. self.btn_pack_vol_cali = QtWidgets.QPushButton("电压校准")
  191. self.vol_widget_layout.addWidget(self.btn_pack_vol_cali)
  192. self.vol_groupbox_layout.addWidget(self.vol_widget)
  193. # self.hard_right_frame_layout.addWidget(self.vol_groupbox, 3)
  194. self.hard_right_cali_frame_layout.addWidget(self.vol_groupbox, 2)
  195. self.cur_groupbox = QtWidgets.QGroupBox("电流校准")
  196. self.cur_groupbox_layout = QtWidgets.QGridLayout(self.cur_groupbox)
  197. self.lb_cali = QtWidgets.QLabel("增益校准值")
  198. self.cur_groupbox_layout.addWidget(self.lb_cali, 0, 0)
  199. self.qline_cali_fbl = QtWidgets.QLineEdit(self.cur_groupbox)
  200. self.qline_cali_fbl.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  201. self.qline_cali_fbl.setValidator(self.validator_1)
  202. self.cur_groupbox_layout.addWidget(self.qline_cali_fbl, 0, 1)
  203. self.lb_zero = QtWidgets.QLabel("偏移准值")
  204. self.cur_groupbox_layout.addWidget(self.lb_zero, 1, 0)
  205. self.qline_cur_offset = QtWidgets.QLineEdit(self.cur_groupbox)
  206. self.qline_cur_offset.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  207. self.qline_cur_offset.setValidator(self.validator)
  208. self.cur_groupbox_layout.addWidget(self.qline_cur_offset,1, 1)
  209. self.lb_dw = QtWidgets.QLabel("A")
  210. self.cur_groupbox_layout.addWidget(self.lb_dw, 1, 2)
  211. self.btn_cur_cali = QtWidgets.QPushButton("电流校准")
  212. self.cur_groupbox_layout.addWidget(self.btn_cur_cali, 2, 0, 1, 3)
  213. # self.hard_right_frame_layout.addWidget(self.cur_groupbox, 3)
  214. self.hard_right_cali_frame_layout.addWidget(self.cur_groupbox, 1)
  215. self.hard_right_frame_layout.addWidget(self.hard_right_cali_frame, 3)
  216. self.temp_groupbox = QtWidgets.QGroupBox("从控温度配置")
  217. self.temp_groupbox_layout = QtWidgets.QHBoxLayout(self.temp_groupbox)
  218. self.temp_qscrollarea = QtWidgets.QScrollArea(self.temp_groupbox)
  219. self.temp_qscrollarea.setWidgetResizable(True)
  220. self.temp_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  221. self.temp_groupbox_layout.addWidget(self.temp_qscrollarea)
  222. self.temp_qwidget = QtWidgets.QWidget()
  223. self.temp_qscrollarea.setWidget(self.temp_qwidget)
  224. self.temp_qscrollarea_layout = QtWidgets.QGridLayout(self.temp_qwidget)
  225. self.temp_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  226. self.temp_qscrollarea_layout.setSpacing(0)
  227. for i in range(16):
  228. if i == 0:
  229. bmu_label = QtWidgets.QLabel("CMU ID")
  230. # bmu_label.setAlignment(Qt.AlignCenter)
  231. self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  232. else:
  233. bmu_label = QtWidgets.QLabel("CMU" + str(i))
  234. # bmu_label.setAlignment(Qt.AlignCenter)
  235. self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  236. for i in range(16):
  237. for j in range(72):
  238. if i == 0:
  239. bmu_label = QtWidgets.QLineEdit("T" + str(j + 1))
  240. # bmu_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  241. bmu_label.setReadOnly(True)
  242. bmu_label.setFixedWidth(30)
  243. self.temp_qscrollarea_layout.addWidget(bmu_label, i , j + 1, 1, 1)
  244. else:
  245. qtemp_check_widget = QtWidgets.QWidget()
  246. qtemp_check_widget_layout = QtWidgets.QHBoxLayout(qtemp_check_widget)
  247. qtemp_check_widget_layout.setContentsMargins(5, 5, 5, 5)
  248. qtemp_check_widget_layout.setSpacing(0)
  249. qtemp_checkbox = QtWidgets.QCheckBox(qtemp_check_widget)
  250. qtemp_checkbox.setFixedWidth(40)
  251. qtemp_check_widget_layout.addWidget(qtemp_checkbox)
  252. self.temp_qscrollarea_layout.addWidget(qtemp_check_widget, i, j + 1, 1, 1)
  253. self.hard_right_frame_layout.addWidget(self.temp_groupbox, 5)
  254. self.btn_widget = QtWidgets.QWidget()
  255. self.btn_widget_layout = QtWidgets.QHBoxLayout(self.btn_widget)
  256. self.btn_read_hard_param = QtWidgets.QPushButton("读取硬件参数")
  257. self.btn_widget_layout.addWidget(self.btn_read_hard_param)
  258. self.btn_exit_hard_param = QtWidgets.QPushButton("退出参数标定")
  259. self.btn_widget_layout.addWidget(self.btn_exit_hard_param)
  260. self.hard_right_frame_layout.addWidget(self.btn_widget)
  261. self.hard_right_frame_layout.addStretch()
  262. self.hard_layout.addWidget(self.hard_right_frame, 1)
  263. QtCore.QMetaObject.connectSlotsByName(Hard)