Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
a492baea18 | |||
096df8075c | |||
ba1b01bccc |
@ -45,6 +45,29 @@ public:
|
|||||||
bool createConfigFile();
|
bool createConfigFile();
|
||||||
bool updateConfigFile();
|
bool updateConfigFile();
|
||||||
|
|
||||||
|
private:
|
||||||
|
string m_configfilePath;
|
||||||
|
Config cfg;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ParameterConfigfile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ParameterConfigfile();
|
||||||
|
void setConfigfilePath(string configfilePath);
|
||||||
|
bool isConfigfileExist();
|
||||||
|
bool parseConfigfile();
|
||||||
|
|
||||||
|
bool getFrameRate(int &frameRate);
|
||||||
|
bool setFrameRate(int frameRate);
|
||||||
|
|
||||||
|
bool getExposeTime(float &exposeTime);
|
||||||
|
bool setExposeTime(float exposeTime);
|
||||||
|
|
||||||
|
bool createConfigFile();
|
||||||
|
// bool updateConfigFile();
|
||||||
|
bool writeConfig2File();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_configfilePath;
|
string m_configfilePath;
|
||||||
Config cfg;
|
Config cfg;
|
||||||
|
@ -130,7 +130,7 @@ public:
|
|||||||
|
|
||||||
void setFramerate(double framerate);
|
void setFramerate(double framerate);
|
||||||
double getFramerate();
|
double getFramerate();
|
||||||
double setExposureTime(float exposureTime);
|
double setExposureTime(float exposureTime_in_us);
|
||||||
int wrapSetExposureTime(float exposureTime_in_us);
|
int wrapSetExposureTime(float exposureTime_in_us);
|
||||||
double getExposureTime();
|
double getExposureTime();
|
||||||
double autoExposure();
|
double autoExposure();
|
||||||
@ -188,6 +188,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Configfile m_configfile;
|
Configfile m_configfile;
|
||||||
|
ParameterConfigfile m_parameterConfigfile;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -468,3 +468,172 @@ bool Configfile::updateConfigFile()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ParameterConfigfile::ParameterConfigfile()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParameterConfigfile::setConfigfilePath(string configfilePath)
|
||||||
|
{
|
||||||
|
m_configfilePath = configfilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::isConfigfileExist()
|
||||||
|
{
|
||||||
|
QFileInfo info(QString::fromStdString(m_configfilePath));
|
||||||
|
|
||||||
|
return info.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::parseConfigfile()
|
||||||
|
{
|
||||||
|
// Read the file. If there is an error, report it and exit.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cfg.readFile(m_configfilePath);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const FileIOException &fioex)
|
||||||
|
{
|
||||||
|
std::cerr << "I/O error while reading file." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch(const ParseException &pex)
|
||||||
|
{
|
||||||
|
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||||
|
<< " - " << pex.getError() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::createConfigFile()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
using namespace libconfig;
|
||||||
|
|
||||||
|
Config cfg;
|
||||||
|
|
||||||
|
Setting &root = cfg.getRoot();
|
||||||
|
|
||||||
|
// Add some settings to the configuration.
|
||||||
|
// Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
||||||
|
// Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
|
||||||
|
// Setting &SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
|
||||||
|
|
||||||
|
Setting &ximeaParam = root.add("ximeaParam", Setting::TypeGroup);
|
||||||
|
ximeaParam.add("frameRate", Setting::TypeInt) = 100;
|
||||||
|
ximeaParam.add("exposeTime", Setting::TypeFloat) = 10.0;
|
||||||
|
|
||||||
|
|
||||||
|
// Write out the new configuration.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||||
|
bool ret = createDir(fileInfo[0]);
|
||||||
|
|
||||||
|
cfg.writeFile(m_configfilePath.c_str());
|
||||||
|
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(const FileIOException &fioex)
|
||||||
|
{
|
||||||
|
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::getFrameRate(int &frameRate)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const Setting &ximeaParam = root["ximeaParam"];
|
||||||
|
frameRate = ximeaParam.lookup("frameRate");
|
||||||
|
|
||||||
|
std::cout << "----------------"<< frameRate<<std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'frameRate' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::setFrameRate(int frameRate)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Setting &frameRate2 = root["ximeaParam"]["frameRate"];
|
||||||
|
frameRate2 = frameRate;
|
||||||
|
|
||||||
|
writeConfig2File();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'frameRate' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::getExposeTime(float &exposeTime)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const Setting &ximeaParam = root["ximeaParam"];
|
||||||
|
exposeTime = ximeaParam.lookup("exposeTime");
|
||||||
|
|
||||||
|
std::cout << "----------------"<< exposeTime<<std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'exposeTime' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::setExposeTime(float exposeTime)
|
||||||
|
{
|
||||||
|
const Setting& root = cfg.getRoot();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Setting &frameRate2 = root["ximeaParam"]["exposeTime"];
|
||||||
|
frameRate2 = exposeTime;
|
||||||
|
|
||||||
|
writeConfig2File();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'exposeTime' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ParameterConfigfile::writeConfig2File()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||||
|
bool ret = createDir(fileInfo[0]);
|
||||||
|
|
||||||
|
cfg.writeFile(m_configfilePath.c_str());
|
||||||
|
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||||
|
}
|
||||||
|
catch(const FileIOException &fioex)
|
||||||
|
{
|
||||||
|
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::cout<<"ximeaAirborneSystem 版本:"<< "36." <<std::endl;
|
std::cout<<"ximeaAirborneSystem 版本:"<< "38." <<std::endl;
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
//UdpServer* x=new UdpServer();
|
//UdpServer* x=new UdpServer();
|
||||||
|
@ -608,66 +608,43 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
|||||||
//判断模式是否为: NAV_POSITION
|
//判断模式是否为: NAV_POSITION
|
||||||
if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_EKF_EULER)
|
if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_EKF_EULER)
|
||||||
{
|
{
|
||||||
m_iSolutionModeCounter++;//
|
m_iSolutionModeCounter++;
|
||||||
|
|
||||||
uint32_t status=logData.ekfEulerData.status;
|
uint32_t status=logData.ekfEulerData.status;
|
||||||
uint32_t mode=status>>24;//?????????????????????????????????????
|
uint32_t mode=status & 0xf;
|
||||||
// uint32_t mode=status;//这是错的
|
|
||||||
|
|
||||||
//一秒钟发射一次mode
|
//一秒钟发射一次mode
|
||||||
if(m_iSolutionModeCounter%200 == 0)
|
if(m_iSolutionModeCounter%200 == 0)
|
||||||
{
|
{
|
||||||
emit sbgSolutionModeSignal(mode);
|
emit sbgSolutionModeSignal(mode);
|
||||||
|
// std::cout << "logData.ekfEulerData.status: " << status << std::endl;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode) {
|
||||||
{
|
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
||||||
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
// std::cout << "此刻模式为: " << "UNINITIALIZED" << std::endl;
|
||||||
// std::cout<<"此刻模式为: "<<"UNINITIALIZED"<<std::endl;
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
break;
|
break;
|
||||||
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
||||||
// std::cout<<"此刻模式为: "<<"VERTICAL_GYRO"<<std::endl;
|
// std::cout << "此刻模式为: " << "VERTICAL_GYRO" << std::endl;
|
||||||
break;
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
case SBG_ECOM_SOL_MODE_AHRS:
|
break;
|
||||||
// std::cout<<"此刻模式为: "<<"AHRS"<<std::endl;
|
case SBG_ECOM_SOL_MODE_AHRS:
|
||||||
break;
|
// std::cout << "此刻模式为: " << "AHRS" << std::endl;
|
||||||
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
// std::cout<<"此刻模式为: "<<"NAV_VELOCITY"<<std::endl;
|
break;
|
||||||
break;
|
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
||||||
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
// std::cout << "此刻模式为: " << "NAV_VELOCITY" << std::endl;
|
||||||
// std::cout<<"此刻模式为: "<<"NAV_POSITION"<<std::endl;
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
|
break;
|
||||||
|
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
||||||
|
// std::cout << "此刻模式为: " << "NAV_POSITION" << std::endl;
|
||||||
|
m_bIsNAV_POSITION_MODE = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
|
||||||
// std::cout<<"此刻模式为: "<<"UNINITIALIZED"<<std::endl;
|
|
||||||
m_bIsNAV_POSITION_MODE=false;
|
|
||||||
break;
|
|
||||||
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
|
||||||
// std::cout<<"此刻模式为: "<<"VERTICAL_GYRO"<<std::endl;
|
|
||||||
m_bIsNAV_POSITION_MODE=false;
|
|
||||||
break;
|
|
||||||
case SBG_ECOM_SOL_MODE_AHRS:
|
|
||||||
// std::cout<<"此刻模式为: "<<"AHRS"<<std::endl;
|
|
||||||
m_bIsNAV_POSITION_MODE=false;
|
|
||||||
break;
|
|
||||||
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
|
||||||
// std::cout<<"此刻模式为: "<<"NAV_VELOCITY"<<std::endl;
|
|
||||||
m_bIsNAV_POSITION_MODE=false;
|
|
||||||
break;
|
|
||||||
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
|
||||||
// std::cout<<"此刻模式为: "<<"NAV_POSITION"<<std::endl;
|
|
||||||
m_bIsNAV_POSITION_MODE=true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_GPS1_POS)
|
else if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_GPS1_POS)
|
||||||
{
|
{
|
||||||
@ -687,6 +664,10 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
|||||||
|
|
||||||
// std::cout<<"纬度精度为:"<<maximal<<std::endl;
|
// std::cout<<"纬度精度为:"<<maximal<<std::endl;
|
||||||
// std::cout<<"numSvUsed:"<<satelliteCounter<<std::endl;
|
// std::cout<<"numSvUsed:"<<satelliteCounter<<std::endl;
|
||||||
|
//
|
||||||
|
// std::cout<<"latitude:"<<logData.gpsPosData.latitude<<std::endl;
|
||||||
|
// std::cout<<"longitude:"<<logData.gpsPosData.longitude<<std::endl;
|
||||||
|
// std::cout<<"altitude:"<<logData.gpsPosData.altitude<<std::endl;
|
||||||
|
|
||||||
emit sbgAccuracySignal(static_cast<int>(maximal), satelliteCounter);
|
emit sbgAccuracySignal(static_cast<int>(maximal), satelliteCounter);
|
||||||
|
|
||||||
@ -727,7 +708,7 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
|||||||
|
|
||||||
|
|
||||||
//控制开始采集高光谱影像,m_bIsNAV_POSITION_MODE &&
|
//控制开始采集高光谱影像,m_bIsNAV_POSITION_MODE &&
|
||||||
if(m_bIsRecordHyperspecatralImage && m_bIsSyncSystemTimeBaseGpstime && receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_UTC_TIME)
|
if(m_bIsRecordHyperspecatralImage && m_bIsSyncSystemTimeBaseGpstime && m_bIsNAV_POSITION_MODE)
|
||||||
{
|
{
|
||||||
m_baseFileName=getFileNameBaseOnTime();
|
m_baseFileName=getFileNameBaseOnTime();
|
||||||
emit sbgReady(calculateTimeDifferenceBetweenSystemAndSbg(logData),m_baseFileName);
|
emit sbgReady(calculateTimeDifferenceBetweenSystemAndSbg(logData),m_baseFileName);
|
||||||
|
@ -28,6 +28,11 @@ XimeaImager::XimeaImager()
|
|||||||
std::cout<<"ximea.cfg 错误:bin1 波段数小于 bin2 波段数的 2 倍!"<<std::endl;
|
std::cout<<"ximea.cfg 错误:bin1 波段数小于 bin2 波段数的 2 倍!"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ximeaParamCfgFile = "/media/nvme/300TC/config/ximeaParam.cfg";
|
||||||
|
m_parameterConfigfile.setConfigfilePath(ximeaParamCfgFile.toStdString());
|
||||||
|
if(!m_parameterConfigfile.isConfigfileExist())
|
||||||
|
m_parameterConfigfile.createConfigFile();
|
||||||
|
m_parameterConfigfile.parseConfigfile();
|
||||||
|
|
||||||
m_recordTempThread=new QThread();
|
m_recordTempThread=new QThread();
|
||||||
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
||||||
@ -121,7 +126,20 @@ void XimeaImager::openImger()
|
|||||||
m_imager.setAcqBufferSize(acqBufferSize);
|
m_imager.setAcqBufferSize(acqBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
setFramerate(100);
|
if (m_parameterConfigfile.isConfigfileExist())
|
||||||
|
{
|
||||||
|
int frameRate;
|
||||||
|
m_parameterConfigfile.getFrameRate(frameRate);
|
||||||
|
setFramerate(frameRate);
|
||||||
|
|
||||||
|
float exposeTime;
|
||||||
|
m_parameterConfigfile.getExposeTime(exposeTime);
|
||||||
|
wrapSetExposureTime(exposeTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setFramerate(100);
|
||||||
|
}
|
||||||
|
|
||||||
//经验证:frameSizeManual和frameSizeAuto相等
|
//经验证:frameSizeManual和frameSizeAuto相等
|
||||||
int frameSizeManual = m_imager.get_band_count()*m_imager.get_sample_count()*2;
|
int frameSizeManual = m_imager.get_band_count()*m_imager.get_sample_count()*2;
|
||||||
@ -186,14 +204,16 @@ void XimeaImager::setFramerate(double framerate)
|
|||||||
{
|
{
|
||||||
m_imager.set_framerate(framerate);
|
m_imager.set_framerate(framerate);
|
||||||
|
|
||||||
int maxExposureTimeInUs=1/framerate*1000000*0.01;
|
int maxExposureTimeInUs=1/framerate*1000000;
|
||||||
setExposureTime(maxExposureTimeInUs);
|
// setExposureTime(maxExposureTimeInUs);
|
||||||
// setExposureTime(1000);
|
// setExposureTime(1000);
|
||||||
|
|
||||||
m_iImagerState=102;
|
m_iImagerState=102;
|
||||||
emit ximeaImageStatus(m_iImagerState);
|
emit ximeaImageStatus(m_iImagerState);
|
||||||
|
|
||||||
emit frameRateSignal(framerate);
|
emit frameRateSignal(framerate);
|
||||||
|
|
||||||
|
m_parameterConfigfile.setFrameRate(framerate);
|
||||||
}
|
}
|
||||||
catch(int xiApiErrorCodes)
|
catch(int xiApiErrorCodes)
|
||||||
{
|
{
|
||||||
@ -240,6 +260,7 @@ double XimeaImager::setExposureTime(float exposureTime_in_us)
|
|||||||
|
|
||||||
//返回设置的积分时间
|
//返回设置的积分时间
|
||||||
integrationTime2Return=m_imager.get_integration_time();
|
integrationTime2Return=m_imager.get_integration_time();
|
||||||
|
m_parameterConfigfile.setExposeTime(integrationTime2Return);
|
||||||
|
|
||||||
return integrationTime2Return;
|
return integrationTime2Return;
|
||||||
}
|
}
|
||||||
@ -528,8 +549,7 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
|||||||
{
|
{
|
||||||
if(m_iImagerState <= 99 || m_iImagerState==100 || m_iImagerState==104)
|
if(m_iImagerState <= 99 || m_iImagerState==100 || m_iImagerState==104)
|
||||||
{
|
{
|
||||||
emit ximeaImageStatus(m_iImagerState);
|
printf("已经开始采集----------------------------!\n");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user