1. 读写配置文件类(Configfile):1)修复一些返回值bug,2)添加读写 裁剪有效窗口的参数 的函数getEffectiveWindowRoi;
2. 在没有采集数据时,读取ximea温度,并写入到csv文件中; 3. 在另外的工程更新了ximea控制类(Iris::IrisXimeaImager),并在此工程加入此更新:从获取的有效窗口中裁剪需要的数据,m_imager.setEffectiveWindowRoi(); 4. 在函数XimeaImager::processXiApiErrorCodes中,增加处理ximea错误码12;
This commit is contained in:
@ -14,24 +14,32 @@ void Configfile::setConfigfilePath(string configfilePath)
|
||||
m_configfilePath = configfilePath;
|
||||
}
|
||||
|
||||
bool Configfile::isConfigfileExist()
|
||||
{
|
||||
QFileInfo info(QString::fromStdString(m_configfilePath));
|
||||
|
||||
int Configfile::parseConfigfile()
|
||||
return info.exists();
|
||||
}
|
||||
|
||||
bool Configfile::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(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
catch(const ParseException &pex)
|
||||
{
|
||||
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||
<< " - " << pex.getError() << std::endl;
|
||||
return(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,12 +49,12 @@ bool Configfile::getBin(int &bin)
|
||||
{
|
||||
bin = cfg.lookup("bin");
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'bin' setting in configuration file." << endl;
|
||||
return(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,16 +79,48 @@ bool Configfile::getEffectiveWindow(int &width, int &offsetx, int &height, int &
|
||||
&& window.lookupValue("height", height)
|
||||
&& window.lookupValue("offsety", offsety)))
|
||||
{
|
||||
return(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
// Ignore.
|
||||
int a=1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
// Output a list of all books in the inventory.
|
||||
try
|
||||
{
|
||||
const Setting &effective_window = root["effective_window_roi"];
|
||||
int count = effective_window.getLength();
|
||||
|
||||
int bin;
|
||||
getBin(bin);
|
||||
|
||||
const Setting &window = effective_window[bin-1];
|
||||
string name = window.getName();
|
||||
|
||||
if(!(window.lookupValue("width", width)
|
||||
&& window.lookupValue("offsetx", offsetx)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getGainOffset(float &gain, float &offset)
|
||||
@ -102,19 +142,19 @@ bool Configfile::getGainOffset(float &gain, float &offset)
|
||||
if(!(gainOffsetSetting.lookupValue("gain", gain)
|
||||
&& gainOffsetSetting.lookupValue("offset", offset)))
|
||||
{
|
||||
return(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
// Ignore.
|
||||
int a=1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
|
||||
int Configfile::createConfigFile()
|
||||
bool Configfile::createConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
@ -129,28 +169,42 @@ int Configfile::createConfigFile()
|
||||
Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
||||
|
||||
Setting &effective_window = root.add("effective_window", Setting::TypeGroup);
|
||||
Setting &effective_windowBin1 = effective_window.add("bin1", Setting::TypeGroup);
|
||||
Setting &effective_windowBin2 = effective_window.add("bin2", Setting::TypeGroup);
|
||||
Setting &effective_window_Bin1 = effective_window.add("bin1", Setting::TypeGroup);
|
||||
Setting &effective_window_Bin2 = effective_window.add("bin2", Setting::TypeGroup);
|
||||
|
||||
effective_windowBin1.add("width", Setting::TypeInt) = 1;
|
||||
effective_windowBin1.add("offsetx", Setting::TypeInt) = 2;
|
||||
effective_windowBin1.add("height", Setting::TypeInt) = 3;
|
||||
effective_windowBin1.add("offsety", Setting::TypeInt) = 4;
|
||||
effective_window_Bin1.add("width", Setting::TypeInt) = 1392;
|
||||
effective_window_Bin1.add("offsetx", Setting::TypeInt) = 272;
|
||||
effective_window_Bin1.add("height", Setting::TypeInt) = 300;
|
||||
effective_window_Bin1.add("offsety", Setting::TypeInt) = 348;
|
||||
|
||||
effective_windowBin2.add("width", Setting::TypeInt) = 5;
|
||||
effective_windowBin2.add("offsetx", Setting::TypeInt) = 6;
|
||||
effective_windowBin2.add("height", Setting::TypeInt) = 7;
|
||||
effective_windowBin2.add("offsety", Setting::TypeInt) = 8;
|
||||
effective_window_Bin2.add("width", Setting::TypeInt) = 712;
|
||||
effective_window_Bin2.add("offsetx", Setting::TypeInt) = 128;
|
||||
effective_window_Bin2.add("height", Setting::TypeInt) = 151;
|
||||
effective_window_Bin2.add("offsety", Setting::TypeInt) = 174;
|
||||
|
||||
Setting &effective_window_roi = root.add("effective_window_roi", Setting::TypeGroup);
|
||||
Setting &effective_window_roi_Bin1 = effective_window_roi.add("bin1", Setting::TypeGroup);
|
||||
Setting &effective_window_roi_Bin2 = effective_window_roi.add("bin2", Setting::TypeGroup);
|
||||
|
||||
effective_window_roi_Bin1.add("width", Setting::TypeInt) = 1364;
|
||||
effective_window_roi_Bin1.add("offsetx", Setting::TypeInt) = 14;
|
||||
// effective_window_roi_Bin1.add("height", Setting::TypeInt) = 300;
|
||||
// effective_window_roi_Bin1.add("offsety", Setting::TypeInt) = 348;
|
||||
|
||||
effective_window_roi_Bin2.add("width", Setting::TypeInt) = 682;
|
||||
effective_window_roi_Bin2.add("offsetx", Setting::TypeInt) = 15;
|
||||
// effective_window_roi_Bin2.add("height", Setting::TypeInt) = 151;
|
||||
// effective_window_roi_Bin2.add("offsety", Setting::TypeInt) = 174;
|
||||
|
||||
Setting &gainOffset = root.add("gainOffset", Setting::TypeGroup);
|
||||
Setting &gainOffsetBin1 = gainOffset.add("bin1", Setting::TypeGroup);
|
||||
Setting &gainOffsetBin2 = gainOffset.add("bin2", Setting::TypeGroup);
|
||||
|
||||
gainOffsetBin1.add("gain", Setting::TypeFloat) = 9.12;
|
||||
gainOffsetBin1.add("offset", Setting::TypeFloat) = -10.2;
|
||||
gainOffsetBin1.add("gain", Setting::TypeFloat) = 2.00313433;
|
||||
gainOffsetBin1.add("offset", Setting::TypeFloat) = -300.46283157590585;
|
||||
|
||||
gainOffsetBin2.add("gain", Setting::TypeFloat) = 11.789;
|
||||
gainOffsetBin2.add("offset", Setting::TypeFloat) = -12.58;
|
||||
gainOffsetBin2.add("gain", Setting::TypeFloat) = 4.00626868;
|
||||
gainOffsetBin2.add("offset", Setting::TypeFloat) = -299.46126663407176;
|
||||
|
||||
|
||||
// Write out the new configuration.
|
||||
@ -162,14 +216,14 @@ int Configfile::createConfigFile()
|
||||
}
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
cerr << "I/O error while writing file: " << output_file << endl;
|
||||
return(EXIT_FAILURE);
|
||||
cerr << "I/O error while writing configuration file: " << output_file << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
|
||||
int Configfile::updateConfigFile()
|
||||
bool Configfile::updateConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
@ -191,13 +245,13 @@ int Configfile::updateConfigFile()
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
std::cerr << "I/O error while reading file." << std::endl;
|
||||
return(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
catch(const ParseException &pex)
|
||||
{
|
||||
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||
<< " - " << pex.getError() << std::endl;
|
||||
return(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find the 'movies' setting. Add intermediate settings if they don't yet
|
||||
@ -233,8 +287,8 @@ int Configfile::updateConfigFile()
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
cerr << "I/O error while writing file: " << output_file << endl;
|
||||
return(EXIT_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user