|
|
@ -26,6 +26,12 @@ Widget::Widget(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
|
|
memset(powerFre, 0, sizeof(powerFre));
|
|
|
|
memset(powerFre, 0, sizeof(powerFre));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(&clientDevState, 0, sizeof(devState));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(&clientAdjInfo, 0, sizeof(dev_adj_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(&clientAdjSet, 0, sizeof(adjSet));
|
|
|
|
|
|
|
|
|
|
|
|
isConnected = 0;
|
|
|
|
isConnected = 0;
|
|
|
|
upFileRecvSize = 0;
|
|
|
|
upFileRecvSize = 0;
|
|
|
|
upFileSize = 0;
|
|
|
|
upFileSize = 0;
|
|
|
@ -606,6 +612,58 @@ void Widget::uiPowerFrequencyRefresh()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 手动校准界面刷新. */
|
|
|
|
|
|
|
|
void Widget::uiManualAdjustRefresh()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint8_t ch = 0;
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取校准通道. */
|
|
|
|
|
|
|
|
for(uint8_t i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QCheckBox *checkBox = reinterpret_cast<QCheckBox*>(ui->adjustTable->cellWidget(i, 0));
|
|
|
|
|
|
|
|
if (checkBox->isChecked())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ch = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ch >= ui->adjustTable->rowCount())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ch = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index = ui->manualAdjBox->currentIndex();
|
|
|
|
|
|
|
|
ui->manualAdjLabel->setText("输入电流" + QString::number(clientAdjInfo.ADCBase_elec[ch][index] / 1000) + "A");
|
|
|
|
|
|
|
|
ui->manualAdjButton->setText("手动校准段" + QString::number(index + 1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::uiAdjustInfoRefresh()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString temp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 2)->setText(QString::number(clientAdjInfo.ADCRatio[i]));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 3)->setText(QString::number(clientAdjInfo.ADC_turns[i]));
|
|
|
|
|
|
|
|
for(int j = 0; j < DAU_POWER_ADJ_CNT; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, j * 3 + 4)->setText(QString::number(clientAdjInfo.ADCBase_elec[i][j]));
|
|
|
|
|
|
|
|
temp.sprintf("%.1f", static_cast<double>(clientAdjInfo.ADCBase[i][j]));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, j * 3 + 5)->setText(temp);
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, j * 3 + 6)->setText(QString::number(clientAdjInfo.ADCAdj[i][j]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->vinEdit->setText(QString::number(clientAdjInfo.vin_adj));
|
|
|
|
|
|
|
|
ui->vinAdjEdit->setText(QString::number(clientAdjInfo.vin));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uiManualAdjustRefresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::protoContact(char *data)
|
|
|
|
void Widget::protoContact(char *data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *pbody = data + sizeof(proto_head_t);
|
|
|
|
char *pbody = data + sizeof(proto_head_t);
|
|
|
@ -768,6 +826,48 @@ int Widget::protoState(char *data)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::protoManualAdjust(char *data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int32_t rv = *reinterpret_cast<int32_t*>(data + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustInfoGet();
|
|
|
|
|
|
|
|
buttonEnable(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 判断返回值. */
|
|
|
|
|
|
|
|
if (0 == rv)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::information(this, "SUCCEED", "校准完成.", QMessageBox::Ok);
|
|
|
|
|
|
|
|
int index = ui->manualAdjBox->currentIndex();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
if (index >= DAU_POWER_ADJ_CNT)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->manualAdjBox->setCurrentIndex(index);
|
|
|
|
|
|
|
|
uiManualAdjustRefresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::warning(this, "WARNING", "校准失败!", QMessageBox::Ok);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::protoAdjustInfo(char *data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* 获取参数. */
|
|
|
|
|
|
|
|
memcpy(&clientAdjInfo, data + sizeof(proto_head_t), sizeof(dev_adj_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 更新界面. */
|
|
|
|
|
|
|
|
protoManualAdjust(data);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::paraseProtocols(char *data)
|
|
|
|
int Widget::paraseProtocols(char *data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(data);
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(data);
|
|
|
@ -821,10 +921,11 @@ int Widget::paraseProtocols(char *data)
|
|
|
|
protoWaveDataUploadReply(data);
|
|
|
|
protoWaveDataUploadReply(data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_INFO:
|
|
|
|
case DEBUG_PRV_ADJ_INFO:
|
|
|
|
//_debug_pkt_adj_get();
|
|
|
|
protoAdjustInfo(data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_INFO_SET:
|
|
|
|
case DEBUG_PRV_ADJ_INFO_SET:
|
|
|
|
//_debug_pkt_adj_set();
|
|
|
|
/* 更新界面. */
|
|
|
|
|
|
|
|
QMessageBox::information(this, "SUCCEED", "操作完成.", QMessageBox::Ok);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_AUTO:
|
|
|
|
case DEBUG_PRV_ADJ_AUTO:
|
|
|
|
//_debug_pkt_adj_auto();
|
|
|
|
//_debug_pkt_adj_auto();
|
|
|
@ -845,7 +946,7 @@ int Widget::paraseProtocols(char *data)
|
|
|
|
//_debug_pkt_history_data_get();
|
|
|
|
//_debug_pkt_history_data_get();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_MANUAL:
|
|
|
|
case DEBUG_PRV_ADJ_MANUAL:
|
|
|
|
//_debug_pkt_adj_manual();
|
|
|
|
protoManualAdjust(data);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_CSG_CONFIG: // 获取配置成功后更新页面
|
|
|
|
case DEBUG_PRV_CSG_CONFIG: // 获取配置成功后更新页面
|
|
|
|
protoCsgConfig(data);
|
|
|
|
protoCsgConfig(data);
|
|
|
@ -1138,6 +1239,65 @@ int Widget::sendMsgDevicePowerFrequencyGet()
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Widget::sendMsgDeviceAdjustInfoSet()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char buf[2048] = {0};
|
|
|
|
|
|
|
|
uint32_t *crc = nullptr;
|
|
|
|
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(buf);
|
|
|
|
|
|
|
|
dev_adj_t *pdata = reinterpret_cast<dev_adj_t*>(buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 初始化报文头. */
|
|
|
|
|
|
|
|
protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_ADJ_INFO_SET);
|
|
|
|
|
|
|
|
memcpy(pdata, &clientAdjInfo, sizeof(dev_adj_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验位. */
|
|
|
|
|
|
|
|
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::sendMsgDeviceAdjustInfoGet()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char buf[2048] = {0};
|
|
|
|
|
|
|
|
uint32_t *crc = nullptr;
|
|
|
|
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(buf);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 初始化报文头. */
|
|
|
|
|
|
|
|
protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_ADJ_INFO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验位. */
|
|
|
|
|
|
|
|
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::sendMsgDeviceAdjustMode(int cmd)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char buf[2048] = {0};
|
|
|
|
|
|
|
|
uint32_t *crc = nullptr;
|
|
|
|
|
|
|
|
proto_head_t *header = reinterpret_cast<proto_head_t*>(buf);
|
|
|
|
|
|
|
|
adjSet *pdata = reinterpret_cast<adjSet*>(buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 初始化报文头. */
|
|
|
|
|
|
|
|
protoHeaderInit(header, sizeof(proto_head_t) + sizeof(adjSet), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, cmd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(pdata, &clientAdjSet, sizeof(adjSet));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验位. */
|
|
|
|
|
|
|
|
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::sendMsgWaveCol()
|
|
|
|
int Widget::sendMsgWaveCol()
|
|
|
@ -1651,3 +1811,252 @@ void Widget::on_waveButton_clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_manualRatioSetButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* 获取参数. */
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
clientAdjInfo.ADCRatio[i] = ui->adjustTable->item(i, 2)->text().toUShort();
|
|
|
|
|
|
|
|
clientAdjInfo.ADC_turns[i] = static_cast<uint8_t>(ui->adjustTable->item(i, 3)->text().toUShort());
|
|
|
|
|
|
|
|
for(int j = 0; j < DAU_POWER_ADJ_CNT ; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
clientAdjInfo.ADCBase_elec[i][j] = ui->adjustTable->item(i, 4 + j * 3)->text().toUInt();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clientAdjInfo.vin_adj = ui->vinEdit->text().toUShort();
|
|
|
|
|
|
|
|
clientAdjInfo.vin = ui->vinAdjEdit->text().toUShort();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustInfoSet();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uiManualAdjustRefresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_manualAdjBox_activated(int index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (index < 10)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uiManualAdjustRefresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_manualAdjButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
adjSet adj;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(&adj, 0, sizeof(adjSet));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取校准通道. */
|
|
|
|
|
|
|
|
for(int32_t i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QCheckBox *checkBox = reinterpret_cast<QCheckBox*>(ui->adjustTable->cellWidget(i, 0));
|
|
|
|
|
|
|
|
if (checkBox->isChecked())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
adj.chSelecet |= 1 << i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adj.manualIndex = static_cast<uint8_t>(ui->manualAdjBox->currentIndex());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
|
|
|
|
buttonEnable(false);
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_MANUAL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_RatioParamGetButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString fileWritePath;
|
|
|
|
|
|
|
|
fileWritePath.append(QCoreApplication::applicationDirPath() + "/adjParam.bin");
|
|
|
|
|
|
|
|
QFile file_write(fileWritePath);
|
|
|
|
|
|
|
|
if (!file_write.open(QIODevice::WriteOnly))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::warning(this, "WARNING", "文件 " + fileWritePath + " 创建失败!", QMessageBox::Ok);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDataStream out(&file_write);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取参数. */
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
clientAdjInfo.ADCRatio[i] = ui->adjustTable->item(i, 2)->text().toUShort();
|
|
|
|
|
|
|
|
clientAdjInfo.ADC_turns[i] = static_cast<uint8_t>(ui->adjustTable->item(i, 3)->text().toUShort());
|
|
|
|
|
|
|
|
for(int j = 0; j < DAU_POWER_ADJ_CNT ; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
clientAdjInfo.ADCBase_elec[i][j] = ui->adjustTable->item(i, 4 + j * 3)->text().toUInt();
|
|
|
|
|
|
|
|
clientAdjInfo.ADCBase[i][j] = ui->adjustTable->item(i, 5 + j * 3)->text().toFloat();
|
|
|
|
|
|
|
|
clientAdjInfo.ADCAdj[i][j] = ui->adjustTable->item(i, 6 + j * 3)->text().toUShort();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clientAdjInfo.vin_adj = ui->vinEdit->text().toUShort();
|
|
|
|
|
|
|
|
clientAdjInfo.vin = ui->vinAdjEdit->text().toUShort();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out.writeRawData(reinterpret_cast<char*>(&clientAdjInfo), sizeof(dev_adj_t));
|
|
|
|
|
|
|
|
file_write.close();
|
|
|
|
|
|
|
|
QMessageBox::information(this, "SUCCEED", "校准系数文件 " + fileWritePath + " 导出完成.", QMessageBox::Ok);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_RatioParamSetButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString Path;
|
|
|
|
|
|
|
|
QString curPath = QCoreApplication::applicationDirPath();
|
|
|
|
|
|
|
|
dev_adj_t tempAdj;
|
|
|
|
|
|
|
|
if (adjFilePath.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
curPath = QCoreApplication::applicationDirPath();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QFileInfo fileinfo = QFileInfo(adjFilePath);
|
|
|
|
|
|
|
|
curPath = fileinfo.path();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Path = QFileDialog::getOpenFileName(this, "Select adj param File", curPath, "*.bin");
|
|
|
|
|
|
|
|
if (Path.isEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adjFilePath = Path;
|
|
|
|
|
|
|
|
settings->setValue("adjFile", adjFilePath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFile file_read(adjFilePath);
|
|
|
|
|
|
|
|
if (!file_read.open(QIODevice::ReadOnly))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::warning(this, "WARNING", "文件 " + adjFilePath +" 打开失败!", QMessageBox::Ok);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDataStream in(&file_read);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int len = in.readRawData(reinterpret_cast<char*>(&tempAdj), sizeof(dev_adj_t));
|
|
|
|
|
|
|
|
if (len != sizeof(dev_adj_t))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
file_read.close();
|
|
|
|
|
|
|
|
QMessageBox::warning(this, "WARNING", "文件 " + adjFilePath +" 读取失败!", QMessageBox::Ok);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_read.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString temp;
|
|
|
|
|
|
|
|
memcpy(&clientAdjInfo, &tempAdj, sizeof(dev_adj_t));
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 2)->setText(QString::number(clientAdjInfo.ADCRatio[i]));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 3)->setText(QString::number(clientAdjInfo.ADC_turns[i]));
|
|
|
|
|
|
|
|
for(int j = 0; j < DAU_POWER_ADJ_CNT; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, j * 3 + 4)->setText(QString::number(clientAdjInfo.ADCBase_elec[i][j]));
|
|
|
|
|
|
|
|
temp.sprintf("%.1f", static_cast<double>(clientAdjInfo.ADCBase[i][j]));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, j * 3 + 5)->setText(temp);
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, j * 3 + 6)->setText(QString::number(clientAdjInfo.ADCAdj[i][j]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->vinEdit->setText(QString::number(clientAdjInfo.vin_adj));
|
|
|
|
|
|
|
|
ui->vinAdjEdit->setText(QString::number(clientAdjInfo.vin));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustInfoSet();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_ratioSetButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint16_t ratio = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取参数. */
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ratio = ui->adjustTable->item(i, 2)->text().toUShort();
|
|
|
|
|
|
|
|
if (40 == ratio)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 4)->setText(QString::number(1000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 7)->setText(QString::number(5000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 10)->setText(QString::number(10000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 13)->setText(QString::number(50000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 16)->setText(QString::number(100000));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(60 == ratio)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 4)->setText(QString::number(1000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 7)->setText(QString::number(5000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 10)->setText(QString::number(10000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 13)->setText(QString::number(50000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 16)->setText(QString::number(100000));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(200 == ratio)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 4)->setText(QString::number(1000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 7)->setText(QString::number(10000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 10)->setText(QString::number(50000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 13)->setText(QString::number(100000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 16)->setText(QString::number(200000));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(400 == ratio)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 4)->setText(QString::number(1000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 7)->setText(QString::number(10000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 10)->setText(QString::number(50000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 13)->setText(QString::number(100000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 16)->setText(QString::number(200000));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(1000 == ratio)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 4)->setText(QString::number(5000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 7)->setText(QString::number(10000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 10)->setText(QString::number(50000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 13)->setText(QString::number(250000));
|
|
|
|
|
|
|
|
ui->adjustTable->item(i, 16)->setText(QString::number(500000));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取参数. */
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
clientAdjInfo.ADCRatio[i] = ui->adjustTable->item(i, 2)->text().toUShort();
|
|
|
|
|
|
|
|
clientAdjInfo.ADC_turns[i] = static_cast<uint8_t>(ui->adjustTable->item(i, 3)->text().toUShort());
|
|
|
|
|
|
|
|
for(int j = 0; j < DAU_POWER_ADJ_CNT ; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
clientAdjInfo.ADCBase_elec[i][j] = ui->adjustTable->item(i, 4 + j * 3)->text().toUInt();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clientAdjInfo.vin_adj = ui->vinEdit->text().toUShort();
|
|
|
|
|
|
|
|
clientAdjInfo.vin = ui->vinAdjEdit->text().toUShort();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustInfoSet();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Widget::on_adjButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
adjSet adj;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(&adj, 0, sizeof(adjSet));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 获取校准通道. */
|
|
|
|
|
|
|
|
for(int32_t i = 0; i < ui->adjustTable->rowCount(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QCheckBox *checkBox = reinterpret_cast<QCheckBox*>(ui->adjustTable->cellWidget(i, 0));
|
|
|
|
|
|
|
|
if (checkBox->isChecked())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
adj.chSelecet |= 1 << i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ui->voltageAdjButtonBox->isChecked())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
adj.isVoltageSel = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 下发配置. */
|
|
|
|
|
|
|
|
//work->adjChSet(&adj);
|
|
|
|
|
|
|
|
buttonEnable(false);
|
|
|
|
|
|
|
|
//work->stateSet(CM_usart::WS_ADJ_AUTO);
|
|
|
|
|
|
|
|
sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_AUTO);
|
|
|
|
|
|
|
|
}
|
|
|
|