From 445da80df86bbb53f3a1d60e2242850b8baa1612 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Mon, 1 May 2017 13:11:10 +0200 Subject: [PATCH] resolved warnings, also from esrf: todo: include changes in zmq --- slsDetectorSoftware/Makefile | 2 +- .../multiSlsDetector/multiSlsDetector.cpp | 58 ++++---- .../slsDetector/slsDetector.cpp | 132 ++++++++++-------- slsDetectorSoftware/slsDetector/slsDetector.h | 2 +- .../slsDetector/slsDetectorActions.cpp | 4 +- .../slsDetector/slsDetectorCommand.cpp | 61 +++++--- .../slsDetector/slsDetectorUtils.cpp | 10 +- .../angularConversionStatic.cpp | 4 +- .../slsDetectorAnalysis/energyConversion.cpp | 6 +- .../slsDetectorAnalysis/energyConversion.h | 2 +- .../slsDetectorAnalysis/fileIOStatic.h | 2 - .../slsDetectorAnalysis/postProcessing.cpp | 12 +- slsDetectorSoftware/threadFiles/Task.h | 12 +- .../threadFiles/ThreadPool.cpp | 8 +- 14 files changed, 179 insertions(+), 136 deletions(-) diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 73219b47c..2f5ff4153 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -69,7 +69,7 @@ gotthardVirtualServer: $(SRC_MYTHEN_SVC) %.o : %.cpp %.h Makefile - $(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) #$(FLAGS) + $(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) $(FLAGS) package: $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index a8cc2e2f7..2e32b1045 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -1192,10 +1192,10 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise ret=*iret[idet]; else if (ret<(*iret[idet]-200) || ret>(*iret[idet]+200)) ret=-1; - delete iret[idet]; }else ret=-1; if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<getDataBytes(); - if (retdet) { - nodata=0; + if (retdet) {; #ifdef VERBOSE cout << "Detector " << id << " returned " << n << " bytes " << endl; #endif @@ -1681,10 +1680,10 @@ int multiSlsDetector::startAndReadAllNoWait(){ if(iret[idet] != NULL){ if(*iret[idet] != OK) ret = FAIL; - delete iret[idet]; }else ret = FAIL; if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<numberOfDetectors; - int nroi[ndet]; int maxroi = ndet*MAX_ROIS; ROI temproi; ROI roiLimits[maxroi]; @@ -2141,7 +2139,6 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){ if(detectors[i]->getErrorMask()) setErrorMask(getErrorMask()|(1<flatFieldFile); @@ -2636,7 +2633,7 @@ int multiSlsDetector::setRateCorrection(double t){ ret=detectors[idet]->setRateCorrection(t); if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<numberOfDetectors; - if(!threadpool){ cout << "Error in creating threadpool. Exiting" << endl; return getNetworkParameter(p); @@ -4033,10 +4028,10 @@ int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imo ret=*iret[idet]; else if (ret!=*iret[idet]) ret=-1; - delete iret[idet]; }else ret=-1; if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<executeLine(1,args,GET_ACTION) << std::endl; - + iline++; // single detector configuration for (int i=0; inumberOfDetectors; i++) { // sprintf(ext,".det%d",i); @@ -4577,6 +4570,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){ cout << iv << " " << names[iv] << endl; strcpy(args[0],names[iv].c_str()); outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; + iline++; } @@ -4588,7 +4582,7 @@ int multiSlsDetector::writeConfigurationFile(string const fname){ return FAIL; } #ifdef VERBOSE - std::cout<< "wrote " <getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask(); #ifdef VERYVERBOSE //append sls det error mask - sprintf(sNumber,"0x%x",slsMask); + sprintf(sNumber,"0x%lx",slsMask); retval.append("Error Mask " + string(sNumber)+string("\n")); #endif //get the error critical level @@ -5757,10 +5751,10 @@ uint64_t multiSlsDetector::setCTBWord(int addr,uint64_t word) { ret1=detectors[idet]->setCTBWord(addr, word); if(detectors[idet]->getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<getErrorMask()) setErrorMask(getErrorMask()|(1<framesPerFile; fileFormatType=parentDet->fileFormatType; if((thisDetector->myDetectorType==GOTTHARD)||(thisDetector->myDetectorType==PROPIX)){ - setFramesPerFile(MAX_FRAMES_PER_FILE); + fileIO::setFramesPerFile(MAX_FRAMES_PER_FILE); pthread_mutex_unlock(&ms); setFileFormat(BINARY); }else if (thisDetector->myDetectorType==EIGER){ - setFramesPerFile(EIGER_MAX_FRAMES_PER_FILE); + fileIO:: setFramesPerFile(EIGER_MAX_FRAMES_PER_FILE); pthread_mutex_unlock(&ms); setFileFormat(BINARY); }else if (thisDetector->myDetectorType==MOENCH){ - setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE); + fileIO:: setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE); pthread_mutex_unlock(&ms); setFileFormat(BINARY); }else if (thisDetector->myDetectorType==JUNGFRAU){ - setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE); + fileIO:: setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE); pthread_mutex_unlock(&ms); setFileFormat(BINARY); }else if (thisDetector->myDetectorType==JUNGFRAUCTB){ setFramesPerFile(JFCTB_MAX_FRAMES_PER_FILE); - pthread_mutex_unlock(&ms); + fileIO:: pthread_mutex_unlock(&ms); setFileFormat(BINARY); }else pthread_mutex_unlock(&ms); + if (thisReceiver != NULL) + delete thisReceiver; thisReceiver = new receiverInterface(dataSocket); // setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips); @@ -926,8 +928,8 @@ int slsDetector::initializeDetectorSize(detectorType type) { int slsDetector::initializeDetectorStructure() { sls_detector_module *thisMod; - char *p2; - p2=(char*)thisDetector; + //char *p2; + //p2=(char*)thisDetector; /** for each of the detector modules up to the maximum number which can be installed initlialize the sls_detector_module structure \sa ::sls_detector_module*/ for (int imod=0; imodnModsMax; imod++) { @@ -995,18 +997,19 @@ 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; @@ -1026,7 +1029,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) 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; @@ -1040,21 +1043,21 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) break; case JUNGFRAU: nch=256*256;//32; - nm=1; + // nm=1; nc=4*2; nd=16; // dacs+adcs na=0; break; case JUNGFRAUCTB: nch=36; - 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; @@ -1753,7 +1756,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; @@ -1774,11 +1776,11 @@ int slsDetector::setNumberOfModules(int n, dimension d){ if (connect == UNDEFINED) cout << "no control socket?" << endl; 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)); std::cout<< "Detector returned error: " << mess << std::endl; @@ -1912,7 +1914,6 @@ int slsDetector::setFlippedData(dimension d, int value){ int retval=-1; int fnum=F_SET_FLIPPED_DATA_RECEIVER; int ret=FAIL; - char mess[MAX_STR_LENGTH]=""; int args[2]={X,-1}; @@ -3365,7 +3366,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV, detectorSettings isetti ostfn << thisDetector->settingsDir << ssettings << "/" << e_eV << "eV" << "/noise.sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER) << setbase(10); string settingsfname = ostfn.str(); #ifdef VERBOSE - printf("Settings File is %s\n", settingsfname1.c_str()); + printf("Settings File is %s\n", settingsfname.c_str()); #endif //read the files myMod=createModule(); @@ -3806,18 +3807,18 @@ int slsDetector::updateDetectorNoWait() { enum readOutFlags ro; // int ret=OK; enum detectorSettings t; - int thr, n, nm; + int thr, n = 0, nm; // 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 cout << "Updating detector last modified by " << lastClientIP << std::endl; #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) { @@ -3839,13 +3840,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)&& @@ -3853,49 +3854,49 @@ int slsDetector::updateDetectorNoWait() { (thisDetector->myDetectorType!= JUNGFRAU)&& (thisDetector->myDetectorType!= MOENCH) && (thisDetector->myDetectorType!= JUNGFRAUCTB)){ //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; //retval=setProbes(tns); if (thisDetector->myDetectorType == JUNGFRAUCTB){ - n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); + n += controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t)); if (retval>=0) thisDetector->timerValue[SAMPLES_JCTB]=retval; - n = controlSocket->ReceiveDataOnly( &ro,sizeof(ro)); + n += controlSocket->ReceiveDataOnly( &ro,sizeof(ro)); thisDetector->roFlags=ro; @@ -3905,6 +3906,11 @@ int slsDetector::updateDetectorNoWait() { // thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB]; } + + + if (!n) + printf("n: %d\n", n); + return OK; } @@ -4315,7 +4321,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) { @@ -4327,7 +4332,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)); @@ -4823,7 +4828,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) { int retval=-1; char mess[MAX_STR_LENGTH]=""; int ret=OK; - int n=0; + #ifdef VERBOSE std::cout<< "Setting speed variable"<< sp << " to " << value << std::endl; #endif @@ -4831,7 +4836,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 std::cout<< "Sent "<< n << " bytes " << std::endl; #endif @@ -5078,7 +5083,7 @@ int slsDetector::sendROI(int n,ROI roiLimits[]){ if (ret!=FAIL){ controlSocket->ReceiveDataOnly(&retvalsize,sizeof(retvalsize)); nrec = controlSocket->ReceiveDataOnly(retval,retvalsize*sizeof(ROI)); - if(nrec!=(retvalsize*sizeof(ROI))){ + if(nrec!=(retvalsize*(int)sizeof(ROI))){ ret=FAIL; std::cout << " wrong size received: received " << nrec << "but expected " << retvalsize*sizeof(ROI) << endl; } @@ -5509,7 +5514,7 @@ int slsDetector::setRateCorrection(double t){ int ret=FAIL; char mess[MAX_STR_LENGTH]=""; int64_t arg = t; - int64_t retval = -1; + #ifdef VERBOSE std::cout<< "Setting Rate Correction to " << arg << endl; #endif @@ -6617,13 +6622,17 @@ int slsDetector::readConfigurationFile(string const fname){ //char *args[1000]; string sargname, sargval; - int iline=0; #ifdef VERBOSE + int iline=0; std::cout<< "config file name "<< fname << std::endl; #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 { std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl; @@ -6711,11 +6720,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 { @@ -6831,7 +6845,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); @@ -6844,7 +6858,6 @@ int slsDetector::programFPGA(string fname){ int ret=FAIL; int fnum=F_PROGRAM_FPGA; char mess[MAX_STR_LENGTH]=""; - int64_t retval = -1; size_t filesize=0; char* fpgasrc = NULL; @@ -7449,6 +7462,7 @@ string slsDetector::checkReceiverOnline() { return string(""); } } + return retval; } @@ -8026,30 +8040,32 @@ string slsDetector::getReceiverLastClientIP(){ int slsDetector::updateReceiverNoWait() { - int n,ind; + int n = 0,ind; char path[MAX_STR_LENGTH]; char lastClientIP[INET_ADDRSTRLEN]; - n = dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); + n += dataSocket->ReceiveDataOnly(lastClientIP,sizeof(lastClientIP)); #ifdef VERBOSE cout << "Updating receiver last modified by " << lastClientIP << std::endl; #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); - n = dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); + n += dataSocket->ReceiveDataOnly(path,MAX_STR_LENGTH); pthread_mutex_lock(&ms); fileIO::setFileName(path); pthread_mutex_unlock(&ms); + if (!n) printf("n: %d\n", n); + return OK; } @@ -8550,9 +8566,9 @@ int slsDetector::setReceiverFifoDepth(int i){ int slsDetector::setCTBPattern(string fname) { - int fnum=F_SET_CTB_PATTERN; - int ret = FAIL; - char retval[MAX_STR_LENGTH]=""; + //int fnum=F_SET_CTB_PATTERN; + //int ret = FAIL; + //char retval[MAX_STR_LENGTH]=""; // if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index f5b8443be..951a70eb4 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -512,7 +512,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 a9c3616a8..bdcc6cebd 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 && iactiongetId(THIS_SOFTWARE_VERSION)); + int64_t retval = myDet->getId(THIS_SOFTWARE_VERSION); + if (retval < 0) + sprintf(answer, "%d", -1); + else + sprintf(answer,"%lx", (long long unsigned int)retval); return string(answer); } @@ -3482,37 +3486,61 @@ string slsDetectorCommand::cmdSN(int narg, char *args[], int action) { if (cmd=="moduleversion") { int ival=-1; if (sscanf(args[0],"moduleversion:%d",&ival)) { - sprintf(answer,"%llx",myDet->getId(MODULE_FIRMWARE_VERSION,ival)); + int64_t retval = myDet->getId(MODULE_FIRMWARE_VERSION, ival); + if (retval < 0) + sprintf(answer, "%d", -1); + else + sprintf(answer,"%lx", (long long unsigned int)retval); return string(answer); } else return string("undefined module number"); } if (cmd=="detectornumber") { - sprintf(answer,"%llx",myDet->getId(DETECTOR_SERIAL_NUMBER)); + int64_t retval = myDet->getId(DETECTOR_SERIAL_NUMBER); + if (retval < 0) + sprintf(answer, "%d", -1); + else + sprintf(answer,"%lx", (long long unsigned int)retval); return string(answer); } if (cmd.find("modulenumber")!=string::npos) { int ival=-1; if (sscanf(args[0],"modulenumber:%d",&ival)) { - sprintf(answer,"%llx",myDet->getId(MODULE_SERIAL_NUMBER,ival)); + int64_t retval = myDet->getId(MODULE_SERIAL_NUMBER, ival); + if (retval < 0) + sprintf(answer, "%d", -1); + else + sprintf(answer,"%lx", (long long unsigned int)retval); return string(answer); } else return string("undefined module number"); } if (cmd=="detectorversion") { - sprintf(answer,"%llx",myDet->getId(DETECTOR_FIRMWARE_VERSION)); + int64_t retval = myDet->getId(DETECTOR_FIRMWARE_VERSION); + if (retval < 0) + sprintf(answer, "%d", -1); + else + sprintf(answer,"%lx", (long long unsigned int)retval); return string(answer); } if (cmd=="softwareversion") { - sprintf(answer,"%llx",myDet->getId(DETECTOR_SOFTWARE_VERSION)); + int64_t retval = myDet->getId(DETECTOR_SOFTWARE_VERSION); + if (retval < 0) + sprintf(answer, "%d", -1); + else + sprintf(answer,"%lx", (long long unsigned int)retval); return string(answer); } if (cmd=="receiverversion") { myDet->setReceiverOnline(ONLINE_FLAG); - sprintf(answer,"%llx",myDet->getId(RECEIVER_VERSION)); + int64_t retval = myDet->getId(RECEIVER_VERSION); + if (retval < 0) + sprintf(answer, "%d", -1); + else + sprintf(answer,"%lx", (long long unsigned int)retval); return string(answer); } return string("unknown id mode ")+cmd; @@ -4558,7 +4586,7 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) { if (action==GET_ACTION) return string("cannot get"); #ifdef VERBOSE - std::cout<< " resetting fpga " << sval << std::endl; + std::cout<< " resetting fpga " << std::endl; #endif myDet->setOnline(ONLINE_FLAG); if(myDet->resetFPGA() == OK) @@ -4938,7 +4966,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { else return string("Could not scan address (hexadecimal fomat) ")+string(args[1]); - if (sscanf(args[2],"%llx",&word)) + if (sscanf(args[2],"%lx",&word)) ; else return string("Could not scan value (hexadecimal fomat) ")+string(args[2]); @@ -4954,7 +4982,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { if (action==PUT_ACTION) { - if (sscanf(args[1],"%llx",&word)) + if (sscanf(args[1],"%lx",&word)) ; else return string("Could not scan value (hexadecimal fomat) ")+string(args[1]); @@ -4971,7 +4999,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { if (action==PUT_ACTION) { - if (sscanf(args[1],"%llx",&word)) + if (sscanf(args[1],"%lx",&word)) ; else return string("Could not scan value (hexadecimal fomat) ")+string(args[1]); @@ -5242,7 +5270,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { if (action==PUT_ACTION) { - if (sscanf(args[1],"%lld",&t)) + if (sscanf(args[1],"%ld",&t)) ; else return string("Could not scan wait time")+string(args[1]); @@ -5265,7 +5293,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { if (action==PUT_ACTION) { - if (sscanf(args[1],"%lld",&t)) + if (sscanf(args[1],"%ld",&t)) ; else return string("Could not scan wait time ")+string(args[1]); @@ -5283,7 +5311,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { } else if (cmd=="patwaittime2") { if (action==PUT_ACTION) { - if (sscanf(args[1],"%lld",&t)) + if (sscanf(args[1],"%ld",&t)) ; else return string("Could not scan wait time ")+string(args[1]); @@ -5471,13 +5499,12 @@ string slsDetectorCommand::cmdPulse(int narg, char *args[], int action) { } - return string(""); -/* + if(retval == OK) return string(" successful"); else return string(" failed"); - */ + } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index 1f135b039..2da38b73d 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -806,7 +806,6 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ slsDetectorCommand *cmd; string names[100]; int nvar=0; - int nvar1=0; names[nvar++]="fname"; names[nvar++]="index"; @@ -886,6 +885,9 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ names[nvar++]="patnloop2"; names[nvar++]="patwait2"; names[nvar++]="patwaittime2"; + break; + default: + break; } @@ -916,7 +918,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ names[nvar++]="flatfield"; names[nvar++]="badchannels"; break; - + default: + break; } switch (getDetectorsType()) { @@ -924,7 +927,8 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){ case MYTHEN: names[nvar++]="trimbits"; break; - + default: + break; } // char ext[100]; diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp index 43e5a4436..2e380323c 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp @@ -255,8 +255,8 @@ int angularConversionStatic::readAngularConversion( ifstream& infile, int nmod, angOff[nm].etilt=epitch; } - // cout << angOff[nm].center << " " << \ - // angOff[nm].r_conversion << " " << \ + // cout << angOff[nm].center << " " << + // angOff[nm].r_conversion << " " << // angOff[nm].offset << endl; } else diff --git a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp index d55e4cc8f..57eee451b 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/energyConversion.cpp @@ -457,7 +457,7 @@ slsDetectorDefs::sls_detector_module* energyConversion::readSettingsFile(string }; -int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int& iodelay, int& tau){ +int energyConversion::writeSettingsFile(string fname, detectorType myDetectorType, sls_detector_module mod, int iodelay, int tau){ ofstream outfile; @@ -537,8 +537,8 @@ int energyConversion::writeSettingsFile(string fname, detectorType myDetectorTyp std::cout << "tau: " << tau << std::endl; #endif outfile.write((char*)mod.dacs, sizeof(dacs_t)*(mod.ndac)); - outfile.write((char*)iodelay, sizeof(iodelay)); - outfile.write((char*)tau, sizeof(tau)); + outfile.write(reinterpret_cast(&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 a3d8720e7..b590d0b20 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -38,7 +38,7 @@ int postProcessing::kbhit(){ } -postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0), badChannelMask(NULL){ +postProcessing::postProcessing(): expTime(NULL), badChannelMask(NULL), ang(NULL), val(NULL), err(NULL), numberOfChannels(0) { pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; mp=mp1; pthread_mutex_init(&mp, NULL); @@ -433,10 +433,9 @@ void* postProcessing::processData(int delflag) { int *myData; - char *p; int dum=1; - int nf=1, ii, nch; - int jctb=0; +// int nf=1, ii, nch; +// int jctb=0; // if (getDetectorsType()==JUNGFRAUCTB) { @@ -467,7 +466,7 @@ void* postProcessing::processData(int delflag) { // if (jctb) { -// p=(char*)myData; +// char* p=(char*)myData; // for (ii=0; ii*m_fn)());} private: - _Class* m_ptr; _Ret (_Class::*m_fn)(); + _Class* m_ptr; }; template @@ -36,8 +36,8 @@ public: ~func0_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)());} private: - _Class* m_ptr; _Ret (_Class::*m_fn)(); + _Class* m_ptr; _Store* m_store; }; @@ -49,8 +49,8 @@ public: ~func1_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));} private: - _Class* m_ptr; _Ret (_Class::*m_fn)(_Arg1); + _Class* m_ptr; _Arg1 m_arg1; _Store* m_store; }; @@ -63,8 +63,8 @@ public: ~func2_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));} private: - _Class* m_ptr; _Ret (_Class::*m_fn)(_Arg1,_Arg2); + _Class* m_ptr; _Arg1 m_arg1; _Arg2 m_arg2; _Store* m_store; @@ -78,8 +78,8 @@ public: ~func3_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3));} private: - _Class* m_ptr; _Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3); + _Class* m_ptr; _Arg1 m_arg1; _Arg2 m_arg2; _Arg3 m_arg3; @@ -94,8 +94,8 @@ public: ~func4_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));} private: - _Class* m_ptr; _Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4); + _Class* m_ptr; _Arg1 m_arg1; _Arg2 m_arg2; _Arg3 m_arg3; diff --git a/slsDetectorSoftware/threadFiles/ThreadPool.cpp b/slsDetectorSoftware/threadFiles/ThreadPool.cpp index 347a15e31..a7e20c873 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 } @@ -85,7 +86,8 @@ int ThreadPool::destroy_threadpool(){ } void* ThreadPool::execute_thread(){ - int ithread = current_thread_number; +//for debugging seting ithread value +// int ithread = current_thread_number; thread_started = true; Task* task = NULL; m_tasks_loaded = false;