receiver modified: fifofreed using callback, last fifo freed after all the process, using locks for fifofree, updating currentframenum only in singlephoton if datacompression

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@701 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2013-11-29 11:39:22 +00:00
parent 03d0d5e6cd
commit adb500c4a0
5 changed files with 73 additions and 30 deletions

View File

@ -13,7 +13,7 @@
singlePhotonFilter::singlePhotonFilter(int nx, int ny,
int fmask, int pmask, int foffset, int poffset, int pperf, int iValue,
int16_t *m, int16_t *s, CircularFifo<char>* f, int d, int* tfcaught, int* fcaught):
int16_t *m, int16_t *s, CircularFifo<char>* f, int d, int* tfcaught, int* fcaught,uint32_t* cframenum):
#ifdef MYROOT1
myTree(NULL),
myFile(NULL),
@ -57,6 +57,7 @@ singlePhotonFilter::singlePhotonFilter(int nx, int ny,
fifo(f),
totalFramesCaught(tfcaught),
framesCaught(fcaught),
currentframenum(cframenum),
freeFifoCallBack(NULL),
pFreeFifo(NULL){
#ifndef MYROOT1
@ -93,6 +94,7 @@ singlePhotonFilter::singlePhotonFilter(int nx, int ny,
pthread_mutex_init(&write_mutex,NULL);
pthread_mutex_init(&running_mutex,NULL);
pthread_mutex_init(&frnum_mutex,NULL);
@ -264,6 +266,7 @@ void singlePhotonFilter::setupAcquisitionParameters(char *outfpath, char* outfna
fnum = 0; pnum = 0; ptot = 0; f0 = 0; firstTime = true; currentThread = -1;
*framesCaught = 0;
*currentframenum = 0;
//initialize
for (int ir=0; ir<nChannelsX; ir++){
@ -449,6 +452,11 @@ void singlePhotonFilter::findHits(){
cout<<"got data semwait:["<<index<<"]:"<<dum<<endl;
isData += HEADER_SIZE_NUM_FRAMES;
if(clusteriframe > *currentframenum){
pthread_mutex_lock(&frnum_mutex);
*currentframenum = clusteriframe;
pthread_mutex_unlock(&frnum_mutex);
}
//for all the frames in one buffer
for (i=0; i < numFramesAlloted[index]; ++i){
@ -462,6 +470,13 @@ void singlePhotonFilter::findHits(){
isData += HEADER_SIZE_NUM_PACKETS;
clusteriframe = (((uint32_t)(*((uint32_t*)(isData)))& frame_index_mask) >>frame_index_offset);
//progress
if((clusteriframe + PROGRESS_INCREMENT) > *currentframenum){
pthread_mutex_lock(&frnum_mutex);
*currentframenum = clusteriframe;
pthread_mutex_unlock(&frnum_mutex);
}
#ifdef VERYVERBOSE
cout << "scurrframnum:" << clusteriframe << endl;
#endif

View File

@ -81,8 +81,9 @@ public:
* @param s mask as to which adcs are inverted
* @param f circular fifo buffer, which needs to be freed
* @param d Size of data with the headers
* @param tfcaught pointer to total frames caught
* @param fcaught pointer to frames caught
* @param tfcaught pointer to total frames caught- needs updation for client
* @param fcaught pointer to frames caught - needs updation for client
* @param cframenum pointer to currentframe num- needs updation for progress for gui
*/
singlePhotonFilter(
int nx,
@ -98,7 +99,8 @@ public:
CircularFifo<char>* f,
int d,
int* tfcaught,
int* fcaught);
int* fcaught,
uint32_t* cframenum);
/** virtual destructor */
virtual ~singlePhotonFilter();
@ -359,7 +361,9 @@ private:
volatile int threads_mask;
pthread_mutex_t write_mutex;
pthread_mutex_t running_mutex;
pthread_mutex_t frnum_mutex;
static const int PROGRESS_INCREMENT = 50;
/** current thread the job being allotted to */
int currentThread;
@ -408,6 +412,9 @@ private:
/** frames caught */
int* framesCaught;
/** current frame number */
uint32_t* currentframenum;
/** call back function */
void (*freeFifoCallBack)(char*, void*);