mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-05 20:30:03 +02:00
updated rxr to use 10 times less memory for moench and plugged possible memory leaks
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@634 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
adcf1e2e8c
commit
b5fb6be6df
@ -2,10 +2,10 @@
|
||||
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/eigerDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3"
|
||||
//#define SVNREV 0x631
|
||||
//#define SVNREV 0x632
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "l_maliakal_d"
|
||||
#define SVNREV 0x631
|
||||
#define SVNREV 0x632
|
||||
#define SVNDATE 0x20130711
|
||||
//
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/gotthardDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3"
|
||||
//#define SVNREV 0x628
|
||||
//#define SVNREV 0x632
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "l_maliakal_d"
|
||||
#define SVNREV 0x628
|
||||
#define SVNDATE 0x20130625
|
||||
#define SVNREV 0x632
|
||||
#define SVNDATE 0x20130711
|
||||
//
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/moenchDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3"
|
||||
//#define SVNREV 0x629
|
||||
//#define SVNREV 0x632
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "l_maliakal_d"
|
||||
#define SVNREV 0x629
|
||||
#define SVNDATE 0x20130710
|
||||
#define SVNREV 0x632
|
||||
#define SVNDATE 0x20130711
|
||||
//
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/mythenDetectorServer"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3"
|
||||
//#define SVNREV 0x628
|
||||
//#define SVNREV 0x632
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "l_maliakal_d"
|
||||
#define SVNREV 0x628
|
||||
#define SVNDATE 0x20130625
|
||||
#define SVNREV 0x632
|
||||
#define SVNDATE 0x20130711
|
||||
//
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define SVNURLLIB "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUIDLIB "951219d9-93cf-4727-9268-0efd64621fa3"
|
||||
//#define SVNREV 0x631
|
||||
//#define SVNREV 0x633
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTHLIB "l_maliakal_d"
|
||||
#define SVNREVLIB 0x631
|
||||
#define SVNREVLIB 0x633
|
||||
#define SVNDATELIB 0x20130711
|
||||
//
|
||||
|
@ -17,14 +17,19 @@
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
/** Circular Fifo (a.k.a. Circular Buffer)
|
||||
* Thread safe for one reader, and one writer */
|
||||
template<typename Element, unsigned int Size>
|
||||
template<typename Element>
|
||||
class CircularFifo {
|
||||
public:
|
||||
enum {Capacity = Size+1};
|
||||
|
||||
CircularFifo() : tail(0), head(0){}
|
||||
CircularFifo(unsigned int Size) : tail(0), head(0){
|
||||
Capacity = Size + 1;
|
||||
array.resize(Capacity);
|
||||
}
|
||||
virtual ~CircularFifo() {}
|
||||
|
||||
bool push(Element*& item_);
|
||||
@ -35,8 +40,9 @@ public:
|
||||
|
||||
private:
|
||||
volatile unsigned int tail; // input index
|
||||
Element* array[Capacity];
|
||||
vector <Element*> array;
|
||||
volatile unsigned int head; // output index
|
||||
unsigned int Capacity;
|
||||
|
||||
unsigned int increment(unsigned int idx_) const;
|
||||
};
|
||||
@ -50,8 +56,8 @@ private:
|
||||
*
|
||||
* \param item_ copy by reference the input item
|
||||
* \return whether operation was successful or not */
|
||||
template<typename Element, unsigned int Size>
|
||||
bool CircularFifo<Element, Size>::push(Element*& item_)
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::push(Element*& item_)
|
||||
{
|
||||
int nextTail = increment(tail);
|
||||
if(nextTail != head)
|
||||
@ -71,8 +77,8 @@ bool CircularFifo<Element, Size>::push(Element*& item_)
|
||||
*
|
||||
* \param item_ return by reference the wanted item
|
||||
* \return whether operation was successful or not */
|
||||
template<typename Element, unsigned int Size>
|
||||
bool CircularFifo<Element, Size>::pop(Element*& item_)
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::pop(Element*& item_)
|
||||
{
|
||||
if(head == tail)
|
||||
return false; // empty queue
|
||||
@ -87,8 +93,8 @@ bool CircularFifo<Element, Size>::pop(Element*& item_)
|
||||
* as the Procuder adds more items.
|
||||
*
|
||||
* \return true if circular buffer is empty */
|
||||
template<typename Element, unsigned int Size>
|
||||
bool CircularFifo<Element, Size>::isEmpty() const
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::isEmpty() const
|
||||
{
|
||||
return (head == tail);
|
||||
}
|
||||
@ -98,8 +104,8 @@ bool CircularFifo<Element, Size>::isEmpty() const
|
||||
* as the Consumer catches up.
|
||||
*
|
||||
* \return true if circular buffer is full. */
|
||||
template<typename Element, unsigned int Size>
|
||||
bool CircularFifo<Element, Size>::isFull() const
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::isFull() const
|
||||
{
|
||||
int tailCheck = (tail+1) % Capacity;
|
||||
return (tailCheck == head);
|
||||
@ -110,8 +116,8 @@ bool CircularFifo<Element, Size>::isFull() const
|
||||
*
|
||||
* \param idx_ the index to the incremented/wrapped
|
||||
* \return new value for the index */
|
||||
template<typename Element, unsigned int Size>
|
||||
unsigned int CircularFifo<Element, Size>::increment(unsigned int idx_) const
|
||||
template<typename Element>
|
||||
unsigned int CircularFifo<Element>::increment(unsigned int idx_) const
|
||||
{
|
||||
// increment or wrap
|
||||
// =================
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
//all max frames defined in sls_detector_defs.h. 20000 gotthard, 100000 for short gotthard, 1000 for moench
|
||||
|
||||
#define FIFO_SIZE 25000
|
||||
|
||||
|
||||
#define GOTTHARD_FIFO_SIZE 25000
|
||||
#define GOTTHARD_ALIGNED_FRAME_SIZE 4096
|
||||
#define GOTTHARD_PACKETS_PER_FRAME 2
|
||||
#define GOTTHARD_BUFFER_SIZE (1286*GOTTHARD_PACKETS_PER_FRAME)
|
||||
@ -32,7 +30,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#define MOENCH_FIFO_SIZE 2500
|
||||
#define MOENCH_ALIGNED_FRAME_SIZE 65536
|
||||
#define MOENCH_PACKETS_PER_FRAME 40
|
||||
#define MOENCH_BUFFER_SIZE (1286*MOENCH_PACKETS_PER_FRAME)
|
||||
|
@ -44,6 +44,8 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit
|
||||
udpSocket(NULL),
|
||||
server_port(DEFAULT_UDP_PORTNO),
|
||||
fifo(NULL),
|
||||
fifofree(NULL),
|
||||
fifosize(GOTTHARD_FIFO_SIZE),
|
||||
shortFrame(-1),
|
||||
bufferSize(GOTTHARD_BUFFER_SIZE),
|
||||
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
||||
@ -63,7 +65,11 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit
|
||||
frameIndexOffset(GOTTHARD_FRAME_INDEX_OFFSET)
|
||||
|
||||
{
|
||||
int aligned_frame_size = GOTTHARD_ALIGNED_FRAME_SIZE;
|
||||
|
||||
if(myDetectorType == MOENCH){
|
||||
aligned_frame_size = MOENCH_ALIGNED_FRAME_SIZE;
|
||||
fifosize = MOENCH_FIFO_SIZE;
|
||||
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||
bufferSize = MOENCH_BUFFER_SIZE;
|
||||
packetsPerFrame = MOENCH_PACKETS_PER_FRAME;
|
||||
@ -71,7 +77,6 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit
|
||||
frameIndexMask = MOENCH_FRAME_INDEX_MASK;
|
||||
frameIndexOffset = MOENCH_FRAME_INDEX_OFFSET;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
strcpy(savefilename,"");
|
||||
@ -83,20 +88,17 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit
|
||||
strcpy(eth,"");
|
||||
|
||||
latestData = new char[bufferSize];
|
||||
fifofree = new CircularFifo<char,FIFO_SIZE>();
|
||||
fifo = new CircularFifo<char,FIFO_SIZE>();
|
||||
|
||||
int aligned_frame_size = GOTTHARD_ALIGNED_FRAME_SIZE;
|
||||
if (det == MOENCH)
|
||||
aligned_frame_size = MOENCH_ALIGNED_FRAME_SIZE;
|
||||
fifofree = new CircularFifo<char>(fifosize);
|
||||
fifo = new CircularFifo<char>(fifosize);
|
||||
|
||||
|
||||
mem0=(char*)malloc(aligned_frame_size*FIFO_SIZE);
|
||||
|
||||
mem0=(char*)malloc(aligned_frame_size*fifosize);
|
||||
if (mem0==NULL) {
|
||||
cout<<"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY!!!!!!!+++++++++++++++++++++" << endl;
|
||||
}
|
||||
buffer=mem0;
|
||||
while (buffer<(mem0+aligned_frame_size*(FIFO_SIZE-1))) {
|
||||
while (buffer<(mem0+aligned_frame_size*(fifosize-1))) {
|
||||
fifofree->push(buffer);
|
||||
buffer+=aligned_frame_size;
|
||||
}
|
||||
@ -284,7 +286,7 @@ int slsReceiverFunctionList::stopReceiver(){
|
||||
#endif
|
||||
//stop listening thread
|
||||
listening_thread_running=0;
|
||||
udpSocket->ShutDownSocket();
|
||||
if(udpSocket) udpSocket->ShutDownSocket();
|
||||
pthread_join(listening_thread,NULL);
|
||||
status = IDLE;
|
||||
|
||||
@ -357,6 +359,7 @@ int slsReceiverFunctionList::startListening(){
|
||||
if (!fifofree->isEmpty()) {
|
||||
fifofree->pop(buffer);
|
||||
|
||||
|
||||
//receiver 2 half frames / 1 short frame / 40 moench frames
|
||||
rc = udpSocket->ReceiveDataOnly(buffer,bufferSize);
|
||||
if( rc < 0)
|
||||
@ -440,7 +443,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
framesInFile=0;
|
||||
framesCaught=0;
|
||||
frameIndex=0;
|
||||
if(sfilefd) sfilefd=0;
|
||||
if(sfilefd) sfilefd=NULL;
|
||||
strcpy(savefilename,"");
|
||||
|
||||
//reset this before each acq or you send old data
|
||||
@ -478,8 +481,10 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
if(enableFileWrite && cbAction > DO_NOTHING){
|
||||
|
||||
if(sfilefd)
|
||||
if(sfilefd){
|
||||
fclose(sfilefd);
|
||||
sfilefd = NULL;
|
||||
}
|
||||
|
||||
if (NULL == (sfilefd = fopen((const char *) (savefilename), "w"))){
|
||||
cout << "Error: Could not create file " << savefilename << endl;
|
||||
@ -594,11 +599,13 @@ int slsReceiverFunctionList::startWriting(){
|
||||
cout << "Total Frames Caught:"<< totalFramesCaught << endl;
|
||||
|
||||
|
||||
if(sfilefd)
|
||||
fclose(sfilefd);
|
||||
if(sfilefd){
|
||||
#ifdef VERBOSE
|
||||
cout << "sfield:" << (int)sfilefd << endl;
|
||||
#endif
|
||||
fclose(sfilefd);
|
||||
sfilefd = NULL;
|
||||
}
|
||||
|
||||
//acquistion over call back
|
||||
if (acquisitionFinishedCallBack)
|
||||
|
@ -291,11 +291,13 @@ private:
|
||||
};
|
||||
|
||||
/** circular fifo to read and write data*/
|
||||
//CircularFifo<dataStruct,FIFO_SIZE>* fifo;
|
||||
CircularFifo<char,FIFO_SIZE>* fifo;
|
||||
CircularFifo<char>* fifo;
|
||||
|
||||
/** circular fifo to read and write data*/
|
||||
CircularFifo<char,FIFO_SIZE>* fifofree;
|
||||
CircularFifo<char>* fifofree;
|
||||
|
||||
/** fifo size */
|
||||
unsigned int fifosize;
|
||||
|
||||
/** short frames */
|
||||
int shortFrame;
|
||||
|
@ -2,10 +2,10 @@
|
||||
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/slsReceiver"
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3"
|
||||
//#define SVNREV 0x629
|
||||
//#define SVNREV 0x632
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH "l_maliakal_d"
|
||||
#define SVNREV 0x629
|
||||
#define SVNDATE 0x20130710
|
||||
#define SVNREV 0x632
|
||||
#define SVNDATE 0x20130711
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user