hard.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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
  6. class Hard(MyFrame):
  7. def setupUi(self, Hard):
  8. self.hard = MyFrame(Hard)
  9. self.hard_layout = QtWidgets.QHBoxLayout(self.hard)
  10. # self.hard_layout.setContentsMargins(5, 5, 5, 5)
  11. self.hard_layout.setSpacing(0)
  12. self.hard_left_groupbox = QtWidgets.QGroupBox(self.hard)
  13. self.hard_left_groupbox.setTitle("单体电压校准")
  14. self.hard_left_groupbox_layout = QtWidgets.QVBoxLayout(self.hard_left_groupbox)
  15. self.hard_left_top_widget = QtWidgets.QWidget()
  16. self.hard_left_top_layout = QtWidgets.QHBoxLayout(self.hard_left_top_widget)
  17. self.lb_cj = QtWidgets.QLabel("从机编号选择:")
  18. self.hard_left_top_layout.addWidget(self.lb_cj)
  19. self.cb_bmu_index = QtWidgets.QComboBox()
  20. for i in range(15):
  21. self.cb_bmu_index.addItem(str(i + 1))
  22. self.hard_left_top_layout.addWidget(self.cb_bmu_index)
  23. self.hard_left_top_layout.addStretch()
  24. self.hard_left_groupbox_layout.addWidget(self.hard_left_top_widget)
  25. self.hard_table = QtWidgets.QTableWidget(self.hard_left_groupbox)
  26. self.hard_table.setColumnCount(6)
  27. self.hard_table.verticalHeader().setVisible(False)
  28. self.hard_table.verticalHeader().setHighlightSections(True)
  29. self.hard_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  30. self.hard_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  31. self.hard_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
  32. self.hard_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
  33. # 设置只能选择行
  34. self.hard_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
  35. self.hard_table.setHorizontalHeaderLabels(["序号", "参数名称", "电池真实值", "BMS上传值", "误差", "单位"])
  36. self.hard_table.setRowCount(72)
  37. for i in range(72):
  38. item = QtWidgets.QTableWidgetItem(str(i + 1))
  39. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  40. self.hard_table.setItem(i, 0, item)
  41. item = QtWidgets.QTableWidgetItem("mV")
  42. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  43. self.hard_table.setItem(i, 5, item)
  44. # if i == 0:
  45. # item = QtWidgets.QTableWidgetItem("所有单体电压")
  46. # item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  47. # self.hard_table.setItem(0, 1, item)
  48. # else:
  49. item = QtWidgets.QTableWidgetItem("C" + str(i + 1) + "单体电压")
  50. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  51. self.hard_table.setItem(i, 1, item)
  52. item = QtWidgets.QLineEdit()
  53. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  54. self.hard_table.setCellWidget(i, 2, item)
  55. item = QtWidgets.QTableWidgetItem("")
  56. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  57. self.hard_table.setItem(i, 3, item)
  58. item = QtWidgets.QTableWidgetItem("")
  59. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  60. self.hard_table.setItem(i, 4, item)
  61. # self.hard_table.item(0, 3).setText("2200")
  62. # self.hard_table.item(4, 3).setText("2200")
  63. # self.hard_table.item(8, 3).setText("2200")
  64. self.hard_left_groupbox_layout.addWidget(self.hard_table)
  65. self.set_widget = QtWidgets.QWidget()
  66. self.set_widget_layout = QtWidgets.QGridLayout(self.set_widget)
  67. self.lb_wctj = QtWidgets.QLabel("误差统计:最大值")
  68. self.set_widget_layout.addWidget(self.lb_wctj, 0, 0, 1, 2)
  69. self.edt_max = QtWidgets.QLineEdit(self.set_widget)
  70. self.edt_max.setText("0")
  71. self.edt_max.setAlignment(Qt.AlignCenter)
  72. self.edt_max.setReadOnly(True)
  73. set_edt_bg(self.edt_max, QColor(Qt.gray))
  74. self.set_widget_layout.addWidget(self.edt_max, 0, 2, 1, 1)
  75. self.lb_zxz = QtWidgets.QLabel("mV 最小值")
  76. self.set_widget_layout.addWidget(self.lb_zxz, 0, 3, 1, 1)
  77. self.edt_min = QtWidgets.QLineEdit(self.set_widget)
  78. self.edt_min.setText("0")
  79. self.edt_min.setAlignment(Qt.AlignCenter)
  80. self.edt_min.setReadOnly(True)
  81. set_edt_bg(self.edt_min, QColor(Qt.gray))
  82. self.set_widget_layout.addWidget(self.edt_min, 0, 4, 1, 1)
  83. self.lb_jz = QtWidgets.QLabel("mV 均值")
  84. self.set_widget_layout.addWidget(self.lb_jz, 0, 5, 1, 1)
  85. self.edt_avg = QtWidgets.QLineEdit(self.set_widget)
  86. self.edt_avg.setText("0")
  87. self.edt_avg.setAlignment(Qt.AlignCenter)
  88. self.edt_avg.setReadOnly(True)
  89. set_edt_bg(self.edt_avg, QColor(Qt.gray))
  90. self.set_widget_layout.addWidget(self.edt_avg, 0, 6, 1, 1)
  91. self.lb_bzz = QtWidgets.QLabel("mV 标准差")
  92. self.set_widget_layout.addWidget(self.lb_bzz, 0, 7, 1, 1)
  93. self.edt_bzc = QtWidgets.QLineEdit(self.set_widget)
  94. self.edt_bzc.setText("0")
  95. self.edt_bzc.setAlignment(Qt.AlignCenter)
  96. self.edt_bzc.setReadOnly(True)
  97. set_edt_bg(self.edt_bzc, QColor(Qt.gray))
  98. self.set_widget_layout.addWidget(self.edt_bzc, 0, 8, 1, 1)
  99. self.lb_dw = QtWidgets.QLabel("mV")
  100. self.set_widget_layout.addWidget(self.lb_dw, 0, 9, 1, 1)
  101. self.lb_dtjzz = QtWidgets.QLabel("单体校准值")
  102. self.set_widget_layout.addWidget(self.lb_dtjzz, 1, 0, 1, 1)
  103. self.edt_cell = QtWidgets.QLineEdit(self.set_widget)
  104. self.edt_cell.setText("0")
  105. self.edt_cell.setAlignment(Qt.AlignCenter)
  106. self.edt_cell.setReadOnly(True)
  107. set_edt_bg(self.edt_cell, QColor(Qt.gray))
  108. self.set_widget_layout.addWidget(self.edt_cell, 1, 1, 1, 1)
  109. self.lb_dsw = QtWidgets.QLabel("mV")
  110. self.set_widget_layout.addWidget(self.lb_dsw, 1, 2, 1, 1)
  111. self.btn_hand = QtWidgets.QPushButton("手动校准")
  112. self.set_widget_layout.addWidget(self.btn_hand, 1, 4, 1, 2)
  113. self.btn_auto = QtWidgets.QPushButton("自动校准")
  114. self.set_widget_layout.addWidget(self.btn_auto, 1, 7, 1, 2)
  115. self.hard_left_groupbox_layout.addWidget(self.set_widget)
  116. self.hard_layout.addWidget(self.hard_left_groupbox, 1)
  117. self.hard_right_frame = MyFrame(self.hard)
  118. self.hard_right_frame_layout = QtWidgets.QVBoxLayout(self.hard_right_frame)
  119. self.rtc_groupbox = QtWidgets.QGroupBox("RTC时钟校准")
  120. self.rtc_groupbox_layout = QtWidgets.QHBoxLayout(self.rtc_groupbox)
  121. self.lb_rtc = QtWidgets.QLabel("RTC时钟")
  122. self.rtc_groupbox_layout.addWidget(self.lb_rtc)
  123. self.qline_rtc = QtWidgets.QLineEdit(self.rtc_groupbox)
  124. self.qline_rtc.setReadOnly(True)
  125. self.rtc_groupbox_layout.addWidget(self.qline_rtc)
  126. self.qcheckbox_rtc = QtWidgets.QCheckBox("实时更新")
  127. self.rtc_groupbox_layout.addWidget(self.qcheckbox_rtc)
  128. self.btn_rtc = QtWidgets.QPushButton("时钟校准")
  129. self.rtc_groupbox_layout.addWidget(self.btn_rtc)
  130. self.hard_right_frame_layout.addWidget(self.rtc_groupbox, 1)
  131. self.vol_groupbox = QtWidgets.QGroupBox("总电压校准")
  132. self.vol_groupbox_layout = QtWidgets.QVBoxLayout(self.vol_groupbox)
  133. self.vol_table = QtWidgets.QTableWidget(self.vol_groupbox)
  134. self.vol_table.setColumnCount(7)
  135. self.vol_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
  136. self.vol_table.verticalHeader().setVisible(False)
  137. self.vol_table.verticalHeader().setHighlightSections(True)
  138. self.vol_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  139. self.vol_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  140. self.vol_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
  141. self.vol_table.setHorizontalHeaderLabels(["序号", "参数名称", "模拟总压值", "BMS上传值", "校准值", "误差", "单位"])
  142. self.vol_table.setRowCount(3)
  143. item = QtWidgets.QTableWidgetItem("1")
  144. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  145. self.vol_table.setItem(0, 0, item)
  146. item = QtWidgets.QTableWidgetItem("总压")
  147. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  148. self.vol_table.setItem(0, 1, item)
  149. item = QtWidgets.QLineEdit()
  150. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  151. self.vol_table.setCellWidget(0, 2, item)
  152. item = QtWidgets.QTableWidgetItem("")
  153. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  154. self.vol_table.setItem(0, 3, item)
  155. item = QtWidgets.QLineEdit()
  156. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  157. self.vol_table.setCellWidget(0, 4, item)
  158. item = QtWidgets.QTableWidgetItem("")
  159. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  160. self.vol_table.setItem(0, 5, item)
  161. item = QtWidgets.QTableWidgetItem("V")
  162. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  163. self.vol_table.setItem(0, 6, item)
  164. item = QtWidgets.QTableWidgetItem("2")
  165. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  166. self.vol_table.setItem(1, 0, item)
  167. item = QtWidgets.QTableWidgetItem("总压2")
  168. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  169. self.vol_table.setItem(1, 1, item)
  170. item = QtWidgets.QLineEdit()
  171. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  172. self.vol_table.setCellWidget(1, 2, item)
  173. item = QtWidgets.QTableWidgetItem("")
  174. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  175. self.vol_table.setItem(1, 3, item)
  176. item = QtWidgets.QLineEdit()
  177. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  178. self.vol_table.setCellWidget(1, 4, item)
  179. item = QtWidgets.QTableWidgetItem("")
  180. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  181. self.vol_table.setItem(1, 5, item)
  182. item = QtWidgets.QTableWidgetItem("V")
  183. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  184. self.vol_table.setItem(1, 6, item)
  185. item = QtWidgets.QTableWidgetItem("3")
  186. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  187. self.vol_table.setItem(2, 0, item)
  188. item = QtWidgets.QTableWidgetItem("总压3")
  189. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  190. self.vol_table.setItem(2, 1, item)
  191. item = QtWidgets.QLineEdit()
  192. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  193. self.vol_table.setCellWidget(2, 2, item)
  194. item = QtWidgets.QTableWidgetItem("")
  195. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  196. self.vol_table.setItem(2, 3, item)
  197. item = QtWidgets.QLineEdit()
  198. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  199. self.vol_table.setCellWidget(2, 4, item)
  200. item = QtWidgets.QTableWidgetItem("")
  201. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  202. self.vol_table.setItem(2, 5, item)
  203. item = QtWidgets.QTableWidgetItem("V")
  204. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  205. self.vol_table.setItem(2, 6, item)
  206. self.vol_groupbox_layout.addWidget(self.vol_table)
  207. self.vol_widget = QtWidgets.QWidget(self.vol_groupbox)
  208. self.vol_widget_layout = QtWidgets.QHBoxLayout(self.vol_widget)
  209. self.btn_hand_cali = QtWidgets.QPushButton("手动校准")
  210. self.vol_widget_layout.addWidget(self.btn_hand_cali)
  211. self.btn_auto_cali = QtWidgets.QPushButton("自动校准")
  212. self.vol_widget_layout.addWidget(self.btn_auto_cali)
  213. self.vol_groupbox_layout.addWidget(self.vol_widget)
  214. self.hard_right_frame_layout.addWidget(self.vol_groupbox, 3)
  215. self.cur_groupbox = QtWidgets.QGroupBox("总电流校准")
  216. self.cur_groupbox_layout = QtWidgets.QVBoxLayout(self.cur_groupbox)
  217. self.cur_table = QtWidgets.QTableWidget(self.cur_groupbox)
  218. self.cur_table.setColumnCount(5)
  219. self.cur_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
  220. self.cur_table.verticalHeader().setVisible(False)
  221. self.cur_table.verticalHeader().setHighlightSections(True)
  222. self.cur_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  223. self.cur_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
  224. self.cur_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
  225. self.cur_table.setHorizontalHeaderLabels(["测试工步", "STEP1", "STEP2", "STEP3", "单位"])
  226. self.cur_table.setRowCount(3)
  227. item = QtWidgets.QTableWidgetItem("模拟电流值")
  228. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  229. self.cur_table.setItem(0, 0, item)
  230. item = QtWidgets.QLineEdit()
  231. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  232. self.cur_table.setCellWidget(0, 1, item)
  233. item = QtWidgets.QLineEdit()
  234. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  235. self.cur_table.setCellWidget(0, 2, item)
  236. item = QtWidgets.QLineEdit()
  237. item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  238. self.cur_table.setCellWidget(0, 3, item)
  239. item = QtWidgets.QTableWidgetItem("A")
  240. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  241. self.cur_table.setItem(0, 4, item)
  242. item = QtWidgets.QTableWidgetItem("BMS上传值")
  243. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  244. self.cur_table.setItem(1, 0, item)
  245. item = QtWidgets.QTableWidgetItem("A")
  246. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  247. self.cur_table.setItem(1, 4, item)
  248. item = QtWidgets.QTableWidgetItem("误差")
  249. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  250. self.cur_table.setItem(2, 0, item)
  251. item = QtWidgets.QTableWidgetItem("A")
  252. item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
  253. self.cur_table.setItem(2, 4, item)
  254. self.cur_groupbox_layout.addWidget(self.cur_table)
  255. self.cur_widget = QtWidgets.QWidget(self.cur_groupbox)
  256. self.cur_widget_layout = QtWidgets.QHBoxLayout(self.cur_widget)
  257. self.lb_cali = QtWidgets.QLabel("增益校准值")
  258. self.cur_widget_layout.addWidget(self.lb_cali)
  259. self.qline_cali = QtWidgets.QLabel(self.cur_widget)
  260. self.cur_widget_layout.addWidget(self.qline_cali)
  261. self.lb_zero = QtWidgets.QLabel("零漂校准值")
  262. self.cur_widget_layout.addWidget(self.lb_zero)
  263. self.qline_zero = QtWidgets.QLabel(self.cur_widget)
  264. self.cur_widget_layout.addWidget(self.qline_zero)
  265. self.btn_cur_hand_cali = QtWidgets.QPushButton("手动校准")
  266. self.cur_widget_layout.addWidget(self.btn_cur_hand_cali)
  267. self.btn_hand_auto_cali = QtWidgets.QPushButton("自动校准")
  268. self.cur_widget_layout.addWidget(self.btn_hand_auto_cali)
  269. self.cur_groupbox_layout.addWidget(self.cur_widget)
  270. self.hard_right_frame_layout.addWidget(self.cur_groupbox, 3)
  271. self.temp_groupbox = QtWidgets.QGroupBox("从控温度配置")
  272. self.temp_groupbox_layout = QtWidgets.QHBoxLayout(self.temp_groupbox)
  273. self.temp_qscrollarea = QtWidgets.QScrollArea(self.temp_groupbox)
  274. self.temp_qscrollarea.setWidgetResizable(True)
  275. self.temp_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  276. self.temp_groupbox_layout.addWidget(self.temp_qscrollarea)
  277. self.temp_qwidget = QtWidgets.QWidget()
  278. self.temp_qscrollarea.setWidget(self.temp_qwidget)
  279. self.temp_qscrollarea_layout = QtWidgets.QGridLayout(self.temp_qwidget)
  280. # self.temp_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  281. self.temp_qscrollarea_layout.setSpacing(0)
  282. for i in range(16):
  283. if i == 0:
  284. bmu_label = QtWidgets.QLabel("CMU ID")
  285. # bmu_label.setAlignment(Qt.AlignCenter)
  286. self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  287. else:
  288. bmu_label = QtWidgets.QLabel("CMU" + str(i))
  289. # bmu_label.setAlignment(Qt.AlignCenter)
  290. self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  291. for i in range(16):
  292. for j in range(72):
  293. if i == 0:
  294. bmu_label = QtWidgets.QLabel("T" + str(j + 1))
  295. # bmu_label.setAlignment(Qt.AlignCenter)
  296. self.temp_qscrollarea_layout.addWidget(bmu_label, i , j + 1, 1, 1)
  297. else:
  298. qtemp_checkbox = QtWidgets.QCheckBox()
  299. # qtemp_lebal.setAlignment(Qt.AlignCenter)
  300. # qtemp_checkbox
  301. qtemp_checkbox.setFixedWidth(40)
  302. # qtemp_lebal.setReadOnly(True)
  303. self.temp_qscrollarea_layout.addWidget(qtemp_checkbox, i, j + 1, 1, 1)
  304. self.hard_right_frame_layout.addWidget(self.temp_groupbox, 2)
  305. self.btn_widget = QtWidgets.QWidget()
  306. self.btn_widget_layout = QtWidgets.QHBoxLayout(self.btn_widget)
  307. self.btn_read_hard_param = QtWidgets.QPushButton("读取硬件参数")
  308. self.btn_widget_layout.addWidget(self.btn_read_hard_param)
  309. self.btn_exit_hard_param = QtWidgets.QPushButton("退出参数标定")
  310. self.btn_widget_layout.addWidget(self.btn_exit_hard_param)
  311. self.hard_right_frame_layout.addWidget(self.btn_widget)
  312. self.hard_right_frame_layout.addStretch()
  313. self.hard_layout.addWidget(self.hard_right_frame, 1)
  314. QtCore.QMetaObject.connectSlotsByName(Hard)