mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-09 03:20:42 +02:00
added nchans for each dimension and edited update offsets to work better for 2d dets
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@514 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
cec069f0e9
commit
ca15ff971d
@ -341,10 +341,23 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
|
||||
#endif
|
||||
|
||||
//set offsets
|
||||
updateOffsets();
|
||||
|
||||
return thisMultiDetector->numberOfDetectors;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void multiSlsDetector::updateOffsets(){
|
||||
int offsetX=0,offsetY=0,numX,numY;
|
||||
int maxChanX = thisMultiDetector->maxNumberOfChannelsPerDetector[X];
|
||||
int maxChanY = thisMultiDetector->maxNumberOfChannelsPerDetector[Y];
|
||||
|
||||
thisMultiDetector->numberOfChannel[X] = 0;
|
||||
thisMultiDetector->maxNumberOfChannel[X] = 0;
|
||||
thisMultiDetector->numberOfChannel[Y] = 0;
|
||||
thisMultiDetector->maxNumberOfChannel[Y] = 0;
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
if (detectors[i]) {
|
||||
thisMultiDetector->offsetX[i] = offsetX;
|
||||
@ -359,6 +372,17 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
|
||||
if ((maxChanX == -1) || ((maxChanX > 0) && (offsetX < maxChanX))){
|
||||
thisMultiDetector->numberOfChannel[X] += detectors[i]->getTotalNumberOfChannels(X);
|
||||
thisMultiDetector->maxNumberOfChannel[X] += numX;
|
||||
//the first time y should be added but offset not increased
|
||||
if (thisMultiDetector->numberOfChannel[Y] == 0){
|
||||
if ((maxChanY == -1) || ((maxChanY > 0) && (numY < maxChanY))){
|
||||
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
|
||||
thisMultiDetector->maxNumberOfChannel[Y] += numY;
|
||||
}else{
|
||||
cout<<"Detector at position " << i << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
|
||||
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
|
||||
thisMultiDetector->maxNumberOfChannel[Y] += numY;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
offsetX = 0;
|
||||
thisMultiDetector->numberOfChannel[X] = 0;
|
||||
@ -368,20 +392,15 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
|
||||
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
|
||||
thisMultiDetector->maxNumberOfChannel[Y] += numY;
|
||||
}else{
|
||||
cout<<"Detector " << id << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
|
||||
cout<<"Detector at position " << i << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
|
||||
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
|
||||
thisMultiDetector->maxNumberOfChannel[Y] += numY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return thisMultiDetector->numberOfDetectors;
|
||||
|
||||
}
|
||||
|
||||
|
||||
string multiSlsDetector::setHostname(const char* name, int pos){
|
||||
|
||||
// int id=0;
|
||||
@ -762,6 +781,8 @@ int multiSlsDetector::removeSlsDetector(int pos) {
|
||||
}
|
||||
}
|
||||
|
||||
updateOffsets();
|
||||
|
||||
return thisMultiDetector->numberOfDetectors;
|
||||
}
|
||||
|
||||
|
@ -1194,6 +1194,9 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
int setReadReceiverFrequency(int i=-1);
|
||||
|
||||
/** updates the multidetector offsets */
|
||||
void updateOffsets();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
@ -490,6 +490,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
switch(thisDetector->myDetectorType) {
|
||||
case MYTHEN:
|
||||
thisDetector->nChans=128;
|
||||
thisDetector->nChan[X]=128;
|
||||
thisDetector->nChan[Y]=1;
|
||||
thisDetector->nChips=10;
|
||||
thisDetector->nDacs=6;
|
||||
thisDetector->nAdcs=0;
|
||||
@ -503,6 +505,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
break;
|
||||
case PICASSO:
|
||||
thisDetector->nChans=128;
|
||||
thisDetector->nChan[X]=128;
|
||||
thisDetector->nChan[Y]=1;
|
||||
thisDetector->nChips=12;
|
||||
thisDetector->nDacs=6;
|
||||
thisDetector->nAdcs=0;
|
||||
@ -512,6 +516,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
break;
|
||||
case GOTTHARD:
|
||||
thisDetector->nChans=128;
|
||||
thisDetector->nChan[X]=128;
|
||||
thisDetector->nChan[Y]=1;
|
||||
thisDetector->nChips=10;
|
||||
thisDetector->nDacs=8;
|
||||
thisDetector->nAdcs=5;
|
||||
@ -521,6 +527,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
break;
|
||||
case MOENCH:
|
||||
thisDetector->nChans=160*160;
|
||||
thisDetector->nChan[X]=160;
|
||||
thisDetector->nChan[Y]=160;
|
||||
thisDetector->nChips=1;
|
||||
thisDetector->nDacs=8;
|
||||
thisDetector->nAdcs=1;
|
||||
@ -530,6 +538,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
break;
|
||||
default:
|
||||
thisDetector->nChans=0;
|
||||
thisDetector->nChan[X]=0;
|
||||
thisDetector->nChan[Y]=0;
|
||||
thisDetector->nChips=0;
|
||||
thisDetector->nDacs=0;
|
||||
thisDetector->nAdcs=0;
|
||||
|
@ -116,6 +116,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
int nModsMax;
|
||||
/** number of channels per chip */
|
||||
int nChans;
|
||||
/** number of channels per chip in one direction */
|
||||
int nChan[2];
|
||||
/** number of chips per module*/
|
||||
int nChips;
|
||||
/** number of dacs per module*/
|
||||
@ -564,6 +566,9 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
/** Returns the number of channels per chip (without connecting to the detector) */
|
||||
int getNChans(){return thisDetector->nChans;}; //
|
||||
|
||||
/** Returns the number of channels per chip (without connecting to the detector) in one direction */
|
||||
int getNChans(dimension d){return thisDetector->nChan[d];}; //
|
||||
|
||||
/** Returns the number of chips per module (without connecting to the detector) */
|
||||
int getNChips(){return thisDetector->nChips;}; //
|
||||
|
||||
@ -575,6 +580,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
|
||||
int getChansPerMod(int imod=0){return thisDetector->nChans*thisDetector->nChips;};
|
||||
|
||||
int getChansPerMod( dimension d,int imod=0){return thisDetector->nChan[d]*thisDetector->nChips;};
|
||||
|
||||
/** Returns the max number of modules in direction d (without connecting to the detector) */
|
||||
int getNMaxMod(dimension d){return thisDetector->nModMax[d];}; //
|
||||
|
||||
@ -584,11 +591,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
|
||||
int getTotalNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
|
||||
|
||||
int getTotalNumberOfChannels(dimension d){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMod[X];};
|
||||
int getTotalNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChips*thisDetector->nMod[X];};
|
||||
|
||||
int getMaxNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
|
||||
|
||||
int getMaxNumberOfChannels(dimension d){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModMax[d];};
|
||||
int getMaxNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChips*thisDetector->nModMax[d];};
|
||||
|
||||
/** Returns number of rois */
|
||||
int getNRoi(){return thisDetector->nROI;};
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include <iomanip> //set precision
|
||||
|
||||
|
||||
#include <sched.h>
|
||||
//#include <sched.h> //sched_idle
|
||||
//#include <fcntl.h> //posix_fadvice
|
||||
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
@ -91,6 +92,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
|
||||
if (det == MOENCH)
|
||||
aligned_frame_size = MOENCH_ALIGNED_FRAME_SIZE;
|
||||
|
||||
|
||||
mem0=(char*)malloc(aligned_frame_size*FIFO_SIZE);
|
||||
if (mem0==NULL) {
|
||||
cout<<"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY!!!!!!!+++++++++++++++++++++" << endl;
|
||||
@ -246,12 +248,12 @@ int slsReceiverFunctionList::startReceiver(){
|
||||
cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl;
|
||||
if (pthread_setschedparam(writing_thread, policy, &write_param) == EPERM)
|
||||
cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl;
|
||||
if (pthread_setschedparam(pthread_self(), 5, &tcp_param) == EPERM)
|
||||
if (pthread_setschedparam(pthread_self(),policy , &tcp_param) == EPERM)
|
||||
cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl;
|
||||
|
||||
|
||||
pthread_getschedparam(pthread_self(),&policy,&tcp_param);
|
||||
cout << "current priority of main tcp thread is " << tcp_param.sched_priority << endl;
|
||||
//pthread_getschedparam(pthread_self(),&policy,&tcp_param);
|
||||
//cout << "current priority of main tcp thread is " << tcp_param.sched_priority << endl;
|
||||
|
||||
}
|
||||
|
||||
@ -453,6 +455,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
if(enableFileWrite || cbAction>0){
|
||||
sfilefd = fopen((const char *) (savefilename), "w");
|
||||
cout << savefilename << endl;
|
||||
//posix_fadvise(fileno(sfilefd),0,0,POSIX_FADV_DONTNEED|POSIX_FADV_SEQUENTIAL);
|
||||
}
|
||||
|
||||
|
||||
@ -468,8 +471,10 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
//start writing in new file
|
||||
if(enableFileWrite || cbAction>0){
|
||||
//fsync(fileno(sfilefd));
|
||||
fclose(sfilefd);
|
||||
sfilefd = fopen((const char *) (savefilename), "w");
|
||||
//posix_fadvise(fileno(sfilefd),0,0,POSIX_FADV_DONTNEED|POSIX_FADV_SEQUENTIAL);
|
||||
}
|
||||
|
||||
//currframenum=(int)(*((int*)latestData));
|
||||
@ -535,7 +540,9 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
cout << "Total Frames Caught:"<< totalFramesCaught << endl;
|
||||
//close file
|
||||
if(sfilefd) fclose(sfilefd);
|
||||
if(sfilefd)
|
||||
fclose(sfilefd);
|
||||
//{ fsync(fileno(sfilefd));fclose(sfilefd);}
|
||||
#ifdef VERBOSE
|
||||
cout << "sfield:" << (int)sfilefd << endl;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user