diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 87369d10f..b2d2a2af4 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -1434,9 +1434,15 @@ float* multiSlsDetector::decodeData(int *datain, float *fdata) { for (int i=0; inumberOfDetectors; i++) { if (detectors[i]) { detectors[i]->decodeData(datap, detp); +#ifdef VERBOSE + cout << "increment pointers " << endl; +#endif datap+=detectors[i]->getDataBytes()/sizeof(int); detp+=detectors[i]->getTotalNumberOfChannels(); +#ifdef VERBOSE + cout << "done " << endl; +#endif // for (int j=0; jgetTotalNumberOfChannels(); j++) { // dataout[ich]=detp[j]; // ich++; @@ -1683,7 +1689,11 @@ int multiSlsDetector::getNMods(){ int multiSlsDetector::getChansPerMod(int imod){ int id=-1, im=-1; - if (decodeNMod(imod, id, im)>=0) { +#ifdef VERBOSE + cout << "get chans per mod " << imod << endl; +#endif + decodeNMod(imod, id, im); + if (id >=0) { if (detectors[id]) { return detectors[id]->getChansPerMod(im); } @@ -1709,6 +1719,9 @@ int multiSlsDetector::getMoveFlag(int imod){ angleConversionConstant * multiSlsDetector::getAngularConversionPointer(int imod){ int id=-1, im=-1; +#ifdef VERBOSE + cout << "get angular conversion pointer " << endl; +#endif if (decodeNMod(imod, id, im)>=0) { if (detectors[id]) { return detectors[id]->getAngularConversionPointer(im); @@ -2695,6 +2708,21 @@ int multiSlsDetector::setDynamicRange(int p) { } +int multiSlsDetector::getMaxMods() { + + + int ret=0, ret1; + + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + ret1=detectors[idet]->getMaxMods(); + ret+=ret1; + } + } + return ret; + +} + int multiSlsDetector::getMaxNumberOfModules(dimension d) { @@ -2702,7 +2730,7 @@ int multiSlsDetector::getMaxNumberOfModules(dimension d) { for (int idet=0; idetnumberOfDetectors; idet++) { if (detectors[idet]) { - ret1=detectors[idet]->getMaxNumberOfModules(); + ret1=detectors[idet]->getMaxNumberOfModules(d); ret+=ret1; } } @@ -2743,14 +2771,14 @@ int multiSlsDetector::setNumberOfModules(int p, dimension d) { int multiSlsDetector::decodeNMod(int i, int &id, int &im) { #ifdef VERBOSE - cout << " Module " << i << " belongs to detector "; + cout << " Module " << i << " belongs to detector " << id ; #endif - if (i<0 || i>=getMaxNumberOfModules()) { + if (i<0 || i>=getMaxMods()) { id=-1; im=-1; #ifdef VERBOSE - cout << id << " position " << im << endl; + cout << "A---------" << id << " position " << im << endl; #endif return -1; @@ -2763,7 +2791,7 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) { id=idet; im=i; #ifdef VERBOSE - cout << id << " position " << im << endl; + cout << "B---------" <numberOfDetectors; i++) { if (detectors[i]) { +#ifdef VERBOSE + cout << " write " << i << endl; +#endif detectors[i]->writeDataFile(outfile, detectors[i]->getTotalNumberOfChannels(), data+off, choff); - choff+=detectors[i]->getMaxNumberOfChannels(); - off+=detectors[i]->getTotalNumberOfChannels(); + choff+=detectors[i]->getMaxNumberOfChannels(); + off+=detectors[i]->getTotalNumberOfChannels(); } } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 5c6ef4e60..9f75d3b48 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -288,9 +288,10 @@ class multiSlsDetector : public slsDetectorUtils { - + int getMaxMods(); int getNMods(); int getChansPerMod(int imod=0); + angleConversionConstant *getAngularConversionPointer(int imod=0); diff --git a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c index 650f70e9b..cd4f04098 100755 --- a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c @@ -46,7 +46,7 @@ int ififostart, ififostop, ififostep, ififo; int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING; -enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF}; +enum externalSignalFlag signals[4]={GATE_IN_ACTIVE_HIGH, TRIGGER_IN_RISING_EDGE, SIGNAL_OFF, SIGNAL_OFF}; #ifdef MCB_FUNCS diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index da638f0e5..1be48e02b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -1380,7 +1380,7 @@ int slsDetector::getMaxNumberOfModules(dimension d){ controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); else { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); - std::cout<< "Deterctor returned error: " << mess << std::endl; + std::cout<< "Detector returned error: " << mess << std::endl; } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) @@ -4919,6 +4919,8 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){ slsDetectorCommand *cmd=new slsDetectorCommand(this); int nvar; + int nsig=-1; + string names[]={ \ "hostname", \ "port", \ @@ -4941,7 +4943,8 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){ "threaded", \ "waitstates", \ "setlength", \ - "clkdivider"}; + "clkdivider", \ + "extsig" }; switch (thisDetector->myDetectorType) { case GOTTHARD: @@ -4951,8 +4954,11 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){ names[9]="servermac"; nvar=10; break; + case MYTHEN: + nsig=4; default: - nvar=22; + nvar=23; + } int iv=0; @@ -4963,8 +4969,16 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){ for (iv=0; ivexecuteLine(1,args,GET_ACTION) << std::endl; + cout << iv << " " << names[iv] << endl; + if (names[iv]=="extsig") { + for (int is=0; isexecuteLine(1,args,GET_ACTION) << std::endl; + } + } else { + strcpy(args[0],names[iv].c_str()); + outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; + } } delete cmd; return iv; @@ -5030,7 +5044,7 @@ int slsDetector::dumpDetectorSetup(string const fname, int level){ "badchannels",\ "angconv",\ "trimbits",\ - "extsig" + "timing" }; int nvar=41; int iv=0; @@ -5103,10 +5117,11 @@ int slsDetector::dumpDetectorSetup(string const fname, int level){ outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl; iv++; - for (int is=0; is<4; is++) { - sprintf(args[0],"%s:%d",names[iv].c_str(),is); + strcpy(args[0],names[iv].c_str()); + // for (int is=0; is<4; is++) { + // sprintf(args[0],"%s:%d",names[iv].c_str(),is); outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; - } + // } iv++; outfile.close(); } diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp index ea999360b..7345f0ca5 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.cpp @@ -36,21 +36,40 @@ angularConversion::~angularConversion(){ float* angularConversion::convertAngles(float pos) { - int imod; + int imod=0; float *ang=new float[getTotalNumberOfChannels()]; float enc=pos; angleConversionConstant *p=NULL; + + int ch0=0; + int chlast=getChansPerMod(0); + int nchmod=getChansPerMod(0); + p=getAngularConversionPointer(imod); + if (getMoveFlag(imod)==0) + enc=0; + else + enc=pos; + for (int ip=0; ip=chlast) { + imod++; + p=getAngularConversionPointer(imod); + if (getMoveFlag(imod)==0) + enc=0; + else + enc=pos; + + ch0=chlast; + nchmod=getChansPerMod(imod); + if (nchmod>0) + chlast+=nchmod; + } + if (p) - ang[ip]=angle(ip%(getChansPerMod()), \ + ang[ip]=angle(ip-ch0, \ enc, \ (*fineOffset)+(*globalOffset), \ p->r_conversion, \ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h index cbedd06c6..bf7cb6452 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversion.h @@ -417,8 +417,6 @@ class angularConversion : public virtual slsDetectorBase { current position of the detector */ float currentPosition; - - /** current position index of the detector */ diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index e94ec2ca9..b861bb862 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -137,15 +137,17 @@ void postProcessing::processFrame(int *myData, int delflag) { fname=createFileName(); - //uses static function?!?!?!? - writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i'); - - doProcessing(fdata,delflag, fname); + //uses static function?!?!?!? + writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i'); + + doProcessing(fdata,delflag, fname); + + delete [] myData; + myData=NULL; + fdata=NULL; - delete [] myData; - myData=NULL; #ifdef VERBOSE - // cout << "Pop data queue " << *fileIndex << endl; + cout << "Pop data queue " << *fileIndex << endl; #endif pthread_mutex_lock(&mp); @@ -159,7 +161,7 @@ void postProcessing::processFrame(int *myData, int delflag) { -void postProcessing::doProcessing(float *fdata, int delflag, string fname) { +void postProcessing::doProcessing(float *lfdata, int delflag, string fname) { /** write raw data file */ @@ -187,13 +189,13 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) { if (*correctionMask&(1<=getNumberOfPositions() && posfinished==1 && queuesize==1)) { @@ -259,6 +262,7 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) { np=finalizeMerging(); /** file writing */ incrementPositionIndex(); + cout << "unlock 1" << endl; pthread_mutex_unlock(&mp); @@ -279,16 +283,21 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) { } else { thisData=new detectorData(getMergedCounts(),getMergedErrors(),getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np); + cout << "lock 2" << endl; pthread_mutex_lock(&mg); finalDataQueue.push(thisData); + cout << "unlock 2" << endl; pthread_mutex_unlock(&mg); } + cout << "lock 3" << endl; pthread_mutex_lock(&mp); } + cout << "unlock 3" << endl; pthread_mutex_unlock(&mp); if (ffcdata) delete [] ffcdata; + ffcdata=NULL; if (ffcerr) @@ -317,8 +326,10 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) { } incrementFileIndex(); - - +#ifdef VERBOSE + cout << "fdata is " << fdata << endl; +#endif + } @@ -449,9 +460,15 @@ void* postProcessing::processData(int delflag) { dum=0; } - if (fdata) + if (fdata) { +#ifdef VERBOSE + cout << "delete fdata" << endl; +#endif delete [] fdata; - +#ifdef VERBOSE + cout << "done " << endl; +#endif + } return 0; }