add:psdk重启后,通知本程序发送本程序的状态;
This commit is contained in:
@ -68,8 +68,36 @@ public:
|
|||||||
// bool updateConfigFile();
|
// bool updateConfigFile();
|
||||||
bool writeConfig2File();
|
bool writeConfig2File();
|
||||||
|
|
||||||
private:
|
|
||||||
string m_configfilePath;
|
string m_configfilePath;
|
||||||
Config cfg;
|
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
|
#endif //XIMEAIMAGERECORDER_CONFIGFILE_H
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include "sbgrecorder.h"
|
#include "sbgrecorder.h"
|
||||||
#include "fileoperation.h"
|
#include "fileoperation.h"
|
||||||
|
|
||||||
|
#include "configfile.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
// #include <sbgEComLib.h>
|
// #include <sbgEComLib.h>
|
||||||
@ -75,6 +77,8 @@ class UdpServer:public QObject
|
|||||||
QThread * m_recordTempThread;
|
QThread * m_recordTempThread;
|
||||||
Record300TcTemperature * m_300tcTemperature;
|
Record300TcTemperature * m_300tcTemperature;
|
||||||
|
|
||||||
|
StateOf300tcConfigfile stateOf300tc;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void systemStart();
|
void systemStart();
|
||||||
void systemStop();
|
void systemStop();
|
||||||
|
@ -554,7 +554,7 @@ bool ParameterConfigfile::getFrameRate(int &frameRate)
|
|||||||
const Setting &ximeaParam = root["ximeaParam"];
|
const Setting &ximeaParam = root["ximeaParam"];
|
||||||
frameRate = ximeaParam.lookup("frameRate");
|
frameRate = ximeaParam.lookup("frameRate");
|
||||||
|
|
||||||
std::cout << "----------------"<< frameRate<<std::endl;
|
// std::cout << "ParameterConfigfile::getFrameRate:"<< frameRate<<std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(const SettingNotFoundException &nfex)
|
catch(const SettingNotFoundException &nfex)
|
||||||
@ -591,7 +591,7 @@ bool ParameterConfigfile::getExposeTime(float &exposeTime)
|
|||||||
const Setting &ximeaParam = root["ximeaParam"];
|
const Setting &ximeaParam = root["ximeaParam"];
|
||||||
exposeTime = ximeaParam.lookup("exposeTime");
|
exposeTime = ximeaParam.lookup("exposeTime");
|
||||||
|
|
||||||
std::cout << "----------------"<< exposeTime<<std::endl;
|
// std::cout << "ParameterConfigfile::getExposeTime"<< exposeTime<<std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(const SettingNotFoundException &nfex)
|
catch(const SettingNotFoundException &nfex)
|
||||||
@ -628,7 +628,7 @@ bool ParameterConfigfile::writeConfig2File()
|
|||||||
bool ret = createDir(fileInfo[0]);
|
bool ret = createDir(fileInfo[0]);
|
||||||
|
|
||||||
cfg.writeFile(m_configfilePath.c_str());
|
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)
|
catch(const FileIOException &fioex)
|
||||||
{
|
{
|
||||||
@ -637,3 +637,126 @@ bool ParameterConfigfile::writeConfig2File()
|
|||||||
}
|
}
|
||||||
return true;
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::cout<<"ximeaAirborneSystem 版本:"<< "39." <<std::endl;
|
std::cout<<"ximeaAirborneSystem 版本:"<< "40." <<std::endl;
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
//UdpServer* x=new UdpServer();
|
//UdpServer* x=new UdpServer();
|
||||||
|
@ -55,7 +55,18 @@ UdpServer::UdpServer()
|
|||||||
connect(m_imager, SIGNAL(frameRateSignal(double)),this, SLOT(sendXimeaImageFrameRate(double)));
|
connect(m_imager, SIGNAL(frameRateSignal(double)),this, SLOT(sendXimeaImageFrameRate(double)));
|
||||||
connect(m_copyFile, SIGNAL(copyFileStatus(int)),this, SLOT(sendCopyFileStatus(int)));
|
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程序
|
//当软件不正常关闭并且重启后,通知其他psdk程序
|
||||||
m_clientIpAddress=QHostAddress(QHostAddress::LocalHost);
|
m_clientIpAddress=QHostAddress(QHostAddress::LocalHost);
|
||||||
@ -76,7 +87,6 @@ UdpServer::UdpServer()
|
|||||||
QString Temperature300tcCSVPath = QDir::cleanPath(QString::fromStdString("/media/nvme/300TC/programRunLog/300tcTemperature") + QDir::separator() + "300tcTemperature_" + currentTime + ".csv");
|
QString Temperature300tcCSVPath = QDir::cleanPath(QString::fromStdString("/media/nvme/300TC/programRunLog/300tcTemperature") + QDir::separator() + "300tcTemperature_" + currentTime + ".csv");
|
||||||
emit record300tcTemperatureSignal(Temperature300tcCSVPath);
|
emit record300tcTemperatureSignal(Temperature300tcCSVPath);
|
||||||
|
|
||||||
|
|
||||||
std::cout<<"UdpServer::UdpServer--------:System ready!"<<std::endl;
|
std::cout<<"UdpServer::UdpServer--------:System ready!"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,8 +188,8 @@ void UdpServer::processPendingDatagrams()
|
|||||||
{
|
{
|
||||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||||
{
|
{
|
||||||
float time = datagramList[1].toFloat();//ms
|
float time = datagramList[1].toFloat();//μs
|
||||||
m_imager->wrapSetExposureTime(time*1000);
|
m_imager->wrapSetExposureTime(time);
|
||||||
std::cout<<"7,手动设置曝光时间为:" << time <<std::endl;
|
std::cout<<"7,手动设置曝光时间为:" << time <<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +218,30 @@ void UdpServer::processPendingDatagrams()
|
|||||||
|
|
||||||
break;
|
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:
|
default:
|
||||||
std::cout<<">=9没有意义!"<<std::endl;
|
std::cout<<">=11没有意义!"<<std::endl;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -271,6 +303,8 @@ void UdpServer::sendSerialPortStatus(int serialPortStatus)
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||||
|
|
||||||
|
stateOf300tc.setSbgState(serialPortStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
||||||
@ -283,6 +317,8 @@ void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||||
|
|
||||||
|
stateOf300tc.setSbgSolutionMode(SolutionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServer::sendSbgAccuracyState(int Accuracy,int SatelliteCounter)
|
void UdpServer::sendSbgAccuracyState(int Accuracy,int SatelliteCounter)
|
||||||
@ -307,11 +343,13 @@ void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||||
|
|
||||||
|
stateOf300tc.setXimeaState(ximeaImageStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime)
|
void UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime)
|
||||||
{
|
{
|
||||||
// std::cout<<"UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame---------------------:"<< ximeaImageStatus <<std::endl;
|
// std::cout<<"UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame---------------------:"<< exposeTime << " " << autoExposeMaxValueOfOneFrame <<std::endl;
|
||||||
|
|
||||||
QByteArray datagram2send;
|
QByteArray datagram2send;
|
||||||
|
|
||||||
@ -319,6 +357,9 @@ void UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOn
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||||
|
|
||||||
|
stateOf300tc.setExposeTime(exposeTime);
|
||||||
|
stateOf300tc.setExposeMaxValueOfOneFrame(autoExposeMaxValueOfOneFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServer::sendXimeaBinState(int spatialBin, int spectralBin)
|
void UdpServer::sendXimeaBinState(int spatialBin, int spectralBin)
|
||||||
@ -343,6 +384,8 @@ void UdpServer::sendXimeaImageFrameRate(double frameRate)
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||||
|
|
||||||
|
stateOf300tc.setFrameRate(frameRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServer::sendCopyFileStatus(int fileStatus)
|
void UdpServer::sendCopyFileStatus(int fileStatus)
|
||||||
|
Reference in New Issue
Block a user