|
|
@ -52,6 +52,7 @@ Widget::Widget(QWidget *parent)
|
|
|
|
is_wave_up = 0;
|
|
|
|
is_wave_up = 0;
|
|
|
|
dataIndex = 0;
|
|
|
|
dataIndex = 0;
|
|
|
|
is_data_up = false;
|
|
|
|
is_data_up = false;
|
|
|
|
|
|
|
|
historyDataSum = 0;
|
|
|
|
logSum = 0;
|
|
|
|
logSum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
energyMode[0] = "未知";
|
|
|
|
energyMode[0] = "未知";
|
|
|
@ -910,6 +911,69 @@ int Widget::protoAdjustInfo(char *data)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::protoLog(char * data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mul_head_t *header = reinterpret_cast<mul_head_t*>(data + sizeof(mul_head_t));
|
|
|
|
|
|
|
|
falsh_log_t *log;
|
|
|
|
|
|
|
|
uint32_t cnt = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 数据头校验. */
|
|
|
|
|
|
|
|
if (header->index != logIndex
|
|
|
|
|
|
|
|
|| header->len > UPDATE_DATA_SIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取文件. */
|
|
|
|
|
|
|
|
QFile file("log.txt");
|
|
|
|
|
|
|
|
if (0 == header->index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
file.remove();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Append))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cnt = header->len / FLASH_LOG_BUF_LEN;
|
|
|
|
|
|
|
|
for(uint32_t i = 0; i < cnt; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log = reinterpret_cast<falsh_log_t*>(data + sizeof(proto_head_t) + sizeof(mul_head_t) + i * FLASH_LOG_BUF_LEN);
|
|
|
|
|
|
|
|
file.write((char *)log->data, strlen((char *)log->data));
|
|
|
|
|
|
|
|
ui->logTextEdit->insertPlainText((char *)log->data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qDebug() << "file ERROR";
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 通知发包线程进入下个状态. */
|
|
|
|
|
|
|
|
if (header->len < UPDATE_DATA_SIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//work->multipleIndexSet(0);
|
|
|
|
|
|
|
|
//work->stateSet(CM_usart::WS_IDLE);
|
|
|
|
|
|
|
|
logIndex = 0;
|
|
|
|
|
|
|
|
buttonEnable(true);
|
|
|
|
|
|
|
|
ui->logIndexLabel->setText("下载完成");
|
|
|
|
|
|
|
|
QMessageBox::information(this, "SUCCEED", "Log 文件下载完成.", QMessageBox::Ok);
|
|
|
|
|
|
|
|
is_log_up = false;
|
|
|
|
|
|
|
|
ui->stateLogButton->setText("下载 Log");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
logIndex = header->index + 1;;
|
|
|
|
|
|
|
|
QString temp;
|
|
|
|
|
|
|
|
temp.sprintf("%d / %d", logIndex, ui->stateLogEdit->text().toInt());
|
|
|
|
|
|
|
|
ui->logIndexLabel->setText(temp);
|
|
|
|
|
|
|
|
//work->multipleIndexSet(header->index + 1);
|
|
|
|
|
|
|
|
sendMsgLogGet();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::protoHistoryData(char * data)
|
|
|
|
int Widget::protoHistoryData(char * data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mul_head_t *header = reinterpret_cast<mul_head_t*>(data + sizeof(proto_head_t));
|
|
|
|
mul_head_t *header = reinterpret_cast<mul_head_t*>(data + sizeof(proto_head_t));
|
|
|
@ -993,6 +1057,7 @@ int Widget::protoHistoryData(char * data)
|
|
|
|
//work->multipleIndexSet(header->index + 1);
|
|
|
|
//work->multipleIndexSet(header->index + 1);
|
|
|
|
sendMsgHistoryDataGet();
|
|
|
|
sendMsgHistoryDataGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::paraseProtocols(char *data)
|
|
|
|
int Widget::paraseProtocols(char *data)
|
|
|
@ -1466,6 +1531,31 @@ int Widget::sendMsgWaveCal()
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::sendMsgLogGet()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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_LOG);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_head->index = logIndex;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::sendMsgHistoryDataGet()
|
|
|
|
int Widget::sendMsgHistoryDataGet()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char buf[2048] = {0};
|
|
|
|
char buf[2048] = {0};
|
|
|
@ -1479,7 +1569,7 @@ int Widget::sendMsgHistoryDataGet()
|
|
|
|
|
|
|
|
|
|
|
|
m_head->index = dataIndex;
|
|
|
|
m_head->index = dataIndex;
|
|
|
|
m_head->len = 0;
|
|
|
|
m_head->len = 0;
|
|
|
|
*data = logSum;
|
|
|
|
*data = historyDataSum;
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验位. */
|
|
|
|
/* 计算校验位. */
|
|
|
|
crc = reinterpret_cast<uint32_t*>(buf + header->len);
|
|
|
|
crc = reinterpret_cast<uint32_t*>(buf + header->len);
|
|
|
@ -1854,7 +1944,7 @@ void Widget::on_stateLogButton_clicked()
|
|
|
|
logIndex = 0;
|
|
|
|
logIndex = 0;
|
|
|
|
QString temp;
|
|
|
|
QString temp;
|
|
|
|
temp.sprintf("0 / %d", ui->stateLogEdit->text().toInt());
|
|
|
|
temp.sprintf("0 / %d", ui->stateLogEdit->text().toInt());
|
|
|
|
//work->logSumSet(ui->stateLogEdit->text().toInt());
|
|
|
|
logSum = ui->stateLogEdit->text().toInt();
|
|
|
|
ui->logTextEdit->clear();
|
|
|
|
ui->logTextEdit->clear();
|
|
|
|
ui->logIndexLabel->setText(temp);
|
|
|
|
ui->logIndexLabel->setText(temp);
|
|
|
|
//work->multipleIndexSet(0);
|
|
|
|
//work->multipleIndexSet(0);
|
|
|
@ -1884,7 +1974,7 @@ 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());
|
|
|
|
logSum = ui->historyDataEdit->text().toInt();
|
|
|
|
historyDataSum = ui->historyDataEdit->text().toInt();
|
|
|
|
ui->dataIndexLabel->setText(temp);
|
|
|
|
ui->dataIndexLabel->setText(temp);
|
|
|
|
sendMsgHistoryDataGet();
|
|
|
|
sendMsgHistoryDataGet();
|
|
|
|
|
|
|
|
|
|
|
|