Compare commits
13 Commits
35
...
061e1f83bd
Author | SHA1 | Date | |
---|---|---|---|
061e1f83bd | |||
d0b67b47c1 | |||
7fa3b70d10 | |||
781b33f577 | |||
f33103c970 | |||
a341e0b2c5 | |||
19e2309be7 | |||
a492baea18 | |||
096df8075c | |||
ba1b01bccc | |||
e4a7c4481b | |||
1476c2bc15 | |||
6d6b662cec |
@ -49,4 +49,55 @@ 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();
|
||||
|
||||
string m_configfilePath;
|
||||
Config cfg;
|
||||
private:
|
||||
};
|
||||
|
||||
class StateOf300tcConfigfile:public ParameterConfigfile
|
||||
{
|
||||
public:
|
||||
StateOf300tcConfigfile();
|
||||
|
||||
bool getSwitchState(bool &switchState);
|
||||
bool setSwitchState(bool switchState);
|
||||
|
||||
bool getSbgState(int &sbgState);
|
||||
bool setSbgState(int sbgState);
|
||||
|
||||
bool getSbgSolutionMode(int &sbgSolutionMode);
|
||||
bool setSbgSolutionMode(int sbgSolutionMode);
|
||||
|
||||
bool getXimeaState(int &ximeaState);
|
||||
bool setXimeaState(int ximeaState);
|
||||
|
||||
bool getExposeMaxValueOfOneFrame(int &exposeMaxValueOfOneFrame);
|
||||
bool setExposeMaxValueOfOneFrame(int exposeMaxValueOfOneFrame);
|
||||
|
||||
bool createConfigFile();
|
||||
|
||||
private:
|
||||
bool getIntValue(int &value, string field);
|
||||
bool setIntValue(int value, string field);
|
||||
|
||||
};
|
||||
#endif //XIMEAIMAGERECORDER_CONFIGFILE_H
|
||||
|
@ -11,17 +11,43 @@
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QDir>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
|
||||
#include "ximeaimager.h"
|
||||
#include "sbgrecorder.h"
|
||||
#include "fileoperation.h"
|
||||
|
||||
#include "configfile.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// #include <sbgEComLib.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
|
||||
class Record300TcTemperature : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Record300TcTemperature();
|
||||
|
||||
void stopRecordTemperature();
|
||||
|
||||
private:
|
||||
bool m_bIsRecord;
|
||||
|
||||
QSerialPort * m_serial;
|
||||
|
||||
float parseMessage(QByteArray * data);
|
||||
public slots:
|
||||
void recordTemperature(QString filePath);
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
class UdpServer:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -48,6 +74,11 @@ class UdpServer:public QObject
|
||||
|
||||
void sender(int status);
|
||||
|
||||
QThread * m_recordTempThread;
|
||||
Record300TcTemperature * m_300tcTemperature;
|
||||
|
||||
StateOf300tcConfigfile stateOf300tc;
|
||||
|
||||
signals:
|
||||
void systemStart();
|
||||
void systemStop();
|
||||
@ -56,6 +87,7 @@ signals:
|
||||
void startDeleteFileSignal();
|
||||
|
||||
void recordXimeaOnlySignal(double,QString);
|
||||
void record300tcTemperatureSignal(QString);
|
||||
|
||||
public slots:
|
||||
void onRecordFinished();
|
||||
|
@ -70,12 +70,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class XimeaImager;
|
||||
class RecordXimeaTemperature : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RecordXimeaTemperature(Iris::IrisXimeaImager * imager);
|
||||
RecordXimeaTemperature(Iris::IrisXimeaImager * imager, XimeaImager * ximeaImager);
|
||||
|
||||
void stopRecordTemperature();
|
||||
|
||||
@ -83,6 +84,7 @@ private:
|
||||
Iris::IrisXimeaImager * m_imager;
|
||||
|
||||
bool m_bIsRecord;
|
||||
XimeaImager * m_ximeaImager;
|
||||
public slots:
|
||||
void recordTemperature(QString filePath);
|
||||
|
||||
@ -130,7 +132,7 @@ public:
|
||||
|
||||
void setFramerate(double framerate);
|
||||
double getFramerate();
|
||||
double setExposureTime(float exposureTime);
|
||||
double setExposureTime(float exposureTime_in_us);
|
||||
int wrapSetExposureTime(float exposureTime_in_us);
|
||||
double getExposureTime();
|
||||
double autoExposure();
|
||||
@ -188,6 +190,7 @@ private:
|
||||
}
|
||||
|
||||
Configfile m_configfile;
|
||||
ParameterConfigfile m_parameterConfigfile;
|
||||
|
||||
|
||||
|
||||
|
@ -468,3 +468,295 @@ bool Configfile::updateConfigFile()
|
||||
|
||||
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 << "ParameterConfigfile::getFrameRate:"<< 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 << "ParameterConfigfile::getExposeTime"<< 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;
|
||||
}
|
||||
|
||||
StateOf300tcConfigfile::StateOf300tcConfigfile()
|
||||
{
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getIntValue(int &value, string field)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
const Setting &ximeaParam = root["ximeaParam"];
|
||||
value = ximeaParam.lookup(field);
|
||||
|
||||
// std::cout << "StateOf300tcConfigfile::getIntValue"<< value<<std::endl;
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setIntValue(int value, string field)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
Setting &frameRate2 = root["ximeaParam"][field];
|
||||
frameRate2 = value;
|
||||
|
||||
writeConfig2File();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::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("sbgState", Setting::TypeInt) = 0;
|
||||
ximeaParam.add("sbgSolutionMode", Setting::TypeInt) = 0;
|
||||
ximeaParam.add("ximeaState", Setting::TypeInt) = 100;
|
||||
ximeaParam.add("frameRate", Setting::TypeInt) = 0;
|
||||
ximeaParam.add("exposeTime", Setting::TypeFloat) = 0.0;
|
||||
ximeaParam.add("exposeMaxValueOfOneFrame", Setting::TypeInt) = 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 StateOf300tcConfigfile::getSbgState(int &sbgState)
|
||||
{
|
||||
return getIntValue(sbgState,"sbgState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setSbgState(int sbgState)
|
||||
{
|
||||
return setIntValue(sbgState,"sbgState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getSbgSolutionMode(int &sbgSolutionMode)
|
||||
{
|
||||
return getIntValue(sbgSolutionMode,"sbgSolutionMode");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setSbgSolutionMode(int sbgSolutionMode)
|
||||
{
|
||||
return setIntValue(sbgSolutionMode,"sbgSolutionMode");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getXimeaState(int &ximeaState)
|
||||
{
|
||||
return getIntValue(ximeaState,"ximeaState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setXimeaState(int ximeaState)
|
||||
{
|
||||
return setIntValue(ximeaState,"ximeaState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getExposeMaxValueOfOneFrame(int &exposeMaxValueOfOneFrame)
|
||||
{
|
||||
return getIntValue(exposeMaxValueOfOneFrame,"exposeMaxValueOfOneFrame");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setExposeMaxValueOfOneFrame(int exposeMaxValueOfOneFrame)
|
||||
{
|
||||
return setIntValue(exposeMaxValueOfOneFrame,"exposeMaxValueOfOneFrame");
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout<<"ximeaAirborneSystem 版本:"<< "35." <<std::endl;
|
||||
std::cout<<"ximeaAirborneSystem 版本:"<< "41." <<std::endl;
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
//UdpServer* x=new UdpServer();
|
||||
|
@ -608,66 +608,43 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
||||
//判断模式是否为: NAV_POSITION
|
||||
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 mode=status>>24;//?????????????????????????????????????
|
||||
// uint32_t mode=status;//这是错的
|
||||
uint32_t mode=status & 0xf;
|
||||
|
||||
//一秒钟发射一次mode
|
||||
if(m_iSolutionModeCounter%200 == 0)
|
||||
{
|
||||
emit sbgSolutionModeSignal(mode);
|
||||
// std::cout << "logData.ekfEulerData.status: " << status << std::endl;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
||||
// std::cout<<"此刻模式为: "<<"UNINITIALIZED"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
||||
// std::cout<<"此刻模式为: "<<"VERTICAL_GYRO"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_AHRS:
|
||||
// std::cout<<"此刻模式为: "<<"AHRS"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
||||
// std::cout<<"此刻模式为: "<<"NAV_VELOCITY"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
||||
// std::cout<<"此刻模式为: "<<"NAV_POSITION"<<std::endl;
|
||||
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;
|
||||
break;
|
||||
default:
|
||||
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)
|
||||
{
|
||||
@ -687,6 +664,10 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
||||
|
||||
// std::cout<<"纬度精度为:"<<maximal<<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);
|
||||
|
||||
@ -727,7 +708,7 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
||||
|
||||
|
||||
//控制开始采集高光谱影像,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 && receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_UTC_TIME)
|
||||
{
|
||||
m_baseFileName=getFileNameBaseOnTime();
|
||||
emit sbgReady(calculateTimeDifferenceBetweenSystemAndSbg(logData),m_baseFileName);
|
||||
|
@ -55,7 +55,18 @@ UdpServer::UdpServer()
|
||||
connect(m_imager, SIGNAL(frameRateSignal(double)),this, SLOT(sendXimeaImageFrameRate(double)));
|
||||
connect(m_copyFile, SIGNAL(copyFileStatus(int)),this, SLOT(sendCopyFileStatus(int)));
|
||||
|
||||
QString ximeaParamCfgFile = "/media/nvme/300TC/config/StateOf300tc.cfg";
|
||||
stateOf300tc.setConfigfilePath(ximeaParamCfgFile.toStdString());
|
||||
if(!stateOf300tc.isConfigfileExist())
|
||||
stateOf300tc.createConfigFile();
|
||||
stateOf300tc.parseConfigfile();
|
||||
|
||||
stateOf300tc.setSbgState(0);
|
||||
stateOf300tc.setSbgSolutionMode(0);
|
||||
stateOf300tc.setXimeaState(100);
|
||||
stateOf300tc.setFrameRate(0);
|
||||
stateOf300tc.setExposeTime(0);
|
||||
stateOf300tc.setExposeMaxValueOfOneFrame(0);
|
||||
|
||||
//当软件不正常关闭并且重启后,通知其他psdk程序
|
||||
m_clientIpAddress=QHostAddress(QHostAddress::LocalHost);
|
||||
@ -65,6 +76,16 @@ UdpServer::UdpServer()
|
||||
|
||||
system("sudo gpio write 10 0");
|
||||
|
||||
m_recordTempThread=new QThread();
|
||||
m_300tcTemperature = new Record300TcTemperature();
|
||||
m_300tcTemperature->moveToThread(m_recordTempThread);
|
||||
m_recordTempThread->start();
|
||||
connect(this, SIGNAL(record300tcTemperatureSignal(QString)),m_300tcTemperature, SLOT(recordTemperature(QString)));
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString Temperature300tcCSVPath = QDir::cleanPath(QString::fromStdString("/media/nvme/300TC/programRunLog/300tcTemperature") + QDir::separator() + "300tcTemperature_" + currentTime + ".csv");
|
||||
emit record300tcTemperatureSignal(Temperature300tcCSVPath);
|
||||
|
||||
std::cout<<"UdpServer::UdpServer--------:System ready!"<<std::endl;
|
||||
}
|
||||
@ -102,7 +123,7 @@ void UdpServer::processPendingDatagrams()
|
||||
case 2://关闭系统:关闭相机和sbg串口,关闭软件
|
||||
{
|
||||
std::cout<<"2代表关闭系统!"<<std::endl;
|
||||
|
||||
m_300tcTemperature->stopRecordTemperature();
|
||||
|
||||
if(m_sbgRecorder->getSbgState()>=1)
|
||||
{
|
||||
@ -167,8 +188,8 @@ void UdpServer::processPendingDatagrams()
|
||||
{
|
||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||
{
|
||||
float time = datagramList[1].toFloat();//ms
|
||||
m_imager->wrapSetExposureTime(time*1000);
|
||||
float time = datagramList[1].toFloat();//μs
|
||||
m_imager->wrapSetExposureTime(time);
|
||||
std::cout<<"7,手动设置曝光时间为:" << time <<std::endl;
|
||||
}
|
||||
|
||||
@ -197,8 +218,30 @@ void UdpServer::processPendingDatagrams()
|
||||
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
std::cout<<"10代表!"<<std::endl;
|
||||
|
||||
int sbgState,sbgSolutionMode,ximeaState,frameRate,exposeMaxValueOfOneFrame;
|
||||
float exposeTime;
|
||||
|
||||
stateOf300tc.getSbgState(sbgState);
|
||||
stateOf300tc.getSbgSolutionMode(sbgSolutionMode);
|
||||
stateOf300tc.getXimeaState(ximeaState);
|
||||
stateOf300tc.getFrameRate(frameRate);
|
||||
stateOf300tc.getExposeTime(exposeTime);
|
||||
stateOf300tc.getExposeMaxValueOfOneFrame(exposeMaxValueOfOneFrame);
|
||||
|
||||
sendSerialPortStatus(sbgState);
|
||||
sendSbgSolutionModeState(sbgSolutionMode);
|
||||
sendXimeaImageStatus(ximeaState);
|
||||
sendXimeaAutoExposeMaxValueOfOneFrame(exposeMaxValueOfOneFrame, exposeTime);
|
||||
sendXimeaImageFrameRate(frameRate);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
std::cout<<">=9没有意义!"<<std::endl;
|
||||
std::cout<<">=11没有意义!"<<std::endl;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -260,6 +303,8 @@ void UdpServer::sendSerialPortStatus(int serialPortStatus)
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setSbgState(serialPortStatus);
|
||||
}
|
||||
|
||||
void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
||||
@ -272,6 +317,8 @@ void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setSbgSolutionMode(SolutionMode);
|
||||
}
|
||||
|
||||
void UdpServer::sendSbgAccuracyState(int Accuracy,int SatelliteCounter)
|
||||
@ -296,11 +343,13 @@ void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setXimeaState(ximeaImageStatus);
|
||||
}
|
||||
|
||||
void UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame---------------------:"<< ximeaImageStatus <<std::endl;
|
||||
// std::cout<<"UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame---------------------:"<< exposeTime << " " << autoExposeMaxValueOfOneFrame <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
@ -308,6 +357,9 @@ void UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOn
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setExposeTime(exposeTime);
|
||||
stateOf300tc.setExposeMaxValueOfOneFrame(autoExposeMaxValueOfOneFrame);
|
||||
}
|
||||
|
||||
void UdpServer::sendXimeaBinState(int spatialBin, int spectralBin)
|
||||
@ -332,6 +384,8 @@ void UdpServer::sendXimeaImageFrameRate(double frameRate)
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setFrameRate(frameRate);
|
||||
}
|
||||
|
||||
void UdpServer::sendCopyFileStatus(int fileStatus)
|
||||
@ -350,3 +404,199 @@ void UdpServer::onRecordFinished()
|
||||
{
|
||||
std::cout<<"UdpServer::onRecordFinished----------------:影像停止采集"<<std::endl;
|
||||
}
|
||||
|
||||
Record300TcTemperature::Record300TcTemperature()
|
||||
{
|
||||
m_bIsRecord = true;
|
||||
}
|
||||
|
||||
void Record300TcTemperature::stopRecordTemperature()
|
||||
{
|
||||
m_bIsRecord = false;
|
||||
}
|
||||
|
||||
void Record300TcTemperature::recordTemperature(QString filePath= nullptr)
|
||||
{
|
||||
if(filePath== nullptr)
|
||||
filePath="300tcTemperature.csv";
|
||||
QList<QString> fileInfo = getFileInfo(filePath);
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
ofstream temperatureFile300Tc(filePath.toStdString().c_str(),ios::app);
|
||||
int counter = 0;
|
||||
|
||||
m_serial=new QSerialPort();
|
||||
|
||||
if(m_serial->isOpen())//如果串口已经打开了 先给他关闭了
|
||||
{
|
||||
m_serial->clear();
|
||||
m_serial->close();
|
||||
}
|
||||
|
||||
QString portname = "ttyUSB2";
|
||||
|
||||
m_serial->setPortName(portname);
|
||||
m_serial->open(QIODevice::ReadWrite);
|
||||
|
||||
bool x=m_serial->setBaudRate(9600);
|
||||
|
||||
QByteArray requestData;
|
||||
while (m_bIsRecord)
|
||||
{
|
||||
counter++;
|
||||
if(m_serial->waitForReadyRead(30000))
|
||||
{
|
||||
requestData = m_serial->readAll();
|
||||
|
||||
float temp = parseMessage(&requestData);
|
||||
if (temp == -10000)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy/MM/dd hh:mm:ss");
|
||||
|
||||
temperatureFile300Tc << currentTime.toStdString() << "," << temp << "\n";
|
||||
|
||||
// if(temp > 80)
|
||||
// {
|
||||
// system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 9,0");
|
||||
// }
|
||||
// if(temp > 90)
|
||||
// {
|
||||
// system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 2");
|
||||
// }
|
||||
//
|
||||
if (counter % 60 == 0)
|
||||
{
|
||||
temperatureFile300Tc.flush();
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// std::cout<<"Record300TcTemperature::recordTemperature--Wait response timeout."<<std::endl;
|
||||
}
|
||||
}
|
||||
m_bIsRecord = true;
|
||||
|
||||
temperatureFile300Tc.close();
|
||||
}
|
||||
|
||||
float Record300TcTemperature::parseMessage(QByteArray * data)
|
||||
{
|
||||
float Lux;
|
||||
float T;
|
||||
float P;
|
||||
float Hum;
|
||||
float H;
|
||||
bool hasTemperature = false;
|
||||
|
||||
// qDebug() << "Received data(hex): " << data->toHex();
|
||||
|
||||
// for (int i = 0; i < data->length(); ++i)
|
||||
// {
|
||||
// qDebug() << i << ":" << (int)data->at(i);
|
||||
// }
|
||||
|
||||
QByteArray target = QByteArray::fromHex("5a5a"); // The pattern to search for
|
||||
|
||||
int offset_tmp = data->indexOf(target);
|
||||
QList<int> offsets;
|
||||
|
||||
while (offset_tmp != -1)
|
||||
{
|
||||
offsets.append(offset_tmp);
|
||||
offset_tmp = data->indexOf(target, offset_tmp + target.size());
|
||||
}
|
||||
|
||||
if (offsets.isEmpty())
|
||||
{
|
||||
// qDebug() << "5A5A not found in the data.";
|
||||
return -10000;
|
||||
}
|
||||
// qDebug() << "5A5A found at offsets:" << offsets;
|
||||
|
||||
for (int i = 0; i < offsets.length(); ++i)
|
||||
{
|
||||
int offset = offsets.at(i);
|
||||
|
||||
int messageClass = data->at(offset + 2);
|
||||
int messageCount = data->at(offset + 3) + 5;
|
||||
// qDebug() << "messageCount:" << messageCount;
|
||||
if (offset + messageCount - 1 > data->length() - 1)
|
||||
{
|
||||
qDebug() << i << ": Some data of this frame is missing! Discarding the frame.";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int checksum = 0;
|
||||
QList<int> numbers;
|
||||
for (int j = 0; j < messageCount - 1; ++j)
|
||||
{
|
||||
if (i==offsets.length()-1 && j== messageCount-1)
|
||||
{
|
||||
int sdf=1;
|
||||
}
|
||||
|
||||
int index = offset + j;
|
||||
|
||||
if (index >= data->length())//Some data of this frame is missing! Discarding the frame.
|
||||
{
|
||||
checksum = -1;
|
||||
break;
|
||||
}
|
||||
int tmp = static_cast<int>(data->at(index));
|
||||
numbers.append(tmp);
|
||||
checksum += tmp;
|
||||
}
|
||||
// qDebug() << "jiaqilai:" << numbers;
|
||||
|
||||
if (checksum == -1)
|
||||
{
|
||||
qDebug() << "Some data of this frame is missing! Discarding the frame.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checksum & 0xFF) != data->at(offset + messageCount - 1))
|
||||
{
|
||||
qDebug() << "Checksum mismatch! Discarding the frame.";
|
||||
continue;
|
||||
}
|
||||
|
||||
//parse data
|
||||
switch (messageClass)
|
||||
{
|
||||
case 0x15:
|
||||
Lux = (float)((data->at(offset + 4)<<24)|(data->at(offset + 5)<<16)|(data->at(offset + 6)<<8)|data->at(offset + 7)) / 100;
|
||||
// qDebug() << "lux: " << Lux;
|
||||
break;
|
||||
case 0x45:
|
||||
T = (float)((data->at(offset + 4)<<8)|data->at(offset + 5)) / 100;
|
||||
P = (float)((data->at(offset + 6)<<24)|(data->at(offset + 7)<<16)|(data->at(offset + 8)<<8)|data->at(offset + 9)) / 100;
|
||||
Hum = (float)((data->at(offset + 10)<<8) | data->at(offset + 11)) / 100;
|
||||
H = (float)((data->at(offset + 12)<<8)|data->at(offset + 13));
|
||||
|
||||
hasTemperature = true;
|
||||
|
||||
// qDebug() << "T: " << T;
|
||||
// qDebug() << "P: " << P;
|
||||
// qDebug() << "Hum: " << Hum;
|
||||
// qDebug() << "H: " << H;
|
||||
break;
|
||||
default : // 可选的
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
if (hasTemperature)
|
||||
{
|
||||
return T;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -10000;
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,14 @@ XimeaImager::XimeaImager()
|
||||
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_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
|
||||
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager, this);
|
||||
m_ximeaTemperature->moveToThread(m_recordTempThread);
|
||||
m_recordTempThread->start();
|
||||
|
||||
@ -121,7 +126,20 @@ void XimeaImager::openImger()
|
||||
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相等
|
||||
int frameSizeManual = m_imager.get_band_count()*m_imager.get_sample_count()*2;
|
||||
@ -137,7 +155,7 @@ void XimeaImager::openImger()
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
m_ximeaTemperatureCSVPath = QDir::cleanPath(QString::fromStdString("/home/programRunLog/hyperspectralLog") + QDir::separator() + "ximeaTemperature_" + currentTime + ".csv");
|
||||
m_ximeaTemperatureCSVPath = QDir::cleanPath(QString::fromStdString("/media/nvme/300TC/programRunLog/ximeaTemperature") + QDir::separator() + "ximeaTemperature_" + currentTime + ".csv");
|
||||
// m_ximeaTemperatureCSVPath = "/home/ximeaTemperature.csv";
|
||||
emit recordXimeaTemperatureSignal(m_ximeaTemperatureCSVPath);
|
||||
}
|
||||
@ -186,14 +204,21 @@ void XimeaImager::setFramerate(double framerate)
|
||||
{
|
||||
m_imager.set_framerate(framerate);
|
||||
|
||||
int maxExposureTimeInUs=1/framerate*1000000*0.01;
|
||||
setExposureTime(maxExposureTimeInUs);
|
||||
// setExposureTime(1000);
|
||||
int exposureTimeInUs = getExposureTime();
|
||||
|
||||
int maxExposureTimeInUs=1/framerate*1000000;
|
||||
|
||||
if (exposureTimeInUs > maxExposureTimeInUs)
|
||||
{
|
||||
wrapSetExposureTime(maxExposureTimeInUs);
|
||||
}
|
||||
|
||||
m_iImagerState=102;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
emit frameRateSignal(framerate);
|
||||
|
||||
m_parameterConfigfile.setFrameRate(framerate);
|
||||
}
|
||||
catch(int xiApiErrorCodes)
|
||||
{
|
||||
@ -229,9 +254,7 @@ double XimeaImager::setExposureTime(float exposureTime_in_us)
|
||||
//确保设置的积分时间比最大积分时间小
|
||||
if(exposureTime_in_us<maxExposureTime_in_us)
|
||||
{
|
||||
|
||||
m_imager.set_integration_time(exposureTime_in_us);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -240,6 +263,7 @@ double XimeaImager::setExposureTime(float exposureTime_in_us)
|
||||
|
||||
//返回设置的积分时间
|
||||
integrationTime2Return=m_imager.get_integration_time();
|
||||
m_parameterConfigfile.setExposeTime(integrationTime2Return);
|
||||
|
||||
return integrationTime2Return;
|
||||
}
|
||||
@ -263,7 +287,7 @@ int XimeaImager::wrapSetExposureTime(float exposureTime_in_us)
|
||||
m_iImagerState=103;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
emit autoExposeMaxValueOfOneFrame(maxValueOfOneFrame, exposureTime/1000);
|
||||
emit autoExposeMaxValueOfOneFrame(maxValueOfOneFrame, exposureTime);
|
||||
|
||||
return maxValueOfOneFrame;
|
||||
}
|
||||
@ -326,7 +350,7 @@ double XimeaImager::autoExposure()
|
||||
|
||||
m_iImagerState=103;
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
emit autoExposeMaxValueOfOneFrame(maxValueOfOneFrame, exposureTime/1000);
|
||||
emit autoExposeMaxValueOfOneFrame(maxValueOfOneFrame, exposureTime);
|
||||
|
||||
std::cout<<"自动曝光完成!"<<std::endl;
|
||||
return exposureTime;
|
||||
@ -523,13 +547,11 @@ double XimeaImager::calculateTimeDifferenceBetweenSbgAndximea(XI_IMG * image, do
|
||||
|
||||
void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString baseFileName)
|
||||
{
|
||||
m_ximeaTemperature->stopRecordTemperature();//开始采集影像前,停止获取相机的温度,以免降低帧率;
|
||||
try
|
||||
{
|
||||
if(m_iImagerState <= 99 || m_iImagerState==100 || m_iImagerState==104)
|
||||
{
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
printf("已经开始采集----------------------------!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -547,14 +569,15 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
|
||||
m_baseFileName=baseFileName;
|
||||
|
||||
std::cout << "曝光时间为:" << getExposureTime()/1000 << "ms" <<std::endl;
|
||||
std::cout << "帧率为:" << getFramerate() << "hz" <<std::endl;
|
||||
std::cout << "曝光时间为:" << getExposureTime() << "μs" <<std::endl;
|
||||
|
||||
using namespace std;
|
||||
// ofstream timesFileHandle(timesFileName.toStdString()+"_ofstream");
|
||||
|
||||
int number_WriteDisk = 100;
|
||||
writeData2Disk->setParm(q, m_qFrameCounter,m_baseFileName,m_iFrameSizeInByte, number_WriteDisk, m_pool, m_rgbImage);
|
||||
emit startWriteDiskSignal();
|
||||
// emit startWriteDiskSignal();
|
||||
|
||||
int indexofbuff;
|
||||
DataBuffer * buffer;
|
||||
@ -565,6 +588,10 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
double timeDifferenceBetweenSbgAndXimea;
|
||||
double * sbgTimeBuffer = new double[number_WriteDisk];
|
||||
|
||||
QString imageFileName=m_baseFileName+".bil";
|
||||
FILE *hFile=fopen(imageFileName.toStdString().c_str(),"w+b");
|
||||
double * imageBuffer = new double[number_WriteDisk];
|
||||
|
||||
m_imager.start();
|
||||
struct timeval timeStart, timeEnd;
|
||||
double runTime=0;
|
||||
@ -578,34 +605,21 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
{
|
||||
timeDifferenceBetweenSbgAndXimea = calculateTimeDifferenceBetweenSbgAndximea(&m_imager.m_image, TimeDifferenceBetweensOSAndSbg);
|
||||
}
|
||||
fwrite(m_imager.m_image.bp,1,m_iFrameSizeInByte, hFile);
|
||||
|
||||
indexofbuff = m_iFrameCounter % number_WriteDisk;
|
||||
|
||||
if (indexofbuff == 1)
|
||||
{
|
||||
r_qtx.lock();
|
||||
buffer = m_pool->newElement();
|
||||
r_qtx.unlock();
|
||||
}
|
||||
|
||||
if (indexofbuff == 0)
|
||||
{
|
||||
memcpy((void *)buffer->data + (number_WriteDisk - 1) * m_iFrameSizeInByte,m_imager.m_image.bp,m_iFrameSizeInByte);
|
||||
sbgTimeBuffer[number_WriteDisk - 1] = getSbgTime(&m_imager.m_image, timeDifferenceBetweenSbgAndXimea);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy((void *)buffer->data + (indexofbuff - 1) * m_iFrameSizeInByte,m_imager.m_image.bp,m_iFrameSizeInByte);
|
||||
sbgTimeBuffer[indexofbuff - 1] = getSbgTime(&m_imager.m_image, timeDifferenceBetweenSbgAndXimea);
|
||||
}
|
||||
|
||||
if (indexofbuff == 0)
|
||||
{
|
||||
r_qtx.lock();
|
||||
q->push(buffer);
|
||||
m_qFrameCounter->push(number_WriteDisk);
|
||||
r_qtx.unlock();
|
||||
|
||||
for (int i = 0; i < number_WriteDisk; ++i)
|
||||
{
|
||||
fprintf(hHimesFile,"%f\n",sbgTimeBuffer[i]);
|
||||
@ -614,11 +628,6 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
}
|
||||
if (indexofbuff != 0)
|
||||
{
|
||||
r_qtx.lock();
|
||||
q->push(buffer);
|
||||
m_qFrameCounter->push(indexofbuff);
|
||||
r_qtx.unlock();
|
||||
|
||||
for (int i = 0; i < indexofbuff; ++i)
|
||||
{
|
||||
fprintf(hHimesFile,"%f\n",sbgTimeBuffer[i]);
|
||||
@ -640,7 +649,7 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
double frameLossRate = frameLossed / m_imager.m_image.acq_nframe;
|
||||
|
||||
std::cout<<"当前采集文件为: "<<baseFileName.toStdString()<< ".bil" <<std::endl;
|
||||
std::cout<<"采集时间为: "<<runTime<< "s" <<std::endl;
|
||||
std::cout<<"采集时间为: "<<runTime/60<< " min" <<std::endl;
|
||||
std::cout<<"当前帧率为: "<<getFramerate() << "hz" <<std::endl;
|
||||
std::cout<<"每秒数据量为: "<<getFramerate()*m_iFrameSizeInByte/(1024*1024)<<"MB"<<std::endl;
|
||||
std::cout<<"理论采集帧数为: "<<m_imager.m_image.acq_nframe<<std::endl;
|
||||
@ -649,6 +658,7 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
std::cout<<"丢帧率为: "<<frameLossRate * 100<< "%" <<std::endl;
|
||||
|
||||
fclose(hHimesFile);
|
||||
fclose(hFile);
|
||||
// timesFileHandle.close();
|
||||
// timesFile.close();
|
||||
|
||||
@ -659,8 +669,6 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
emit ximeaImageStatus(m_iImagerState);
|
||||
|
||||
emit recordFinished();
|
||||
|
||||
emit recordXimeaTemperatureSignal(m_ximeaTemperatureCSVPath);//停止采集影像后,继续获取传感器温度;
|
||||
}
|
||||
catch(int xiApiErrorCodes)
|
||||
{
|
||||
@ -894,10 +902,12 @@ DataBuffer::~DataBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
RecordXimeaTemperature::RecordXimeaTemperature(Iris::IrisXimeaImager * imager)
|
||||
RecordXimeaTemperature::RecordXimeaTemperature(Iris::IrisXimeaImager * imager, XimeaImager * ximeaImager)
|
||||
{
|
||||
m_imager = imager;
|
||||
m_bIsRecord = true;
|
||||
|
||||
m_ximeaImager = ximeaImager;
|
||||
}
|
||||
|
||||
void RecordXimeaTemperature::stopRecordTemperature()
|
||||
@ -909,19 +919,56 @@ void RecordXimeaTemperature::recordTemperature(QString filePath= nullptr)
|
||||
{
|
||||
if(filePath== nullptr)
|
||||
filePath="ximeaTemperature.csv";
|
||||
ofstream ximeaTemperatureFile(filePath.toStdString().c_str(),ios::app);
|
||||
QList<QString> fileInfo = getFileInfo(filePath);
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
ofstream ximeaTemperatureFile(filePath.toStdString().c_str(),ios::app);
|
||||
int counter = 0;
|
||||
while(m_bIsRecord)
|
||||
{
|
||||
counter++;
|
||||
|
||||
float temp = m_imager->getTemperature();
|
||||
if(temp > 80 && m_ximeaImager->getImagerState() == 104)
|
||||
{
|
||||
ximeaTemperatureFile.flush();
|
||||
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 9,0");
|
||||
}
|
||||
if(temp > 90)
|
||||
{
|
||||
ximeaTemperatureFile.flush();
|
||||
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 2");
|
||||
}
|
||||
|
||||
// 获取剩余硬盘空间和剩余采集时间
|
||||
FILE *fp;
|
||||
char buffer[128];
|
||||
fp = popen("cat /sys/devices/virtual/thermal/thermal_zone1/temp", "r");
|
||||
if (fp == NULL) {
|
||||
perror("popen");
|
||||
}
|
||||
|
||||
// 读取输出并处理
|
||||
unsigned long long temper;
|
||||
if (fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||
{
|
||||
temper = strtoull(buffer, NULL, 10);
|
||||
// printf("CPU温度: %.2f;\n", (float)temper/1000);
|
||||
}
|
||||
pclose(fp);
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy/MM/dd hh:mm:ss");
|
||||
|
||||
ximeaTemperatureFile << currentTime.toStdString() << "," << temp << "\n";
|
||||
ximeaTemperatureFile << currentTime.toStdString() << "," << temp << "," << (float)temper/1000 << "\n";
|
||||
|
||||
// std::cout<<"RecordXimeaTemperature::recordTemperature----------------:ximea Temperature is "<< temp <<std::endl;
|
||||
// std::cout<<"RecordXimeaTemperature::recordTemperature----------------:ximea state is "<< m_ximeaImager->getImagerState() <<std::endl;
|
||||
|
||||
if (counter % 60 == 0)
|
||||
{
|
||||
ximeaTemperatureFile.flush();
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@ -938,29 +985,9 @@ WriteData2Disk::WriteData2Disk()
|
||||
void WriteData2Disk::write2Disk()
|
||||
{
|
||||
QString imageFileName=m_QbaseFileName+".bil";
|
||||
// FILE *hFile=fopen(imageFileName.toStdString().c_str(),"w+b");
|
||||
FILE *hFile=fopen(imageFileName.toStdString().c_str(),"w+b");
|
||||
|
||||
|
||||
int fd = open(imageFileName.toStdString().c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
|
||||
size_t fileSize = m_iFrameSizeInByte*(size_t)100*(size_t)60*(size_t)5;
|
||||
size_t fileSizeIncrement = m_iFrameSizeInByte*(size_t)100*(size_t)60*(size_t)5;
|
||||
if (lseek(fd, fileSize - 1, SEEK_SET) == -1) {
|
||||
std::cerr << "Error calling lseek()\n";
|
||||
return;
|
||||
}
|
||||
if (write(fd, "", 1) == -1) {
|
||||
std::cerr << "Error writing last byte of the file\n";
|
||||
return;
|
||||
}
|
||||
void* addr = mmap(nullptr, fileSize, PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
std::cerr << "Error mmapping the file\n";
|
||||
return;
|
||||
}
|
||||
|
||||
size_t sizeWrited2disk = 0;
|
||||
|
||||
int frameCounter = 0;
|
||||
int frameNumber;
|
||||
unsigned short * dataBuffer = new unsigned short[m_iFrameSizeInByte/2*m_iNumber_WriteDisk];
|
||||
@ -975,12 +1002,18 @@ void WriteData2Disk::write2Disk()
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------队列为空,采集线程已经退出!"<<std::endl;
|
||||
break;
|
||||
}
|
||||
else if(isExitWriteData2Disk)
|
||||
{
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------isExitWriteData2Disk:true"<<std::endl;
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------队列大小"<<m_q->size()<<std::endl;
|
||||
}
|
||||
else if(bempty && !isExitWriteData2Disk)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
r_qtx.lock();
|
||||
DataBuffer * buffer = m_q->front();
|
||||
int frameNumber = m_qFrameCounter->front();
|
||||
@ -996,77 +1029,23 @@ void WriteData2Disk::write2Disk()
|
||||
|
||||
|
||||
// std::cout<<"WriteData2Disk::write2Disk-----------------------正在写磁盘!" << m_pool->max_size() <<std::endl;//
|
||||
fwrite(dataBuffer,1,m_iFrameSizeInByte*frameNumber, hFile);
|
||||
|
||||
|
||||
if (fileSize < sizeWrited2disk + m_iFrameSizeInByte*frameNumber)
|
||||
{
|
||||
// if (munmap(addr, fileSize) == -1) {
|
||||
// std::cerr << "Error un-mmapping the file\n";
|
||||
// }
|
||||
|
||||
// std::cout<<"老fileSize:" << fileSize <<std::endl;
|
||||
size_t new_size = fileSize + fileSizeIncrement;
|
||||
if (ftruncate(fd, new_size) == -1) {
|
||||
std::cerr << "Error calling ftruncate()\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// Remap the file with the new size
|
||||
addr = mremap(addr, fileSize, new_size, MREMAP_MAYMOVE);
|
||||
if (addr == MAP_FAILED) {
|
||||
std::cerr << "Error calling mremap()\n";
|
||||
return;
|
||||
}
|
||||
|
||||
fileSize = new_size;
|
||||
// std::cout<<"新fileSize:" << fileSize <<std::endl;
|
||||
|
||||
}
|
||||
// fwrite(dataBuffer,1,m_iFrameSizeInByte*frameNumber, hFile);
|
||||
memcpy(addr + sizeWrited2disk, dataBuffer, m_iFrameSizeInByte*frameNumber);
|
||||
|
||||
sizeWrited2disk = sizeWrited2disk + m_iFrameSizeInByte*frameNumber;
|
||||
// std::cout<<"sizeWrited2disk:" << sizeWrited2disk <<std::endl;
|
||||
|
||||
frameCounter++;
|
||||
}
|
||||
m_rgbImage->m_VideoWriter.release();
|
||||
// fclose(hFile);
|
||||
fclose(hFile);
|
||||
delete[] dataBuffer;
|
||||
|
||||
|
||||
|
||||
|
||||
// if (munmap(addr, fileSize) == -1) {
|
||||
// std::cerr << "Error un-mmapping the file\n";
|
||||
// }
|
||||
|
||||
// Resize the file to 4096 bytes
|
||||
if (ftruncate(fd, sizeWrited2disk) == -1) {
|
||||
std::cerr << "Error calling ftruncate()\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// Remap the file with the new size
|
||||
addr = mremap(addr, fileSize, sizeWrited2disk, MREMAP_MAYMOVE);
|
||||
if (addr == MAP_FAILED) {
|
||||
std::cerr << "Error calling mremap()\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (munmap(addr, sizeWrited2disk) == -1) {
|
||||
std::cerr << "Error un-mmapping the file\n";
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------写磁盘线程将退出,内存池可达到的最多元素数:" << m_pool->max_size() <<std::endl;
|
||||
std::cout<<"WriteData2Disk::write2Disk-----------------------写磁盘线程将退出,fwrite 调用次数:" << frameCounter <<std::endl;
|
||||
}
|
||||
|
||||
void WriteData2Disk::exitWriteData2Disk()
|
||||
{
|
||||
std::cout<< "执行函数:WriteData2Disk::exitWriteData2Disk" <<std::endl;
|
||||
isExitWriteData2Disk = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user