3122 lines
92 KiB
C++
3122 lines
92 KiB
C++
#include "mainwindow.h"
|
||
#include "ui_mainwindow.h"
|
||
|
||
#include<QGridLayout>
|
||
#include<QFileDialog>
|
||
#include<QPushButton>
|
||
#include <QDebug>
|
||
#include <QMessageBox>
|
||
#include <QThread>
|
||
#include <QtConcurrent/QtConcurrent>
|
||
|
||
|
||
|
||
MainWindow::MainWindow(QWidget *parent)
|
||
: QMainWindow(parent)
|
||
, ui(new Ui::MainWindow)
|
||
{
|
||
ui->setupUi(this);
|
||
|
||
Init();
|
||
}
|
||
|
||
MainWindow::~MainWindow()
|
||
{
|
||
delete ui;
|
||
}
|
||
|
||
void MainWindow::openFile()
|
||
{
|
||
if (ui->openFile->text() == "打开文件") {
|
||
//选择导入的文件路径
|
||
loadpath = QFileDialog::getOpenFileName(this,"选择文件","/", "Files(*.json)");
|
||
qDebug() << loadpath << endl;
|
||
|
||
if(loadpath.isEmpty()) return;
|
||
jsonModel->loadJson(loadpath);
|
||
ui->treeView->expandAll();
|
||
|
||
ui->openFile->setText("保存文件");
|
||
|
||
openFileFlag = true;
|
||
|
||
if (openFileFlag && openSerialPortFlag) {
|
||
ui->readConfigFile->setEnabled(true);
|
||
ui->writeConfigFile->setEnabled(true);
|
||
} else {
|
||
ui->readConfigFile->setEnabled(false);
|
||
ui->writeConfigFile->setEnabled(false);
|
||
}
|
||
|
||
} else {
|
||
if(loadpath.isEmpty()) return;
|
||
jsonModel->dumpJson(loadpath);
|
||
}
|
||
}
|
||
|
||
void MainWindow::scanSerialPort()
|
||
{
|
||
/* 查找可用串口 */
|
||
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
|
||
// ui->SerialPort->addItem(info.portName());
|
||
ui->SerialPort->addItem(info.portName() + ":" +info.description());
|
||
}
|
||
|
||
}
|
||
|
||
void MainWindow::parityItemInit()
|
||
{
|
||
QList <QString> list;
|
||
list<<"None"<<"Even"<<"Odd"<<"Space"<<"Mark";
|
||
for (int i = 0; i < 5; i++) {
|
||
ui->comboBox_4->addItem(list[i]);
|
||
}
|
||
ui->comboBox_4->setCurrentIndex(0);
|
||
}
|
||
|
||
void MainWindow::Init()
|
||
{
|
||
ui->readConfigFile->setEnabled(false);
|
||
ui->writeConfigFile->setEnabled(false);
|
||
|
||
scanSerialPort();
|
||
parityItemInit();
|
||
serialPort = new QSerialPort(this);
|
||
|
||
jsonModel = new JsonTreeModel(this);
|
||
ui->treeView->setModel(jsonModel);
|
||
|
||
openSerialPortFlag = false;
|
||
openFileFlag = false;
|
||
|
||
|
||
connect(ui->openFile,SIGNAL(clicked()),this,SLOT(openFile()));
|
||
|
||
connect(ui->SerialPortPushButton,SIGNAL(clicked())
|
||
,this,SLOT(openSerialPortPushButtonClicked()));
|
||
connect(ui->readConfigFile,SIGNAL(clicked())
|
||
,this,SLOT(readCfgFile()));
|
||
connect(ui->writeConfigFile,SIGNAL(clicked())
|
||
,this,SLOT(writeCfgFile()));
|
||
|
||
}
|
||
|
||
uint16_t MainWindow::modbusCrc(uint8_t *arr_buff, uint8_t len)
|
||
{
|
||
uint16_t crc=0xFFFF;
|
||
uint16_t i, j;
|
||
|
||
for ( j=0; j<len; j++){
|
||
crc=crc ^*arr_buff++;
|
||
for ( i=0; i<8; i++){
|
||
if( ( crc&0x0001) >0){
|
||
crc=crc>>1;
|
||
crc=crc^ 0xa001;
|
||
}else{
|
||
crc=crc>>1;
|
||
}
|
||
}
|
||
}
|
||
return crc;
|
||
}
|
||
|
||
void MainWindow::openSerialPortPushButtonClicked()
|
||
{
|
||
if (ui->SerialPortPushButton->text() == "打开串口") {
|
||
/* 设置串口名 */
|
||
// serialPort->setPortName(ui->SerialPort->currentText());
|
||
serialPort->setPort((const QSerialPortInfo)(ui->SerialPort->currentText().section(':', 0, 0)));
|
||
|
||
/* 设置波特率 */
|
||
serialPort->setBaudRate(ui->comboBox_2->currentText().toInt());
|
||
|
||
/* 设置数据位数 */
|
||
switch (ui->comboBox_3->currentText().toInt()) {
|
||
case 5:
|
||
serialPort->setDataBits(QSerialPort::Data5);
|
||
break;
|
||
case 6:
|
||
serialPort->setDataBits(QSerialPort::Data6);
|
||
break;
|
||
case 7:
|
||
serialPort->setDataBits(QSerialPort::Data7);
|
||
break;
|
||
case 8:
|
||
serialPort->setDataBits(QSerialPort::Data8);
|
||
break;
|
||
default: break;
|
||
}
|
||
|
||
/* 设置奇偶校验 */
|
||
switch (ui->comboBox_4->currentIndex()) {
|
||
case 0:
|
||
serialPort->setParity(QSerialPort::NoParity);
|
||
break;
|
||
case 1:
|
||
serialPort->setParity(QSerialPort::EvenParity);
|
||
break;
|
||
case 2:
|
||
serialPort->setParity(QSerialPort::OddParity);
|
||
break;
|
||
case 3:
|
||
serialPort->setParity(QSerialPort::SpaceParity);
|
||
break;
|
||
case 4:
|
||
serialPort->setParity(QSerialPort::MarkParity);
|
||
break;
|
||
default: break;
|
||
}
|
||
|
||
/* 设置停止位 */
|
||
switch (ui->comboBox_5->currentText().toInt()) {
|
||
case 1:
|
||
serialPort->setStopBits(QSerialPort::OneStop);
|
||
break;
|
||
case 2:
|
||
serialPort->setStopBits(QSerialPort::TwoStop);
|
||
break;
|
||
default: break;
|
||
}
|
||
|
||
/* 设置流控制 */
|
||
serialPort->setFlowControl(QSerialPort::NoFlowControl);
|
||
if (!serialPort->open(QIODevice::ReadWrite))
|
||
QMessageBox::about(NULL, "错误",
|
||
"串口无法打开!可能串口已经被占用!");
|
||
else {
|
||
ui->SerialPort->setEnabled(false);
|
||
ui->comboBox_2->setEnabled(false);
|
||
ui->comboBox_3->setEnabled(false);
|
||
ui->comboBox_4->setEnabled(false);
|
||
ui->comboBox_5->setEnabled(false);
|
||
|
||
ui->SerialPortPushButton->setText("关闭串口");
|
||
ui->label_6->setStyleSheet("color: red;");
|
||
// pushButton[0]->setEnabled(true);
|
||
|
||
openSerialPortFlag = true;
|
||
|
||
if (openFileFlag && openSerialPortFlag) {
|
||
ui->readConfigFile->setEnabled(true);
|
||
ui->writeConfigFile->setEnabled(true);
|
||
} else {
|
||
ui->readConfigFile->setEnabled(false);
|
||
ui->writeConfigFile->setEnabled(false);
|
||
}
|
||
}
|
||
|
||
} else {
|
||
serialPort->close();
|
||
ui->SerialPort->setEnabled(true);
|
||
ui->comboBox_2->setEnabled(true);
|
||
ui->comboBox_3->setEnabled(true);
|
||
ui->comboBox_4->setEnabled(true);
|
||
ui->comboBox_5->setEnabled(true);
|
||
ui->label_6->setStyleSheet("color: block;");
|
||
ui->SerialPortPushButton->setText("打开串口");
|
||
|
||
openSerialPortFlag = false;
|
||
|
||
if (openFileFlag && openSerialPortFlag) {
|
||
ui->readConfigFile->setEnabled(true);
|
||
ui->writeConfigFile->setEnabled(true);
|
||
} else {
|
||
ui->readConfigFile->setEnabled(false);
|
||
ui->writeConfigFile->setEnabled(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
void MainWindow::readCfgFile()
|
||
{
|
||
qDebug(" in readCfgFile ");
|
||
|
||
uint8_t readCfgBuf[256];
|
||
uint8_t *readCfgPoint = readCfgBuf;
|
||
|
||
/* 起始标志 */
|
||
*readCfgPoint = 'S';
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = 'L';
|
||
readCfgPoint += 1;
|
||
|
||
/* 唯一ID */
|
||
// QJsonDocument json_doc;
|
||
|
||
// 判断是否解析失败
|
||
// if (jsonModel->readJson() != true || !json_doc.isNull()) {
|
||
// if (!jsonModel->readJson() || !jsonModel->json_doc.isNull()) {
|
||
// qDebug() << "Json格式错误!" ;
|
||
// return;
|
||
// }
|
||
|
||
|
||
/* 唯一ID */
|
||
bool flag = jsonModel->readJson();
|
||
if (!flag) {
|
||
qDebug() << "Json格式错误1!" ;
|
||
return;
|
||
}
|
||
|
||
if (jsonModel->json_doc.isNull()) {
|
||
qDebug() << "Json格式错误2!" ;
|
||
return;
|
||
}
|
||
|
||
/* 获取根 { } */
|
||
// QJsonObject rootObj = json_doc.object();
|
||
|
||
if (!jsonModel->json_doc.isObject()) {
|
||
qDebug() << "json_doc.isObject()" ;
|
||
}
|
||
|
||
QJsonValue tempValue = jsonModel->json_doc.object().value("充电控制盒配置文件");
|
||
// QJsonValue tempValue = rootObj.value("充电控制盒配置文件");
|
||
// QJsonValue tempValue = rootObj.value("chargeControlCfgFile");
|
||
QJsonObject tempObject;
|
||
QJsonObject rootObj;
|
||
if (tempValue.isObject()) {
|
||
rootObj = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "充电控制盒配置文件 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
|
||
|
||
tempValue = rootObj.value("设备的唯一地址");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "onlyID object error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
|
||
tempValue = tempObject.value("unique_Device_ID");
|
||
QJsonArray tempArray;
|
||
if (tempValue.isArray()) {
|
||
tempArray = tempValue.toArray();
|
||
}
|
||
else {
|
||
qDebug() << "onlyID object error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
|
||
QString tempString = tempArray.at(0).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
bool ok;
|
||
*readCfgPoint = tempString.toInt(&ok, 16);
|
||
readCfgPoint += 1;
|
||
// readCfgBuf[2] = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(1).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[3] = tempString.toInt(&ok, 16);
|
||
*readCfgPoint = tempString.toInt(&ok, 16);
|
||
readCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(2).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[4] = tempString.toInt(&ok, 16);
|
||
*readCfgPoint = tempString.toInt(&ok, 16);
|
||
readCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(3).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[5] = tempString.toInt(&ok, 16);
|
||
*readCfgPoint = tempString.toInt(&ok, 16);
|
||
readCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(4).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[6] = tempString.toInt(&ok, 16);
|
||
*readCfgPoint = tempString.toInt(&ok, 16);
|
||
readCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(5).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[7] = tempString.toInt(&ok, 16);
|
||
*readCfgPoint = tempString.toInt(&ok, 16);
|
||
readCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(6).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[8] = tempString.toInt(&ok, 16);
|
||
*readCfgPoint = tempString.toInt(&ok, 16);
|
||
readCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
// qDebug(" 0x%x ", readCfgBuf[0]);
|
||
// qDebug(" 0x%x ", readCfgBuf[1]);
|
||
// qDebug(" 0x%x ", readCfgBuf[2]);
|
||
// qDebug(" 0x%x ", readCfgBuf[3]);
|
||
// qDebug(" 0x%x ", readCfgBuf[4]);
|
||
// qDebug(" 0x%x ", readCfgBuf[5]);
|
||
// qDebug(" 0x%x ", readCfgBuf[6]);
|
||
// qDebug(" 0x%x ", readCfgBuf[7]);
|
||
// qDebug(" 0x%x ", readCfgBuf[8]);
|
||
/* 功能码 */
|
||
// readCfgBuf[9] = 0xD1;
|
||
*readCfgPoint = 0xD1;
|
||
readCfgPoint += 1;
|
||
|
||
/* 数据长度 */
|
||
*readCfgPoint = 60 >> 8;
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = 60;
|
||
readCfgPoint += 1;
|
||
|
||
/* 数据内容 */
|
||
*readCfgPoint = (uint8_t)(0x0000 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0000;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0001 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0001;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0002 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0002;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0100 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0100;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0101 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0101;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0102 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0102;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0103 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0103;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0104 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0104;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0105 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0105;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0106 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0106;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0107 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0107;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0108 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0108;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0109 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0109;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x010A >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x010A;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x010B >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x010B;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x010C >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x010C;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x010D >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x010D;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x010E >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x010E;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x010F >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x010F;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0110 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0110;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0111 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0111;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0112 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0112;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0113 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0113;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0114 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0114;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0115 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0115;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0116 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0116;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0117 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0117;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0118 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0118;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x0119 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x0119;
|
||
readCfgPoint += 1;
|
||
|
||
*readCfgPoint = (uint8_t)(0x011A >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)0x011A;
|
||
readCfgPoint += 1;
|
||
|
||
/* crc校验 */
|
||
uint16_t tempU16 = 0;
|
||
tempU16 = modbusCrc(readCfgBuf, (60 + 12));
|
||
*readCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
readCfgPoint += 1;
|
||
*readCfgPoint = (uint8_t)tempU16;
|
||
readCfgPoint += 1;
|
||
|
||
/* 结束标志 */
|
||
*readCfgPoint = 0x16;
|
||
|
||
// for (int i = 0; i < 29 * 2 + 12 + 3; i++) {
|
||
// qDebug(" 0x%x ", readCfgBuf[i]);
|
||
// }
|
||
|
||
// /* 设备的唯一地址 */
|
||
// tempValue = rootObj.value("设备的唯一地址");
|
||
// if (tempValue.isObject()) {
|
||
// tempObject = tempValue.toObject();
|
||
// }
|
||
// else {
|
||
// qDebug() << "设备的唯一地址 error" << tempValue.type() ;
|
||
// return;
|
||
// }
|
||
// tempValue = tempObject.value("类型");
|
||
// if (tempValue.isString()) {
|
||
// tempString = tempValue.toString();
|
||
// }
|
||
// else {
|
||
// qDebug() << "设备的唯一地址 error" << tempValue.type() ;
|
||
// return;
|
||
// }
|
||
// tempString.remove("H");
|
||
// // 将字符串转换为整数(基数为 16)
|
||
//// readCfgBuf[11] = tempString.toInt(&ok, 16);
|
||
// *readCfgPoint = tempString.toInt(&ok, 16);
|
||
// readCfgPoint += 1;
|
||
// if (!ok) {
|
||
// qDebug() << "转换失败!";
|
||
// return;
|
||
// }
|
||
// readCfgBuf[10] = 0;
|
||
// readCfgBuf[10]++;
|
||
//// qDebug(" 0x%x ", readCfgBuf[11]);
|
||
|
||
// /* 对上通讯波特率 */
|
||
// tempValue = rootObj.value("SL协议对上通信波特率");
|
||
// if (tempValue.isObject()) {
|
||
// tempObject = tempValue.toObject();
|
||
// }
|
||
// else {
|
||
// qDebug() << "SL协议对上通信波特率error" << tempValue.type() ;
|
||
// return;
|
||
// }
|
||
// tempValue = tempObject.value("类型");
|
||
// if (tempValue.isString()) {
|
||
// tempString = tempValue.toString();
|
||
// }
|
||
// else {
|
||
// qDebug() << "SL协议对上通信波特率类型 error" << tempValue.type() ;
|
||
// return;
|
||
// }
|
||
// tempString.remove("H");
|
||
// // 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[11] = tempString.toInt(&ok, 16);
|
||
// if (!ok) {
|
||
// qDebug() << "转换失败!";
|
||
// return;
|
||
// }
|
||
// readCfgBuf[10]++;
|
||
//// qDebug(" 0x%x ", readCfgBuf[11]);
|
||
|
||
// /* SL协议对下通信波特率 */
|
||
// tempValue = rootObj.value("SL协议对下通信波特率");
|
||
// if (tempValue.isObject()) {
|
||
// tempObject = tempValue.toObject();
|
||
// }
|
||
// else {
|
||
// qDebug() << "SL协议对下通信波特率 error" << tempValue.type() ;
|
||
// return;
|
||
// }
|
||
// tempValue = tempObject.value("类型");
|
||
// if (tempValue.isString()) {
|
||
// tempString = tempValue.toString();
|
||
// }
|
||
// else {
|
||
// qDebug() << "SL协议对下通信波特率 error" << tempValue.type() ;
|
||
// return;
|
||
// }
|
||
// tempString.remove("H");
|
||
// // 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[11] = tempString.toInt(&ok, 16);
|
||
// if (!ok) {
|
||
// qDebug() << "转换失败!";
|
||
// return;
|
||
// }
|
||
// readCfgBuf[10]++;
|
||
|
||
// ui->SerialPortPushButton->setDisabled(true);
|
||
// ui->readConfigFile->setDisabled(true);
|
||
// ui->writeConfigFile->setDisabled(true);
|
||
|
||
serialPort->write(reinterpret_cast<const char*>(readCfgBuf), (60 + 12 + 3));
|
||
|
||
QTimer::singleShot(1500, [this]() {
|
||
QByteArray data = serialPort->readAll();
|
||
// serialPort->write("hello world");
|
||
for (int i = 0; i < data.length(); i++) {
|
||
qDebug() << QString::asprintf("0x%x", static_cast<unsigned char>(data.at(i)));
|
||
}
|
||
|
||
uint16_t crc16;
|
||
uint8_t *repData = (uint8_t *)data.data();
|
||
uint16_t tempU16;
|
||
uint8_t *analysisCfgData = repData + 12;
|
||
|
||
/* 起始标志 */
|
||
if (*repData != 'S' || *(repData + 1) != 'L') {
|
||
qDebug() << "start flag error";
|
||
goto error;
|
||
}
|
||
|
||
/* 功能码 */
|
||
if (*(repData + 9) != 0xD1) {
|
||
qDebug() << "function Code error";
|
||
goto error;
|
||
}
|
||
|
||
tempU16 = (*(repData + 10) << 8) | (*(repData + 11));
|
||
qDebug() << "len" << tempU16;
|
||
crc16 = (*(repData + 12 + tempU16) << 8) | (*(repData + 13 + tempU16));
|
||
|
||
/* crc校验 */
|
||
if (crc16 != modbusCrc(repData, tempU16 + 12)) {
|
||
qDebug() << "crc error";
|
||
qDebug() << QString::asprintf("0x%x", static_cast<uint16_t>(crc16));
|
||
qDebug() << QString::asprintf("0x%x", static_cast<uint16_t>(modbusCrc(repData, tempU16 + 12)));
|
||
goto error;
|
||
}
|
||
|
||
/* 结束标志 */
|
||
if (*(repData + 14 + tempU16) != 0x16) {
|
||
qDebug() << "end flag error";
|
||
goto error;
|
||
}
|
||
|
||
while (analysisCfgData != NULL && analysisCfgData != (repData + 12 + tempU16)) {
|
||
analysisCfgData = analysisReadCfgData(&analysisCfgData);
|
||
}
|
||
if (analysisCfgData != (repData + 12 + tempU16)) {
|
||
qDebug() << "analysisCfgData error";
|
||
goto error;
|
||
}
|
||
|
||
jsonModel->refreshJson();
|
||
|
||
QMessageBox::information(this,
|
||
tr("配置文件"),
|
||
tr("读取配置文件成功"),
|
||
QMessageBox::Ok,
|
||
QMessageBox::Ok);
|
||
// reply = QMessageBox::information(this, "写入成功",
|
||
return;
|
||
|
||
error:
|
||
QMessageBox::information(this,
|
||
tr("配置文件"),
|
||
tr("读取配置文件失败"),
|
||
QMessageBox::Ok,
|
||
QMessageBox::Ok);
|
||
|
||
});
|
||
|
||
// /* 延时1.5S */
|
||
// QThread::msleep(1500);
|
||
// QByteArray data = serialPort->readAll();
|
||
|
||
// ui->SerialPortPushButton->setEnabled(true);
|
||
// ui->readConfigFile->setEnabled(true);
|
||
// ui->writeConfigFile->setEnabled(true);
|
||
|
||
// uint16_t crc16;
|
||
// uint8_t *repData = (uint8_t *)data.data();
|
||
//// QMessageBox::standardButton reply;
|
||
|
||
// if (data.length() < 17) {
|
||
// goto error;
|
||
// }
|
||
|
||
// /* 起始标志 */
|
||
// if (*repData != 'S' || *(repData + 1) != 'L') {
|
||
// goto error;
|
||
// }
|
||
|
||
//// /* 地址 */
|
||
//// if (data.at(0) != 'S' || data.at(1) != 'L') {
|
||
//// goto error;
|
||
//// }
|
||
|
||
// if (*(repData + 9) != 0xD0) {
|
||
// goto error;
|
||
// }
|
||
|
||
// crc16 = (*(repData + 14) << 8) | *(repData + 15);
|
||
// if (crc16 != modbusCrc(repData, 14)) {
|
||
// goto error;
|
||
// }
|
||
|
||
// if (*(repData + 12) != 0xAA) {
|
||
// goto error;
|
||
// }
|
||
|
||
// QMessageBox::information(this,
|
||
// tr("Information消息框标题"),
|
||
// tr("这是Information消息框的内容。"),
|
||
// QMessageBox::Ok | QMessageBox::Cancel,
|
||
// QMessageBox::Ok);
|
||
//// reply = QMessageBox::information(this, "写入成功",
|
||
// return;
|
||
|
||
//error:
|
||
// QMessageBox::information(this,
|
||
// tr("Information消息框标题error"),
|
||
// tr("这是Information消息框的内容error。"),
|
||
// QMessageBox::Ok | QMessageBox::Cancel,
|
||
// QMessageBox::Ok);
|
||
|
||
}
|
||
|
||
|
||
void MainWindow::writeCfgFile()
|
||
{
|
||
qDebug(" in writeCfgFile ");
|
||
uint8_t writeCfgBuf[256];
|
||
uint8_t *writeCfgPoint = writeCfgBuf;
|
||
|
||
/* 起始标志 */
|
||
*writeCfgPoint = 'S';
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = 'L';
|
||
writeCfgPoint += 1;
|
||
|
||
/* 唯一ID */
|
||
// QJsonDocument json_doc;
|
||
|
||
// 判断是否解析失败
|
||
// if (jsonModel->readJson() != true || !json_doc.isNull()) {
|
||
// if (!jsonModel->readJson() || !jsonModel->json_doc.isNull()) {
|
||
// qDebug() << "Json格式错误!" ;
|
||
// return;
|
||
// }
|
||
|
||
|
||
/* 唯一ID */
|
||
bool flag = jsonModel->readJson();
|
||
if (!flag) {
|
||
qDebug() << "Json格式错误1!" ;
|
||
return;
|
||
}
|
||
|
||
if (jsonModel->json_doc.isNull()) {
|
||
qDebug() << "Json格式错误2!" ;
|
||
return;
|
||
}
|
||
|
||
/* 获取根 { } */
|
||
// QJsonObject rootObj = json_doc.object();
|
||
|
||
if (!jsonModel->json_doc.isObject()) {
|
||
qDebug() << "json_doc.isObject()" ;
|
||
}
|
||
|
||
QJsonValue tempValue = jsonModel->json_doc.object().value("充电控制盒配置文件");
|
||
// QJsonValue tempValue = rootObj.value("充电控制盒配置文件");
|
||
// QJsonValue tempValue = rootObj.value("chargeControlCfgFile");
|
||
QJsonObject tempObject;
|
||
QJsonObject rootObj;
|
||
if (tempValue.isObject()) {
|
||
rootObj = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "充电控制盒配置文件 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
|
||
|
||
tempValue = rootObj.value("设备的唯一地址");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "onlyID object error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
|
||
tempValue = tempObject.value("unique_Device_ID");
|
||
QJsonArray tempArray;
|
||
if (tempValue.isArray()) {
|
||
tempArray = tempValue.toArray();
|
||
}
|
||
else {
|
||
qDebug() << "onlyID object error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
|
||
QString tempString = tempArray.at(0).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
bool ok;
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
// readCfgBuf[2] = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(1).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[3] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(2).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[4] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(3).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[5] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(4).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[6] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(5).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[7] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(6).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[8] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
/* 功能码 */
|
||
*writeCfgPoint = 0xD0;
|
||
writeCfgPoint += 1;
|
||
|
||
/* 帧编号 */
|
||
*writeCfgPoint = 1;
|
||
writeCfgPoint += 1;
|
||
|
||
/* 总帧数 */
|
||
*writeCfgPoint = 1;
|
||
writeCfgPoint += 1;
|
||
|
||
|
||
/* 数据长度 */
|
||
uint16_t dataLen = 0;
|
||
writeCfgPoint += 2;
|
||
|
||
/* 数据内容 */
|
||
/* 更改设备的唯一地址 */
|
||
tempValue = rootObj.value("更改设备的唯一地址");
|
||
/*
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "更改设备的唯一地址 error" << tempValue.type() ;
|
||
return;
|
||
}*/
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "更改设备的唯一地址 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
uint16_t tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("更改设备的唯一地址");
|
||
tempValue = tempObject.value("unique_Device_ID");
|
||
if (tempValue.isArray()) {
|
||
tempArray = tempValue.toArray();
|
||
}
|
||
else {
|
||
qDebug() << "更改设备的唯一地址 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(0).toString();
|
||
tempString.remove("0x");
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(1).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[3] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(2).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[4] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(3).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[5] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(4).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[6] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(5).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[7] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
|
||
tempString = tempArray.at(6).toString();
|
||
tempString.remove("0x");
|
||
// 将字符串转换为整数(基数为 16)
|
||
// readCfgBuf[8] = tempString.toInt(&ok, 16);
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
dataLen += 7;
|
||
|
||
/* SL协议对上通信波特率 */
|
||
tempValue = rootObj.value("SL协议对上通信波特率");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "SL协议对上通信波特率 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "更改设备的唯一地址 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("SL协议对上通信波特率");
|
||
tempValue = tempObject.value("SL_Protocol_Communication_Baud_Rate_Up");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "SL_Protocol_Communication_Baud_Rate_Up error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("0x");
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
dataLen += 1;
|
||
|
||
/* SL协议对下通信波特率 */
|
||
tempValue = rootObj.value("SL协议对下通信波特率");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "SL协议对下通信波特率 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("SL协议对下通信波特率");
|
||
tempValue = tempObject.value("SL_Protocol_Communication_Baud_Rate_Down");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "SL_Protocol_Communication_Baud_Rate_Down error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("0x");
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
dataLen += 1;
|
||
|
||
/* 电源盒类型 */
|
||
tempValue = rootObj.value("电源盒类型");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "电源盒类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("电源盒类型");
|
||
tempValue = tempObject.value("power_Box_Type");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "power_Box_Type error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("0x");
|
||
*writeCfgPoint = tempString.toInt(&ok, 16);
|
||
writeCfgPoint += 1;
|
||
dataLen += 1;
|
||
|
||
/* 恒压充电阈值电压 */
|
||
tempValue = rootObj.value("恒压充电阈值电压");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "恒压充电阈值电压 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("恒压充电阈值电压");
|
||
tempValue = tempObject.value("constant_Voltage_V");
|
||
float tempFloat;
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
}
|
||
else if (tempValue.isDouble()) {
|
||
tempFloat = tempValue.toDouble();
|
||
}
|
||
else {
|
||
qDebug() << "constant_Voltage_V error" << tempValue.type();
|
||
return;
|
||
}
|
||
|
||
qDebug() << "constant_Voltage_V:" << tempFloat;
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 浮充充电阈值电流 */
|
||
tempValue = rootObj.value("浮充充电阈值电流");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "浮充充电阈值电流 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("浮充充电阈值电流");
|
||
tempValue = tempObject.value("float_I");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
}
|
||
else if (tempValue.isDouble()) {
|
||
tempFloat = tempValue.toDouble();
|
||
}
|
||
else {
|
||
qDebug() << "float_I error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
// tempFloat = tempString.toFloat(&ok);
|
||
// if (!ok) {
|
||
// qDebug() << "转换失败!";
|
||
// return;
|
||
// }
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 启动充电太阳能板开路电压 */
|
||
tempValue = rootObj.value("启动充电太阳能板开路电压");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "启动充电太阳能板开路电压 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("启动充电太阳能板开路电压");
|
||
tempValue = tempObject.value("start_Solar_Open_Circuit_V");
|
||
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
}
|
||
else if (tempValue.isDouble()) {
|
||
tempFloat = tempValue.toDouble();
|
||
}
|
||
else {
|
||
qDebug() << "start_Solar_Open_Circuit_V error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
// tempFloat = tempString.toFloat(&ok);
|
||
// if (!ok) {
|
||
// qDebug() << "转换失败!";
|
||
// return;
|
||
// }
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 停止充电太阳能板输出电压 */
|
||
tempValue = rootObj.value("停止充电太阳能板输出电压");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "停止充电太阳能板输出电压 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("停止充电太阳能板输出电压");
|
||
tempValue = tempObject.value("stop_Solar_Output_Circuit_V");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
}
|
||
else if (tempValue.isDouble()) {
|
||
tempFloat = tempValue.toDouble();
|
||
}
|
||
else {
|
||
qDebug() << "stop_Solar_Output_Circuit_V error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
// tempFloat = tempString.toFloat(&ok);
|
||
// if (!ok) {
|
||
// qDebug() << "转换失败!";
|
||
// return;
|
||
// }
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 启动时开路电压检测间隔 */
|
||
tempValue = rootObj.value("启动时开路电压检测间隔");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "启动时开路电压检测间隔 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("启动时开路电压检测间隔");
|
||
tempValue = tempObject.value("check_Can_Start_Time");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "check_Can_Start_Time error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 短路判断延时 */
|
||
tempValue = rootObj.value("短路判断延时");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "短路判断延时 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("短路判断延时");
|
||
tempValue = tempObject.value("short_Circuit_Judgment_Delay");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "short_Circuit_Judgment_Delay error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 前端输入功率不足判断延时 */
|
||
tempValue = rootObj.value("前端输入功率不足判断延时");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "前端输入功率不足判断延时 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("前端输入功率不足判断延时");
|
||
tempValue = tempObject.value("input_Power_Low_Judgment_Delay");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "input_Power_Low_Judgment_Delay error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 前端输入功率不足后再次输出延时 */
|
||
tempValue = rootObj.value("前端输入功率不足后再次输出延时");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "前端输入功率不足后再次输出延时 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("前端输入功率不足后再次输出延时");
|
||
tempValue = tempObject.value("input_Power_Low_Again_Output_Delay");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "input_Power_Low_Again_Output_Delay error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 第一段保护延时 */
|
||
tempValue = rootObj.value("第一段保护延时");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "第一段保护延时 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("第一段保护延时");
|
||
tempValue = tempObject.value("first_Stage_Protection_Delay");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "first_Stage_Protection_Delay error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 第一段保护的电流 */
|
||
tempValue = rootObj.value("第一段保护的电流");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "第一段保护的电流 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("第一段保护的电流");
|
||
tempValue = tempObject.value("first_Stage_Protection_Curr");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "first_Stage_Protection_Curr error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 第二段保护延时 */
|
||
tempValue = rootObj.value("第二段保护延时");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "第二段保护延时 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("第二段保护延时");
|
||
tempValue = tempObject.value("second_Stage_Protection_Delay");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "second_Stage_Protection_Delay error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 第二段保护的电流 */
|
||
tempValue = rootObj.value("第二段保护的电流");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "第二段保护的电流 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("第二段保护的电流");
|
||
tempValue = tempObject.value("second_Stage_Protection_Curr");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "second_Stage_Protection_Curr error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 第三段保护延时 */
|
||
tempValue = rootObj.value("第三段保护延时");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "第三段保护延时 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("第三段保护延时");
|
||
tempValue = tempObject.value("third_Stage_Protection_Delay");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "third_Stage_Protection_Delay error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
uint32_t tempU32 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU32 >> 24);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)(tempU32 >> 16);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)(tempU32 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU32;
|
||
writeCfgPoint += 1;
|
||
dataLen += 4;
|
||
|
||
/* 第三段保护的电流 */
|
||
tempValue = rootObj.value("第三段保护的电流");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "第三段保护的电流 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("第三段保护的电流");
|
||
tempValue = tempObject.value("third_Stage_Protection_Curr");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "third_Stage_Protection_Curr error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 前端输入功率不足检测延时 */
|
||
tempValue = rootObj.value("前端输入功率不足检测延时");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "前端输入功率不足检测延时 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("前端输入功率不足检测延时");
|
||
tempValue = tempObject.value("input_Power_Low_Detection_Delay");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "input_Power_Low_Detection_Delay error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 前端输入功率不足检测电压 */
|
||
tempValue = rootObj.value("前端输入功率不足检测电压");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "前端输入功率不足检测电压 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("前端输入功率不足检测电压");
|
||
tempValue = tempObject.value("input_Power_Low_Detection_Volt");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "input_Power_Low_Detection_Volt error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 最大太阳能板输出电压 */
|
||
tempValue = rootObj.value("最大太阳能板输出电压");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "最大太阳能板输出电压 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("最大太阳能板输出电压");
|
||
tempValue = tempObject.value("max_Open_Solar_Output_Circuit_V");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "max_Open_Solar_Output_Circuit_V error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 最大充电电流 */
|
||
tempValue = rootObj.value("最大充电电流");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "最大充电电流 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
qDebug() << "最大充电电流 类型" << tempU16;
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("最大充电电流");
|
||
tempValue = tempObject.value("max_Charg_Curr");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "max_Charg_Curr error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
qDebug() << "最大充电电流" << tempFloat;
|
||
qDebug() << "最大充电电流" << tempU16;
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 检测回路阻抗时的最小充电电流 */
|
||
tempValue = rootObj.value("检测回路阻抗时的最小充电电流");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "检测回路阻抗时的最小充电电流 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("检测回路阻抗时的最小充电电流");
|
||
tempValue = tempObject.value("min_Check_Loop_Impedance_Charg_Curr");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "min_Check_Loop_Impedance_Charg_Curr error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 全功率输出温度 */
|
||
tempValue = rootObj.value("全功率输出温度");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "全功率输出温度 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("全功率输出温度");
|
||
tempValue = tempObject.value("full_Power_Output_Temperature");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "full_Power_Output_Temperature error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 降功率输出温度 */
|
||
tempValue = rootObj.value("降功率输出温度");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "降功率输出温度 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("降功率输出温度");
|
||
tempValue = tempObject.value("reduce_Power_Output_Temperature");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "reduce_Power_Output_Temperature error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 停止输出温度 */
|
||
tempValue = rootObj.value("停止输出温度");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "停止输出温度 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("停止输出温度");
|
||
tempValue = tempObject.value("stop_PowerOutput_Temperature");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "stop_PowerOutput_Temperature error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
|
||
/* 恒压充电时的输出电压 */
|
||
tempValue = rootObj.value("恒压充电时的输出电压");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "恒压充电时的输出电压 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("恒压充电时的输出电压");
|
||
tempValue = tempObject.value("constant_Voltage_Charge_V");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "constant_Voltage_Charge_V error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
qDebug() << "constant_Voltage_Charge_V" << tempFloat;
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
// qDebug() << "constant_Voltage_Charge_V * 10" << tempU16;
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 浮充充电时的输出电压 */
|
||
tempValue = rootObj.value("浮充充电时的输出电压");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "浮充充电时的输出电压 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("浮充充电时的输出电压");
|
||
tempValue = tempObject.value("float_ChargeV");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "float_ChargeV error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempFloat = tempString.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
tempU16 = (uint16_t)(tempFloat * 10 + 0.5f);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 充电时开路电压采集间隔 */
|
||
tempValue = rootObj.value("充电时开路电压采集间隔");
|
||
if (tempValue.isObject()) {
|
||
tempObject = tempValue.toObject();
|
||
}
|
||
else {
|
||
qDebug() << "充电时开路电压采集间隔 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempValue = tempObject.value("类型");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "类型 error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempString.remove("H");
|
||
// 将字符串转换为整数(基数为 16)
|
||
tempU16 = tempString.toInt(&ok, 16);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
tempValue = rootObj.value("充电时开路电压采集间隔");
|
||
tempValue = tempObject.value("collect_OpenCircuit_Voltage_Time");
|
||
if (tempValue.isString()) {
|
||
tempString = tempValue.toString();
|
||
}
|
||
else {
|
||
qDebug() << "collect_OpenCircuit_Voltage_Time error" << tempValue.type() ;
|
||
return;
|
||
}
|
||
tempU16 = tempString.toInt(&ok);
|
||
if (!ok) {
|
||
qDebug() << "转换失败!";
|
||
return;
|
||
}
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
dataLen += 2;
|
||
|
||
/* 数据长度 */
|
||
writeCfgBuf[12] = (uint8_t)(dataLen >> 8);
|
||
writeCfgBuf[13] = (uint8_t)dataLen;
|
||
|
||
/* modbusCrc校验 */
|
||
tempU16 = modbusCrc(writeCfgBuf, dataLen + 14);
|
||
*writeCfgPoint = (uint8_t)(tempU16 >> 8);
|
||
writeCfgPoint += 1;
|
||
*writeCfgPoint = (uint8_t)tempU16;
|
||
writeCfgPoint += 1;
|
||
|
||
*writeCfgPoint = 0x16;
|
||
|
||
// for (int i = 0; i < dataLen + 17; i++) {
|
||
// qDebug(" 0x%x ", writeCfgBuf[i]);
|
||
// }
|
||
|
||
serialPort->write(reinterpret_cast<const char*>(writeCfgBuf), (dataLen + 17));
|
||
|
||
QTimer::singleShot(1500, [this]() {
|
||
QByteArray data = serialPort->readAll();
|
||
// serialPort->write("hello world");
|
||
for (int i = 0; i < data.length(); i++) {
|
||
qDebug() << QString::asprintf("0x%x", static_cast<unsigned char>(data.at(i)));
|
||
}
|
||
uint16_t crc16;
|
||
uint8_t *repData = (uint8_t *)data.data();
|
||
// QMessageBox::standardButton reply;
|
||
|
||
if (data.length() < 16) {
|
||
qDebug() << "len is error";
|
||
goto error;
|
||
}
|
||
|
||
/* 起始标志 */
|
||
if (*repData != 'S' || *(repData + 1) != 'L') {
|
||
qDebug() << "start flag error";
|
||
goto error;
|
||
}
|
||
|
||
// /* 地址 */
|
||
// if (data.at(0) != 'S' || data.at(1) != 'L') {
|
||
// goto error;
|
||
// }
|
||
|
||
if (*(repData + 9) != 0xD0) {
|
||
qDebug() << "function code error";
|
||
goto error;
|
||
}
|
||
|
||
crc16 = (*(repData + 13) << 8) | *(repData + 14);
|
||
if (crc16 != modbusCrc(repData, 13)) {
|
||
qDebug() << "crc error";
|
||
goto error;
|
||
}
|
||
|
||
if (*(repData + 12) != 0xAA) {
|
||
qDebug() << "data error";
|
||
goto error;
|
||
}
|
||
|
||
QMessageBox::information(this,
|
||
tr("配置文件"),
|
||
tr("写入配置文件成功"),
|
||
QMessageBox::Ok,
|
||
QMessageBox::Ok);
|
||
// reply = QMessageBox::information(this, "写入成功",
|
||
return;
|
||
|
||
error:
|
||
QMessageBox::information(this,
|
||
tr("配置文件"),
|
||
tr("写入配置文件失败"),
|
||
QMessageBox::Ok,
|
||
QMessageBox::Ok);
|
||
|
||
});
|
||
|
||
|
||
// /* 延时1.5S */
|
||
// QThread::msleep(1500);
|
||
// QByteArray data = serialPort->readAll();
|
||
|
||
|
||
// serialPort->write("hello world");
|
||
|
||
//// ui->SerialPortPushButton->setEnabled(true);
|
||
//// ui->readConfigFile->setEnabled(true);
|
||
//// ui->writeConfigFile->setEnabled(true);
|
||
// for (int i = 0; i < data.length(); i++) {
|
||
// qDebug() << QString::asprintf("0x%x", data.at(i));
|
||
// }
|
||
|
||
|
||
// uint16_t crc16;
|
||
// uint8_t *repData = (uint8_t *)data.data();
|
||
//// QMessageBox::standardButton reply;
|
||
|
||
// if (data.length() < 17) {
|
||
// goto error;
|
||
// }
|
||
|
||
// /* 起始标志 */
|
||
// if (*repData != 'S' || *(repData + 1) != 'L') {
|
||
// goto error;
|
||
// }
|
||
|
||
//// /* 地址 */
|
||
//// if (data.at(0) != 'S' || data.at(1) != 'L') {
|
||
//// goto error;
|
||
//// }
|
||
|
||
// if (*(repData + 9) != 0xD0) {
|
||
// goto error;
|
||
// }
|
||
|
||
// crc16 = (*(repData + 14) << 8) | *(repData + 15);
|
||
// if (crc16 != modbusCrc(repData, 14)) {
|
||
// goto error;
|
||
// }
|
||
|
||
// if (*(repData + 12) != 0xAA) {
|
||
// goto error;
|
||
// }
|
||
|
||
// QMessageBox::information(this,
|
||
// tr("配置文件"),
|
||
// tr("写入配置文件成功"),
|
||
// QMessageBox::Ok,
|
||
// QMessageBox::Ok);
|
||
//// reply = QMessageBox::information(this, "写入成功",
|
||
// return;
|
||
|
||
//error:
|
||
// QMessageBox::information(this,
|
||
// tr("配置文件"),
|
||
// tr("写入配置文件失败"),
|
||
// QMessageBox::Ok,
|
||
// QMessageBox::Ok);
|
||
}
|
||
|
||
uint8_t *MainWindow::analysisReadCfgData(uint8_t **cfgData)
|
||
{
|
||
QJsonValue tempValue = jsonModel->json_doc.object().value("充电控制盒配置文件");
|
||
QJsonObject rootObj;
|
||
QJsonObject tempObject;
|
||
rootObj = tempValue.toObject();
|
||
|
||
uint16_t dataType;
|
||
dataType = (**cfgData << 8) | *(*cfgData + 1);
|
||
|
||
/* 唯一ID */
|
||
if (dataType == 0x0000) {
|
||
tempValue = rootObj.value("更改设备的唯一地址");
|
||
tempObject = tempValue.toObject();
|
||
tempValue = tempObject.value("unique_Device_ID");
|
||
|
||
QJsonArray tempArray = tempValue.toArray();
|
||
|
||
// tempArray.replace(0, QString::asprintf("0x%x", (*(*cfgData + 2))));
|
||
// tempArray.replace(1, QString::asprintf("0x%x", (*(*cfgData + 3))));
|
||
// tempArray.replace(2, QString::asprintf("0x%x", (*(*cfgData + 4))));
|
||
// tempArray.replace(3, QString::asprintf("0x%x", (*(*cfgData + 5))));
|
||
// tempArray.replace(4, QString::asprintf("0x%x", (*(*cfgData + 6))));
|
||
// tempArray.replace(5, QString::asprintf("0x%x", (*(*cfgData + 7))));
|
||
// tempArray.replace(6, QString::asprintf("0x%x", (*(*cfgData + 8))));
|
||
|
||
// tempObject["unique_Device_ID"] = tempArray;
|
||
|
||
return (*cfgData + 9);
|
||
}
|
||
|
||
/* 对上通信波特率 */
|
||
if (dataType == 0x0001) {
|
||
tempValue = rootObj.value("SL协议对上通信波特率");
|
||
tempObject = tempValue.toObject();
|
||
|
||
tempObject["SL_Protocol_Communication_Baud_Rate_Up"] = QString::asprintf("0x%x", (*(*cfgData + 2)));
|
||
// tempObject["SL_Protocol_Communication_Baud_Rate_Up"] = "0x03";
|
||
|
||
rootObj["SL协议对上通信波特率"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 3);
|
||
}
|
||
|
||
/* 对下通信波特率 */
|
||
if (dataType == 0x0002) {
|
||
tempValue = rootObj.value("SL协议对下通信波特率");
|
||
tempObject = tempValue.toObject();
|
||
|
||
tempObject["SL_Protocol_Communication_Baud_Rate_Down"] = QString::asprintf("0x%x", (*(*cfgData + 2)));
|
||
|
||
rootObj["SL协议对下通信波特率"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 3);
|
||
}
|
||
|
||
/* 电源盒类型 */
|
||
if (dataType == 0x0100) {
|
||
tempValue = rootObj.value("电源盒类型");
|
||
tempObject = tempValue.toObject();
|
||
tempObject["power_Box_Type"] = QString::asprintf("0x%x", (*(*cfgData + 2)));
|
||
|
||
rootObj["电源盒类型"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 3);
|
||
}
|
||
|
||
/* 恒压充电阈值电压 */
|
||
if (dataType == 0x0101) {
|
||
tempValue = rootObj.value("恒压充电阈值电压");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2)) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["constant_Voltage_V"] = tempF;
|
||
|
||
rootObj["恒压充电阈值电压"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 浮充充电阈值电流 */
|
||
if (dataType == 0x0102) {
|
||
tempValue = rootObj.value("浮充充电阈值电流");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["float_I"] = tempF;
|
||
|
||
rootObj["浮充充电阈值电流"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 启动充电太阳能板开路电压 */
|
||
if (dataType == 0x0103) {
|
||
tempValue = rootObj.value("启动充电太阳能板开路电压");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["start_Solar_Open_Circuit_V"] = tempF;
|
||
|
||
rootObj["启动充电太阳能板开路电压"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 停止充电太阳能板输出电压 */
|
||
if (dataType == 0x0104) {
|
||
tempValue = rootObj.value("停止充电太阳能板输出电压");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["stop_Solar_Output_Circuit_V"] = tempF;
|
||
|
||
rootObj["停止充电太阳能板输出电压"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 启动时开路电压检测间隔 */
|
||
if (dataType == 0x0105) {
|
||
tempValue = rootObj.value("启动时开路电压检测间隔");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["check_Can_Start_Time"] = tempU16;
|
||
|
||
rootObj["启动时开路电压检测间隔"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 短路判断延时 */
|
||
if (dataType == 0x0106) {
|
||
tempValue = rootObj.value("短路判断延时");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["short_Circuit_Judgment_Delay"] = tempU16;
|
||
|
||
rootObj["短路判断延时"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 前端输入功率不足判断延时 */
|
||
if (dataType == 0x0107) {
|
||
tempValue = rootObj.value("前端输入功率不足判断延时");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["input_Power_Low_Judgment_Delay"] = tempU16;
|
||
|
||
rootObj["前端输入功率不足判断延时"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 前端输入功率不足后再次输出延时 */
|
||
if (dataType == 0x0108) {
|
||
tempValue = rootObj.value("前端输入功率不足后再次输出延时");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["input_Power_Low_Again_Output_Delay"] = tempU16;
|
||
|
||
rootObj["前端输入功率不足后再次输出延时"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 第一段保护延时 */
|
||
if (dataType == 0x0109) {
|
||
tempValue = rootObj.value("第一段保护延时");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["first_Stage_Protection_Delay"] = tempU16;
|
||
|
||
rootObj["第一段保护延时"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 第一段保护的电流 */
|
||
if (dataType == 0x010A) {
|
||
tempValue = rootObj.value("第一段保护的电流");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["first_Stage_Protection_Curr"] = tempF;
|
||
|
||
rootObj["第一段保护的电流"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 第二段保护延时 */
|
||
if (dataType == 0x010B) {
|
||
tempValue = rootObj.value("第二段保护延时");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["second_Stage_Protection_Delay"] = tempU16;
|
||
|
||
rootObj["第二段保护延时"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 第二段保护的电流 */
|
||
if (dataType == 0x010C) {
|
||
tempValue = rootObj.value("第二段保护的电流");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["second_Stage_Protection_Curr"] = tempF;
|
||
|
||
rootObj["第二段保护的电流"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 第三段保护延时 */
|
||
if (dataType == 0x010D) {
|
||
tempValue = rootObj.value("第三段保护延时");
|
||
tempObject = tempValue.toObject();
|
||
int tempU32 = (*(*cfgData + 2) << 24) | (*(*cfgData + 3) << 16) | (*(*cfgData + 4) << 8) | (*(*cfgData + 5));
|
||
tempObject["third_Stage_Protection_Delay"] = tempU32;
|
||
|
||
rootObj["第三段保护延时"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 6);
|
||
}
|
||
|
||
/* 第三段保护的电流 */
|
||
if (dataType == 0x010E) {
|
||
tempValue = rootObj.value("第三段保护的电流");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["third_Stage_Protection_Curr"] = tempF;
|
||
|
||
rootObj["第三段保护的电流"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 前端输入功率不足检测延时 */
|
||
if (dataType == 0x010F) {
|
||
tempValue = rootObj.value("前端输入功率不足检测延时");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["input_Power_Low_Detection_Delay"] = tempU16;
|
||
|
||
rootObj["前端输入功率不足检测延时"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 前端输入功率不足检测电压 */
|
||
if (dataType == 0x0110) {
|
||
tempValue = rootObj.value("前端输入功率不足检测电压");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["input_Power_Low_Detection_Volt"] = tempF;
|
||
|
||
rootObj["前端输入功率不足检测电压"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 最大太阳能板输出电压 */
|
||
if (dataType == 0x0111) {
|
||
tempValue = rootObj.value("最大太阳能板输出电压");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["max_Open_Solar_Output_Circuit_V"] = tempF;
|
||
|
||
rootObj["最大太阳能板输出电压"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 最大充电电流 */
|
||
if (dataType == 0x0112) {
|
||
tempValue = rootObj.value("最大充电电流");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["max_Charg_Curr"] = tempF;
|
||
|
||
rootObj["最大充电电流"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 检测回路阻抗时的最小充电电流 */
|
||
if (dataType == 0x0113) {
|
||
tempValue = rootObj.value("检测回路阻抗时的最小充电电流");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["min_Check_Loop_Impedance_Charg_Curr"] = tempF;
|
||
|
||
rootObj["检测回路阻抗时的最小充电电流"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 全功率输出温度 */
|
||
if (dataType == 0x0114) {
|
||
tempValue = rootObj.value("全功率输出温度");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["full_Power_Output_Temperature"] = tempF;
|
||
|
||
rootObj["全功率输出温度"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 降功率输出温度 */
|
||
if (dataType == 0x0115) {
|
||
tempValue = rootObj.value("降功率输出温度");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["reduce_Power_Output_Temperature"] = tempF;
|
||
|
||
rootObj["降功率输出温度"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 停止输出温度 */
|
||
if (dataType == 0x0116) {
|
||
tempValue = rootObj.value("停止输出温度");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["stop_PowerOutput_Temperature"] = tempF;
|
||
|
||
rootObj["停止输出温度"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 恒压充电时的输出电压 */
|
||
if (dataType == 0x0117) {
|
||
tempValue = rootObj.value("恒压充电时的输出电压");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["constant_Voltage_Charge_V"] = tempF;
|
||
|
||
rootObj["恒压充电时的输出电压"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 浮充充电时的输出电压 */
|
||
if (dataType == 0x0118) {
|
||
tempValue = rootObj.value("浮充充电时的输出电压");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["float_ChargeV"] = tempF;
|
||
|
||
rootObj["浮充充电时的输出电压"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 充电时开路电压采集间隔 */
|
||
if (dataType == 0x0119) {
|
||
tempValue = rootObj.value("充电时开路电压采集间隔");
|
||
tempObject = tempValue.toObject();
|
||
uint16_t tempU16 = (*(*cfgData + 2) << 8) | (*(*cfgData + 3));
|
||
tempObject["collect_OpenCircuit_Voltage_Time"] = tempU16;
|
||
|
||
rootObj["充电时开路电压采集间隔"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
/* 反向充电保护电流 */
|
||
if (dataType == 0x011A) {
|
||
tempValue = rootObj.value("反向充电保护电流");
|
||
tempObject = tempValue.toObject();
|
||
float tempF = (float)((*(*cfgData + 2) << 8) | (*(*cfgData + 3))) / 10.0f;
|
||
tempObject["reverse_Charge_Protection_Curr"] = tempF;
|
||
|
||
rootObj["反向充电保护电流"] = tempObject;
|
||
QJsonObject jsonDocObj = jsonModel->json_doc.object();
|
||
jsonDocObj["充电控制盒配置文件"] = rootObj;
|
||
jsonModel->json_doc.setObject(jsonDocObj);
|
||
|
||
return (*cfgData + 4);
|
||
}
|
||
|
||
qDebug() << "analysisCfgData error" << dataType;
|
||
return NULL;
|
||
}
|