|
|
@ -8,6 +8,15 @@
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *ReadOnlyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Q_UNUSED(parent)
|
|
|
|
|
|
|
|
Q_UNUSED(option)
|
|
|
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget::Widget(QWidget *parent)
|
|
|
|
Widget::Widget(QWidget *parent)
|
|
|
|
: QWidget(parent),ui(new Ui::form)
|
|
|
|
: QWidget(parent),ui(new Ui::form)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -41,6 +50,9 @@ Widget::Widget(QWidget *parent)
|
|
|
|
logIndex = 0;
|
|
|
|
logIndex = 0;
|
|
|
|
waveIndex = 0;
|
|
|
|
waveIndex = 0;
|
|
|
|
is_wave_up = 0;
|
|
|
|
is_wave_up = 0;
|
|
|
|
|
|
|
|
dataIndex = 0;
|
|
|
|
|
|
|
|
is_data_up = false;
|
|
|
|
|
|
|
|
logSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
energyMode[0] = "未知";
|
|
|
|
energyMode[0] = "未知";
|
|
|
|
energyMode[1] = "正常模式";
|
|
|
|
energyMode[1] = "正常模式";
|
|
|
@ -85,6 +97,38 @@ Widget::Widget(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
|
|
//searchUsablePort();
|
|
|
|
//searchUsablePort();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readOnlyDelegate = new ReadOnlyDelegate(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 配置历史数据页面表格 */
|
|
|
|
|
|
|
|
//如下代码设置横向表格头的间隔线,有四个方向的间隔线,不需要间隔线的可以设置为0px
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->setStyleSheet(
|
|
|
|
|
|
|
|
"QHeaderView::section{"
|
|
|
|
|
|
|
|
"border-top:0px solid #E5E5E5;"
|
|
|
|
|
|
|
|
"border-left:0px solid #E5E5E5;"
|
|
|
|
|
|
|
|
"border-right:0.5px solid #E5E5E5;"
|
|
|
|
|
|
|
|
"border-bottom: 0.5px solid #E5E5E5;"
|
|
|
|
|
|
|
|
"background-color:red;"
|
|
|
|
|
|
|
|
"padding:4px;"
|
|
|
|
|
|
|
|
"}"
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->historyDataTable->columnCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->historyDataTable->setItemDelegateForColumn(i, readOnlyDelegate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(0, 50);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(1, 130);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(2, 60);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(3, 60);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(4, 60);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(5, 60);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(6, 110);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(7, 110);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(8, 110);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(9, 110);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(10, 110);
|
|
|
|
|
|
|
|
ui->historyDataTable->horizontalHeader()->resizeSection(11, 110);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget::~Widget()
|
|
|
|
Widget::~Widget()
|
|
|
@ -866,7 +910,90 @@ int Widget::protoAdjustInfo(char *data)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::protoHistoryData(char * data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mul_head_t *header = reinterpret_cast<mul_head_t*>(data + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
fd_data_t *pHistoryData;
|
|
|
|
|
|
|
|
uint32_t cnt = 0;
|
|
|
|
|
|
|
|
/* 数据头校验. */
|
|
|
|
|
|
|
|
if (header->index != dataIndex
|
|
|
|
|
|
|
|
|| header->len > UPDATE_DATA_SIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取文件. */
|
|
|
|
|
|
|
|
cnt = header->len / FD_BUF_LEN;
|
|
|
|
|
|
|
|
for(uint32_t i = 0; i < cnt; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pHistoryData = reinterpret_cast<fd_data_t*>(data + sizeof(proto_head_t) + sizeof(mul_head_t) + i * FD_BUF_LEN);
|
|
|
|
|
|
|
|
int32_t row = ui->historyDataTable->rowCount();
|
|
|
|
|
|
|
|
ui->historyDataTable->insertRow(row);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QTableWidgetItem *item = new QTableWidgetItem (QString::number(pHistoryData->id));
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 0, item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
time_t cur = static_cast<time_t>(pHistoryData->run_time);
|
|
|
|
|
|
|
|
tm *day;
|
|
|
|
|
|
|
|
day = localtime(&cur);
|
|
|
|
|
|
|
|
QString temp;
|
|
|
|
|
|
|
|
temp.sprintf("%d/%d/%d %d:%d:%d", day->tm_year + 1900, day->tm_mon+1, day->tm_mday, day->tm_hour, day->tm_min, day->tm_sec);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 1, item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->temperature / 10.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 2, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->vin / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 3, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->vbat / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 4, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->vsc / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 5, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->elec[0] / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 6, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->elec[1] / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 7, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->elec[2] / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 8, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->elec[3] / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 9, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->elec[4] / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 10, item);
|
|
|
|
|
|
|
|
temp.sprintf("%.2f", pHistoryData->elec[5] / 1000.0);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem (temp);
|
|
|
|
|
|
|
|
ui->historyDataTable->setItem(row, 11, item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (header->len < UPDATE_DATA_SIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//work->multipleIndexSet(0);
|
|
|
|
|
|
|
|
//work->stateSet(CM_usart::WS_IDLE);
|
|
|
|
|
|
|
|
dataIndex = 0;
|
|
|
|
|
|
|
|
buttonEnable(true);
|
|
|
|
|
|
|
|
ui->dataIndexLabel->setText("下载完成");
|
|
|
|
|
|
|
|
QMessageBox::information(this, "SUCCEED", "历史数据下载完成.", QMessageBox::Ok);
|
|
|
|
|
|
|
|
ui->historyDataButton->setText("下载数据");
|
|
|
|
|
|
|
|
is_data_up = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dataIndex = header->index + 1;
|
|
|
|
|
|
|
|
QString temp;
|
|
|
|
|
|
|
|
temp.sprintf("%d / %d", dataIndex, ui->historyDataEdit->text().toInt());
|
|
|
|
|
|
|
|
ui->dataIndexLabel->setText(temp);
|
|
|
|
|
|
|
|
//work->multipleIndexSet(header->index + 1);
|
|
|
|
|
|
|
|
sendMsgHistoryDataGet();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::paraseProtocols(char *data)
|
|
|
|
int Widget::paraseProtocols(char *data)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -943,7 +1070,7 @@ int Widget::paraseProtocols(char *data)
|
|
|
|
//_debug_pkt_log_get();
|
|
|
|
//_debug_pkt_log_get();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_HISTORY_DATA:
|
|
|
|
case DEBUG_PRV_HISTORY_DATA:
|
|
|
|
//_debug_pkt_history_data_get();
|
|
|
|
protoHistoryData(data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_MANUAL:
|
|
|
|
case DEBUG_PRV_ADJ_MANUAL:
|
|
|
|
protoManualAdjust(data);
|
|
|
|
protoManualAdjust(data);
|
|
|
@ -1318,7 +1445,7 @@ int Widget::sendMsgWaveCol()
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::senMsgWaveCal()
|
|
|
|
int Widget::sendMsgWaveCal()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char buf[2048] = {0};
|
|
|
|
char buf[2048] = {0};
|
|
|
|
uint32_t *crc = nullptr;
|
|
|
|
uint32_t *crc = nullptr;
|
|
|
@ -1339,6 +1466,29 @@ int Widget::senMsgWaveCal()
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::sendMsgHistoryDataGet()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char buf[2048] = {0};
|
|
|
|
|
|
|
|
uint32_t *crc = nullptr;
|
|
|
|
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(buf);
|
|
|
|
|
|
|
|
mul_head_t *m_head = reinterpret_cast<mul_head_t*>(buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
int32_t *data = reinterpret_cast<int32_t*>(buf + sizeof(proto_head_t) + sizeof(mul_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 初始化报文头. */
|
|
|
|
|
|
|
|
protoHeaderInit(header, sizeof(proto_head_t) + sizeof(mul_head_t) + sizeof(uint32_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_HISTORY_DATA);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_head->index = dataIndex;
|
|
|
|
|
|
|
|
m_head->len = 0;
|
|
|
|
|
|
|
|
*data = logSum;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验位. */
|
|
|
|
|
|
|
|
crc = reinterpret_cast<uint32_t*>(buf + header->len);
|
|
|
|
|
|
|
|
*crc = crc32(buf, header->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HexPrint(__FUNCTION__, buf, header->len + 4);
|
|
|
|
|
|
|
|
writeData(buf, header->len + 4);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1677,7 +1827,7 @@ void Widget::on_waveColButton_clicked()
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_waveRefreshButton_clicked()
|
|
|
|
void Widget::on_waveRefreshButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
sendMsgDeviceStateGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_waveCalButton_clicked()
|
|
|
|
void Widget::on_waveCalButton_clicked()
|
|
|
@ -1734,10 +1884,9 @@ void Widget::on_historyDataButton_clicked()
|
|
|
|
dataIndex = 0;
|
|
|
|
dataIndex = 0;
|
|
|
|
QString temp;
|
|
|
|
QString temp;
|
|
|
|
temp.sprintf("0 / %d", ui->historyDataEdit->text().toInt());
|
|
|
|
temp.sprintf("0 / %d", ui->historyDataEdit->text().toInt());
|
|
|
|
//work->logSumSet(ui->historyDataEdit->text().toInt());
|
|
|
|
logSum = ui->historyDataEdit->text().toInt();
|
|
|
|
ui->dataIndexLabel->setText(temp);
|
|
|
|
ui->dataIndexLabel->setText(temp);
|
|
|
|
//work->multipleIndexSet(0);
|
|
|
|
sendMsgHistoryDataGet();
|
|
|
|
//work->stateSet(CM_usart::WS_HISTORY_DATA_GET);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int row = ui->historyDataTable->rowCount();
|
|
|
|
int row = ui->historyDataTable->rowCount();
|
|
|
|
if (row > 0)
|
|
|
|
if (row > 0)
|
|
|
@ -2055,8 +2204,6 @@ void Widget::on_adjButton_clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
/* 下发配置. */
|
|
|
|
//work->adjChSet(&adj);
|
|
|
|
|
|
|
|
buttonEnable(false);
|
|
|
|
buttonEnable(false);
|
|
|
|
//work->stateSet(CM_usart::WS_ADJ_AUTO);
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_AUTO);
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_AUTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|