From f546814d39af864a8ffc9055a812c0f103e4acf5 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Thu, 27 Aug 2015 10:44:24 +0200 Subject: [PATCH] reduced size of file names in gui --- .../multiSlsDetector/multiSlsDetector.cpp | 10 +++- .../slsDetectorAnalysis/fileIOStatic.h | 53 ++++++++++++++----- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 0f7bae2af..73e5c7e9f 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -4598,6 +4598,8 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex int *retdet = NULL, *p=retval; string fullFName=""; string ext=""; + int index=-1,f_index=-1,p_index=-1,det_index=-1; + double sv0=-1,sv1=-1; if(getDetectorsType() == EIGER){ maxX = thisMultiDetector->numberOfChannel[X]; @@ -4645,9 +4647,15 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex ext = ext.erase(0,dot); else ext = ""; + + //get variables + fileIOStatic::getVariablesFromFileName(fName,index, f_index, p_index, sv0, sv1, det_index); + fullFName.append(fileIOStatic::getReceiverFileNameToConcatenate(fName)); } } - fullFName.append(getReceiverFileNameToConcatenate(fName)); + if(!fileIOStatic::verifySameFrame(fName,index,f_index, p_index, sv0, sv1, det_index)){ + fullFName.append(fileIOStatic::getReceiverFileNameToConcatenate(fName)); + } } }else { #ifdef VERBOSE diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h b/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h index b0e394ed3..af8f909cf 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h @@ -161,32 +161,32 @@ class fileIOStatic { index=i; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse file index from " << s << endl; \ + else cout << "Warning: ******************************** cannot parse file index from " << s << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) \ s=fname.substr(0,uscore); \ - else cout << "******************************** cannot parse frame index from " << s << endl; \ + else cout << "Warning: ******************************** cannot parse frame index from " << s << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) \ s=fname.substr(0,uscore); \ - else cout << "******************************** cannot parse detector index from " << s << endl; \ - uscore=s.rfind("_"); + else cout << "Warning: ******************************** cannot parse detector index from " << s << endl; \ + uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \ p_index=i; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse position index" << endl; \ + else cout << "Warning: ******************************** cannot parse position index from " << s << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) { \ sv1=f; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse scan varable 1" << endl; \ + else cout << "Warning: ******************************** cannot parse scan varable 1 from " << s << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) { \ sv0=f; \ } \ - else cout << "******************************** cannot parse scan varable 0" << endl; \ + else cout << "Warning: ******************************** cannot parse scan varable 0 from " << s << endl; \ return index; \ }; @@ -216,41 +216,68 @@ class fileIOStatic { index=i; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse file index" << endl; \ + else cout << "Warning: ******************************** cannot parse file index" << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"f%d",&i)) { \ f_index=i; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse frame index" << endl; \ + else cout << "Warning: ******************************** cannot parse frame index" << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"d%d",&i)) { \ detindex=i; \ + s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse detector id" << endl; \ + else cout << "Warning: ******************************** cannot parse detector id" << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"p%d",&i)) { \ p_index=i; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse position index" << endl; \ + else cout << "Warning: ******************************** cannot parse position index" << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"s%lf",&f)) { \ sv1=f; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse scan varable 1" << endl; \ + else cout << "Warning: ******************************** cannot parse scan varable 1" << endl; \ uscore=s.rfind("_"); \ if (sscanf( s.substr(uscore+1,s.size()-uscore-1).c_str(),"S%lf",&f)) { \ sv0=f; \ s=fname.substr(0,uscore); \ } \ - else cout << "******************************** cannot parse scan varable 0" << endl; \ + else cout << "Warning: ******************************** cannot parse scan varable 0" << endl; \ return index; \ }; + /** static function that verifies if the new file name containing new parameters matches all the given parameters + \param fname new complete file name prefix + \param index reference to index + \param f_index reference to frame index + \param p_index reference to position index + \param sv0 reference to scan variable 0 + \param sv1 reference to scan variable 1 + \param detindex reference to detector id + \returns file name + */ + static int verifySameFrame(string fname, int index, int f_index, int p_index, double sv0, double sv1, int detindex) { \ + int new_index=-1; + int new_f_index=-1; + int new_p_index=-1; + int new_det_index=-1; + double new_sv0=-1; + double new_sv1=-1; + getVariablesFromFileName(fname,new_index, new_f_index, new_p_index, new_sv0, new_sv1, new_det_index); + if(index!=new_index) return 0; + if(f_index!=new_f_index) return 0; + if(p_index!=new_p_index) return 0; + if(sv0!=new_sv0) return 0; + if(sv1!=new_sv1) return 0; + return 1; + } + /** static function that returns the name variable from the receiver complete file name prefix \param fname complete file name prefix