123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- from ui.own.frame_theme import MyFrame
- from ui.own.palette_theme import set_edt_bg
- from utils.qt import QtWidgets, QtCore, Qt, QColor, QtGui
- class Hard(MyFrame):
- def setupUi(self, Hard):
- self.reg = QtCore.QRegExp('^[\-\+]?\d+(\.\d)?$')
- self.validator = QtGui.QRegExpValidator(self)
- self.validator.setRegExp(self.reg)
- self.reg = QtCore.QRegExp('^[\-\+]?\d+(\.\d\d\d)?$')
- self.validator_1 = QtGui.QRegExpValidator(self)
- self.validator_1.setRegExp(self.reg)
- self.reg = QtCore.QRegExp('^[1-9]\d*$')
- self.validator_2 = QtGui.QRegExpValidator(self)
- self.validator_2.setRegExp(self.reg)
- self.hard = MyFrame(Hard)
- self.hard_layout = QtWidgets.QHBoxLayout(self.hard)
- # self.hard_layout.setContentsMargins(5, 5, 5, 5)
- self.hard_layout.setSpacing(0)
- self.hard_left_groupbox = QtWidgets.QGroupBox(self.hard)
- self.hard_left_groupbox.setTitle("单体电压校准")
- self.hard_left_groupbox_layout = QtWidgets.QVBoxLayout(self.hard_left_groupbox)
- self.hard_left_top_widget = QtWidgets.QWidget()
- self.hard_left_top_layout = QtWidgets.QHBoxLayout(self.hard_left_top_widget)
- self.lb_cj = QtWidgets.QLabel("从机编号选择:")
- self.hard_left_top_layout.addWidget(self.lb_cj)
- self.cb_bmu_index = QtWidgets.QComboBox()
- for i in range(15):
- self.cb_bmu_index.addItem(str(i + 1))
- self.hard_left_top_layout.addWidget(self.cb_bmu_index)
- self.hard_left_top_layout.addStretch()
- self.hard_left_groupbox_layout.addWidget(self.hard_left_top_widget)
- self.hard_table = QtWidgets.QTableWidget(self.hard_left_groupbox)
- self.hard_table.setColumnCount(6)
- self.hard_table.verticalHeader().setVisible(False)
- self.hard_table.verticalHeader().setHighlightSections(True)
- self.hard_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
- self.hard_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
- self.hard_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
- self.hard_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
- # 设置只能选择行
- self.hard_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
- self.hard_table.setHorizontalHeaderLabels(["序号", "参数名称", "电池真实值", "BMS上传值", "误差", "单位"])
- self.hard_table.setRowCount(72)
- for i in range(72):
- item = QtWidgets.QTableWidgetItem(str(i + 1))
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.hard_table.setItem(i, 0, item)
- item = QtWidgets.QTableWidgetItem("mV")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.hard_table.setItem(i, 5, item)
- item = QtWidgets.QTableWidgetItem("C" + str(i + 1) + "单体电压")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.hard_table.setItem(i, 1, item)
- item = QtWidgets.QLineEdit()
- item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- item.setValidator(self.validator_2)
- self.hard_table.setCellWidget(i, 2, item)
- item = QtWidgets.QTableWidgetItem("")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.hard_table.setItem(i, 3, item)
- item = QtWidgets.QTableWidgetItem("")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.hard_table.setItem(i, 4, item)
-
- # self.hard_table.item(0, 3).setText("2200")
- # self.hard_table.item(4, 3).setText("2200")
- # self.hard_table.item(8, 3).setText("2200")
- self.hard_left_groupbox_layout.addWidget(self.hard_table)
- self.set_widget = QtWidgets.QWidget()
- self.set_widget_layout = QtWidgets.QGridLayout(self.set_widget)
- self.lb_wctj = QtWidgets.QLabel("误差统计:最大值")
- self.set_widget_layout.addWidget(self.lb_wctj, 0, 0, 1, 2)
- self.edt_max = QtWidgets.QLineEdit(self.set_widget)
- self.edt_max.setText("0")
- self.edt_max.setAlignment(Qt.AlignCenter)
- self.edt_max.setReadOnly(True)
- set_edt_bg(self.edt_max, QColor(Qt.gray))
- self.set_widget_layout.addWidget(self.edt_max, 0, 2, 1, 1)
- self.lb_zxz = QtWidgets.QLabel("mV 最小值")
- self.set_widget_layout.addWidget(self.lb_zxz, 0, 3, 1, 1)
- self.edt_min = QtWidgets.QLineEdit(self.set_widget)
- self.edt_min.setText("0")
- self.edt_min.setAlignment(Qt.AlignCenter)
- self.edt_min.setReadOnly(True)
- set_edt_bg(self.edt_min, QColor(Qt.gray))
- self.set_widget_layout.addWidget(self.edt_min, 0, 4, 1, 1)
- self.lb_jz = QtWidgets.QLabel("mV 均值")
- self.set_widget_layout.addWidget(self.lb_jz, 0, 5, 1, 1)
- self.edt_avg = QtWidgets.QLineEdit(self.set_widget)
- self.edt_avg.setText("0")
- self.edt_avg.setAlignment(Qt.AlignCenter)
- self.edt_avg.setReadOnly(True)
- set_edt_bg(self.edt_avg, QColor(Qt.gray))
- self.set_widget_layout.addWidget(self.edt_avg, 0, 6, 1, 1)
- self.lb_bzz = QtWidgets.QLabel("mV 标准差")
- self.set_widget_layout.addWidget(self.lb_bzz, 0, 7, 1, 1)
- self.edt_bzc = QtWidgets.QLineEdit(self.set_widget)
- self.edt_bzc.setText("0")
- self.edt_bzc.setAlignment(Qt.AlignCenter)
- self.edt_bzc.setReadOnly(True)
- set_edt_bg(self.edt_bzc, QColor(Qt.gray))
- self.set_widget_layout.addWidget(self.edt_bzc, 0, 8, 1, 1)
- self.lb_dw = QtWidgets.QLabel("mV")
- self.set_widget_layout.addWidget(self.lb_dw, 0, 9, 1, 1)
- self.lb_dtjzz = QtWidgets.QLabel("单体校准值")
- self.set_widget_layout.addWidget(self.lb_dtjzz, 1, 0, 1, 1)
- self.edt_cell = QtWidgets.QLineEdit(self.set_widget)
- self.edt_cell.setText("0")
- self.edt_cell.setAlignment(Qt.AlignCenter)
- # self.edt_cell.setReadOnly(True)
- set_edt_bg(self.edt_cell, QColor(Qt.gray))
- self.set_widget_layout.addWidget(self.edt_cell, 1, 1, 1, 1)
- self.lb_dsw = QtWidgets.QLabel("mV")
- self.set_widget_layout.addWidget(self.lb_dsw, 1, 2, 1, 1)
- self.btn_hand = QtWidgets.QPushButton("单体校准")
- self.set_widget_layout.addWidget(self.btn_hand, 1, 4, 1, 2)
- self.btn_auto = QtWidgets.QPushButton("全部校准")
- self.set_widget_layout.addWidget(self.btn_auto, 1, 7, 1, 2)
- self.hard_left_groupbox_layout.addWidget(self.set_widget)
- self.hard_layout.addWidget(self.hard_left_groupbox, 1)
- self.hard_right_frame = MyFrame(self.hard)
- self.hard_right_frame_layout = QtWidgets.QVBoxLayout(self.hard_right_frame)
- self.rtc_groupbox = QtWidgets.QGroupBox("RTC时钟校准")
- self.rtc_groupbox_layout = QtWidgets.QHBoxLayout(self.rtc_groupbox)
- self.lb_rtc = QtWidgets.QLabel("RTC时钟")
- self.rtc_groupbox_layout.addWidget(self.lb_rtc)
- self.qline_rtc = QtWidgets.QLineEdit(self.rtc_groupbox)
- self.qline_rtc.setReadOnly(True)
- self.rtc_groupbox_layout.addWidget(self.qline_rtc)
- self.btn_rtc = QtWidgets.QPushButton("时钟校准")
- self.rtc_groupbox_layout.addWidget(self.btn_rtc)
- self.hard_right_frame_layout.addWidget(self.rtc_groupbox, 1)
- self.hard_right_cali_frame = MyFrame(self.hard_right_frame)
- self.hard_right_cali_frame_layout = QtWidgets.QHBoxLayout(self.hard_right_cali_frame)
- self.vol_groupbox = QtWidgets.QGroupBox("电压校准")
- self.vol_groupbox_layout = QtWidgets.QVBoxLayout(self.vol_groupbox)
- self.vol_table = QtWidgets.QTableWidget(self.vol_groupbox)
- self.vol_table.setColumnCount(4)
- self.vol_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
- self.vol_table.verticalHeader().setVisible(False)
- self.vol_table.verticalHeader().setHighlightSections(True)
- self.vol_table.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
- self.vol_table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
- self.vol_table.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
- self.vol_table.setHorizontalHeaderLabels(["序号", "参数名称", "误差", "单位"])
- self.vol_table.setRowCount(3)
- item = QtWidgets.QTableWidgetItem("1")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(0, 0, item)
- item = QtWidgets.QTableWidgetItem("总压")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(0, 1, item)
- item = QtWidgets.QLineEdit()
- item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- item.setValidator(self.validator)
- self.vol_table.setCellWidget(0, 2, item)
- item = QtWidgets.QTableWidgetItem("V")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(0, 3, item)
- item = QtWidgets.QTableWidgetItem("2")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(1, 0, item)
- item = QtWidgets.QTableWidgetItem("总压2")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(1, 1, item)
- item = QtWidgets.QLineEdit()
- item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- item.setValidator(self.validator)
- self.vol_table.setCellWidget(1, 2, item)
- item = QtWidgets.QTableWidgetItem("V")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(1, 3, item)
- item = QtWidgets.QTableWidgetItem("3")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(2, 0, item)
- item = QtWidgets.QTableWidgetItem("总压3")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(2, 1, item)
- item = QtWidgets.QLineEdit()
- item.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- item.setValidator(self.validator)
- self.vol_table.setCellWidget(2, 2, item)
- item = QtWidgets.QTableWidgetItem("V")
- item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.vol_table.setItem(2, 3, item)
- self.vol_groupbox_layout.addWidget(self.vol_table)
- self.vol_widget = QtWidgets.QWidget(self.vol_groupbox)
- self.vol_widget_layout = QtWidgets.QHBoxLayout(self.vol_widget)
- self.btn_pack_vol_cali = QtWidgets.QPushButton("电压校准")
- self.vol_widget_layout.addWidget(self.btn_pack_vol_cali)
- self.vol_groupbox_layout.addWidget(self.vol_widget)
- # self.hard_right_frame_layout.addWidget(self.vol_groupbox, 3)
- self.hard_right_cali_frame_layout.addWidget(self.vol_groupbox, 2)
- self.cur_groupbox = QtWidgets.QGroupBox("电流校准")
- self.cur_groupbox_layout = QtWidgets.QGridLayout(self.cur_groupbox)
- self.lb_cali = QtWidgets.QLabel("增益校准值")
- self.cur_groupbox_layout.addWidget(self.lb_cali, 0, 0)
- self.qline_cali_fbl = QtWidgets.QLineEdit(self.cur_groupbox)
- self.qline_cali_fbl.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.qline_cali_fbl.setValidator(self.validator_1)
- self.cur_groupbox_layout.addWidget(self.qline_cali_fbl, 0, 1)
- self.lb_zero = QtWidgets.QLabel("偏移准值")
- self.cur_groupbox_layout.addWidget(self.lb_zero, 1, 0)
- self.qline_cur_offset = QtWidgets.QLineEdit(self.cur_groupbox)
- self.qline_cur_offset.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- self.qline_cur_offset.setValidator(self.validator)
- self.cur_groupbox_layout.addWidget(self.qline_cur_offset,1, 1)
- self.lb_dw = QtWidgets.QLabel("A")
- self.cur_groupbox_layout.addWidget(self.lb_dw, 1, 2)
- self.btn_cur_cali = QtWidgets.QPushButton("电流校准")
- self.cur_groupbox_layout.addWidget(self.btn_cur_cali, 2, 0, 1, 3)
- # self.hard_right_frame_layout.addWidget(self.cur_groupbox, 3)
- self.hard_right_cali_frame_layout.addWidget(self.cur_groupbox, 1)
- self.hard_right_frame_layout.addWidget(self.hard_right_cali_frame, 3)
- self.temp_groupbox = QtWidgets.QGroupBox("从控温度配置")
- self.temp_groupbox_layout = QtWidgets.QHBoxLayout(self.temp_groupbox)
- self.temp_qscrollarea = QtWidgets.QScrollArea(self.temp_groupbox)
- self.temp_qscrollarea.setWidgetResizable(True)
- self.temp_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
- self.temp_groupbox_layout.addWidget(self.temp_qscrollarea)
- self.temp_qwidget = QtWidgets.QWidget()
- self.temp_qscrollarea.setWidget(self.temp_qwidget)
- self.temp_qscrollarea_layout = QtWidgets.QGridLayout(self.temp_qwidget)
- self.temp_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
- self.temp_qscrollarea_layout.setSpacing(0)
- for i in range(16):
- if i == 0:
- bmu_label = QtWidgets.QLabel("CMU ID")
- # bmu_label.setAlignment(Qt.AlignCenter)
- self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
- else:
- bmu_label = QtWidgets.QLabel("CMU" + str(i))
- # bmu_label.setAlignment(Qt.AlignCenter)
- self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
- for i in range(16):
- for j in range(72):
- if i == 0:
- bmu_label = QtWidgets.QLineEdit("T" + str(j + 1))
- # bmu_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
- bmu_label.setReadOnly(True)
- bmu_label.setFixedWidth(30)
- self.temp_qscrollarea_layout.addWidget(bmu_label, i , j + 1, 1, 1)
- else:
- qtemp_check_widget = QtWidgets.QWidget()
- qtemp_check_widget_layout = QtWidgets.QHBoxLayout(qtemp_check_widget)
- qtemp_check_widget_layout.setContentsMargins(5, 5, 5, 5)
- qtemp_check_widget_layout.setSpacing(0)
- qtemp_checkbox = QtWidgets.QCheckBox(qtemp_check_widget)
- qtemp_checkbox.setFixedWidth(40)
- qtemp_check_widget_layout.addWidget(qtemp_checkbox)
- self.temp_qscrollarea_layout.addWidget(qtemp_check_widget, i, j + 1, 1, 1)
- self.hard_right_frame_layout.addWidget(self.temp_groupbox, 5)
-
- self.btn_widget = QtWidgets.QWidget()
- self.btn_widget_layout = QtWidgets.QHBoxLayout(self.btn_widget)
- self.btn_read_hard_param = QtWidgets.QPushButton("读取硬件参数")
- self.btn_widget_layout.addWidget(self.btn_read_hard_param)
- self.btn_exit_hard_param = QtWidgets.QPushButton("退出参数标定")
- self.btn_widget_layout.addWidget(self.btn_exit_hard_param)
- self.hard_right_frame_layout.addWidget(self.btn_widget)
- self.hard_right_frame_layout.addStretch()
- self.hard_layout.addWidget(self.hard_right_frame, 1)
- QtCore.QMetaObject.connectSlotsByName(Hard)
|