From c0ed0e231d9c7a617c985010f319e12d30a8a403 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Thu, 30 Jan 2014 16:40:28 +0000 Subject: [PATCH] make it work for multi threaded compression receiver for moench only git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@721 951219d9-93cf-4727-9268-0efd64621fa3 --- .../slsReceiver/slsReceiverFunctionList.h | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h index d8879c0cc..fc1def62c 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h @@ -210,6 +210,12 @@ public: */ int stopReceiver(); + /** + * Closes all files + * @param ithr thread index + */ + void closeFile(int ithr = -1); + private: /** @@ -249,9 +255,11 @@ private: /** * Creates new tree and file for compression + * @param ithr thread number + * @param iframe frame number *\returns OK for succces or FAIL for failure */ - int createCompressionFile(); + int createCompressionFile(int ithr, int iframe); /** * Creates new file @@ -439,9 +447,6 @@ private: /** to know if listening and writer threads created properly */ int thread_started; - /** mask showing which threads are running */ - volatile int32_t writerthreads_mask; - /** current writer thread index*/ int currentWriterThreadIndex; @@ -480,15 +485,6 @@ private: pthread_mutex_t write_mutex; -//filter - singlePhotonDetector *singlePhotonDet; - - moench02ModuleData *mdecoder; - - bool commonModeSubtractionEnable; - - int iFrame; - /** callback arguments are filepath @@ -531,27 +527,32 @@ private: * 2 we open, close, write file, callback does not do anything */ int cbAction; + //filter + singlePhotonDetector *singlePhotonDet[MAX_NUM_WRITER_THREADS]; + moench02ModuleData *mdecoder[MAX_NUM_WRITER_THREADS]; + + bool commonModeSubtractionEnable; public: #ifdef MYROOT1 /** Tree where the hits are stored */ - static TTree *myTree; + TTree *myTree[MAX_NUM_WRITER_THREADS]; /** File where the tree is saved */ - static TFile *myFile; + TFile *myFile[MAX_NUM_WRITER_THREADS]; #endif /** File Descriptor */ - static FILE *sfilefd; + FILE *sfilefd; - /** if the receiver threads are running*/ - static int receiver_threads_running; + /** mask showing which threads are running */ + volatile uint32_t writerthreads_mask; - /** 0 if receiver is idle, 1 otherwise */ - static int running; + /** 0 if listening thread is idle, 1 otherwise */ + int listening_thread_running; /** callback arguments are