Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
061e1f83bd | |||
d0b67b47c1 | |||
7fa3b70d10 | |||
781b33f577 |
@ -68,8 +68,36 @@ public:
|
||||
// bool updateConfigFile();
|
||||
bool writeConfig2File();
|
||||
|
||||
private:
|
||||
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();
|
||||
|
@ -554,7 +554,7 @@ bool ParameterConfigfile::getFrameRate(int &frameRate)
|
||||
const Setting &ximeaParam = root["ximeaParam"];
|
||||
frameRate = ximeaParam.lookup("frameRate");
|
||||
|
||||
std::cout << "----------------"<< frameRate<<std::endl;
|
||||
// std::cout << "ParameterConfigfile::getFrameRate:"<< frameRate<<std::endl;
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
@ -591,7 +591,7 @@ bool ParameterConfigfile::getExposeTime(float &exposeTime)
|
||||
const Setting &ximeaParam = root["ximeaParam"];
|
||||
exposeTime = ximeaParam.lookup("exposeTime");
|
||||
|
||||
std::cout << "----------------"<< exposeTime<<std::endl;
|
||||
// std::cout << "ParameterConfigfile::getExposeTime"<< exposeTime<<std::endl;
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
@ -628,7 +628,7 @@ bool ParameterConfigfile::writeConfig2File()
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||
// cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||
}
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
@ -637,3 +637,126 @@ bool ParameterConfigfile::writeConfig2File()
|
||||
}
|
||||
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 版本:"<< "39." <<std::endl;
|
||||
std::cout<<"ximeaAirborneSystem 版本:"<< "41." <<std::endl;
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
//UdpServer* x=new UdpServer();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
|
||||
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;
|
||||
@ -588,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;
|
||||
@ -601,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]);
|
||||
@ -637,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]);
|
||||
@ -672,6 +658,7 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
|
||||
std::cout<<"丢帧率为: "<<frameLossRate * 100<< "%" <<std::endl;
|
||||
|
||||
fclose(hHimesFile);
|
||||
fclose(hFile);
|
||||
// timesFileHandle.close();
|
||||
// timesFile.close();
|
||||
|
||||
@ -944,17 +931,36 @@ void RecordXimeaTemperature::recordTemperature(QString filePath= nullptr)
|
||||
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;
|
||||
|
Reference in New Issue
Block a user