moved the test function to the slsDetectorUtils class

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@154 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-03-19 14:50:01 +00:00
parent 145e38eac1
commit aae550b997
4 changed files with 79 additions and 70 deletions

View File

@ -4610,10 +4610,10 @@ int slsDetector::loadImageToDetector(imageType index,string const fname){
#endif
if(readDataFile(fname,arg)){
std::cout<< "Could not open file "<< fname << std::endl;
ret = sendImageToDetector(index,arg);
return ret;
}
ret = sendImageToDetector(index,arg);
std::cout<< "Could not open file "<< fname << std::endl;
return ret;
}
@ -5444,66 +5444,6 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
}
int slsDetector::testFunction(int times) {
int i,count=0;
runStatus s;
short int dataVals[thisDetector->nChans*thisDetector->nChips];
for(i=0;i<times;i++){
std::cout<<std::endl<<dec<<i+1<<": \t";
//usleep(2000000);
startAcquisition();
s = getRunStatus();
if(s==IDLE){
s = getRunStatus();
if(s==IDLE)
std::cout<<"IDLE"<<std::endl;
//exit(-1);
}
else if (s==RUNNING){
count=0;
while(s==RUNNING){
count++;
if(count==3){
std::cout<<"STUCK"<<std::endl;
exit(-1);
}
usleep(2);
//val=readRegister(0x25);
s = getRunStatus();
}
}
else{
std::cout<<"\nWeird Status.Exit\n";
exit(-1);
}
system("rm ~/wORKSPACE/scratch/run* ");
//system("more ~/wORKSPACE/scratch/run* ");
usleep(1000000);
setFileIndex(0);
readAll();
processData(1);
if(readDataFile("/home/l_maliakal_d/wORKSPACE/scratch/run_1.raw",dataVals)){
std::cout<< "Could not open file "<< std::endl;
exit(-1);
}
for(int j=1277;j< (thisDetector->nChans*thisDetector->nChips);j++)
cout<<"\t"<<j<<":"<<dataVals[j];
if(dataVals[1278]!=2558){
std::cout<< "DATA ERROR!! "<< std::endl;
exit(-1);
}
}
std::cout<<std::endl;
return 0;
}
/* returns if the detector is Master, slave or nothing
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE

View File

@ -1337,9 +1337,6 @@ typedef struct sharedSlsDetector {
*/
int sendImageToDetector(imageType index,short int arg[]);
/** temporary test fucntion */
int testFunction(int times=0);
/**
Sets/gets the synchronization mode of the various detectors
\param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS

View File

@ -1244,7 +1244,7 @@ void slsDetectorUtils::acquire(int delflag){
setTotalProgress();
// setTotalProgress();
progressIndex=0;
*stoppedFlag=0;
@ -1625,6 +1625,7 @@ void* slsDetectorUtils::processData(int delflag) {
std::cout<< " processing data - threaded mode " << *threadedProcessing << endl;
#endif
setTotalProgress();
//cout << "thread mutex lock line 6505" << endl;
pthread_mutex_lock(&mp);
queuesize=dataQueue.size();
@ -1688,14 +1689,14 @@ void* slsDetectorUtils::processData(int delflag) {
//process data
/** decode data */
fdata=decodeData(myData);
fname=createFileName();
//uses static function?!?!?!?
// writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
/** write raw data file */
if (*correctionMask==0 && delflag==1) {
@ -1941,7 +1942,7 @@ void* slsDetectorUtils::processData(int delflag) {
// cout << "looping on dataque size" << endl;
#endif
}
#ifdef VERBOSE
// cout << "queue empty -mutex unlock line 1883" << endl;
#endif
@ -2614,3 +2615,70 @@ float slsDetectorUtils::getCurrentProgress() {
}
int slsDetectorUtils::testFunction(int times) {
int i,count=0;
runStatus s;
int nchans = getTotalNumberOfChannels();
short int dataVals[nchans];
for(i=0;i<times;i++){
std::cout<<std::endl<<dec<<i+1<<": \t";
startAcquisition();
s = getRunStatus();
if(s==IDLE){
s = getRunStatus();
if(s==IDLE)
std::cout<<"IDLE"<<std::endl;
}
else if (s==RUNNING){
count=0;
while(s==RUNNING){
count++;
if(count==5){
std::cout<<"STUCK"<<std::endl;
exit(-1);
}
usleep(2);
//val=readRegister(0x25);
s = getRunStatus();
}
}
else{
std::cout<<"\nWeird Status.Exit\n";
exit(-1);
}
system("rm ~/wORKSPACE/scratch/run* ");
//system("more ~/wORKSPACE/scratch/run* ");
usleep(1000000);
setFileIndex(0);
int b;
b=setThreadedProcessing(-1);
setThreadedProcessing(0);
readAll();
processData(1);
setThreadedProcessing(b);
if(!readDataFile("/home/l_maliakal_d/wORKSPACE/scratch/run_1.raw",dataVals)){
std::cout<< "Could not open file "<< std::endl;
exit(-1);
}
std::cout<<std::endl;
for(int j=1277;j< (nchans);j++)
std::cout<<"\t"<<j<<":"<<dataVals[j];
if(dataVals[1278]!=2558){
std::cout<< "DATA ERROR!! "<< std::endl;
exit(-1);
}
}
std::cout<<std::endl;
return 0;
}

View File

@ -776,6 +776,10 @@ s
int setTotalProgress();
float getCurrentProgress();
/** temporary test fucntion */
int testFunction(int times=0);
protected:
static const int64_t thisSoftwareVersion=0x20120124;