This commit is contained in:
Dhanya Maliakal 2016-08-15 12:10:16 +02:00
parent 882202c2bc
commit b64af8dc8d
2 changed files with 40 additions and 27 deletions

View File

@ -477,6 +477,15 @@ private:
* Class Members ********************************************************* * Class Members *********************************************************
*************************************************************************/ *************************************************************************/
/** Maximum Number of Writer Threads */
#ifdef DCOMPRESS
/**** most likely not used ***/
const static int MAX_NUMBER_OF_WRITER_THREADS = 15;
#else
const static int MAX_NUMBER_OF_WRITER_THREADS = 2;
#endif
//**detector parameters*** //**detector parameters***
/** Size of 1 Frame including headers */ /** Size of 1 Frame including headers */
int frameSize; int frameSize;
@ -513,7 +522,7 @@ private:
#endif #endif
/** Complete File name */ /** Complete File name */
char completeFileName[MAX_STR_LENGTH]; char completeFileName[MAX_NUMBER_OF_WRITER_THREADS][MAX_STR_LENGTH];
/** Maximum Packets Per File **/ /** Maximum Packets Per File **/
int maxPacketsPerFile; int maxPacketsPerFile;
@ -521,23 +530,24 @@ private:
/** If file created successfully for all Writer Threads */ /** If file created successfully for all Writer Threads */
bool fileCreateSuccess; bool fileCreateSuccess;
char fileHeader[1000]; char fileHeader[MAX_NUMBER_OF_WRITER_THREADS][MAX_STR_LENGTH];
//***acquisition indices/count parameters*** //***acquisition indices/count parameters***
/** Frame Number of First Frame of an entire Acquisition (including all scans) */ /** Frame Number of First Frame of an entire Acquisition (including all scans) */
uint64_t startAcquisitionIndex; uint64_t startAcquisitionIndex[MAX_NUMBER_OF_LISTENING_THREADS];
/** Frame index at start of each real time acquisition (eg. for each scan) */ /** Frame index at start of each real time acquisition (eg. for each scan) */
uint64_t startFrameIndex; uint64_t startFrameIndex[MAX_NUMBER_OF_LISTENING_THREADS];
/** Actual current frame index of each time acquisition (eg. for each scan) */ /** Actual current frame index of each time acquisition (eg. for each scan) */
uint64_t frameIndex; uint64_t frameIndex[MAX_NUMBER_OF_WRITER_THREADS];
/** Current Frame Number */ /** Current Frame Number */
uint64_t currentFrameNumber; uint64_t currentFrameNumber[MAX_NUMBER_OF_WRITER_THREADS];
/** Previous Frame number from buffer to calculate loss */ /** Previous Frame number from buffer to calculate loss */
int64_t previousFrameNumber; int64_t previousFrameNumber;
@ -545,26 +555,27 @@ private:
/** Last Frame Index Listened To */ /** Last Frame Index Listened To */
int32_t lastFrameIndex; int32_t lastFrameIndex;
/* Acquisition started */ /* Acquisition started */
bool acqStarted; bool acqStarted[MAX_NUMBER_OF_LISTENING_THREADS];
/* Measurement started */ /* Measurement started */
bool measurementStarted; bool measurementStarted[MAX_NUMBER_OF_LISTENING_THREADS];
/** Total Frame Count listened to by listening threads */ /** Total Frame Count listened to by listening threads */
int totalListeningFrameCount[MAX_NUMBER_OF_LISTENING_THREADS]; int totalListeningFrameCount[MAX_NUMBER_OF_LISTENING_THREADS];
/** Pckets currently in current file, starts new file when it reaches max */ /** Pckets currently in current file, starts new file when it reaches max */
uint32_t packetsInFile; uint32_t packetsInFile[MAX_NUMBER_OF_WRITER_THREADS];
/** Number of Missing Packets per buffer*/ /** Number of Missing Packets per buffer*/
uint32_t numMissingPackets; uint32_t numMissingPackets[MAX_NUMBER_OF_WRITER_THREADS];
/** Total Number of Missing Packets in acquisition*/ /** Total Number of Missing Packets in acquisition*/
uint32_t numTotMissingPackets; uint32_t numTotMissingPackets[MAX_NUMBER_OF_WRITER_THREADS];
/** Number of Missing Packets in file */ /** Number of Missing Packets in file */
uint32_t numTotMissingPacketsInFile; uint32_t numTotMissingPacketsInFile[MAX_NUMBER_OF_WRITER_THREADS];
@ -587,7 +598,7 @@ private:
genericSocket* udpSocket[MAX_NUMBER_OF_LISTENING_THREADS]; genericSocket* udpSocket[MAX_NUMBER_OF_LISTENING_THREADS];
/** File Descriptor */ /** File Descriptor */
FILE *sfilefd; FILE *sfilefd[MAX_NUMBER_OF_WRITER_THREADS];
/** Number of Jobs Per Buffer */ /** Number of Jobs Per Buffer */
int numberofJobsPerBuffer; int numberofJobsPerBuffer;
@ -605,22 +616,22 @@ private:
//***receiver to GUI parameters*** //***receiver to GUI parameters***
/** Current Frame copied for GUI */ /** Current Frame copied for GUI */
char* latestData; char* latestData[MAX_NUMBER_OF_WRITER_THREADS];
/** If Data to be sent to GUI is ready */ /** If Data to be sent to GUI is ready */
bool guiDataReady; bool guiDataReady[MAX_NUMBER_OF_WRITER_THREADS];
/** Pointer to data to be sent to GUI */ /** Pointer to data to be sent to GUI */
char* guiData; char* guiData[MAX_NUMBER_OF_WRITER_THREADS];
/** Pointer to file name to be sent to GUI */ /** Pointer to file name to be sent to GUI */
char guiFileName[MAX_STR_LENGTH]; char guiFileName[MAX_STR_LENGTH];
/** Semaphore to synchronize Writer and GuiReader threads*/ /** Semaphore to synchronize Writer and GuiReader threads*/
sem_t writerGuiSemaphore; sem_t writerGuiSemaphore[MAX_NUMBER_OF_WRITER_THREADS];
/** counter for nth frame to gui */ /** counter for nth frame to gui */
int frametoGuiCounter; int frametoGuiCounter[MAX_NUMBER_OF_WRITER_THREADS];
@ -653,9 +664,6 @@ private:
//***writer thread parameters*** //***writer thread parameters***
/** Maximum Number of Writer Threads */
const static int MAX_NUMBER_OF_WRITER_THREADS = 15;
/** Number of Writer Threads */ /** Number of Writer Threads */
int numberofWriterThreads; int numberofWriterThreads;

