BatteryMonitor/mainwindow.cpp

4002 lines
194 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "mainwindow.h"
#include "modbus-private.h"
#include "ui_mainwindow.h"
#include "appproto.h"
#include "appproto_english.h"
#include "delegate.h"
#include <QApplication>
#include <QTranslator>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QSettings>
#include <QLabel>
#include <QDebug>
#include <QTime>
#include <QTreeView>
#include <QStandardItem>
#include <QStandardItemModel>
#include "proto/battery.pb.h"
#include "proto/battery_english.pb.h"
#include "chartpaint.h"
#include <fstream>
#include <QToolTip>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMetaType>
#include <QTreeView>
#include "modbusrtu.h"
#include <QWidget>
#include <QCloseEvent>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->init();
this->setMenuStyle();
m_AppProto = new AppProto;
m_AppProto_English = new Appproto_English;
connect(ui->tabWidget_paraset, SIGNAL(currentChanged(int)), this, SLOT(on_tabChanged(int)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::init()
{
/* 设置标题 */
setWindowTitle("Battery Monitor");
/* 设置Logo */
setWindowIcon(QIcon(":/Image/icon.png"));
// this->showMaximized();
/* 读取配置文件 */
ini = new QSettings("config.ini", QSettings::IniFormat);
if(QFile::exists("config.ini")) {
/* 状态栏显示 */
if(ini->value("Window/ShowStatusbar") == "true") {
statusBar()->show();
ui->actionShow_Status_bar->setChecked(true);
}
else {
statusBar()->hide();
ui->actionShow_Status_bar->setChecked(false);
}
}
else{
ini->setValue("System/Language", LANGUAGE_ENG);
ini->setValue("Window/ShowStatusbar", true);
ini->sync();
}
/* 设置初始界面语言 */
if(ini->value("System/Language") == LANGUAGE_ENG) {
QTranslator trans;
qDebug() << "ini in the mainwindow :" << ini->value("System/Language");
trans.load(":/Language/BatteryMonitor_ENG.qm");
QApplication::installTranslator(&trans);
ui->retranslateUi(this);
}
else if(ini->value("System/Language") == LANGUAGE_CHN) {
qDebug() << "ini in the mainwindow :" << ini->value("System/Language");
QTranslator trans;
trans.load(":/Language/BatteryMonitor_CHN.qm");
QApplication::installTranslator(&trans);
ui->retranslateUi(this);
}
// connect(ui->actionChinese, &QAction::triggered, this, [=]{
// ini->setValue("System/Language", LANGUAGE_CHN);
// ini->sync();
// QTranslator trans;
// trans.load(":/Language/BatteryMonitor_CHN.qm");
// QApplication::installTranslator(&trans);
// ui->retranslateUi(this);
// });
// connect(ui->actionEnglish, &QAction::triggered, this, [=]{
// ini->setValue("System/Language", LANGUAGE_ENG);
// ini->sync();
// QTranslator trans;
// trans.load(":/Language/BatteryMonitor_ENG.qm");
// QApplication::installTranslator(&trans);
// ui->retranslateUi(this);
// });
/* 状态栏设置 */
statusBarConnectedIcon = new QLabel();
statusBarConnectedType = new QLabel();
statusBarCompany = new QLabel();
statusBarConnectedIcon->setPixmap(QPixmap(QIcon(":/Image/connected1.png").pixmap(QSize(24, 24))));
statusBarConnectedType->setText("RS485");
statusBarCompany->setText("BLUESUN");
ui->statusbar->addWidget(statusBarConnectedIcon);
ui->statusbar->addWidget(statusBarConnectedType);
ui->statusbar->addPermanentWidget(statusBarCompany);
/* 菜单栏设置 */
connect(ui->actionExit, &QAction::triggered, this, [=]{
this->close();
});
connect(ui->actionConnect, &QAction::triggered, this, [=]{
});
connect(ui->actionDisconnect, &QAction::triggered, this, [=]{
});
connect(ui->actionAuto_Connect, &QAction::triggered, this, [=]{
});
connect(ui->actionShow_Status_bar, &QAction::triggered, this, [=]{
if(ini->value("Window/ShowStatusbar") == true) {
this->statusBar()->hide();
ui->actionShow_Status_bar->setChecked(false);
ini->setValue("Window/ShowStatusbar", false);
ini->sync();
}
else {
this->statusBar()->show();
ui->actionShow_Status_bar->setChecked(true);
ini->setValue("Window/ShowStatusbar", true);
ini->sync();
}
});
/* 设置初始页 */
ui->stackedWidget->setCurrentIndex(PAGE_HOME);
/* Debug页面槽函数 */
connect(ui->pageDebugBtnClear, &QPushButton::pressed, this, [=]{
ui->pageDebugTextBrowser->clear();
});
connect(ui->pageDebugCheckBoxSaveLog, &QCheckBox::stateChanged, this, [=]{
if(ui->pageDebugCheckBoxSaveLog->isChecked()) {
pageDebugLogFlag = true;
QString filename = QFileDialog::getSaveFileName(this, "Save log", "Communication log", "Log Files (*.txt);;All Files (*)");
logFile = new QFile(filename);
if (logFile->open(QIODevice::Append | QIODevice::Text)) {
}
}
else {
pageDebugLogFlag = false;
logFile->close();
}
});
//初始化batt
bat = new batt();
//初始化绘制柱状图
// chartPat = new ChartPaint();
// //电量充,电量放,时间充,时间放
// // int array[] = {20, 30, 12, 12};
// // int array1[] = {1000, 1200, 500, 600};
// // int array_day_chart[] = {base_info1_45[39], base_info1_45[41], base_info1_45[42], base_info1_45[43]};
// // QChartView *chartView = chartPat->Paint("日", array);
// // QChartView *chartView1 = chartPat->Paint("累计", array1);
// gridLayout = new QGridLayout();
// QHBoxLayout *hBoxLayout = new QHBoxLayout();
// hBoxLayout->addLayout(gridLayout);
// ui->tab_charts->setLayout(hBoxLayout);
//绘制单体表格
// sglChartInit(7);
// ui->groupBox_color_sgl->setStyleSheet("QGroupBox { border: none; }");
// ui->scrollArea_sgl_charts->setFrameShape(QFrame::NoFrame);
ui->scrollAreaChart->setFrameShape(QFrame::NoFrame);
ui->scrollAreaChart->setStyleSheet("background-color: #FFFFFF;"); //设置背景颜色为纯白色
ui->widgetControl->setStyleSheet("background-color: #FFFFFF;");
ui->groupBox->setStyleSheet("background-color: #FFFFFF;");
ui->groupBox_trouble_control->setStyleSheet("background-color: #FFFFFF;");
ui->groupBox_chart->setStyleSheet("background-color: #FFFFFF;");
ui->groupBox_class_color->setStyleSheet("QGroupBox { border: none; }");
ui->BCU_DIDO->setStyleSheet("background-color: #FFFFFF;");
ui->BCU_alarm->setStyleSheet("background-color: #FFFFFF;");
ui->BCU_statisInfo->setStyleSheet("background-color: #FFFFFF;");
ui->BCU_sysInfo->setStyleSheet("background-color: #FFFFFF;");
//设置按钮的提示文本
ui->btnHome->setToolTip("概述信息(Overview Information)");
ui->btnBattery->setToolTip("详细信息(Detailed Information)");
ui->btnParaSet->setToolTip("参数设置(Parameter Settings)");
ui->btnDebug->setToolTip("报文信息(Message Information)");
ui->btnFlash->setToolTip("升级调试(Upgrade Debugging)");
ui->btnSetup->setToolTip("串口信息(Serial Port)");
ui->btnSetup->setStyleSheet("QToolTip { position: absolute; left: 20px; top: 20px; }");
// ui->btnRecord->setToolTip("记录导出");
//设置初始颜色
// ui->close_color->setStyleSheet("QLabel{"
// "background-image: url(:/Image/trouble-background-normal.png);"
// "border: 1px solid gray;"
// "}");
// ui->open_color->setStyleSheet("QLabel{"
// "background-image: url(:/Image/trouble-background-default.png);"
// "border: 1px solid gray;"
// "}");
ui->relay_negative->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->relay_positive->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->relay_precharge->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->relay_disconnector->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->color_trouble_1->setStyleSheet("background-image: url(:/Image/trouble-background-1.png);");
ui->color_trouble_2->setStyleSheet("background-image: url(:/Image/trouble-background-2.png);");
ui->color_trouble_3->setStyleSheet("background-image: url(:/Image/trouble-background-3.png);");
ui->color_trouble_normal->setStyleSheet("background-image: url(:/Image/trouble-background-normal.png);");
// ui->color_sgl_high->setStyleSheet("background-color: rgb(255, 0, 0);");
// ui->color_sgl_low->setStyleSheet("background-color: rgb(0, 255, 0);");
// ui->color_equilibrium->setStyleSheet("background-color: rgb(0, 0, 200);");
// ui->color_short_circuit->setStyleSheet("background-color: rgb(255, 165, 0);");
// ui->groupBox_color_sgl->setStyleSheet("QGroupBox { border: none; }");
ui->label_all_overVol->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_all_underVol->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_sgl_overVol->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_sgl_underVol->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_sgl_overTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_sgl_underTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_over_diff_press->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_over_diff_tempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_over_curr->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_high_vol_trouble->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_mas_slave_com->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_sgl_vol_bar->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_sgl_tem_bar->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_over_soc->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_under_soc->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_insu_leak->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_adhesion->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_prechg_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_over_supply->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_under_supply->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_T1_highTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_T1_underTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_T2_highTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_T2_underTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_balance_overTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_reserve1->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_highVol_lock->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_curr_trouble->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_pole_highTempt->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_reserve2->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_reserve3->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_PCS_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_EMS_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_fuse_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_ang_fe_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_EEPROM_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_RTC_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_ADC_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_SD_status->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_feedback_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_heating_overFast->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_limit_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_open_cir_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_epo_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_fire_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_con_ins_overtime->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_reserve4->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_hot_out_of_con->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_bat_box_overVol->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_bat_box_underVol->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_ligntning_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_AC_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_UPS_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_water_flooding_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_guard_worng->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
ui->label_gas_det_wrong->setStyleSheet("QLabel{"
"background-image: url(:/Image/trouble-background-default.png);"
"border: 1px solid gray;"
"}");
// QStandardItemModel *model = new QStandardItemModel(ui->treeViewBCUbmu);
// // 创建一级目录项
// QStandardItem *rootItem = new QStandardItem("BCU01");
// // 设置一级目录项的字体为加粗
// QFont boldFont = rootItem->font();
// boldFont.setBold(true);
// rootItem->setFont(boldFont);
// model->appendRow(rootItem);
// ui->tabWidgetBCU->setCurrentIndex(0);
// ui->tabWidgetBMU->setCurrentIndex(0);
// connect(ui->treeViewBCUbmu, &QTreeView::clicked, [=](const QModelIndex index){
// if(index.parent().isValid())
// {
// qDebug() << "BMU" << index.column() << index.row();
// ui->pageBatteryStackWidget->setCurrentIndex(1);
// }
// else
// {
// qDebug() << "BCU" << index.column() << index.row();
// ui->pageBatteryStackWidget->setCurrentIndex(0);
// }
// });
// for (int i = 1; i <= 26; ++i) {
// QString bmuName = QString("BMU%1").arg(i);
// QStandardItem *bmuItem = new QStandardItem(bmuName);
// rootItem->appendRow(bmuItem);
// }
// ui->treeViewBCUbmu->setModel(model);
// ui->treeViewBCUbmu->setHeaderHidden(true);
// ui->treeViewBCUbmu->setAnimated(true);
// ui->treeViewBCUbmu->expandAll();
// ui->treeViewBCUbmu->setEditTriggers(QAbstractItemView::NoEditTriggers);
// ui->treeViewBCUbmu->show();
}
void MainWindow::sglChartInit(int bat_count)
{
// ui->tabWidget_sgl_info->setCurrentWidget(ui->tab_vol);
QStringList labels = {
"Bmu", "C1", "C2",
"C3", "C4", "C5", "C6", "C7",
"C8", "C9", "C10", "C11", "C12",
"C13", "C14", "C15", "C16",
};
//单体电压
QTableWidget *page_paraset_sys_sgl_vol = new QTableWidget(bat_count, 17);
page_paraset_sys_sgl_vol->horizontalHeader()->setDefaultSectionSize(40);
page_paraset_sys_sgl_vol->verticalHeader()->setDefaultSectionSize(30);
page_paraset_sys_sgl_vol->verticalHeader()->setVisible(false);
page_paraset_sys_sgl_vol->setHorizontalHeaderLabels(QStringList(labels));
//row的索引比row的值要小1
for (int row = 0; row < page_paraset_sys_sgl_vol->rowCount(); ++row) {
for (int col = 0; col < page_paraset_sys_sgl_vol->columnCount(); ++col) {
if (col == 0)
{
QLabel *label = new QLabel(QString::number(row+1), this);
label->setAlignment(Qt::AlignCenter);
QFont font("黑体", 10);
label->setFont(font);
label->setFixedSize(40, 30);
page_paraset_sys_sgl_vol->setCellWidget(row, col, label);
}
if(col >= 1)
{
QLabel *label = new QLabel(this);
labelListVol.append(label);
// QFont font("黑体", 10);
// label->setFont(font);
label->setFixedSize(40, 30);
page_paraset_sys_sgl_vol->setCellWidget(row, col, label);
}
}
}
//单体温度
QTableWidget *page_paraset_sys_sgl_temp = new QTableWidget(bat_count, 17);
page_paraset_sys_sgl_temp->horizontalHeader()->setDefaultSectionSize(40);
page_paraset_sys_sgl_temp->verticalHeader()->setDefaultSectionSize(30);
page_paraset_sys_sgl_temp->verticalHeader()->setVisible(false);
page_paraset_sys_sgl_temp->setHorizontalHeaderLabels(QStringList(labels));
//row的索引比row的值要小1
for (int row = 0; row < page_paraset_sys_sgl_temp->rowCount(); ++row) {
for (int col = 0; col < page_paraset_sys_sgl_temp->columnCount(); ++col) {
if (col == 0)
{
QLabel *label = new QLabel(QString::number(row+1), this);
label->setAlignment(Qt::AlignCenter);
QFont font("黑体", 10);
label->setFont(font);
label->setFixedSize(40, 30);
page_paraset_sys_sgl_temp->setCellWidget(row, col, label);
}
if(col >= 1)
{
QLabel *label = new QLabel(this);
labelListTempt.append(label);
// QFont font("黑体", 10);
// label->setFont(font);
label->setFixedSize(40, 30);
page_paraset_sys_sgl_temp->setCellWidget(row, col, label);
}
}
}
QHBoxLayout *hBoxLayout_vol = new QHBoxLayout();
QHBoxLayout *hBoxLayout_tempt = new QHBoxLayout();
hBoxLayout_vol->addWidget(page_paraset_sys_sgl_vol);
hBoxLayout_tempt->addWidget(page_paraset_sys_sgl_temp);
// ui->tab_vol->setLayout(hBoxLayout_vol);
// ui->tab_tempt->setLayout(hBoxLayout_tempt);
}
void MainWindow::setMenuStyle()
{
/* 设置菜单按钮样式表 */
connect(ui->btnHome, &QPushButton::pressed, this, [=]{
ui->stackedWidget->setCurrentIndex(PAGE_HOME);
ui->btnHome->setStyleSheet("#btnHome{"
"background-image: url(:/Image/home2.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnBattery->setStyleSheet("#btnBattery{"
"background-image: url(:/Image/battery.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnBattery::hover{"
"background-image: url(:/Image/battery1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
);
ui->btnParaSet->setStyleSheet("#btnParaSet{"
"background-image: url(:/Image/paraSet.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnParaSet::hover{"
"background-image: url(:/Image/paraSet1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnDebug->setStyleSheet("#btnDebug{"
"background-image: url(:/Image/debug.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnDebug::hover{"
"background-image: url(:/Image/debug1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnFlash->setStyleSheet("#btnFlash{"
"background-image: url(:/Image/hardware-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnFlash::hover{"
"background-image: url(:/Image/hardware-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnSetup->setStyleSheet("#btnSetup{"
"background-image: url(:/Image/advance-set-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnSetup::hover{"
"background-image: url(:/Image/advance-set-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
// ui->btnRecord->setStyleSheet("#btnRecord{"
// "background-image: url(:/Image/record-out-black.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnRecord::hover{"
// "background-image: url(:/Image/record-out-gray.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
});
connect(ui->btnBattery, &QPushButton::pressed, this, [=]{
ui->stackedWidget->setCurrentIndex(PAGE_BATTERY);
ui->btnBattery->setStyleSheet("#btnBattery{"
"background-image: url(:/Image/battery2.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnHome->setStyleSheet("#btnHome{"
"background-image: url(:/Image/home.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnHome::hover{"
"background-image: url(:/Image/home1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnParaSet->setStyleSheet("#btnParaSet{"
"background-image: url(:/Image/paraSet.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnParaSet::hover{"
"background-image: url(:/Image/paraSet1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnDebug->setStyleSheet("#btnDebug{"
"background-image: url(:/Image/debug.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnDebug::hover{"
"background-image: url(:/Image/debug1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnFlash->setStyleSheet("#btnFlash{"
"background-image: url(:/Image/hardware-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnFlash::hover{"
"background-image: url(:/Image/hardware-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnSetup->setStyleSheet("#btnSetup{"
"background-image: url(:/Image/advance-set-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnSetup::hover{"
"background-image: url(:/Image/advance-set-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
// ui->btnRecord->setStyleSheet("#btnRecord{"
// "background-image: url(:/Image/record-out-black.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnRecord::hover{"
// "background-image: url(:/Image/record-out-gray.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
});
connect(ui->btnParaSet, &QPushButton::pressed, this, [=]{
ui->stackedWidget->setCurrentIndex(PAGE_PARASET);
ui->btnParaSet->setStyleSheet("#btnParaSet{"
"background-image: url(:/Image/paraSet2.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnHome->setStyleSheet("#btnHome{"
"background-image: url(:/Image/home.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnHome::hover{"
"background-image: url(:/Image/home1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnBattery->setStyleSheet("#btnBattery{"
"background-image: url(:/Image/battery.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnBattery::hover{"
"background-image: url(:/Image/battery1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnDebug->setStyleSheet("#btnDebug{"
"background-image: url(:/Image/debug.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnDebug::hover{"
"background-image: url(:/Image/debug1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnFlash->setStyleSheet("#btnFlash{"
"background-image: url(:/Image/hardware-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnFlash::hover{"
"background-image: url(:/Image/hardware-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnSetup->setStyleSheet("#btnSetup{"
"background-image: url(:/Image/advance-set-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnSetup::hover{"
"background-image: url(:/Image/advance-set-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
// ui->btnRecord->setStyleSheet("#btnRecord{"
// "background-image: url(:/Image/record-out-black.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnRecord::hover{"
// "background-image: url(:/Image/record-out-gray.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
});
connect(ui->btnDebug, &QPushButton::pressed, this, [=]{
ui->stackedWidget->setCurrentIndex(PAGE_DEBUG);
ui->btnDebug->setStyleSheet("#btnDebug{"
"background-image: url(:/Image/debug2.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnHome->setStyleSheet("#btnHome{"
"background-image: url(:/Image/home.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnHome::hover{"
"background-image: url(:/Image/home1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnBattery->setStyleSheet("#btnBattery{"
"background-image: url(:/Image/battery.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnBattery::hover{"
"background-image: url(:/Image/battery1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnParaSet->setStyleSheet("#btnParaSet{"
"background-image: url(:/Image/paraSet.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnParaSet::hover{"
"background-image: url(:/Image/paraSet1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnFlash->setStyleSheet("#btnFlash{"
"background-image: url(:/Image/hardware-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnFlash::hover{"
"background-image: url(:/Image/hardware-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnSetup->setStyleSheet("#btnSetup{"
"background-image: url(:/Image/advance-set-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnSetup::hover{"
"background-image: url(:/Image/advance-set-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
// ui->btnRecord->setStyleSheet("#btnRecord{"
// "background-image: url(:/Image/record-out-black.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnRecord::hover{"
// "background-image: url(:/Image/record-out-gray.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
});
connect(ui->btnFlash, &QPushButton::pressed, this, [=]{
ui->stackedWidget->setCurrentIndex(PAGE_FLASH);
ui->btnFlash->setStyleSheet("#btnFlash{"
"background-image: url(:/Image/hardware-line2.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnHome->setStyleSheet("#btnHome{"
"background-image: url(:/Image/home.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnHome::hover{"
"background-image: url(:/Image/home1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnBattery->setStyleSheet("#btnBattery{"
"background-image: url(:/Image/battery.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnBattery::hover{"
"background-image: url(:/Image/battery1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnParaSet->setStyleSheet("#btnParaSet{"
"background-image: url(:/Image/paraSet.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnParaSet::hover{"
"background-image: url(:/Image/paraSet1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnDebug->setStyleSheet("#btnDebug{"
"background-image: url(:/Image/debug.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnDebug::hover{"
"background-image: url(:/Image/debug1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
ui->btnSetup->setStyleSheet("#btnSetup{"
"background-image: url(:/Image/advance-set-line.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}"
"#btnSetup::hover{"
"background-image: url(:/Image/advance-set-line1.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
// ui->btnRecord->setStyleSheet("#btnRecord{"
// "background-image: url(:/Image/record-out-black.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnRecord::hover{"
// "background-image: url(:/Image/record-out-gray.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
});
// connect(ui->btnRecord, &QPushButton::pressed, this, [=]{
// ui->stackedWidget->setCurrentWidget(ui->pageRecord);
// ui->btnRecord->setStyleSheet("#btnRecord{"
// "background-image: url(:/Image/record-out-green.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
// ui->btnHome->setStyleSheet("#btnHome{"
// "background-image: url(:/Image/home.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnHome::hover{"
// "background-image: url(:/Image/home1.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
// ui->btnBattery->setStyleSheet("#btnBattery{"
// "background-image: url(:/Image/battery.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnBattery::hover{"
// "background-image: url(:/Image/battery1.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// );
// ui->btnParaSet->setStyleSheet("#btnParaSet{"
// "background-image: url(:/Image/paraSet.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnParaSet::hover{"
// "background-image: url(:/Image/paraSet1.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
// ui->btnDebug->setStyleSheet("#btnDebug{"
// "background-image: url(:/Image/debug.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnDebug::hover{"
// "background-image: url(:/Image/debug1.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
// ui->btnFlash->setStyleSheet("#btnFlash{"
// "background-image: url(:/Image/hardware-line.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnFlash::hover{"
// "background-image: url(:/Image/hardware-line1.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
// ui->btnSetup->setStyleSheet("#btnSetup{"
// "background-image: url(:/Image/advance-set-line.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}"
// "#btnSetup::hover{"
// "background-image: url(:/Image/advance-set-line1.png);"
// "background-repeat: no-repeat;"
// "background-position: center;"
// "background-color: rgba(255, 255, 255, 0);"
// "}");
// });
connect(ui->btnSetup, &QPushButton::pressed, this, [=]{
emit showLogin();
ui->btnSetup->setStyleSheet("#btnSetup{"
"background-image: url(:/Image/advance-set-line2.png);"
"background-repeat: no-repeat;"
"background-position: center;"
"background-color: rgba(255, 255, 255, 0);"
"}");
});
ui->btn_close_neg->setStyleSheet("QPushButton { background-color: #87CEFA; color: white; }"
"QPushButton:hover { background-color: #77B5D6; color: white; }");
ui->btn_close_pos->setStyleSheet("QPushButton { background-color: #87CEFA; color: white; }"
"QPushButton:hover { background-color: #77B5D6; color: white; }");
ui->btn_close_prechg->setStyleSheet("QPushButton { background-color: #87CEFA; color: white; }"
"QPushButton:hover { background-color: #77B5D6; color: white; }");
ui->btn_open_prechg->setStyleSheet("QPushButton { background-color: #87CEFA; color: white; }"
"QPushButton:hover { background-color: #77B5D6; color: white; }");
ui->btn_open_neg->setStyleSheet("QPushButton { background-color: #87CEFA; color: white; }"
"QPushButton:hover { background-color: #77B5D6; color: white; }");
ui->btn_open_pos->setStyleSheet("QPushButton { background-color: #87CEFA; color: white; }"
"QPushButton:hover { background-color: #77B5D6; color: white; }");
}
void MainWindow::slot_pageDebugDisplayMessage(QByteArray byteArray, int dataType)
{
if(ui->pageDebugCheckBoxDisplay->isChecked() == true) {
QString timeStr = QString(QDateTime::currentDateTime().toString("[yyyy-MM-dd hh:mm:ss.zzz] "));
QString tmpStr;
QString showStr;
for(int i = 0; i < byteArray.size(); i++) {
tmpStr += QString("%1 ").arg((quint8)byteArray.at(i), 2, 16, QChar('0'));
// QString hexString = QString::number(tmpStr, 16);
// qDebug() << "recvdata:" << tmpStr.toInt(&ok, 16);
}
if(dataType == TypeRecvData) {
if(ui->pageDebugCheckBoxStarmp->isChecked()) {
showStr = timeStr + "<html><span body><span style=\"color:blue;\">Rx: </span></span body></html>" + tmpStr;
}
else {
showStr = "<html><span body><span style=\"color:blue;\">Rx: </span></span body></html>" + tmpStr;
}
if(pageDebugLogFlag == true) {
if(logFile->isOpen()) {
QTextStream textStream(logFile);
textStream << timeStr + "Rx: " + tmpStr + '\n';
}
}
}
else if(dataType == TypeSendData) {
if(ui->pageDebugCheckBoxStarmp->isChecked()) {
showStr = timeStr + "<html><span body><span style=\"color:orange;\">Tx: </span></span body></html>" + tmpStr;
}
else {
showStr = "<html><span body><span style=\"color:orange;\">Tx: </span></span body></html>" + tmpStr;
}
if(pageDebugLogFlag == true) {
if(logFile->isOpen()) {
QTextStream textStream(logFile);
textStream << timeStr + "Rx: " + tmpStr + '\n';
}
}
}
ui->pageDebugTextBrowser->append(showStr);
}
}
void MainWindow::slot_pageHomeSglDataMessage(QByteArray byteArray, int dataType)
{
if(dataType == TypeRecvData)
{
QList<int> result_int;
bool ok;
for (int i = 3; i < byteArray.size(); i += 2) {
quint8 firstByte = (i < byteArray.size())? byteArray.at(i) : 0;
quint8 secondByte = (i + 1 < byteArray.size())? byteArray.at(i + 1) : 0;
QString hexValue = QString("%1%2")
.arg(QString::number(firstByte, 16).rightJustified(2, '0'))
.arg(QString::number(secondByte, 16).rightJustified(2, '0'));
result_int += hexValue.toInt(&ok, 16);
}
sgl_vol_info = result_int;
sgl_vol_info.removeLast();
sgl_info_process(sgl_vol_info, labelListVol);
}
}
void MainWindow::slot_pageHomeSglTempt(QByteArray byteArray, int dataType)
{
if(dataType == TypeRecvData)
{
QList<int> result_int;
bool ok;
for (int i = 3; i < byteArray.size(); i += 2) {
quint8 firstByte = (i < byteArray.size())? byteArray.at(i) : 0;
quint8 secondByte = (i + 1 < byteArray.size())? byteArray.at(i + 1) : 0;
QString hexValue = QString("%1%2")
.arg(QString::number(firstByte, 16).rightJustified(2, '0'))
.arg(QString::number(secondByte, 16).rightJustified(2, '0'));
result_int += hexValue.toInt(&ok, 16);
}
sgl_tempt_info = result_int;
sgl_tempt_info.removeLast();
sgl_info_process(sgl_tempt_info, labelListTempt);
}
}
void MainWindow::slot_pageHomeBaseInfo1_45(QByteArray byteArray, int dataType)
{
if(dataType == TypeRecvData)
{
// qDebug() << "33333333333333333333333333333333";
QList<int> result_int;
bool ok;
for (int i = 3; i < byteArray.size(); i += 2) {
quint8 firstByte = (i < byteArray.size())? byteArray.at(i) : 0;
quint8 secondByte = (i + 1 < byteArray.size())? byteArray.at(i + 1) : 0;
QString hexValue = QString("%1%2")
.arg(QString::number(firstByte, 16).rightJustified(2, '0'))
.arg(QString::number(secondByte, 16).rightJustified(2, '0'));
result_int += hexValue.toInt(&ok, 16);
}
base_info1_45 = result_int;
// qDebug() << base_info1_45;
ui->volValue->setText(QString::number(base_info1_45[0]));
ui->batVal_vol_all->setText(QString::number(base_info1_45[0]));
ui->currValue->setText(QString::number(base_info1_45[1]));
ui->batVal_cur_all->setText(QString::number(base_info1_45[1]));
ui->batVal_soc->setText(QString::number(base_info1_45[2]));
ui->widgetBatt->setValue(base_info1_45[2]);
ui->batVal_soh->setText(QString::number(base_info1_45[3]));
ui->batVal_soe->setText(QString::number(base_info1_45[4]));
ui->batVal_rated_vol->setText(QString::number(base_info1_45[5]));
ui->batVal_rated_cap->setText(QString::number(base_info1_45[6]));
ui->batVal_remain_cap->setText(QString::number(base_info1_45[7]));
ui->batVal_bat_count->setText(QString::number(base_info1_45[12]));
battery_count = base_info1_45[12];
ui->batVal_tempt_count->setText(QString::number(base_info1_45[14]));
ui->batVal_max_dischg_cur->setText(QString::number(base_info1_45[16]));
ui->batVal_max_dischg_pwer->setText(QString::number(base_info1_45[17]));
ui->batVal_max_chg_cur->setText(QString::number(base_info1_45[18]));
ui->batVal_max_chg_pwer->setText(QString::number(base_info1_45[19]));
ui->batVal_pos_insu_res->setText(QString::number(base_info1_45[20]));
ui->batVal_neg_insu_res->setText(QString::number(base_info1_45[21]));
ui->batVal_sgl_vol_avg->setText(QString::number(base_info1_45[22]));
ui->batVal_sgl_max_press_diff->setText(QString::number(base_info1_45[23]));
ui->batVal_max_sgl_vol->setText(QString::number(base_info1_45[24]));
ui->batVal_max_sgl_vol_bmu_num->setText(QString::number(base_info1_45[25]));
ui->batVal_max_sgl_vol_serial_num->setText(QString::number(base_info1_45[26]));
ui->batVal_min_sgl_vol->setText(QString::number(base_info1_45[27]));
ui->batVal_min_sgl_vol_bmu_num->setText(QString::number(base_info1_45[28]));
ui->batVal_min_sgl_vol_serial_num->setText(QString::number(base_info1_45[29]));
ui->batVal_sgl_temp_avg->setText(QString::number(base_info1_45[30]));
ui->batVal_sgl_max_temp_diff->setText(QString::number(base_info1_45[31]));
ui->batVal_max_sgl_temp->setText(QString::number(base_info1_45[32]));
ui->batVal_max_sgl_temp_bmu_num->setText(QString::number(base_info1_45[33]));
ui->batVal_max_sgl_temp_serial_num->setText(QString::number(base_info1_45[34]));
ui->batVal_min_sgl_temp->setText(QString::number(base_info1_45[35]));
ui->batVal_min_sgl_temp_bmu_num->setText(QString::number(base_info1_45[36]));
ui->batVal_min_sgl_temp_serial_num->setText(QString::number(base_info1_45[37]));
ui->batVal_day_chg_cap->setText(QString::number(base_info1_45[38]));
ui->batVal_day_chg_ele->setText(QString::number(base_info1_45[39]));
ui->batVal_day_dischg_cap->setText(QString::number(base_info1_45[40]));
ui->batVal_day_dischg_ele->setText(QString::number(base_info1_45[41]));
ui->batVal_day_chg_time->setText(QString::number(base_info1_45[42]));
ui->batVal_day_dischg_time->setText(QString::number(base_info1_45[43]));
ui->batVal_leiji_chg_cap->setText(QString::number(base_info1_45[44]));
// int array_day_chart[] = {base_info1_45[39], base_info1_45[41], base_info1_45[42], base_info1_45[43]};
// QChartView *chartView_day = chartPat->Paint("日", array_day_chart);
// chartView_day->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// gridLayout->addWidget(chartView_day, 0, 0);
// ui->batVal_leiji_chg_ele->setText(QString::number(base_info1_45[46]));
}
}
void MainWindow::slot_pageHomeBaseInfo57_78(QByteArray byteArray, int dataType)
{
if(dataType == TypeRecvData)
{
QList<int> result_int;
bool ok;
for (int i = 3; i < byteArray.size(); i += 2) {
quint8 firstByte = (i < byteArray.size())? byteArray.at(i) : 0;
quint8 secondByte = (i + 1 < byteArray.size())? byteArray.at(i + 1) : 0;
QString hexValue = QString("%1%2")
.arg(QString::number(firstByte, 16).rightJustified(2, '0'))
.arg(QString::number(secondByte, 16).rightJustified(2, '0'));
result_int += hexValue.toInt(&ok, 16);
}
base_info57_78 = result_int;
ui->batVal_bcu_work_status->setText(QString::number(base_info57_78[0]));
ui->batVal_relay_neg_status->setText(QString::number(base_info57_78[1]));
ui->batVal_relay_pos_status->setText(QString::number(base_info57_78[2]));
ui->batVal_relay_dischg_status->setText(QString::number(base_info57_78[3]));
ui->batVal_relay_chg_status->setText(QString::number(base_info57_78[4]));
ui->batVal_relay_prechg_status->setText(QString::number(base_info57_78[5]));
ui->batVal_relay_status->setText(QString::number(base_info57_78[6]));
ui->batVal_on_off_status->setText(QString::number(base_info57_78[7]));
ui->batVal_trouble_status->setText(QString::number(base_info57_78[8]));
/*66~73
故障1~8的故障等级
故障9~16的故障等级
故障17~24的故障等级
故障25~32的故障等级
故障33~40的故障等级
故障41~48的故障等级
故障49~56的故障等级
故障57~64的故障等级
*/
ui->batVal_bat_cycle_number->setText(QString::number(base_info57_78[17]));
ui->batVal_max_chg_cell_vol->setText(QString::number(base_info57_78[18]));
ui->batVal_min_chg_cell_vol->setText(QString::number(base_info57_78[19]));
/*77,78
最大允许充电总压
最小允许放电总压
*/
}
}
void MainWindow::slot_pageHomeBaseInfo83_106(QByteArray byteArray, int dataType)
{
if(dataType == TypeRecvData)
{
QList<int> result_int;
bool ok;
for (int i = 3; i < byteArray.size(); i += 2) {
quint8 firstByte = (i < byteArray.size())? byteArray.at(i) : 0;
quint8 secondByte = (i + 1 < byteArray.size())? byteArray.at(i + 1) : 0;
QString hexValue = QString("%1%2")
.arg(QString::number(firstByte, 16).rightJustified(2, '0'))
.arg(QString::number(secondByte, 16).rightJustified(2, '0'));
result_int += hexValue.toInt(&ok, 16);
}
base_info83_106 = result_int;
ui->batVal_samp_press_all->setText(QString::number(base_info83_106[0]));
/*84~95
一级故障故障位1~16
一级故障故障位17~32
一级故障故障位33~48
一级故障故障位49~64
二级故障故障位1~16
二级故障故障位17~32
二级故障故障位33~48
二级故障故障位49~64
三级故障故障位1~16
三级故障故障位17~32
三级故障故障位33~48
三级故障故障位49~64
*/
ui->batVal_state_machine->setText(QString::number(base_info83_106[13]));
ui->batVal_chg_satus->setText(QString::number(base_info83_106[14]));
ui->batVal_dischg_satus->setText(QString::number(base_info83_106[15]));
ui->batVal_high_press_close_status->setText(QString::number(base_info83_106[16]));
ui->batVal_fan_status->setText(QString::number(base_info83_106[17]));
ui->batVal_all_alert->setText(QString::number(base_info83_106[18]));
ui->batVal__trouble_all->setText(QString::number(base_info83_106[19]));
/*103~106
BCU地址
BCU主回路状态
BCU回路闭合指令
BCU是否允许闭合主回路
*/
}
}
void MainWindow::slot_pageHomeBaseInfo47_49_51_53_55(QList<int> byteArray, int dataType)
{
if(dataType == TypeRecvData)
{
// QList<int> result_int;
// bool ok;
// for (int i = 3; i < byteArray.size(); i += 2) {
// quint8 firstByte = (i < byteArray.size())? byteArray.at(i) : 0;
// quint8 secondByte = (i + 1 < byteArray.size())? byteArray.at(i + 1) : 0;
// QString hexValue = QString("%1%2")
// .arg(QString::number(firstByte, 16).rightJustified(2, '0'))
// .arg(QString::number(secondByte, 16).rightJustified(2, '0'));
// result_int += hexValue.toInt(&ok, 16);
// }
// for (int i = 0; i < byteArray.size(); i += 2) {
// uint16_t value;
// memcpy(&value, byteArray.data() + i, 2);
// base_info47_49_51_53_55.append(value);
// // qDebug() << "Value: " << value;
// }
// base_info47_49_51_53_55 = result_int;
// qDebug() << byteArray;
ui->batVal_leiji_chg_ele->setText(QString::number(byteArray[0]));
ui->batVal_leiji_dischg_cap->setText(QString::number(byteArray[1]));
ui->batVal_leiji_dischg_ele->setText(QString::number(byteArray[2]));
ui->batVal_leiji_chg_time->setText(QString::number(byteArray[3]));
ui->batVal_leiji_dischg_time->setText(QString::number(byteArray[4]));
// int array_leiji_chart[] = {byteArray[0], byteArray[2], byteArray[3], byteArray[4]};
// QChartView *chartView_leiji = chartPat->Paint("累计", array_leiji_chart);
// chartView_leiji->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// chartView_leiji->setSizeAdjustPolicy(QChartView::AdjustToContents);
// gridLayout->addWidget(chartView_leiji, 0, 1);
}
}
void MainWindow::sgl_info_process(QList<int> sgl_info, QList<QLabel*> labelList)
{
// ui->tabWidget_sgl_info->update();
int MaxIndex = findMaxIndex(sgl_info);
int MinIndex = findMinIndex(sgl_info);
/*
ui->color_sgl_high->setStyleSheet("background-color: rgb(255, 0, 0);");
ui->color_sgl_low->setStyleSheet("background-color: rgb(0, 255, 0);");
ui->color_equilibrium->setStyleSheet("background-color: rgb(0, 0, 200);");
ui->color_short_circuit->setStyleSheet("background-color: rgb(255, 165, 0);");
*/
for (int i=0;i < sgl_info.size(); i++)
{
labelList[i]->setText(QString::number(sgl_info[i]));
labelList[i]->setAlignment(Qt::AlignCenter);
QFont font("黑体", 10);
labelList[i]->setFont(font);
if(i == MaxIndex)
{
labelList[MaxIndex]->setStyleSheet("QLabel{background-color:rgb(255, 0, 0);}");
}
else if (i == MinIndex)
{
labelList[MinIndex]->setStyleSheet("QLabel{background-color:rgb(0, 255, 0);}");
}
else
{
labelList[i]->setStyleSheet("QLabel{background-color:rgb(255, 255, 255);}");
}
}
}
int MainWindow::findMaxIndex(QList<int> sgl_info)
{
if (sgl_info.isEmpty()) return -1;
int maxValue = sgl_info.at(0);
int maxIndex = 0;
for (int i = 1; i < sgl_info.size(); ++i) {
int value = sgl_info.at(i);
if (value > maxValue) {
maxValue = value;
maxIndex = i;
}
}
return maxIndex;
}
int MainWindow::findMinIndex(QList<int> sgl_info)
{
if (sgl_info.isEmpty()) return -1;
int minValue = sgl_info.at(0);
int minIndex = 0;
for (int i = 1; i < sgl_info.size(); ++i) {
int value = sgl_info.at(i);
if (value < minValue) {
minValue = value;
minIndex = i;
}
}
return minIndex;
}
void MainWindow::getLanNumberSlot(int number)
{
lan = number;
qDebug() << "lan:" << lan;
pageBatteryInit();
pageParaSetInit();
pageParaSetInit_alert_value();
pageParaSetInit_alert_delay();
pageParaSetInit_alert_release_value();
pageParaSetInit_alert_release_delay();
pageParaSetInit_alert_dropcurr_rate();
pageParaSetInit_alert_solve_measure();
pageParaSetInit_DIDO_setting();
pageParaSetInit_balance_setting();
pageParaSetInit_SOX_setting();
pageParaSetInit_other_setting();
}
void MainWindow::pageBatteryInit()
{
}
void MainWindow::pageParaSetInit()
{
ui->tabWidget_paraset->setCurrentIndex(0);
ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_paraset_sys->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_paraset_sys->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_paraset_sys->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_paraset_sys->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_paraset_sys->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_paraset_sys->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_paraset_sys->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_paraset_sys->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_paraset_sys->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_paraset_sys->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_paraset_sys->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_paraset_sys->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_paraset_sys->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_paraset_sys->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_paraset_sys->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_paraset_sys->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_paraset_sys->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_paraset_sys->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_paraset_sys->horizontalHeader()->setSectionsClickable(false);
ui->tableView_paraset_sys->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_paraset_sys->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_paraset_sys->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_paraset_sys->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_paraset_sys->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_paraset_sys->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_paraset_sys->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_paraset_sys->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_paraset_sys->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
qDebug() << "english_item size: 11111111111111" << item.itemattr_size();
for(int i = 0; i < item.itemattr_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
qDebug() << "item size: 11111111111111" << item.itemattr_size();
for(int i = 0; i < item.itemattr_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_alert_value()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_paraset_alert_value->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_paraset_alert_value->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_paraset_alert_value->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_paraset_alert_value->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_paraset_alert_value->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_paraset_alert_value->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_paraset_alert_value->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_paraset_alert_value->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_paraset_alert_value->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_paraset_alert_value->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_paraset_alert_value->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_paraset_alert_value->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_paraset_alert_value->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_paraset_alert_value->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_paraset_alert_value->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_paraset_alert_value->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_paraset_alert_value->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_paraset_alert_value->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_paraset_alert_value->horizontalHeader()->setSectionsClickable(false);
ui->tableView_paraset_alert_value->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_paraset_alert_value->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_paraset_alert_value->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_paraset_alert_value->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_paraset_alert_value->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_paraset_alert_value->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_value->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_value->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_value->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_value_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_value(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_value(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_value(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_value_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_value(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_value(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_value(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_alert_delay()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_paraset_alert_delay->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_paraset_alert_delay->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_paraset_alert_delay->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_paraset_alert_delay->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_paraset_alert_delay->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_paraset_alert_delay->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_paraset_alert_delay->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_paraset_alert_delay->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_paraset_alert_delay->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_paraset_alert_delay->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_paraset_alert_delay->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_paraset_alert_delay->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_paraset_alert_delay->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_paraset_alert_delay->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_paraset_alert_delay->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_paraset_alert_delay->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_paraset_alert_delay->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_paraset_alert_delay->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_paraset_alert_delay->horizontalHeader()->setSectionsClickable(false);
ui->tableView_paraset_alert_delay->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_paraset_alert_delay->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_paraset_alert_delay->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_paraset_alert_delay->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_paraset_alert_delay->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_paraset_alert_delay->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_delay->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_delay->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_delay->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_delay_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_delay(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_delay(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_delay(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_delay_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_delay(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_delay(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_delay(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_alert_release_value()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_paraset_alert_release_value->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_paraset_alert_release_value->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_paraset_alert_release_value->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_paraset_alert_release_value->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_paraset_alert_release_value->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_paraset_alert_release_value->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_paraset_alert_release_value->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_paraset_alert_release_value->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_paraset_alert_release_value->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_paraset_alert_release_value->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_paraset_alert_release_value->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_paraset_alert_release_value->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_paraset_alert_release_value->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_paraset_alert_release_value->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_paraset_alert_release_value->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_paraset_alert_release_value->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_paraset_alert_release_value->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_paraset_alert_release_value->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_paraset_alert_release_value->horizontalHeader()->setSectionsClickable(false);
ui->tableView_paraset_alert_release_value->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_paraset_alert_release_value->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_paraset_alert_release_value->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_paraset_alert_release_value->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_paraset_alert_release_value->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_paraset_alert_release_value->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_release_value->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_release_value->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_release_value->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0) {
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_release_value_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_value(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_release_value(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_value(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1) {
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_release_value_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_value(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_release_value(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_value(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_alert_release_delay()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_paraset_alert_release_delay->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_paraset_alert_release_delay->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_paraset_alert_release_delay->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_paraset_alert_release_delay->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_paraset_alert_release_delay->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_paraset_alert_release_delay->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_paraset_alert_release_delay->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_paraset_alert_release_delay->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_paraset_alert_release_delay->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_paraset_alert_release_delay->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_paraset_alert_release_delay->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_paraset_alert_release_delay->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_paraset_alert_release_delay->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_paraset_alert_release_delay->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_paraset_alert_release_delay->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_paraset_alert_release_delay->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_paraset_alert_release_delay->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_paraset_alert_release_delay->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_paraset_alert_release_delay->horizontalHeader()->setSectionsClickable(false);
ui->tableView_paraset_alert_release_delay->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_paraset_alert_release_delay->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_paraset_alert_release_delay->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_paraset_alert_release_delay->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_paraset_alert_release_delay->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_paraset_alert_release_delay->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_release_delay->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_release_delay->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_release_delay->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_release_delay_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_delay(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_release_delay(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_delay(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_release_delay_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_delay(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_release_delay(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_release_delay(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_alert_dropcurr_rate()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_paraset_alert_dropcurr_rate->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_paraset_alert_dropcurr_rate->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_paraset_alert_dropcurr_rate->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_paraset_alert_dropcurr_rate->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_paraset_alert_dropcurr_rate->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_paraset_alert_dropcurr_rate->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_paraset_alert_dropcurr_rate->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_paraset_alert_dropcurr_rate->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_paraset_alert_dropcurr_rate->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_paraset_alert_dropcurr_rate->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_paraset_alert_dropcurr_rate->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_paraset_alert_dropcurr_rate->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_paraset_alert_dropcurr_rate->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_paraset_alert_dropcurr_rate->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_paraset_alert_dropcurr_rate->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_paraset_alert_dropcurr_rate->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_paraset_alert_dropcurr_rate->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_paraset_alert_dropcurr_rate->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_paraset_alert_dropcurr_rate->horizontalHeader()->setSectionsClickable(false);
ui->tableView_paraset_alert_dropcurr_rate->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_paraset_alert_dropcurr_rate->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_paraset_alert_dropcurr_rate->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_paraset_alert_dropcurr_rate->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_paraset_alert_dropcurr_rate->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_paraset_alert_dropcurr_rate->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_dropcurr_rate->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_dropcurr_rate->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_dropcurr_rate->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0) {
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_dropcurr_rate_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_dropcurr_rate(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_dropcurr_rate(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_dropcurr_rate(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_dropcurr_rate_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_dropcurr_rate(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_dropcurr_rate(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_dropcurr_rate(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_alert_solve_measure()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_paraset_alert_solve_mease->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_paraset_alert_solve_mease->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_paraset_alert_solve_mease->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_paraset_alert_solve_mease->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_paraset_alert_solve_mease->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_paraset_alert_solve_mease->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_paraset_alert_solve_mease->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_paraset_alert_solve_mease->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_paraset_alert_solve_mease->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_paraset_alert_solve_mease->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_paraset_alert_solve_mease->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_paraset_alert_solve_mease->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_paraset_alert_solve_mease->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_paraset_alert_solve_mease->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_paraset_alert_solve_mease->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_paraset_alert_solve_mease->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_paraset_alert_solve_mease->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_paraset_alert_solve_mease->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_paraset_alert_solve_mease->horizontalHeader()->setSectionsClickable(false);
ui->tableView_paraset_alert_solve_mease->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_paraset_alert_solve_mease->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_paraset_alert_solve_mease->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_paraset_alert_solve_mease->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_paraset_alert_solve_mease->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_paraset_alert_solve_mease->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_solve_mease->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_solve_mease->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_paraset_alert_solve_mease->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0) {
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_solve_measure_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_solve_measure(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_solve_measure(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_solve_measure(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_alert_solve_measure_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_solve_measure(i)->name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.mutable_itemattr_alert_solve_measure(i)->value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.mutable_itemattr_alert_solve_measure(i)->introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_DIDO_setting()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_DIDO_setting->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_DIDO_setting->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_DIDO_setting->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_DIDO_setting->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_DIDO_setting->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_DIDO_setting->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_DIDO_setting->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_DIDO_setting->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_DIDO_setting->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_DIDO_setting->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_DIDO_setting->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_DIDO_setting->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_DIDO_setting->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_DIDO_setting->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_DIDO_setting->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_DIDO_setting->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_DIDO_setting->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_DIDO_setting->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_DIDO_setting->horizontalHeader()->setSectionsClickable(false);
ui->tableView_DIDO_setting->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_DIDO_setting->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_DIDO_setting->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_DIDO_setting->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_DIDO_setting->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_DIDO_setting->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_DIDO_setting->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_DIDO_setting->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_DIDO_setting->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i=0; i < item.itemattr_dido_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_dido(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_dido(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_dido(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i=0; i < item.itemattr_dido_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_dido(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_dido(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_dido(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_balance_setting()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_balance_setting->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_balance_setting->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_balance_setting->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_balance_setting->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_balance_setting->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_balance_setting->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_balance_setting->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_balance_setting->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_balance_setting->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_balance_setting->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_balance_setting->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_balance_setting->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_balance_setting->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_balance_setting->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_balance_setting->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_balance_setting->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_balance_setting->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_balance_setting->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_balance_setting->horizontalHeader()->setSectionsClickable(false);
ui->tableView_balance_setting->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_balance_setting->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_balance_setting->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_balance_setting->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_balance_setting->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_balance_setting->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_balance_setting->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_balance_setting->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_balance_setting->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i< item.itemattr_balance_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_balance(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_balance(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_balance(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i< item.itemattr_balance_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_balance(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_balance(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_balance(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_SOX_setting()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_SOX_setting->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_SOX_setting->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_SOX_setting->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_SOX_setting->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_SOX_setting->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_SOX_setting->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_SOX_setting->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_SOX_setting->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_SOX_setting->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_SOX_setting->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_SOX_setting->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_SOX_setting->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_SOX_setting->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_SOX_setting->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_SOX_setting->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_SOX_setting->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_SOX_setting->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_SOX_setting->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_SOX_setting->horizontalHeader()->setSectionsClickable(false);
ui->tableView_SOX_setting->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_SOX_setting->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_SOX_setting->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_SOX_setting->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_SOX_setting->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_SOX_setting->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_SOX_setting->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_SOX_setting->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_SOX_setting->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for (int i=0; i < item.itemattr_sox_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_sox(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_sox(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_sox(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for (int i=0; i < item.itemattr_sox_size(); i++)
{
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_sox(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_sox(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_sox(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
void MainWindow::pageParaSetInit_other_setting()
{
// ui->tabWidget_paraset->setStyleSheet("background-color: #FFFFFF;");
// ui->pageParaSet->setStyleSheet("background-color: #FFFFFF;");
/*设置默认行高*/
ui->tableView_other_setting->verticalHeader()->setDefaultSectionSize(26);
/*设置交替行颜色--允许交替行颜色*/
ui->tableView_other_setting->setAlternatingRowColors(true);
/*设置水平/垂直滚动模式--一次滚动一个项目*/
ui->tableView_other_setting->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
ui->tableView_other_setting->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
/*设置选择行为--每次选择只有一整行*/
ui->tableView_other_setting->setSelectionBehavior(QAbstractItemView::SelectRows);
/*设置拖放行为--不允许拖放*/
ui->tableView_other_setting->setDragDropMode(QAbstractItemView::NoDragDrop);
/*设置选择模式--只能选择一个项目*/
ui->tableView_other_setting->setSelectionMode(QAbstractItemView::SingleSelection);
/*设置Tab导航键--允许使用Tab键导航shift+tab反向导航*/
ui->tableView_other_setting->setTabKeyNavigation(true);
/*设置是否自动换行--取消自动换行*/
ui->tableView_other_setting->setWordWrap(false);
/*设置文本省略模式--省略号不会出现在文本中*/
ui->tableView_other_setting->setTextElideMode(Qt::ElideNone);
/*设置左上角全选按钮--禁用*/
ui->tableView_other_setting->setCornerButtonEnabled(false);
/*设置是否支持表头排序--应该和表头是否可以单击保持一致*/
ui->tableView_other_setting->setSortingEnabled(false);
/*设置是否显示网格线*/
ui->tableView_other_setting->setShowGrid(true);
/*设置垂直表头是否可见*/
ui->tableView_other_setting->verticalHeader()->setVisible(true);
/*设置选中一行表头是否加粗--不加粗*/
ui->tableView_other_setting->horizontalHeader()->setHighlightSections(true);
/*设置最后一行是否拉伸填充*/
ui->tableView_other_setting->horizontalHeader()->setStretchLastSection(true);
/*设置行标题最小宽度尺寸*/
ui->tableView_other_setting->horizontalHeader()->setMinimumSectionSize(0);
/*设置行标题最小高度*/
ui->tableView_other_setting->horizontalHeader()->setFixedHeight(20);
/*设置表头是否可以单击--不可单击*/
ui->tableView_other_setting->horizontalHeader()->setSectionsClickable(false);
ui->tableView_other_setting->verticalHeader()->setHidden(false);
/*是否可编辑*/
if(true)
{
ui->tableView_other_setting->setEditTriggers(QAbstractItemView::CurrentChanged|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
}
else
{
ui->tableView_other_setting->setEditTriggers(QAbstractItemView::NoEditTriggers);
}
QStringList columnNames;
QList<int> columnWidths;
columnNames << "check" << "name" << "value" << "introduce";
columnWidths << 60 << 420 << 120 << 120;
model = new QStandardItemModel;
model->setHorizontalHeaderLabels(columnNames);
ui->tableView_other_setting->setModel(model);
int count = columnNames.count();
for(int i = 0; i< count;i++)
{
ui->tableView_other_setting->setColumnWidth(i, columnWidths.at(i));
}
Delegate *checkDelegate = new Delegate;
checkDelegate->setDelegateType("QCheckBox");
checkDelegate->setDelegateColumn(0);
ui->tableView_other_setting->setItemDelegateForColumn(0, checkDelegate);
Delegate *lineEidtDelegate = new Delegate;
lineEidtDelegate->setDelegateType("QLineEdit");
ui->tableView_other_setting->setItemDelegateForColumn(1,lineEidtDelegate);
Delegate * lineEidtDelegate1 = new Delegate;
lineEidtDelegate1->setDelegateType("QLineEdit");
ui->tableView_other_setting->setItemDelegateForColumn(2, lineEidtDelegate1);
Delegate *lineEidtDelegate2 = new Delegate;
lineEidtDelegate2->setDelegateType("QLineEdit");
ui->tableView_other_setting->setItemDelegateForColumn(3,lineEidtDelegate2);
if(lan == 0)
{
BatteryConfig_English::Item item;
std::ifstream finBetteryData("battery_english.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_other_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_other(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_other(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_other(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
else if(lan == 1)
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
for(int i = 0; i < item.itemattr_other_size(); i++) {
for(int j = 0; j < 4; j++) {
if(j == 1) {
model->setItem(i, j, new QStandardItem(item.itemattr_other(i).name().c_str()));
}
else if(j == 2) {
model->setItem(i, j, new QStandardItem(QString::number(item.itemattr_other(i).value())));
}
else if(j == 3) {
model->setItem(i, j, new QStandardItem(item.itemattr_other(i).introduce().c_str()));
}
}
}
finBetteryData.close();
finBetteryData.clear();
}
}
}
// void MainWindow::setNum(QString value)
// {
// qDebug("###1");
// QModelIndex currentIndex = ui->pageParaSetTableView->currentIndex();
// if(currentIndex.column() == 3)
// {
// model->setData(model->index(currentIndex.row(), 10), value.toFloat());
// }
// }
void MainWindow::slot_getBcuNumberFromDialoglogin(int number)
{
// QTreeView treeView;
// 创建模型
QStandardItemModel *model = new QStandardItemModel(ui->treeViewBCUbmu);
// QMap<QModelIndex, int> indexTopPageMap;
//创建一级目录项数为可变的
QStringList bcuNames;
qDebug() << "number: " << number;
for (int i = 1; i <= number; ++i) {
QString bcuName = QString("BCU%1").arg(i);
bcuNames.append(bcuName);
}
qDebug() << "BCUNames" << bcuNames;
// 创建一级目录项
int count = 0;
for (const QString &name : bcuNames)
{
QStandardItem *rootItem = new QStandardItem(name);
// 设置一级目录项的字体为加粗
QFont boldFont = rootItem->font();
boldFont.setBold(true);
rootItem->setFont(boldFont);
count++;
model->appendRow(rootItem);
for (int i = 1; i <= 26; ++i)
{
QString bmuName = QString("BMU%1").arg(i);
QStandardItem *bmuItem = new QStandardItem(bmuName);
rootItem->appendRow(bmuItem);
}
}
ui->tabWidgetBCU->setCurrentIndex(0);
ui->tabWidgetBMU->setCurrentIndex(0);
connect(ui->treeViewBCUbmu, &QTreeView::clicked, [=](const QModelIndex index){
//BCU被点击的索引已被实现bmu待定
if(index.parent().isValid())
{
qDebug() << "index" << index;
qDebug() << "BMU" << index.column() << index.row();
ui->pageBatteryStackWidget->setCurrentIndex(1);
}
else
{
// qDebug() << "index" << index;
qDebug() << "BCU" << index.row();
// int topLeveIndex = index.row();
ui->pageBatteryStackWidget->setCurrentIndex(0);
}
});
ui->treeViewBCUbmu->setModel(model);
ui->treeViewBCUbmu->setHeaderHidden(true);
ui->treeViewBCUbmu->setAnimated(true);
ui->treeViewBCUbmu->expandAll();
ui->treeViewBCUbmu->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->treeViewBCUbmu->show();
}
void MainWindow::on_pageParaSetCheck_stateChanged(int arg1)
{
QWidget *currentWidget = ui->tabWidget_paraset->currentWidget();
if (currentWidget) {
QTableView *tableView = currentWidget->findChild<QTableView *>();
if (tableView) {
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(tableView->model());
if (model) {
if(arg1 == Qt::CheckState::Checked) {
for(int i = 0; i < model->rowCount(); i++) {
model->setItem(i, 0, new QStandardItem("true"));
}
}
else {
for(int i = 0; i < model->rowCount(); i++) {
model->setItem(i, 0, new QStandardItem("false"));
}
}
}
}
}
}
void MainWindow::on_pageParaSetRead_clicked()
{
BatteryConfig::Item item;
std::ifstream finBetteryData("battery.data", std::ios::binary);
if(!item.ParseFromIstream(&finBetteryData)) {
qDebug() << __FUNCTION__ << __LINE__ << "proto parse failed";
finBetteryData.close();
finBetteryData.clear();
}
else {
QList<int> checkRow_read;
QList<int> checkAddress_read;
QWidget *currentWidget = ui->tabWidget_paraset->currentWidget();
if (currentWidget)
{
QTableView *tableView = currentWidget->findChild<QTableView *>();
if (tableView)
{
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(tableView->model());
if (model)
{
switch (tabWidget_paraset_index)
{
case 0:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr(row)->set_value(data);
int tempAddress = item.mutable_itemattr(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 1:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_balance(row)->set_value(data);
int tempAddress = item.mutable_itemattr_balance(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 2:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_sox(row)->set_value(data);
int tempAddress = item.mutable_itemattr_sox(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 3:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_dido(row)->set_value(data);
int tempAddress = item.mutable_itemattr_dido(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 4:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_alert_value(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_value(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 5:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_alert_delay(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_delay(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 6:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_alert_release_value(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_release_value(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 7:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_alert_release_delay(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_release_delay(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 8:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_alert_dropcurr_rate(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_dropcurr_rate(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 9:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_alert_solve_measure(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_solve_measure(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
case 10:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr_other(row)->set_value(data);
int tempAddress = item.mutable_itemattr_other(row)->addr();
checkRow_read.append(row);
checkAddress_read.append(tempAddress);
}
}
}
}
break;
}
}
}
}
if (checkRow_read.isEmpty())
{
QMessageBox::warning(nullptr, "警告", "勾选框无勾选,请勾选后再操作");
}
else{
int startAddress = -1;
int consecutiveCount = 0;
QList<QPair<int, int>> pairs_addr;//addr, the number of the continuous
int row_index_i = 0; // 防止勾选框不间断时checkRow_read与checkAddress_read值与索引不匹配的问题
for (int row : checkRow_read)
{
int address = checkAddress_read[row_index_i];
if (startAddress == -1)
{
startAddress = address;
consecutiveCount = 1;
}
else if (address == startAddress + consecutiveCount)
{
consecutiveCount++;
}
else
{
if (consecutiveCount > 1)
{
pairs_addr.append(qMakePair(startAddress, consecutiveCount));
}
else
{
pairs_addr.append(qMakePair(startAddress, 1));
}
startAddress = address;
consecutiveCount = 1;
}
row_index_i++;
}
if (consecutiveCount > 1)
{
pairs_addr.append(qMakePair(startAddress, consecutiveCount));
}
else
{
pairs_addr.append(qMakePair(startAddress, 1));
}
int rowStart = 0;
QList<QPair<int, int>>::iterator it;
for (it = pairs_addr.begin(); it!= pairs_addr.end(); ++it) {
qDebug() << "First element read: " << it->first << ", Second element read: " << it->second;
uint16_t result[it->second];
int tempIndex = checkRow_read[rowStart];
emit read_regs_signals(it->first, it->second, result, tempIndex);
rowStart += it->second;
}
rowStart = 0;
qDebug() << "read of the row" << checkRow_read;
qDebug() << "read of the address" << checkAddress_read;
}
finBetteryData.close();
finBetteryData.clear();
}
}
void MainWindow::slot_pageParaSetShow(QByteArray byteArray, int dataType, int row, int nb)
{
Q_UNUSED(dataType);
QList<int> result_int;
bool ok;
for (int i = 3; i < byteArray.size(); i += 2) {
quint8 firstByte = (i < byteArray.size())? byteArray.at(i) : 0;
quint8 secondByte = (i + 1 < byteArray.size())? byteArray.at(i + 1) : 0;
QString hexValue = QString("%1%2")
.arg(QString::number(firstByte, 16).rightJustified(2, '0'))
.arg(QString::number(secondByte, 16).rightJustified(2, '0'));
result_int += hexValue.toInt(&ok, 16);
}
// qDebug() << "test read holding regs" << result_int;
qDebug() << "the row of the start index:" << row << "the number of the setting: " << nb;
qDebug() << result_int;
int i = 0;
for(;i < nb; row++, i++)
{
QWidget *currentWidget = ui->tabWidget_paraset->currentWidget();
if (currentWidget)
{
QTableView *tableView = currentWidget->findChild<QTableView *>();
if (tableView)
{
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(tableView->model());
if (model)
{
QModelIndex index = model->index(row, 2);
model->setData(index, result_int[i]);
qDebug() << "row " << row << " result: " << result_int[i];
}
}
}
}
}
void MainWindow::closeEvent(QCloseEvent *e)
{
emit closeThread();
QWidget::closeEvent(e);
}
void MainWindow::on_pageParaSetWrite_clicked()
{
BatteryConfig::Item item;
// 从磁盘读取 protobuf 文件
std::ifstream finBetteryData("battery.data", std::ios::in | std::ios::binary);
if (!finBetteryData.is_open()) {
}
// 获取文件大小
finBetteryData.seekg(0, std::ios::end);
size_t size = finBetteryData.tellg();
finBetteryData.seekg(0, std::ios::beg);
// 读取文件内容到字符串
std::string serialized_data(size, '\0');
if (!finBetteryData.read(&serialized_data[0], size)) {
}
finBetteryData.close();
// 反序列化 protobuf 数据
if (!item.ParseFromString(serialized_data)) {
}
QList<int> checkRow_write;//存放被勾选的勾选框的索引值
QVector<uint16_t> originVector;//存放被勾选的勾选框的value
QWidget *currentWidget = ui->tabWidget_paraset->currentWidget();
if (currentWidget)
{
QTableView *tableView = currentWidget->findChild<QTableView *>();
if (tableView)
{
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(tableView->model());
if (model)
{
switch (tabWidget_paraset_index) {
case 0:
//仅需地址和值
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr(row)->set_value(data);
int tempAddress = item.mutable_itemattr(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr(row)->value());
}
}
}
}
break;
case 1:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_balance(row)->set_value(data);
int tempAddress = item.mutable_itemattr_balance(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_balance(row)->value());
}
}
}
}
break;
case 2:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_sox(row)->set_value(data);
int tempAddress = item.mutable_itemattr_sox(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_sox(row)->value());
}
}
}
}
break;
case 3:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_dido(row)->set_value(data);
int tempAddress = item.mutable_itemattr_dido(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_dido(row)->value());
}
}
}
}
break;
case 4:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_alert_value(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_value(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_alert_value(row)->value());
}
}
}
}
break;
case 5:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_alert_delay(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_delay(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_alert_delay(row)->value());
}
}
}
}
break;
case 6:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_alert_release_value(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_release_value(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_alert_release_value(row)->value());
}
}
}
}
break;
case 7:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_alert_release_delay(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_release_delay(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_alert_release_delay(row)->value());
}
}
}
}
break;
case 8:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_alert_dropcurr_rate(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_dropcurr_rate(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_alert_dropcurr_rate(row)->value());
}
}
}
}
break;
case 9:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_alert_solve_measure(row)->set_value(data);
int tempAddress = item.mutable_itemattr_alert_solve_measure(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_alert_solve_measure(row)->value());
}
}
}
}
break;
case 10:
qDebug() << "the tabWidget_paraset_index is : " << tabWidget_paraset_index;
for(int row = 0; row < model->rowCount(); row++)
{
for(int column = 0; column < model->columnCount(); column++)
{
if(column == 0)
{
QModelIndex index = model->index(row, column);
QString data = model->data(index).toString();
if(data == "true") {
index = model->index(row, 2);
// int tempAddress = item.mutable_itemattr(row)->addr();
// int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
uint16_t data = model->data(index).toUInt();
item.mutable_itemattr_other(row)->set_value(data);
int tempAddress = item.mutable_itemattr_other(row)->addr();
// qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
checkRow_write.append(tempAddress);
originVector.append(item.mutable_itemattr_other(row)->value());
}
}
}
}
break;
}
}
}
}
// for(int row = 0; row < model->rowCount(); row++)
// {
// for(int column = 0; column < model->columnCount(); column++)
// {
// if(column == 0)
// {
// QModelIndex index = model->index(row, column);
// QString data = model->data(index).toString();
// if(data == "true") {
// index = model->index(row, 2);
// // int tempAddress = item.mutable_itemattr(row)->addr();
// // int resultAddress = tempAddress < 4000 ? tempAddress - 3000 : tempAddress -4000 + 162;
// uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr(row)->set_value(data);
// // qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
// checkRow_write.append(row);
// originVector.append(item.mutable_itemattr(row)->value());
// }
// }
// }
// }
// for(int row = 0; row < model->rowCount(); row++) {
// for(int column = 0; column < model->columnCount(); column++) {
// if(column == 0) {
// QModelIndex index = model->index(row, column);
// QString data = model->data(index).toString();
// if(data == "true") {
// index = model->index(row, 2);
// uint16_t data = model->data(index).toUInt();
// item.mutable_itemattr(row)->set_value(data);
// // qDebug() << "the address:" << item.mutable_itemattr(row)->addr() << " , the value is :" <<data;
// checkRow_write.append(row);
// originVector.append(item.mutable_itemattr(row)->value());
// }
// }
// }
// }
qDebug() << "write of the row" << checkRow_write;
qDebug() << "originalLIst of the value" << originVector;
if (checkRow_write.isEmpty())
{
QMessageBox::warning(nullptr, "警告", "勾选框无勾选,请勾选后再操作");
}
else
{
for (int i=0; i<checkRow_write.size();i++)
{
emit write_regs_signals(checkRow_write[i], originVector[i]);
}
}
// 序列化消息对象
std::string new_serialized_data;
if (!item.SerializeToString(&new_serialized_data)) {
}
// 将序列化后的数据写回磁盘
std::ofstream foutBetteryData("battery.data", std::ios::out | std::ios::binary | std::ios::trunc);
if (!foutBetteryData.is_open()) {
}
// 写入文件
if (!foutBetteryData.write(new_serialized_data.c_str(), new_serialized_data.size())) {
}
foutBetteryData.close();
// qDebug() << item.mutable_itemattr(0)->value();
// qDebug() << "update";
}
void MainWindow::on_tabChanged(int index)
{
tabWidget_paraset_index = index;
ui->pageParaSetCheck->setCheckState(Qt::Unchecked);
}