included exitReceiver, using different threads to listen and write packets in receiver, edited circularfifo to use pointer references, and acquire returns frames caught

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@362 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2012-11-30 09:28:52 +00:00
parent d8af12456d
commit 6b935f3bd2
12 changed files with 335 additions and 101 deletions

View File

@ -8,7 +8,9 @@
#include "sls_detector_defs.h"
#include "receiver_defs.h"
#include "genericSocket.h"
#include "circularFifo.h"
#include <string.h>
#include <pthread.h>
#include <stdio.h>
@ -28,7 +30,7 @@ public:
/**
* Destructor
*/
virtual ~slsReceiverFunctionList(){};
virtual ~slsReceiverFunctionList(){ if(latestData) delete latestData;};
/**
* Returns status of receiver: idle, running or error
@ -132,6 +134,20 @@ public:
*/
int startListening();
/**
* Static function - Thread started which writes packets to file.
* Called by startReceiver()
* @param this_pointer pointer to this object
*/
static void* startWritingThread(void *this_pointer);
/**
* Thread started which writes packets to file.
* Called by startReceiver()
*
*/
int startWriting();
/**
* Returns the buffer-current frame read by receiver
*/
@ -185,20 +201,23 @@ private:
/** Frames currently in current file, starts new file when it reaches max */
int framesInFile;
/** if the listening thread is running*/
//static int listening_thread_running;
/** Previous Frame number from buffer */
int prevframenum;
/** thread listening to packets */
pthread_t listening_thread;
/** thread writing packets */
pthread_t writing_thread;
/** status of receiver */
runStatus status;
/** File Descriptor */
//static FILE *sfilefd;
/** Receiver buffer */
char buffer[BUFFER_SIZE];
char* buffer;
/** latest data */
char* latestData;
/** UDP Socket between Receiver and Detector */
genericSocket* udpSocket;
@ -206,6 +225,17 @@ private:
/** Server UDP Port*/
int server_port;
/** Element structure to put inside a fifo */
struct dataStruct {
char* buffer;
int rc;
};
//dataStruct* dataReadFrame;
/** circular fifo to read and write data*/
CircularFifo<dataStruct,FIFO_SIZE>* fifo;
public:
/** File Descriptor */
static FILE *sfilefd;