View File

@ -56,7 +56,8 @@ UDPStandardImplementation::UDPStandardImplementation(){
UDPStandardImplementation::~UDPStandardImplementation(){ UDPStandardImplementation::~UDPStandardImplementation(){
FILE_LOG(logDEBUG) << __AT__ << " called"; FILE_LOG(logDEBUG) << __AT__ << " called";
closeFile(); for(int i=0;i<MAX_NUMBER_OF_WRITER_THREADS; i++)
closeFile(i);
deleteMembers(); deleteMembers();
} }
@ -76,13 +77,15 @@ void UDPStandardImplementation::deleteMembers(){
closeFile(); closeFile();
//filter //filter
deleteFilter(); deleteFilter();
for(int i=0; i<numberofListeningThreads; i++){ for(int i=0; i<MAX_NUMBER_OF_LISTENING_THREADS; i++){
if(mem0[i]) {free(mem0[i]); mem0[i] = NULL;} if(mem0[i]) {free(mem0[i]); mem0[i] = NULL;}
if(fifo[i]) {delete fifo[i]; fifo[i] = NULL;} if(fifo[i]) {delete fifo[i]; fifo[i] = NULL;}
if(fifoFree[i]) {delete fifoFree[i]; fifoFree[i] = NULL;} if(fifoFree[i]) {delete fifoFree[i]; fifoFree[i] = NULL;}
} }
if(latestData) {delete[] latestData; latestData = NULL;} for(int i=0; i<MAX_NUMBER_OF_WRITER_THREADS; i++){
guiData = NULL; if(latestData[i]) {delete[] latestData; latestData = NULL;}
guiData[i] = NULL;
}
//kill threads //kill threads
if(threadStarted){ if(threadStarted){
createListeningThreads(true); createListeningThreads(true);
@ -136,10 +139,12 @@ void UDPStandardImplementation::initializeMembers(){
myFile[i] = (NULL); myFile[i] = (NULL);
} }
#endif #endif
strcpy(completeFileName,""); for(int i=0; i<MAX_NUMBER_OF_WRITER_THREADS; i++){
strcpy(completeFileName[i],"");
strcpy(fileHeader[i],"");
}
maxPacketsPerFile = 0; maxPacketsPerFile = 0;
fileCreateSuccess = false; fileCreateSuccess = false;
strcpy(fileHeader,"");
//***acquisition indices parameters*** //***acquisition indices parameters***
startAcquisitionIndex = 0; startAcquisitionIndex = 0;