第一次提交
This commit is contained in:
203
Source/M300/PSDK_Qt/Config/ConfigParser_M300RTK.cpp
Normal file
203
Source/M300/PSDK_Qt/Config/ConfigParser_M300RTK.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
#include "ConfigParser_M300RTK.h"
|
||||
|
||||
ZZ_ConfigParser_M300RTK::ZZ_ConfigParser_M300RTK(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_bInit = false;
|
||||
//return 0;
|
||||
}
|
||||
|
||||
ZZ_ConfigParser_M300RTK::~ZZ_ConfigParser_M300RTK()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ZZ_ConfigParser_M300RTK::GetParams(AppRegInfo& struAppRegInfo, HardwareInfo& struHardwareInfo,UIConfig& struUIConfig)
|
||||
{
|
||||
Initialize("/home/DJI/Settings/");
|
||||
LoadParams();
|
||||
struAppRegInfo = m_struAppRegInfo;
|
||||
struHardwareInfo = m_struHardwareInfo;
|
||||
struUIConfig = m_struUIConfig;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ConfigParser_M300RTK::UpdateUIConfig(UIConfig struUIConfig)
|
||||
{
|
||||
m_pqfM300ConfigFiles[2]->setValue(QString("PSDK/CaptureMode"), struUIConfig.sCaptureMode);
|
||||
|
||||
m_pqfM300ConfigFiles[2]->setValue(QString("PSDK/SamplingRate"), struUIConfig.sSamplingRate);
|
||||
|
||||
m_pqfM300ConfigFiles[2]->setValue(QString("PSDK/DecisionHeight"), struUIConfig.sDecisionHeight);
|
||||
}
|
||||
|
||||
int ZZ_ConfigParser_M300RTK::Initialize(QString qstrConfigFolderPath)
|
||||
{
|
||||
if (m_bInit)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
QDir qdConfigFiles(qstrConfigFolderPath);
|
||||
if (!qdConfigFiles.exists())
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300: Func Initialize. Dir not exists";
|
||||
return 1;
|
||||
}
|
||||
|
||||
qdConfigFiles.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
qdConfigFiles.setSorting(QDir::DirsFirst);
|
||||
|
||||
QFileInfoList qfList = qdConfigFiles.entryInfoList();
|
||||
if (qfList.size() < 1)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func Initialize. Empty folder";
|
||||
return 2;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
do
|
||||
{
|
||||
QFileInfo qfInfo = qfList.at(i);
|
||||
bool bisDir = qfInfo.isDir();
|
||||
if (bisDir)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (qfInfo.fileName() == "AppInfoConfig.ini")
|
||||
{
|
||||
//QSettings qsTemp(qfInfo.filePath(), QSettings::Format::IniFormat);
|
||||
m_pqfM300ConfigFiles[0] = new QSettings(qfInfo.filePath(), QSettings::Format::IniFormat);
|
||||
qDebug() << qfInfo.filePath();
|
||||
j++;
|
||||
}
|
||||
if (qfInfo.fileName() == "HardwareSettings.ini")
|
||||
{
|
||||
//m_qfM300ConfigFiles[1].setUserIniPath(qfInfo.filePath());
|
||||
m_pqfM300ConfigFiles[1] = new QSettings(qfInfo.filePath(), QSettings::Format::IniFormat);
|
||||
qDebug() << qfInfo.filePath();
|
||||
j++;
|
||||
}
|
||||
if (qfInfo.fileName() == "SystemSettings.ini")
|
||||
{
|
||||
m_pqfM300ConfigFiles[2] = new QSettings(qfInfo.filePath(), QSettings::Format::IniFormat);
|
||||
//m_qfM300ConfigFiles[2].setUserIniPath(qfInfo.filePath());
|
||||
qDebug() << qfInfo.filePath();
|
||||
j++;
|
||||
}
|
||||
//qDebug() << qfInfo.filePath() << ":" << qfInfo.fileName();
|
||||
}
|
||||
++i;
|
||||
} while (i < qfList.size());
|
||||
|
||||
if (j != 3)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func Initialize. File count not match";
|
||||
return 3;
|
||||
}
|
||||
|
||||
m_bInit = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ConfigParser_M300RTK::LoadParams()
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QString qstrUSER_APP_NAME = m_pqfM300ConfigFiles[0]->value(QString("DJI/USER_APP_NAME"),"Error").toString();
|
||||
qDebug() << qstrUSER_APP_NAME;
|
||||
if (qstrUSER_APP_NAME=="Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.USER_APP_NAME not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_APP_ID = m_pqfM300ConfigFiles[0]->value(QString("DJI/USER_APP_ID"), "Error").toString();
|
||||
qDebug() << qstrUSER_APP_ID;
|
||||
if (qstrUSER_APP_ID == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.USER_APP_ID not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_APP_KEY = m_pqfM300ConfigFiles[0]->value(QString("DJI/USER_APP_KEY"), "Error").toString();
|
||||
qDebug() << qstrUSER_APP_KEY;
|
||||
if (qstrUSER_APP_KEY == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.USER_APP_KEY not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_APP_LICENSE = m_pqfM300ConfigFiles[0]->value(QString("DJI/USER_APP_LICENSE"), "Error").toString();
|
||||
qDebug() << qstrUSER_APP_LICENSE;
|
||||
if (qstrUSER_APP_LICENSE == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.USER_APP_KEY not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString qstrUSER_DEVELOPER_ACCOUNT = m_pqfM300ConfigFiles[0]->value(QString("DJI/USER_DEVELOPER_ACCOUNT"), "Error").toString();
|
||||
qDebug() << qstrUSER_DEVELOPER_ACCOUNT;
|
||||
if (qstrUSER_DEVELOPER_ACCOUNT == "Error")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.USER_APP_KEY not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_struAppRegInfo.qstrUserAppAcc = qstrUSER_DEVELOPER_ACCOUNT;
|
||||
m_struAppRegInfo.qstrUserAppID = qstrUSER_APP_ID;
|
||||
m_struAppRegInfo.qstrUserAppKey = qstrUSER_APP_KEY;
|
||||
m_struAppRegInfo.qstrUserAppLic = qstrUSER_APP_LICENSE;
|
||||
m_struAppRegInfo.qstrUserAppName = qstrUSER_APP_NAME;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QString qstrUSER_BAUD_RATE = m_pqfM300ConfigFiles[1]->value(QString("COMPORT/USER_BAUD_RATE"),"NULL").toString();
|
||||
qDebug() << qstrUSER_BAUD_RATE;
|
||||
if (qstrUSER_BAUD_RATE == "NULL")
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.USER_BAUD_RATE not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
int iCONFIG_HARDWARE_CONNECTION = m_pqfM300ConfigFiles[1]->value(QString("ADV MODE/CONFIG_HARDWARE_CONNECTION"),10000).toInt();
|
||||
qDebug() << iCONFIG_HARDWARE_CONNECTION;
|
||||
if (iCONFIG_HARDWARE_CONNECTION == 10000)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.CONFIG_HARDWARE_CONNECTION not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_struHardwareInfo.enumHCM = HardwareConnectionMode(iCONFIG_HARDWARE_CONNECTION);
|
||||
m_struHardwareInfo.qstrBaudRate = qstrUSER_BAUD_RATE;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int iCaptureMode = m_pqfM300ConfigFiles[2]->value(QString("PSDK/CaptureMode"), -1).toInt();
|
||||
qDebug() << iCaptureMode;
|
||||
if (iCaptureMode == -1)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.CaptureMode not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_struUIConfig.sCaptureMode = (short)iCaptureMode;
|
||||
|
||||
int iSamplingRate = m_pqfM300ConfigFiles[2]->value(QString("PSDK/SamplingRate"), -1).toInt();
|
||||
qDebug() << iSamplingRate;
|
||||
if (iSamplingRate == -1)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.SamplingRate not load";
|
||||
return 1;
|
||||
}
|
||||
m_struUIConfig.sSamplingRate = (short)iSamplingRate;
|
||||
|
||||
int iDecisionHeight = m_pqfM300ConfigFiles[2]->value(QString("PSDK/DecisionHeight"), -1).toInt();
|
||||
qDebug() << iDecisionHeight;
|
||||
if (iDecisionHeight == -1)
|
||||
{
|
||||
qDebug() << "ZZ_ConfigParser_M300:Func LoadParams.DecisionHeight not load";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
26
Source/M300/PSDK_Qt/Config/ConfigParser_M300RTK.h
Normal file
26
Source/M300/PSDK_Qt/Config/ConfigParser_M300RTK.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types_M300.h"
|
||||
using namespace ZZ::Device::DJI::M300RTK;
|
||||
|
||||
class ZZ_ConfigParser_M300RTK :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_ConfigParser_M300RTK(QObject* parent = nullptr);
|
||||
virtual ~ZZ_ConfigParser_M300RTK();
|
||||
public:
|
||||
private:
|
||||
bool m_bInit;
|
||||
QSettings *m_pqfM300ConfigFiles[3];
|
||||
|
||||
AppRegInfo m_struAppRegInfo;
|
||||
HardwareInfo m_struHardwareInfo;
|
||||
UIConfig m_struUIConfig;
|
||||
public:
|
||||
int GetParams(AppRegInfo &struAppRegInfo, HardwareInfo &struHardwareInfo, UIConfig& struUIConfig);
|
||||
int UpdateUIConfig(UIConfig struUIConfig);
|
||||
private:
|
||||
int Initialize(QString qstrConfigFolderPath);
|
||||
int LoadParams();
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
[DJI]
|
||||
USER_APP_NAME=Project_Grixis
|
||||
USER_APP_ID=126401
|
||||
USER_APP_KEY=a313e3617b16c56a11502bd91a61d6f
|
||||
USER_APP_LICENSE=BNrpsD+UJ2lj8kmVgN4GnXg+AZiQwaxSuf/WvA072DFdLy2h+NCQizf+nR+WcjEEKeTknSzPbfqlvAc/WSJwrtqV/gYXSVPtSlK0AaV61SeKBvZQpogoyaZy07fWNCZrha3OAQsHj18TtU5RjOn6gYapzGDAPQVG6Q/At/H/9GSPQr5uwxI20fVWUTOkymYLM/04CNQGsToPD+fZwixExjjjHjdD9K7R0D4EgyvbqMpMLlkspBLR/9h6/oVxefOyaHJIi+pk+IdLFFC3omnrh7U3/4b95LA3t22J1GJvqvO2cyphjrSXsaDdctvtj6EjE8WhEXQCvmYm0VIHWz/0Qw==
|
||||
USER_DEVELOPER_ACCOUNT=1033584732@qq.com
|
@ -0,0 +1,4 @@
|
||||
[COMPORT]
|
||||
USER_BAUD_RATE=230400
|
||||
[ADV MODE]
|
||||
CONFIG_HARDWARE_CONNECTION=1
|
@ -0,0 +1,4 @@
|
||||
[PSDK]
|
||||
SamplingRate=1
|
||||
CaptureMode=0
|
||||
DecisionHeight=10
|
Reference in New Issue
Block a user