diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index fb1ae4bda..d792ab0c2 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -1436,7 +1436,7 @@ int* multiSlsDetector::getDataFromDetector() { int n = 0; int* retval= NULL; int *retdet, *p=retval; - int nodata=1, nodatadet=-1; + int nodatadet=-1; int nodatadetectortype = false; detectorType types = getDetectorsType(); if(types == EIGER || types == JUNGFRAU){ @@ -1455,7 +1455,6 @@ int* multiSlsDetector::getDataFromDetector() { if(!nodatadetectortype){ n=detectors[id]->getDataBytes(); if (retdet) { - nodata=0; #ifdef VERBOSE cout << "Detector " << id << " returned " << n << " bytes " << endl; #endif @@ -2105,7 +2104,6 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){ n = 0; int num = 0,i,j; int ndet = thisMultiDetector->numberOfDetectors; - int nroi[ndet]; int maxroi = ndet*MAX_ROIS; ROI temproi; ROI roiLimits[maxroi]; @@ -2120,7 +2118,6 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){ if(detectors[i]->getErrorMask()) setErrorMask(getErrorMask()|(1<setRateCorrection(t); if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<nModsMax; imod++) { @@ -967,66 +967,67 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) sls_detector_module *myMod=(sls_detector_module*)malloc(sizeof(sls_detector_module)); - int nch, nm, nc, nd, na=0; + int nch, nc, nd, na=0; + //int nm = 0; switch(t) { case MYTHEN: nch=128; // complete mythen system - nm=24; + // nm=24; nc=10; nd=6; // dacs break; case PICASSO: nch=128; // complete mythen system - nm=24; + // nm=24; nc=12; nd=6; // dacs+adcs break; case GOTTHARD: nch=128; - nm=1; + // nm=1; nc=10; nd=8; // dacs+adcs na=5; break; case PROPIX: nch=22*22; - nm=1; + // nm=1; nc=1; nd=8; // dacs+adcs na=5; break; case EIGER: nch=256*256; // one EIGER half module - nm=1; //modules/detector + // nm=1; //modules/detector nc=4*1; //chips nd=16; //dacs na=0; break; case MOENCH: nch=160*160; - nm=1; //modules/detector + // nm=1; //modules/detector nc=1; //chips nd=8; //dacs na=1; break; case JUNGFRAU: nch=256*256;//32; - nm=1; + // nm=1; nc=4*2; nd=16; // dacs+adcs na=0; break; case JUNGFRAUCTB: nch=32;//32; - nm=1; + // nm=1; nc=1; nd=8; // dacs+adcs na=1; break; default: nch=0; // dum! - nm=0; //modules/detector + // nm=0; //modules/detector nc=0; //chips nd=0; //dacs+adcs na=0; @@ -1672,7 +1673,6 @@ int slsDetector::setNumberOfModules(int n, dimension d){ int ret=FAIL; char mess[MAX_STR_LENGTH]="dummy"; int connect; - int num; arg[0]=d; arg[1]=n; @@ -1693,11 +1693,11 @@ int slsDetector::setNumberOfModules(int n, dimension d){ if (connect == UNDEFINED) printf( "no control socket? \n" ); else if (connect == OK){ - num = controlSocket->SendDataOnly(&fnum,sizeof(fnum)); - num = controlSocket->SendDataOnly(&arg,sizeof(arg)); - num = controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&arg,sizeof(arg)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret!=FAIL) { - num = controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); printf( "Detector returned error: %s \n", mess ); @@ -3728,18 +3728,18 @@ int slsDetector::updateDetectorNoWait() { // int ret=OK; enum detectorSettings t; - int thr, n, nm; + int thr, n, nm = 0; // int it; int64_t retval;// tns=-1; char lastClientIP[INET_ADDRSTRLEN]; - n = controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); + n += controlSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); #ifdef VERBOSE printf( "Updating detector last modified by %s \n", lastClientIP ); #endif - n = controlSocket->ReceiveDataOnly(&nm,sizeof(nm)); + n += controlSocket->ReceiveDataOnly(&nm,sizeof(nm)); thisDetector->nMod[X]=nm; - n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); + n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); /// Should be overcome at a certain point! if (thisDetector->myDetectorType==MYTHEN) { @@ -3761,13 +3761,13 @@ int slsDetector::updateDetectorNoWait() { if (thisDetector->nModMax[Y]nMod[Y]) thisDetector->nModMax[Y]=thisDetector->nMod[Y]; - n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); + n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); thisDetector->dynamicRange=nm; - n = controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); + n += controlSocket->ReceiveDataOnly( &nm,sizeof(nm)); thisDetector->dataBytes=nm; //t=setSettings(GET_SETTINGS); - n = controlSocket->ReceiveDataOnly( &t,sizeof(t)); + n += controlSocket->ReceiveDataOnly( &t,sizeof(t)); thisDetector->currentSettings=t; if((thisDetector->myDetectorType!= GOTTHARD)&& @@ -3775,42 +3775,45 @@ int slsDetector::updateDetectorNoWait() { (thisDetector->myDetectorType!= JUNGFRAU)&& (thisDetector->myDetectorType!= MOENCH)){ //thr=getThresholdEnergy(); - n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); + n += controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); thisDetector->currentThresholdEV=thr; } //retval=setFrames(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[FRAME_NUMBER]=retval; // retval=setExposureTime(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[ACQUISITION_TIME]=retval; if(thisDetector->myDetectorType == EIGER){ //retval=setSubFrameExposureTime(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[SUBFRAME_ACQUISITION_TIME]=retval; } //retval=setPeriod(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[FRAME_PERIOD]=retval; //retval=setDelay(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[DELAY_AFTER_TRIGGER]=retval; // retval=setGates(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[GATES_NUMBER]=retval; //retval=setProbes(tns); if (thisDetector->myDetectorType == MYTHEN){ - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[PROBES_NUMBER]=retval; } //retval=setTrains(tns); - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); thisDetector->timerValue[CYCLES_NUMBER]=retval; + if (!n) + printf("n: %d\n", n); + return OK; } @@ -4216,7 +4219,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ int64_t retval = -1; char mess[MAX_STR_LENGTH]=""; int ret=OK; - int n=0; if (index!=MEASUREMENTS_NUMBER) { @@ -4228,7 +4230,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&index,sizeof(index)); - n=controlSocket->SendDataOnly(&t,sizeof(t)); + controlSocket->SendDataOnly(&t,sizeof(t)); controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); if (ret==FAIL) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); @@ -4705,7 +4707,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) { int retval=-1; char mess[MAX_STR_LENGTH]=""; int ret=OK; - int n=0; + #ifdef VERBOSE printf( "Setting speed variable %d to %d \n", sp, value ); #endif @@ -4713,7 +4715,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); controlSocket->SendDataOnly(&sp,sizeof(sp)); - n=controlSocket->SendDataOnly(&value,sizeof(value)); + controlSocket->SendDataOnly(&value,sizeof(value)); #ifdef VERBOSE printf( "Sent %d bytes \n", n ); #endif @@ -6477,13 +6479,17 @@ int slsDetector::readConfigurationFile(string const fname){ //char *args[1000]; string sargname, sargval; - int iline=0; #ifdef VERBOSE + int iline=0; printf( "config file name %s \n", fname.c_str() ); #endif infile.open(fname.c_str(), ios_base::in); if (infile.is_open()) { +#ifdef VERBOSE iline=readConfigurationFile(infile); +#else + readConfigurationFile(infile); +#endif infile.close(); } else { printf( "Error opening configuration file %s for reading \n", fname.c_str() ); @@ -6571,11 +6577,16 @@ int slsDetector::writeConfigurationFile(string const fname){ ofstream outfile; +#ifdef VERBOSE int ret; - +#endif outfile.open(fname.c_str(),ios_base::out); if (outfile.is_open()) { - ret=writeConfigurationFile(outfile); +#ifdef VERBOSE + ret=writeConfigurationFile(outfile); +#else + writeConfigurationFile(outfile); +#endif outfile.close(); } else { @@ -6691,7 +6702,7 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){ -int slsDetector::writeSettingsFile(string fname, int imod, int& iodelay, int& tau){ +int slsDetector::writeSettingsFile(string fname, int imod, int iodelay, int tau){ return writeSettingsFile(fname,thisDetector->myDetectorType, detectorModules[imod], iodelay, tau); @@ -7795,21 +7806,21 @@ string slsDetector::getReceiverLastClientIP(){ int slsDetector::updateReceiverNoWait() { - int n,ind; + int n,ind = 0; char path[MAX_STR_LENGTH]; char lastClientIP[INET_ADDRSTRLEN]; - n = dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); + n += dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); #ifdef VERBOSE printf( "Updating receiver last modified by %s \n", lastClientIP ); #endif - n = dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); + n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); pthread_mutex_lock(&ms); fileIO::setFileIndex(ind); pthread_mutex_unlock(&ms); - n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); + n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); pthread_mutex_lock(&ms); fileIO::setFilePath(path); pthread_mutex_unlock(&ms); @@ -7819,6 +7830,8 @@ int slsDetector::updateReceiverNoWait() { fileIO::setFileName(path); pthread_mutex_unlock(&ms); + if (!n) printf("n: %d\n", n); + return OK; } diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index ed8f57ac0..fa3cc8e25 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -511,7 +511,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion { \sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int) */ using energyConversion::writeSettingsFile; - int writeSettingsFile(string fname, int imod, int& iodelay, int& tau); + int writeSettingsFile(string fname, int imod, int iodelay, int tau); /** diff --git a/slsDetectorSoftware/slsDetector/slsDetectorActions.cpp b/slsDetectorSoftware/slsDetector/slsDetectorActions.cpp index 5d0b77621..6db2329a2 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorActions.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorActions.cpp @@ -75,10 +75,10 @@ int slsDetectorActions::setActionScript(int iaction, string fname) { int slsDetectorActions::setActionParameter(int iaction, string par) { - int am; + // int am; if (iaction>=0 && iaction(&iodelay), sizeof(iodelay)); + outfile.write(reinterpret_cast(&tau), sizeof(tau)); outfile.write((char*)mod.chanregs, sizeof(int)*(mod.nchan)); outfile.close(); diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h index 54a104e03..8aec3cb47 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.h @@ -119,7 +119,7 @@ class energyConversion \sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module) */ - int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int& iodelay, int& tau); + int writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau); /** allocates the momery for a detector module structure \param myDetectorType detector type (needed for number of channels, chips, dacs etc.) diff --git a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h b/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h index 178f4b9b0..ae909b06b 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/fileIOStatic.h @@ -534,9 +534,7 @@ class fileIOStatic { static int readDataFile(int nch, string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f') { \ ifstream infile; \ int iline=0; \ - int maxchans; \ string str; \ - maxchans=nch; \ infile.open(fname.c_str(), ios_base::in); \ if (infile.is_open()) { \ iline=readDataFile(nch, infile, data, err, ang, dataformat, 0); \ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index 5f331775f..8d8a36452 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -879,10 +879,14 @@ void postProcessing::startThread(int delflag) { else ret = pthread_create(&dataProcessingThread, &tattr,startProcessDataNoDelete, (void*)this); + if (ret) + printf("ret %d\n", ret); + pthread_attr_destroy(&tattr); // scheduling parameters of target thread ret = pthread_setschedparam(dataProcessingThread, policy, ¶m); + } diff --git a/slsDetectorSoftware/threadFiles/ThreadPool.cpp b/slsDetectorSoftware/threadFiles/ThreadPool.cpp index e1d473ead..2a1781d5c 100644 --- a/slsDetectorSoftware/threadFiles/ThreadPool.cpp +++ b/slsDetectorSoftware/threadFiles/ThreadPool.cpp @@ -67,12 +67,13 @@ int ThreadPool::destroy_threadpool(){ /*cout << "Broadcasting STOP signal to all threads..." << endl;*/ m_task_cond_var.broadcast(); // notify all threads we are shttung down - int ret = -1; + //int ret = -1; for (int i = 0; i < m_pool_size; i++) { void* result; sem_post(&semStart); sem_post(&semDone); - ret = pthread_join(m_threads[i], &result); + //ret = + pthread_join(m_threads[i], &result); /*cout << "pthread_join() returned " << ret << ": " << strerror(errno) << endl;*/ m_task_cond_var.broadcast(); // try waking up a bunch of threads that are still waiting }