#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import os
from ui.own.frame_theme import MyFrame
from utils.qt import QtWidgets, QtGui, QIcon, QPixmap, Qt
from utils.resource import resource_path
from utils.globalvar import SD


class TopPage(QtWidgets.QWidget):

    def __init__(self, parent=None):
        super(TopPage, self).__init__(parent)
        self.initUI()

    def initUI(self):
        self.verticalLayout = QtWidgets.QVBoxLayout(self)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(0)

        # 设置参数
        self.top_widget = MyFrame(self)
        self.top_layout = QtWidgets.QVBoxLayout(self.top_widget)
        self.top_layout.setContentsMargins(0, 0, 0, 0)
        self.top_layout.setSpacing(0)
        self.top_groupbox = QtWidgets.QGroupBox(self.top_widget)
        self.top_groupbox.setTitle("参数配置")
        self.top_groupbox_layout = QtWidgets.QHBoxLayout(self.top_groupbox)

        self.top_qscrollarea = QtWidgets.QScrollArea(self.top_groupbox)
        self.top_qscrollarea.setWidgetResizable(True)
        # self.top_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.top_groupbox_layout.addWidget(self.top_qscrollarea)

        self.top_qwidget = QtWidgets.QWidget()
        self.top_qscrollarea.setWidget(self.top_qwidget)

        self.top_qscrollarea_layout = QtWidgets.QGridLayout(self.top_qwidget)
        self.top_qscrollarea_layout.setObjectName("scrollLayout")
        # self.top_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
        self.top_qscrollarea_layout.setSpacing(0)


        self.tv = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tv.setTitle("总压")
        self.tv_layout = QtWidgets.QHBoxLayout(self.tv)
        self.lb_tv_value = QtWidgets.QLabel(self.tv)
        self.lb_tv_value.setText("    ")
        self.tv_layout.addWidget(self.lb_tv_value)
        self.lb_tv = QtWidgets.QLabel(self.tv)
        self.lb_tv.setText("V")
        self.tv_layout.addWidget(self.lb_tv)
        self.top_qscrollarea_layout.addWidget(self.tv, 0, 0, 1, 1)

        self.tcur = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcur.setTitle("电流")
        self.tcur_layout = QtWidgets.QHBoxLayout(self.tcur)
        self.lb_tcur_value = QtWidgets.QLabel(self.tcur)
        self.lb_tcur_value.setText("    ")
        self.tcur_layout.addWidget(self.lb_tcur_value)
        self.lb_tcur = QtWidgets.QLabel(self.tcur)
        self.lb_tcur.setText("A")
        self.tcur_layout.addWidget(self.lb_tcur)
        self.top_qscrollarea_layout.addWidget(self.tcur, 0, 1, 1, 1)

        self.tsoc = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tsoc.setTitle("SOC")
        self.soc_layout = QtWidgets.QHBoxLayout(self.tsoc)
        self.lb_soc_value = QtWidgets.QLabel(self.tsoc)
        self.lb_soc_value.setText("    ")
        self.soc_layout.addWidget(self.lb_soc_value)
        self.lb_soc = QtWidgets.QLabel(self.tsoc)
        self.lb_soc.setText("%")
        self.soc_layout.addWidget(self.lb_soc)
        self.top_qscrollarea_layout.addWidget(self.tsoc, 0, 2, 1, 1)

        self.tsoh = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tsoh.setTitle("SOH")
        self.tsoh_layout = QtWidgets.QHBoxLayout(self.tsoh)
        self.lb_tsoh_value = QtWidgets.QLabel(self.tsoh)
        self.lb_tsoh_value.setText("    ")
        self.tsoh_layout.addWidget(self.lb_tsoh_value)
        self.lb_tsoh = QtWidgets.QLabel(self.tsoh)
        self.lb_tsoh.setText("%")
        self.tsoh_layout.addWidget(self.lb_tsoh)
        self.top_qscrollarea_layout.addWidget(self.tsoh, 0, 3, 1, 1)

        self.tsoe = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tsoe.setTitle("SOE")
        self.tsoe_layout = QtWidgets.QHBoxLayout(self.tsoe)
        self.lb_tsoe_value = QtWidgets.QLabel(self.tsoe)
        self.lb_tsoe_value.setText("    ")
        self.tsoe_layout.addWidget(self.lb_tsoe_value)
        self.lb_tsoe = QtWidgets.QLabel(self.tsoe)
        self.lb_tsoe.setText("%")
        self.tsoe_layout.addWidget(self.lb_tsoe)
        self.top_qscrollarea_layout.addWidget(self.tsoe, 0, 4, 1, 1)

        self.tcellhv = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcellhv.setTitle("单体最高电压")
        self.tcellhv_layout = QtWidgets.QHBoxLayout(self.tcellhv)
        self.lb_tcellhv_value = QtWidgets.QLabel(self.tcellhv)
        self.lb_tcellhv_value.setText("    ")
        self.tcellhv_layout.addWidget(self.lb_tcellhv_value)
        self.lb_tcellhv = QtWidgets.QLabel(self.tcellhv)
        self.lb_tcellhv.setText("mV")
        self.tcellhv_layout.addWidget(self.lb_tcellhv)
        self.top_qscrollarea_layout.addWidget(self.tcellhv, 0, 5, 1, 1)

        self.tcelllv = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcelllv.setTitle("单体最低电压")
        self.tcelllv_layout = QtWidgets.QHBoxLayout(self.tcelllv)
        self.lb_tcelllv_value = QtWidgets.QLabel(self.tcelllv)
        self.lb_tcelllv_value.setText("    ")
        self.tcelllv_layout.addWidget(self.lb_tcelllv_value)
        self.lb_tcelllv = QtWidgets.QLabel(self.tcelllv)
        self.lb_tcelllv.setText("mV")
        self.tcelllv_layout.addWidget(self.lb_tcelllv)
        self.top_qscrollarea_layout.addWidget(self.tcelllv, 0, 6, 1, 1)

        self.tcellhv_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcellhv_index.setTitle("最高单体电压编号")
        self.tcellhv_index_layout = QtWidgets.QHBoxLayout(self.tcellhv_index)
        self.lb_tcellhv_index_value = QtWidgets.QLabel(self.tcellhv_index)
        self.lb_tcellhv_index_value.setText("    ")
        self.tcellhv_index_layout.addWidget(self.lb_tcellhv_index_value)
        self.lb_tcellhv_index = QtWidgets.QLabel(self.tcellhv_index)
        self.lb_tcellhv_index.setText("")
        self.tcellhv_index_layout.addWidget(self.lb_tcellhv_index)
        self.top_qscrollarea_layout.addWidget(self.tcellhv_index, 0, 7, 1, 1)

        self.tcellhv_slave_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcellhv_slave_index.setTitle("最高单体电压从控编号")
        self.tcellhv_slave_index_layout = QtWidgets.QHBoxLayout(self.tcellhv_slave_index)
        self.lb_tcellhv_slave_index_value = QtWidgets.QLabel(self.tcellhv_slave_index)
        self.lb_tcellhv_slave_index_value.setText("    ")
        self.tcellhv_slave_index_layout.addWidget(self.lb_tcellhv_slave_index_value)
        self.lb_tcellhv_slave_index = QtWidgets.QLabel(self.tcellhv_slave_index)
        self.lb_tcellhv_slave_index.setText("")
        self.tcellhv_slave_index_layout.addWidget(self.lb_tcellhv_slave_index)
        self.top_qscrollarea_layout.addWidget(self.tcellhv_slave_index, 0, 8, 1, 1)

        self.tcellhv_in_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcellhv_in_index.setTitle("最高单体电压从控内编号")
        self.tcellhv_in_index_layout = QtWidgets.QHBoxLayout(self.tcellhv_in_index)
        self.lb_tcellhv_in_index_value = QtWidgets.QLabel(self.tcellhv_in_index)
        self.lb_tcellhv_in_index_value.setText("    ")
        self.tcellhv_in_index_layout.addWidget(self.lb_tcellhv_in_index_value)
        self.lb_tcellhv_in_index = QtWidgets.QLabel(self.tcellhv_in_index)
        self.lb_tcellhv_in_index.setText("")
        self.tcellhv_in_index_layout.addWidget(self.lb_tcellhv_in_index)
        self.top_qscrollarea_layout.addWidget(self.tcellhv_in_index, 0, 9, 1, 1)

        self.tcelllv_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcelllv_index.setTitle("最低单体电压编号")
        self.tcelllv_index_layout = QtWidgets.QHBoxLayout(self.tcelllv_index)
        self.lb_tcelllv_index_value = QtWidgets.QLabel(self.tcelllv_index)
        self.lb_tcelllv_index_value.setText("    ")
        self.tcelllv_index_layout.addWidget(self.lb_tcelllv_index_value)
        self.lb_tcelllv_index = QtWidgets.QLabel(self.tcelllv_index)
        self.lb_tcelllv_index.setText("")
        self.tcelllv_index_layout.addWidget(self.lb_tcelllv_index)
        self.top_qscrollarea_layout.addWidget(self.tcelllv_index, 1, 0, 1, 1)

        self.tcelllv_slave_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcelllv_slave_index.setTitle("最低单体电压从控编号")
        self.tcelllv_slave_index_layout = QtWidgets.QHBoxLayout(self.tcelllv_slave_index)
        self.lb_tcelllv_slave_index_value = QtWidgets.QLabel(self.tcelllv_slave_index)
        self.lb_tcelllv_slave_index_value.setText("    ")
        self.tcelllv_slave_index_layout.addWidget(self.lb_tcelllv_slave_index_value)
        self.lb_tcelllv_slave_index = QtWidgets.QLabel(self.tcelllv_slave_index)
        self.lb_tcelllv_slave_index.setText("")
        self.tcelllv_slave_index_layout.addWidget(self.lb_tcelllv_slave_index)
        self.top_qscrollarea_layout.addWidget(self.tcelllv_slave_index, 1, 1, 1, 1)

        self.tcelllv_in_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tcelllv_in_index.setTitle("最低单体电压从控内编号")
        self.tcelllv_in_index_layout = QtWidgets.QHBoxLayout(self.tcelllv_in_index)
        self.lb_tcelllv_in_index_value = QtWidgets.QLabel(self.tcelllv_in_index)
        self.lb_tcelllv_in_index_value.setText("    ")
        self.tcelllv_in_index_layout.addWidget(self.lb_tcelllv_in_index_value)
        self.lb_tcelllv_in_index = QtWidgets.QLabel(self.tcelllv_in_index)
        self.lb_tcelllv_in_index.setText("")
        self.tcelllv_in_index_layout.addWidget(self.lb_tcelllv_in_index)
        self.top_qscrollarea_layout.addWidget(self.tcelllv_in_index, 1, 2, 1, 1)

        self.avg_vol = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.avg_vol.setTitle("平均电压")
        self.avg_vol_layout = QtWidgets.QHBoxLayout(self.avg_vol)
        self.lb_avg_vol_value = QtWidgets.QLabel(self.avg_vol)
        self.lb_avg_vol_value.setText("    ")
        self.avg_vol_layout.addWidget(self.lb_avg_vol_value)
        self.lb_avg_vol = QtWidgets.QLabel(self.avg_vol)
        self.lb_avg_vol.setText("mV")
        self.avg_vol_layout.addWidget(self.lb_avg_vol)
        self.top_qscrollarea_layout.addWidget(self.avg_vol, 1, 3, 1, 1)

        self.diff_vol = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.diff_vol.setTitle("单体最大压差")
        self.diff_vol_layout = QtWidgets.QHBoxLayout(self.diff_vol)
        self.lb_diff_vol_value = QtWidgets.QLabel(self.diff_vol)
        self.lb_diff_vol_value.setText("    ")
        self.diff_vol_layout.addWidget(self.lb_diff_vol_value)
        self.lb_diff_vol = QtWidgets.QLabel(self.diff_vol)
        self.lb_diff_vol.setText("mV")
        self.diff_vol_layout.addWidget(self.lb_diff_vol)
        self.top_qscrollarea_layout.addWidget(self.diff_vol, 1, 4, 1, 1)

        self.h_temp = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.h_temp.setTitle("最高电池温度")
        self.h_temp_layout = QtWidgets.QHBoxLayout(self.h_temp)
        self.lb_h_temp_value = QtWidgets.QLabel(self.h_temp)
        self.lb_h_temp_value.setText("    ")
        self.h_temp_layout.addWidget(self.lb_h_temp_value)
        self.lb_h_temp = QtWidgets.QLabel(self.h_temp)
        self.lb_h_temp.setText("℃")
        self.h_temp_layout.addWidget(self.lb_h_temp)
        self.top_qscrollarea_layout.addWidget(self.h_temp, 1, 5, 1, 1)

        self.l_temp = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.l_temp.setTitle("最低电池温度")
        self.l_temp_layout = QtWidgets.QHBoxLayout(self.l_temp)
        self.lb_l_temp_value = QtWidgets.QLabel(self.l_temp)
        self.lb_l_temp_value.setText("    ")
        self.l_temp_layout.addWidget(self.lb_l_temp_value)
        self.lb_l_temp = QtWidgets.QLabel(self.l_temp)
        self.lb_l_temp.setText("℃")
        self.l_temp_layout.addWidget(self.lb_l_temp)
        self.top_qscrollarea_layout.addWidget(self.l_temp, 1, 6, 1, 1)

        self.h_temp_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.h_temp_index.setTitle("最高单体温度编号")
        self.h_temp_index_layout = QtWidgets.QHBoxLayout(self.h_temp_index)
        self.lb_h_temp_index_value = QtWidgets.QLabel(self.h_temp_index)
        self.lb_h_temp_index_value.setText("    ")
        self.h_temp_index_layout.addWidget(self.lb_h_temp_index_value)
        self.lb_h_temp_index = QtWidgets.QLabel(self.h_temp_index)
        self.lb_h_temp_index.setText("")
        self.h_temp_index_layout.addWidget(self.lb_h_temp_index)
        self.top_qscrollarea_layout.addWidget(self.h_temp_index, 1, 7, 1, 1)

        self.h_temp_slave_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.h_temp_slave_index.setTitle("最高单体温度从控编号")
        self.h_temp_slave_index_layout = QtWidgets.QHBoxLayout(self.h_temp_slave_index)
        self.lb_h_temp_slave_index_value = QtWidgets.QLabel(self.h_temp_slave_index)
        self.lb_h_temp_slave_index_value.setText("    ")
        self.h_temp_slave_index_layout.addWidget(self.lb_h_temp_slave_index_value)
        self.lb_h_temp_slave_index = QtWidgets.QLabel(self.h_temp_slave_index)
        self.lb_h_temp_slave_index.setText("")
        self.h_temp_slave_index_layout.addWidget(self.lb_h_temp_slave_index)
        self.top_qscrollarea_layout.addWidget(self.h_temp_slave_index, 1, 8, 1, 1)

        self.h_temp_in_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.h_temp_in_index.setTitle("最高单体温度从控内编号")
        self.h_temp_in_index_layout = QtWidgets.QHBoxLayout(self.h_temp_in_index)
        self.lb_h_temp_in_index_value = QtWidgets.QLabel(self.h_temp_in_index)
        self.lb_h_temp_in_index_value.setText("    ")
        self.h_temp_in_index_layout.addWidget(self.lb_h_temp_in_index_value)
        self.lb_h_temp_in_index = QtWidgets.QLabel(self.h_temp_in_index)
        self.lb_h_temp_in_index.setText("")
        self.h_temp_in_index_layout.addWidget(self.lb_h_temp_in_index)
        self.top_qscrollarea_layout.addWidget(self.h_temp_in_index, 1, 9, 1, 1)

        self.avg_temp = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.avg_temp.setTitle("平均温度")
        self.avg_temp_layout = QtWidgets.QHBoxLayout(self.avg_temp)
        self.lb_avg_temp_value = QtWidgets.QLabel(self.avg_temp)
        self.lb_avg_temp_value.setText("    ")
        self.avg_temp_layout.addWidget(self.lb_avg_temp_value)
        self.lb_avg_temp = QtWidgets.QLabel("℃")
        self.avg_temp_layout.addWidget(self.lb_avg_temp)
        self.top_qscrollarea_layout.addWidget(self.avg_temp, 2, 0, 1, 1)

        self.diff_temp = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.diff_temp.setTitle("单体最大温差")
        self.diff_temp_layout = QtWidgets.QHBoxLayout(self.diff_temp)
        self.lb_diff_temp_value = QtWidgets.QLabel(self.diff_temp)
        self.lb_diff_temp_value.setText("    ")
        self.diff_temp_layout.addWidget(self.lb_diff_temp_value)
        self.lb_diff_temp = QtWidgets.QLabel(self.diff_temp)
        self.lb_diff_temp.setText("℃")
        self.diff_temp_layout.addWidget(self.lb_diff_temp)
        self.top_qscrollarea_layout.addWidget(self.diff_temp, 2, 1, 1, 1)

        self.sys_against = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.sys_against.setTitle("系统绝缘阻抗")
        self.sys_against_layout = QtWidgets.QHBoxLayout(self.sys_against)
        self.lb_sys_against_value = QtWidgets.QLabel(self.sys_against)
        self.lb_sys_against_value.setText("    ")
        self.sys_against_layout.addWidget(self.lb_sys_against_value)
        self.lb_sys_against = QtWidgets.QLabel(self.sys_against)
        self.lb_sys_against.setText("kΩ")
        self.sys_against_layout.addWidget(self.lb_sys_against)
        self.top_qscrollarea_layout.addWidget(self.sys_against, 2, 2, 1, 1)

        self.sys_p_against = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.sys_p_against.setTitle("系统正极绝缘阻抗")
        self.sys_p_against_layout = QtWidgets.QHBoxLayout(self.sys_p_against)
        self.lb_sys_p_against_value = QtWidgets.QLabel(self.sys_p_against)
        self.lb_sys_p_against_value.setText("    ")
        self.sys_p_against_layout.addWidget(self.lb_sys_p_against_value)
        self.lb_sys_p_against = QtWidgets.QLabel(self.sys_p_against)
        self.lb_sys_p_against.setText("kΩ")
        self.sys_p_against_layout.addWidget(self.lb_sys_p_against)
        self.top_qscrollarea_layout.addWidget(self.sys_p_against, 2, 3, 1, 1)

        self.sys_n_against = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.sys_n_against.setTitle("系统负极绝缘阻抗")
        self.sys_n_against_layout = QtWidgets.QHBoxLayout(self.sys_n_against)
        self.lb_sys_n_against_value = QtWidgets.QLabel(self.sys_n_against)
        self.lb_sys_n_against_value.setText("    ")
        self.sys_n_against_layout.addWidget(self.lb_sys_n_against_value)
        self.lb_sys_n_against = QtWidgets.QLabel(self.sys_n_against)
        self.lb_sys_n_against.setText("kΩ")
        self.sys_n_against_layout.addWidget(self.lb_sys_n_against)
        self.top_qscrollarea_layout.addWidget(self.sys_n_against, 2, 4, 1, 1)

        self.nom_cap = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.nom_cap.setTitle("标称容量")
        self.nom_cap_layout = QtWidgets.QHBoxLayout(self.nom_cap)
        self.lb_nom_cap_value = QtWidgets.QLabel(self.nom_cap)
        self.lb_nom_cap_value.setText("    ")
        self.nom_cap_layout.addWidget(self.lb_nom_cap_value)
        self.lb_nom_cap = QtWidgets.QLabel(self.nom_cap)
        self.lb_nom_cap.setText("Ah")
        self.nom_cap_layout.addWidget(self.lb_nom_cap)
        self.top_qscrollarea_layout.addWidget(self.nom_cap, 2, 5, 1, 1)

        self.all_cap = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.all_cap.setTitle("总容量")
        self.all_cap_layout = QtWidgets.QHBoxLayout(self.all_cap)
        self.lb_all_cap_value = QtWidgets.QLabel(self.all_cap)
        self.lb_all_cap_value.setText("    ")
        self.all_cap_layout.addWidget(self.lb_all_cap_value)
        self.lb_all_cap = QtWidgets.QLabel(self.all_cap)
        self.lb_all_cap.setText("Ah")
        self.all_cap_layout.addWidget(self.lb_all_cap)
        self.top_qscrollarea_layout.addWidget(self.all_cap, 2, 6, 1, 1)

        self.left_cap = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.left_cap.setTitle("剩余容量")
        self.left_cap_layout = QtWidgets.QHBoxLayout(self.left_cap)
        self.lb_left_cap_value = QtWidgets.QLabel(self.left_cap)
        self.lb_left_cap_value.setText("    ")
        self.left_cap_layout.addWidget(self.lb_left_cap_value)
        self.lb_left_cap = QtWidgets.QLabel(self.left_cap)
        self.lb_left_cap.setText("Ah")
        self.left_cap_layout.addWidget(self.lb_left_cap)
        self.top_qscrollarea_layout.addWidget(self.left_cap, 2, 7, 1, 1)

        self.chg_kwh = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.chg_kwh.setTitle("累计充电能量")
        self.chg_kwh_layout = QtWidgets.QHBoxLayout(self.chg_kwh)
        self.lb_chg_kwh_value = QtWidgets.QLabel(self.chg_kwh)
        self.lb_chg_kwh_value.setText("    ")
        self.chg_kwh_layout.addWidget(self.lb_chg_kwh_value)
        self.lb_chg_kwh = QtWidgets.QLabel(self.chg_kwh)
        self.lb_chg_kwh.setText("kWh")
        self.chg_kwh_layout.addWidget(self.lb_chg_kwh)
        self.top_qscrollarea_layout.addWidget(self.chg_kwh, 2, 8, 1, 1)

        self.dchg_kwh = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.dchg_kwh.setTitle("累计放电能量")
        self.dchg_kwh_layout = QtWidgets.QHBoxLayout(self.dchg_kwh)
        self.lb_dchg_kwh_value = QtWidgets.QLabel(self.dchg_kwh)
        self.lb_dchg_kwh_value.setText("    ")
        self.dchg_kwh_layout.addWidget(self.lb_dchg_kwh_value)
        self.lb_dchg_kwh = QtWidgets.QLabel(self.dchg_kwh)
        self.lb_dchg_kwh.setText("kWh")
        self.dchg_kwh_layout.addWidget(self.lb_dchg_kwh)
        self.top_qscrollarea_layout.addWidget(self.dchg_kwh, 2, 9, 1, 1)

        self.chg_kw = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.chg_kw.setTitle("当前允许充电功率")
        self.chg_kw_layout = QtWidgets.QHBoxLayout(self.chg_kw)
        self.lb_chg_kw_value = QtWidgets.QLabel(self.chg_kw)
        self.lb_chg_kw_value.setText("    ")
        self.chg_kw_layout.addWidget(self.lb_chg_kw_value)
        self.lb_chg_kw = QtWidgets.QLabel(self.chg_kw)
        self.lb_chg_kw.setText("kW")
        self.chg_kw_layout.addWidget(self.lb_chg_kw)
        self.top_qscrollarea_layout.addWidget(self.chg_kw, 3, 0, 1, 1)

        self.dchg_kw = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.dchg_kw.setTitle("当前允许放电功率")
        self.dchg_kw_layout = QtWidgets.QHBoxLayout(self.dchg_kw)
        self.lb_dchg_kw_value = QtWidgets.QLabel(self.dchg_kw)
        self.lb_dchg_kw_value.setText("    ")
        self.dchg_kw_layout.addWidget(self.lb_dchg_kw_value)
        self.lb_dchg_kw = QtWidgets.QLabel(self.dchg_kw)
        self.lb_dchg_kw.setText("kW")
        self.dchg_kw_layout.addWidget(self.lb_dchg_kw)
        self.top_qscrollarea_layout.addWidget(self.dchg_kw, 3, 1, 1, 1)

        self.max_chg_vol = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.max_chg_vol.setTitle("当前允许最大充电电压")
        self.max_chg_vol_layout = QtWidgets.QHBoxLayout(self.max_chg_vol)
        self.lb_max_chg_vol_value = QtWidgets.QLabel(self.max_chg_vol)
        self.lb_max_chg_vol_value.setText("    ")
        self.max_chg_vol_layout.addWidget(self.lb_max_chg_vol_value)
        self.lb_max_chg_vol = QtWidgets.QLabel(self.max_chg_vol)
        self.lb_max_chg_vol.setText("V")
        self.max_chg_vol_layout.addWidget(self.lb_max_chg_vol)
        self.top_qscrollarea_layout.addWidget(self.max_chg_vol, 3, 2, 1, 1)

        self.max_chg_cur = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.max_chg_cur.setTitle("当前允许最大充电电流")
        self.max_chg_cur_layout = QtWidgets.QHBoxLayout(self.max_chg_cur)
        self.lb_max_chg_cur_value = QtWidgets.QLabel(self.max_chg_cur)
        self.lb_max_chg_cur_value.setText("    ")
        self.max_chg_cur_layout.addWidget(self.lb_max_chg_cur_value)
        self.lb_max_chg_cur = QtWidgets.QLabel(self.max_chg_cur)
        self.lb_max_chg_cur.setText("A")
        self.max_chg_cur_layout.addWidget(self.lb_max_chg_cur)
        self.top_qscrollarea_layout.addWidget(self.max_chg_cur, 3, 3, 1, 1)

        self.max_dchg_cur = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.max_dchg_cur.setTitle("当前允许最大放电电流")
        self.max_dchg_cur_layout = QtWidgets.QHBoxLayout(self.max_dchg_cur)
        self.lb_max_dchg_cur_value = QtWidgets.QLabel(self.max_dchg_cur)
        self.lb_max_dchg_cur_value.setText("    ")
        self.max_dchg_cur_layout.addWidget(self.lb_max_dchg_cur_value)
        self.lb_max_dchg_cur = QtWidgets.QLabel(self.max_dchg_cur)
        self.lb_max_dchg_cur.setText("A")
        self.max_dchg_cur_layout.addWidget(self.lb_max_dchg_cur)
        self.top_qscrollarea_layout.addWidget(self.max_dchg_cur, 3, 4, 1, 1)

        self.max_dchg_vol = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.max_dchg_vol.setTitle("当前允许放电限制电压")
        self.max_dchg_vol_layout = QtWidgets.QHBoxLayout(self.max_dchg_vol)
        self.lb_max_dchg_vol_value = QtWidgets.QLabel(self.max_dchg_vol)
        self.lb_max_dchg_vol_value.setText("    ")
        self.max_dchg_vol_layout.addWidget(self.lb_max_dchg_vol_value)
        self.lb_max_dchg_vol = QtWidgets.QLabel(self.max_dchg_vol)
        self.lb_max_dchg_vol.setText("V")
        self.max_dchg_vol_layout.addWidget(self.lb_max_dchg_vol)

        self.sum_vol = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.sum_vol.setTitle("单体累加电压和")
        self.sum_vol_layout = QtWidgets.QHBoxLayout(self.sum_vol)
        self.lb_sum_vol_value = QtWidgets.QLabel(self.sum_vol)
        self.lb_sum_vol_value.setText("    ")
        self.sum_vol_layout.addWidget(self.lb_sum_vol_value)
        self.lb_sum_vol = QtWidgets.QLabel(self.sum_vol)
        self.lb_sum_vol.setText("V")
        self.sum_vol_layout.addWidget(self.lb_sum_vol)
        self.top_qscrollarea_layout.addWidget(self.sum_vol, 3, 5, 1, 1)

        self.tv_2 = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tv_2.setTitle("总压2")
        self.tv_2_layout = QtWidgets.QHBoxLayout(self.tv_2)
        self.lb_tv_2_value = QtWidgets.QLabel(self.tv_2)
        self.lb_tv_2_value.setText("    ")
        self.tv_2_layout.addWidget(self.lb_tv_2_value)
        self.lb_tv_2 = QtWidgets.QLabel(self.tv_2)
        self.lb_tv_2.setText("V")
        self.tv_2_layout.addWidget(self.lb_tv_2)
 

        self.tv_3 = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.tv_3.setTitle("总压3")
        self.tv_3_layout = QtWidgets.QHBoxLayout(self.tv_3)
        self.lb_tv_3_value = QtWidgets.QLabel(self.tv_3)
        self.lb_tv_3_value.setText("    ")
        self.tv_3_layout.addWidget(self.lb_tv_3_value)
        self.lb_tv_3 = QtWidgets.QLabel(self.tv_3)
        self.lb_tv_3.setText("V")
        self.tv_3_layout.addWidget(self.lb_tv_3)

        self.left_energy = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.left_energy.setTitle("系统剩余能量")
        self.left_energy_layout = QtWidgets.QHBoxLayout(self.left_energy)
        self.lb_left_energy_value = QtWidgets.QLabel(self.left_energy)
        self.lb_left_energy_value.setText("    ")
        self.left_energy_layout.addWidget(self.lb_left_energy_value)
        self.lb_left_energy = QtWidgets.QLabel(self.left_energy)
        self.lb_left_energy.setText("kWh")
        self.left_energy_layout.addWidget(self.lb_left_energy)
        self.top_qscrollarea_layout.addWidget(self.left_energy, 4, 0, 1, 1)

        self.nowday_chg_energy = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.nowday_chg_energy.setTitle("当天累计充电能量")
        self.nowday_chg_energy_layout = QtWidgets.QHBoxLayout(self.nowday_chg_energy)
        self.lb_nowday_chg_energy_value = QtWidgets.QLabel(self.nowday_chg_energy)
        self.lb_nowday_chg_energy_value.setText("    ")
        self.nowday_chg_energy_layout.addWidget(self.lb_nowday_chg_energy_value)
        self.lb_nowday_chg_energy = QtWidgets.QLabel(self.nowday_chg_energy)
        self.lb_nowday_chg_energy.setText("kWh")
        self.nowday_chg_energy_layout.addWidget(self.lb_nowday_chg_energy)
        self.top_qscrollarea_layout.addWidget(self.nowday_chg_energy, 4, 1, 1, 1)

        self.nowday_dchg_energy = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.nowday_dchg_energy.setTitle("当天累计放电能量")
        self.nowday_dchg_energy_layout = QtWidgets.QHBoxLayout(self.nowday_dchg_energy)
        self.lb_nowday_dchg_energy_value = QtWidgets.QLabel(self.nowday_dchg_energy)
        self.lb_nowday_dchg_energy_value.setText("    ")
        self.nowday_dchg_energy_layout.addWidget(self.lb_nowday_dchg_energy_value)
        self.lb_nowday_dchg_energy = QtWidgets.QLabel(self.nowday_dchg_energy)
        self.lb_nowday_dchg_energy.setText("kWh")
        self.nowday_dchg_energy_layout.addWidget(self.lb_nowday_dchg_energy)
        self.top_qscrollarea_layout.addWidget(self.nowday_dchg_energy, 4, 2, 1, 1)

        self.circle_num = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.circle_num.setTitle("循环次数")
        self.circle_num_layout = QtWidgets.QHBoxLayout(self.circle_num)
        self.lb_circle_num_value = QtWidgets.QLabel(self.circle_num)
        self.lb_circle_num_value.setText("    ")
        self.circle_num_layout.addWidget(self.lb_circle_num_value)
        self.lb_circle_num = QtWidgets.QLabel(self.circle_num)
        self.lb_circle_num.setText("")
        self.circle_num_layout.addWidget(self.lb_circle_num)
        self.top_qscrollarea_layout.addWidget(self.circle_num, 4, 3, 1, 1)

        self.gdcy_vol = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.gdcy_vol.setTitle("供电采样电压")
        self.gdcy_vol_layout = QtWidgets.QHBoxLayout(self.gdcy_vol)
        self.lb_gdcy_vol_value = QtWidgets.QLabel(self.gdcy_vol)
        self.lb_gdcy_vol_value.setText("    ")
        self.gdcy_vol_layout.addWidget(self.lb_gdcy_vol_value)
        self.lb_gdcy_vol = QtWidgets.QLabel(self.gdcy_vol)
        self.lb_gdcy_vol.setText("V")
        self.gdcy_vol_layout.addWidget(self.lb_gdcy_vol)
        self.top_qscrollarea_layout.addWidget(self.gdcy_vol, 4, 4, 1, 1)

        self.jz_temp_high = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.jz_temp_high.setTitle("最高极柱温度")
        self.jz_temp_high_layout = QtWidgets.QHBoxLayout(self.jz_temp_high)
        self.lb_jz_temp_high_value = QtWidgets.QLabel(self.jz_temp_high)
        self.lb_jz_temp_high_value.setText("    ")
        self.jz_temp_high_layout.addWidget(self.lb_jz_temp_high_value)
        self.lb_jz_temp_high = QtWidgets.QLabel(self.jz_temp_high)
        self.lb_jz_temp_high.setText("℃")
        self.jz_temp_high_layout.addWidget(self.lb_jz_temp_high)

        self.jz_temp_high_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.jz_temp_high_index.setTitle("最高极柱温度编号")
        self.jz_temp_high_index_layout = QtWidgets.QHBoxLayout(self.jz_temp_high_index)
        self.lb_jz_temp_high_index_value = QtWidgets.QLabel(self.jz_temp_high_index)
        self.lb_jz_temp_high_index_value.setText("    ")
        self.jz_temp_high_index_layout.addWidget(self.lb_jz_temp_high_index_value)
        self.lb_jz_temp_high_index = QtWidgets.QLabel(self.jz_temp_high_index)
        self.lb_jz_temp_high_index.setText("")
        self.jz_temp_high_index_layout.addWidget(self.lb_jz_temp_high_index)

        self.bcu_temp_high = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.bcu_temp_high.setTitle("最高极柱温度")
        self.bcu_temp_high_layout = QtWidgets.QHBoxLayout(self.bcu_temp_high)
        self.lb_bcu_temp_high_value = QtWidgets.QLabel(self.bcu_temp_high)
        self.lb_bcu_temp_high_value.setText("    ")
        self.bcu_temp_high_layout.addWidget(self.lb_bcu_temp_high_value)
        self.lb_bcu_temp_high = QtWidgets.QLabel(self.bcu_temp_high)
        self.lb_bcu_temp_high.setText("℃")
        self.bcu_temp_high_layout.addWidget(self.lb_bcu_temp_high)

        self.bcu_temp_high_index = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.bcu_temp_high_index.setTitle("最高极柱温度编号")
        self.bcu_temp_high_index_layout = QtWidgets.QHBoxLayout(self.bcu_temp_high_index)
        self.lb_bcu_temp_high_index_value = QtWidgets.QLabel(self.bcu_temp_high_index)
        self.lb_bcu_temp_high_index_value.setText("    ")
        self.bcu_temp_high_index_layout.addWidget(self.lb_bcu_temp_high_index_value)
        self.lb_bcu_temp_high_index = QtWidgets.QLabel(self.bcu_temp_high_index)
        self.lb_bcu_temp_high_index.setText("")
        self.bcu_temp_high_index_layout.addWidget(self.lb_bcu_temp_high_index)

        self.mos_temp_1 = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.mos_temp_1.setTitle("MOS温度1")
        self.mos_temp_1_layout = QtWidgets.QHBoxLayout(self.mos_temp_1)
        self.lb_mos_temp_1_value = QtWidgets.QLabel(self.mos_temp_1)
        self.lb_mos_temp_1_value.setText("    ")
        self.mos_temp_1_layout.addWidget(self.lb_mos_temp_1_value)
        self.lb_mos_temp_1 = QtWidgets.QLabel(self.mos_temp_1)
        self.lb_mos_temp_1.setText("℃")
        self.mos_temp_1_layout.addWidget(self.lb_mos_temp_1)

        self.mos_temp_2 = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.mos_temp_2.setTitle("MOS温度2")
        self.mos_temp_2_layout = QtWidgets.QHBoxLayout(self.mos_temp_2)
        self.lb_mos_temp_2_value = QtWidgets.QLabel(self.mos_temp_2)
        self.lb_mos_temp_2_value.setText("    ")
        self.mos_temp_2_layout.addWidget(self.lb_mos_temp_2_value)
        self.lb_mos_temp_2 = QtWidgets.QLabel(self.mos_temp_2)
        self.lb_mos_temp_2.setText("℃")
        self.mos_temp_2_layout.addWidget(self.lb_mos_temp_2)

        self.soc_high = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.soc_high.setTitle("最高单体SOC")
        self.soc_high_layout = QtWidgets.QHBoxLayout(self.soc_high)
        self.lb_soc_high_value = QtWidgets.QLabel(self.soc_high)
        self.lb_soc_high_value.setText("    ")
        self.soc_high_layout.addWidget(self.lb_soc_high_value)
        self.lb_soc_high = QtWidgets.QLabel(self.soc_high)
        self.lb_soc_high.setText("")
        self.soc_high_layout.addWidget(self.lb_soc_high)

        self.soc_low = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.soc_low.setTitle("最低单体SOC")
        self.soc_low_layout = QtWidgets.QHBoxLayout(self.soc_low)
        self.lb_soc_low_value = QtWidgets.QLabel(self.soc_low)
        self.lb_soc_low_value.setText("    ")
        self.soc_low_layout.addWidget(self.lb_soc_low_value)
        self.lb_soc_low = QtWidgets.QLabel(self.soc_low)
        self.lb_soc_low.setText("")
        self.soc_low_layout.addWidget(self.lb_soc_low)

        self.soc_avg = QtWidgets.QGroupBox(self.top_qscrollarea)
        self.soc_avg.setTitle("平均单体SOC")
        self.soc_avg_layout = QtWidgets.QHBoxLayout(self.soc_avg)
        self.lb_soc_avg_value = QtWidgets.QLabel(self.soc_avg)
        self.lb_soc_avg_value.setText("    ")
        self.soc_avg_layout.addWidget(self.lb_soc_avg_value)
        self.lb_soc_avg = QtWidgets.QLabel(self.soc_avg)
        self.lb_soc_avg.setText("")
        self.soc_avg_layout.addWidget(self.lb_soc_avg)

        if SD.CCU_TYPE == 1:
            self.top_qscrollarea_layout.addWidget(self.tv_2, 3, 6, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.tv_3, 3, 7, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.jz_temp_high, 4, 5, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.jz_temp_high_index, 4, 6, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.bcu_temp_high, 4, 7, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.bcu_temp_high_index, 4, 8, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.mos_temp_1, 4, 9, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.mos_temp_2, 5, 0, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.soc_high, 5, 1, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.soc_low, 5, 2, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.soc_avg, 5, 3, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.max_dchg_vol, 5, 4, 1, 1)
            self.nom_energy = QtWidgets.QGroupBox(self.top_qscrollarea)
            self.nom_energy.setTitle("系统标称能量")
            self.nom_energy_layout = QtWidgets.QHBoxLayout(self.nom_energy)
            self.lb_nom_energy_value = QtWidgets.QLabel(self.nom_energy)
            self.lb_nom_energy_value.setText("    ")
            self.nom_energy_layout.addWidget(self.lb_nom_energy_value)
            self.lb_nom_energy = QtWidgets.QLabel(self.nom_energy)
            self.lb_nom_energy.setText("kWh")
            self.nom_energy_layout.addWidget(self.lb_nom_energy)
            self.top_qscrollarea_layout.addWidget(self.nom_energy, 3, 8, 1, 1)

            self.all_energy = QtWidgets.QGroupBox(self.top_qscrollarea)
            self.all_energy.setTitle("系统总能量")
            self.all_energy_layout = QtWidgets.QHBoxLayout(self.all_energy)
            self.lb_all_energy_value = QtWidgets.QLabel(self.all_energy)
            self.lb_all_energy_value.setText("    ")
            self.all_energy_layout.addWidget(self.lb_all_energy_value)
            self.lb_all_energy = QtWidgets.QLabel(self.all_energy)
            self.lb_all_energy.setText("kWh")
            self.all_energy_layout.addWidget(self.lb_all_energy)
            self.top_qscrollarea_layout.addWidget(self.all_energy, 3, 9, 1, 1)
        else:
            self.tv_2.setHidden(True)
            self.tv_3.setHidden(True)
            self.jz_temp_high.setHidden(True)
            self.jz_temp_high_index.setHidden(True)
            self.bcu_temp_high.setHidden(True)
            self.bcu_temp_high_index.setHidden(True)
            self.nom_energy = QtWidgets.QGroupBox(self.top_qscrollarea)
            self.nom_energy.setTitle("系统标称能量")
            self.nom_energy_layout = QtWidgets.QHBoxLayout(self.nom_energy)
            self.lb_nom_energy_value = QtWidgets.QLabel(self.nom_energy)
            self.lb_nom_energy_value.setText("    ")
            self.nom_energy_layout.addWidget(self.lb_nom_energy_value)
            self.lb_nom_energy = QtWidgets.QLabel(self.nom_energy)
            self.lb_nom_energy.setText("kWh")
            self.nom_energy_layout.addWidget(self.lb_nom_energy)
            self.top_qscrollarea_layout.addWidget(self.nom_energy, 3, 6, 1, 1)

            self.all_energy = QtWidgets.QGroupBox(self.top_qscrollarea)
            self.all_energy.setTitle("系统总能量")
            self.all_energy_layout = QtWidgets.QHBoxLayout(self.all_energy)
            self.lb_all_energy_value = QtWidgets.QLabel(self.all_energy)
            self.lb_all_energy_value.setText("    ")
            self.all_energy_layout.addWidget(self.lb_all_energy_value)
            self.lb_all_energy = QtWidgets.QLabel(self.all_energy)
            self.lb_all_energy.setText("kWh")
            self.all_energy_layout.addWidget(self.lb_all_energy)
            self.top_qscrollarea_layout.addWidget(self.all_energy, 3, 7, 1, 1)

            self.top_qscrollarea_layout.addWidget(self.mos_temp_1, 3, 8, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.mos_temp_2, 3, 9, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.soc_high, 4, 5, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.soc_low, 4, 6, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.soc_avg, 4, 7, 1, 1)
            self.top_qscrollarea_layout.addWidget(self.max_dchg_vol, 4, 8, 1, 1)
        self.top_layout.addWidget(self.top_groupbox)
        self.verticalLayout.addWidget(self.top_widget)
