mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-27 16:50:02 +02:00
from private to protected
This commit is contained in:
parent
e0ee1fb386
commit
7986746194
@ -32,7 +32,7 @@ $(info )
|
||||
|
||||
.PHONY: all intdoc package eigerReceiver clean
|
||||
|
||||
all: lib receiver
|
||||
all: builddir lib receiver
|
||||
|
||||
intdoc: $(SRC_H) $(SRC_CLNT)
|
||||
doxygen doxy.config
|
||||
@ -76,6 +76,8 @@ clean: buildclean
|
||||
rm $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so
|
||||
rm $(PROGS)
|
||||
|
||||
builddir:
|
||||
if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi
|
||||
|
||||
buildclean:
|
||||
rm -rf $(OBJS)
|
||||
|
@ -319,7 +319,7 @@ class UDPBaseImplementation : private virtual slsReceiverDefs, public UDPInterfa
|
||||
*/
|
||||
int shutDownUDPSockets();
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
/*
|
||||
void not_implemented(string method_name){
|
||||
@ -466,6 +466,10 @@ private:
|
||||
void handleDataCompression(int ithread, char* wbuffer[], int &npackets, char* data, int xmax, int ymax, int &nf);
|
||||
|
||||
|
||||
|
||||
//// Could be done more fine-grained... TODO
|
||||
// private:
|
||||
protected:
|
||||
/** structure of an eiger image header*/
|
||||
typedef struct
|
||||
{
|
||||
@ -683,6 +687,9 @@ private:
|
||||
/** 10Gbe enable*/
|
||||
int tengigaEnable;
|
||||
|
||||
// TODO: not properly sure where to put these...
|
||||
/** structure of an eiger image header*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
UDPStandardImplementation();
|
||||
UDPStandardImplementation();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -466,308 +466,6 @@ private:
|
||||
void handleDataCompression(int ithread, char* wbuffer[], int &npackets, char* data, int xmax, int ymax, int &nf);
|
||||
|
||||
|
||||
/** structure of an eiger image header*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char header_before[20];
|
||||
unsigned char fnum[4];
|
||||
unsigned char header_after[24];
|
||||
} eiger_image_header;
|
||||
|
||||
|
||||
/** structure of an eiger image header*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char num1[4];
|
||||
unsigned char num2[4];
|
||||
} eiger_packet_header;
|
||||
|
||||
/** max number of listening threads */
|
||||
const static int MAX_NUM_LISTENING_THREADS = EIGER_MAX_PORTS;
|
||||
|
||||
/** max number of writer threads */
|
||||
const static int MAX_NUM_WRITER_THREADS = 15;
|
||||
|
||||
/** detector type */
|
||||
detectorType myDetectorType;
|
||||
|
||||
/** detector hostname */
|
||||
char detHostname[MAX_STR_LENGTH];
|
||||
|
||||
/** status of receiver */
|
||||
runStatus status;
|
||||
|
||||
/** UDP Socket between Receiver and Detector */
|
||||
genericSocket* udpSocket[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** Server UDP Port*/
|
||||
int server_port[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** ethernet interface or IP to listen to */
|
||||
char *eth;
|
||||
|
||||
/** max packets per file **/
|
||||
int maxPacketsPerFile;
|
||||
|
||||
/** File write enable */
|
||||
int enableFileWrite;
|
||||
|
||||
/** File over write enable */
|
||||
int overwrite;
|
||||
|
||||
/** Complete File name */
|
||||
char savefilename[MAX_STR_LENGTH];
|
||||
|
||||
/** File Name without frame index, file index and extension*/
|
||||
char fileName[MAX_STR_LENGTH];
|
||||
|
||||
/** File Path */
|
||||
char filePath[MAX_STR_LENGTH];
|
||||
|
||||
/** File Index */
|
||||
int fileIndex;
|
||||
|
||||
/** scan tag */
|
||||
int scanTag;
|
||||
|
||||
/** if frame index required in file name */
|
||||
int frameIndexNeeded;
|
||||
|
||||
/* Acquisition started */
|
||||
bool acqStarted;
|
||||
|
||||
/* Measurement started */
|
||||
bool measurementStarted;
|
||||
|
||||
/** Frame index at start of each real time acquisition (eg. for each scan) */
|
||||
uint32_t startFrameIndex;
|
||||
|
||||
/** Actual current frame index of each time acquisition (eg. for each scan) */
|
||||
uint32_t frameIndex;
|
||||
|
||||
/** Frames Caught for each real time acquisition (eg. for each scan) */
|
||||
int packetsCaught;
|
||||
|
||||
/** Total packets caught for an entire acquisition (including all scans) */
|
||||
int totalPacketsCaught;
|
||||
|
||||
/** Pckets currently in current file, starts new file when it reaches max */
|
||||
int packetsInFile;
|
||||
|
||||
/** Frame index at start of an entire acquisition (including all scans) */
|
||||
uint32_t startAcquisitionIndex;
|
||||
|
||||
/** Actual current frame index of an entire acquisition (including all scans) */
|
||||
uint32_t acquisitionIndex;
|
||||
|
||||
/** number of packets per frame*/
|
||||
int packetsPerFrame;
|
||||
|
||||
/** frame index mask */
|
||||
uint32_t frameIndexMask;
|
||||
|
||||
/** packet index mask */
|
||||
uint32_t packetIndexMask;
|
||||
|
||||
/** frame index offset */
|
||||
int frameIndexOffset;
|
||||
|
||||
/** acquisition period */
|
||||
int64_t acquisitionPeriod;
|
||||
|
||||
/** frame number */
|
||||
int32_t numberOfFrames;
|
||||
|
||||
/** dynamic range */
|
||||
int dynamicRange;
|
||||
|
||||
/** short frames */
|
||||
int shortFrame;
|
||||
|
||||
/** current frame number */
|
||||
uint32_t currframenum;
|
||||
|
||||
/** Previous Frame number from buffer */
|
||||
uint32_t prevframenum;
|
||||
|
||||
/** size of one frame */
|
||||
int frameSize;
|
||||
|
||||
/** buffer size. different from framesize as we wait for one packet instead of frame for eiger */
|
||||
int bufferSize;
|
||||
|
||||
/** oen buffer size */
|
||||
int onePacketSize;
|
||||
|
||||
/** latest data */
|
||||
char* latestData;
|
||||
|
||||
/** gui data ready */
|
||||
int guiDataReady;
|
||||
|
||||
/** points to the data to send to gui */
|
||||
char* guiData;
|
||||
|
||||
/** points to the filename to send to gui */
|
||||
char* guiFileName;
|
||||
|
||||
/** temporary number for eiger frame number as its not included in the packet */
|
||||
uint32_t guiFrameNumber;
|
||||
|
||||
/** send every nth frame to gui or only upon gui request*/
|
||||
int nFrameToGui;
|
||||
|
||||
/** fifo size */
|
||||
unsigned int fifosize;
|
||||
|
||||
/** number of jobs per thread for data compression */
|
||||
int numJobsPerThread;
|
||||
|
||||
/** datacompression - save only hits */
|
||||
bool dataCompression;
|
||||
|
||||
/** memory allocated for the buffer */
|
||||
char *mem0[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** circular fifo to store addresses of data read */
|
||||
CircularFifo<char>* fifo[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** circular fifo to store addresses of data already written and ready to be resued*/
|
||||
CircularFifo<char>* fifoFree[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** Receiver buffer */
|
||||
char *buffer[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** number of writer threads */
|
||||
int numListeningThreads;
|
||||
|
||||
/** number of writer threads */
|
||||
int numWriterThreads;
|
||||
|
||||
/** to know if listening and writer threads created properly */
|
||||
int thread_started;
|
||||
|
||||
/** current listening thread index*/
|
||||
int currentListeningThreadIndex;
|
||||
|
||||
/** current writer thread index*/
|
||||
int currentWriterThreadIndex;
|
||||
|
||||
/** thread listening to packets */
|
||||
pthread_t listening_thread[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** thread writing packets */
|
||||
pthread_t writing_thread[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
/** total frame count the listening thread has listened to */
|
||||
int totalListeningFrameCount[MAX_NUM_LISTENING_THREADS];
|
||||
|
||||
/** mask showing which listening threads are running */
|
||||
volatile uint32_t listeningthreads_mask;
|
||||
|
||||
/** mask showing which writer threads are running */
|
||||
volatile uint32_t writerthreads_mask;
|
||||
|
||||
/** mask showing which threads have created files*/
|
||||
volatile uint32_t createfile_mask;
|
||||
|
||||
/** OK if file created was successful */
|
||||
int ret_createfile;
|
||||
|
||||
/** variable used to self terminate threads waiting for semaphores */
|
||||
int killAllListeningThreads;
|
||||
|
||||
/** variable used to self terminate threads waiting for semaphores */
|
||||
int killAllWritingThreads;
|
||||
|
||||
/** 10Gbe enable*/
|
||||
int tengigaEnable;
|
||||
|
||||
|
||||
|
||||
|
||||
//semaphores
|
||||
/** semaphore to synchronize writer and guireader threads */
|
||||
sem_t smp;
|
||||
/** semaphore to synchronize listener threads */
|
||||
sem_t listensmp[MAX_NUM_LISTENING_THREADS];
|
||||
/** semaphore to synchronize writer threads */
|
||||
sem_t writersmp[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
|
||||
//mutex
|
||||
/** guiDataReady mutex */
|
||||
pthread_mutex_t dataReadyMutex;
|
||||
|
||||
/** mutex for status */
|
||||
pthread_mutex_t status_mutex;
|
||||
|
||||
/** mutex for progress variable currframenum */
|
||||
pthread_mutex_t progress_mutex;
|
||||
|
||||
/** mutex for writing data to file */
|
||||
pthread_mutex_t write_mutex;
|
||||
|
||||
/** File Descriptor */
|
||||
FILE *sfilefd;
|
||||
|
||||
//filter
|
||||
singlePhotonDetector<uint16_t> *singlePhotonDet[MAX_NUM_WRITER_THREADS];
|
||||
slsReceiverData<uint16_t> *receiverdata[MAX_NUM_WRITER_THREADS];
|
||||
moenchCommonMode *cmSub;
|
||||
bool commonModeSubtractionEnable;
|
||||
|
||||
#ifdef MYROOT1
|
||||
/** Tree where the hits are stored */
|
||||
TTree *myTree[MAX_NUM_WRITER_THREADS];
|
||||
|
||||
/** File where the tree is saved */
|
||||
TFile *myFile[MAX_NUM_WRITER_THREADS];
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
callback arguments are
|
||||
filepath
|
||||
filename
|
||||
fileindex
|
||||
data size
|
||||
|
||||
return value is
|
||||
0 callback takes care of open,close,write file
|
||||
1 callback writes file, we have to open, close it
|
||||
2 we open, close, write file, callback does not do anything
|
||||
|
||||
*/
|
||||
int (*startAcquisitionCallBack)(char*, char*,int, int, void*);
|
||||
void *pStartAcquisition;
|
||||
|
||||
/**
|
||||
args to acquisition finished callback
|
||||
total frames caught
|
||||
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(int, void*);
|
||||
void *pAcquisitionFinished;
|
||||
|
||||
|
||||
/**
|
||||
args to raw data ready callback are
|
||||
framenum
|
||||
datapointer
|
||||
datasize in bytes
|
||||
file descriptor
|
||||
guidatapointer (NULL, no data required)
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*);
|
||||
void *pRawDataReady;
|
||||
|
||||
/** The action which decides what the user and default responsibilites to save data are
|
||||
* 0 raw data ready callback takes care of open,close,write file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything */
|
||||
int cbAction;
|
||||
|
||||
|
||||
public:
|
||||
|
@ -94,11 +94,12 @@ void UDPBaseImplementation::resetTotalFramesCaught(){
|
||||
/*file parameters*/
|
||||
|
||||
char* UDPBaseImplementation::getFilePath() const{
|
||||
FILE_LOG(logWARNING) << "[WARNING] This is a base implementation, " << __func__ << " could have no effects.";
|
||||
//FILE_LOG(logWARNING) << "[WARNING] This is a base implementation, " << __func__ << " could have no effects.";
|
||||
return (char*)filePath;
|
||||
}
|
||||
|
||||
char* UDPBaseImplementation::setFilePath(const char c[]){
|
||||
inline char* UDPBaseImplementation::setFilePath(const char c[]){
|
||||
cout << "SET FILE PATH " << c << endl;
|
||||
if(strlen(c)){
|
||||
//check if filepath exists
|
||||
struct stat st;
|
||||
@ -109,6 +110,7 @@ char* UDPBaseImplementation::setFilePath(const char c[]){
|
||||
FILE_LOG(logWARNING) << "FilePath does not exist:" << filePath;
|
||||
}
|
||||
}
|
||||
cout << getFilePath() << " " << filePath << endl;
|
||||
return getFilePath();
|
||||
}
|
||||
|
||||
@ -117,7 +119,7 @@ char* UDPBaseImplementation::getFileName() const{
|
||||
return (char*)fileName;
|
||||
}
|
||||
|
||||
char* UDPBaseImplementation::setFileName(const char c[]){
|
||||
inline char* UDPBaseImplementation::setFileName(const char c[]){
|
||||
//cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
||||
|
||||
if(strlen(c))
|
||||
@ -132,17 +134,15 @@ int UDPBaseImplementation::getFileIndex(){
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setFileIndex(int i){
|
||||
cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
||||
/*
|
||||
//cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
||||
if(i>=0)
|
||||
fileIndex = i;
|
||||
*/
|
||||
return getFileIndex();
|
||||
}
|
||||
|
||||
|
||||
int UDPBaseImplementation::setFrameIndexNeeded(int i){
|
||||
cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
||||
//cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
||||
frameIndexNeeded = i;
|
||||
return frameIndexNeeded;
|
||||
}
|
||||
@ -871,8 +871,10 @@ int UDPBaseImplementation::setupWriter(){
|
||||
|
||||
|
||||
//acquisition start call back returns enable write
|
||||
if (startAcquisitionCallBack)
|
||||
if (startAcquisitionCallBack){
|
||||
cout << filePath << " - " << fileName << endl;
|
||||
cbAction=startAcquisitionCallBack(filePath,fileName,fileIndex,bufferSize,pStartAcquisition);
|
||||
}
|
||||
|
||||
if(cbAction < DO_EVERYTHING)
|
||||
cout << endl << "Note: Call back activated. Data saving must be taken care of by user in call back." << endl;
|
||||
@ -952,14 +954,21 @@ int UDPBaseImplementation::createCompressionFile(int ithr, int iframe){
|
||||
|
||||
|
||||
int UDPBaseImplementation::createNewFile(){
|
||||
int gt = getFrameIndex();
|
||||
if(gt==-1) gt=0;
|
||||
|
||||
cout << "[WARNING] This is a base implementation, " << __func__ << " not correctly implemented" << endl;
|
||||
|
||||
|
||||
/*
|
||||
int gt = getFrameIndex();
|
||||
if(gt==-1) gt=0;
|
||||
//create file name
|
||||
if(frameIndexNeeded==-1)
|
||||
sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||
else
|
||||
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,(packetsCaught/packetsPerFrame),fileIndex);
|
||||
|
||||
cout << filePath << " + " << fileName << endl;
|
||||
|
||||
//if filewrite and we are allowed to write
|
||||
if(enableFileWrite && cbAction > DO_NOTHING){
|
||||
//close
|
||||
@ -974,7 +983,7 @@ int UDPBaseImplementation::createNewFile(){
|
||||
return FAIL;
|
||||
}
|
||||
}else if (NULL == (sfilefd = fopen((const char *) (savefilename), "w"))){
|
||||
cout << "Error: Could not create file " << savefilename << endl;
|
||||
cout << "Error: Could not creat dsdasdserwe file " << savefilename << endl;
|
||||
return FAIL;
|
||||
}
|
||||
//setting buffer
|
||||
@ -1001,7 +1010,7 @@ int UDPBaseImplementation::createNewFile(){
|
||||
prevframenum = currframenum;
|
||||
packetsInFile = 0;
|
||||
}
|
||||
|
||||
*/
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -110,8 +110,11 @@ void UDPStandardImplementation::initializeMembers(){
|
||||
strcpy(detHostname,"");
|
||||
strcpy(guiFileName,"");
|
||||
strcpy(savefilename,"");
|
||||
strcpy(filePath,"");
|
||||
strcpy(fileName,"run");
|
||||
|
||||
setFileName("run");
|
||||
setFilePath("");
|
||||
//strcpy(filePath,"");
|
||||
//strcpy(fileName,"run");
|
||||
|
||||
|
||||
//status
|
||||
@ -122,16 +125,17 @@ void UDPStandardImplementation::initializeMembers(){
|
||||
}
|
||||
|
||||
|
||||
UDPStandardImplementation::UDPStandardImplementation():
|
||||
thread_started(0),
|
||||
eth(NULL),
|
||||
latestData(NULL),
|
||||
guiFileName(NULL),
|
||||
guiFrameNumber(0),
|
||||
tengigaEnable(0){
|
||||
UDPStandardImplementation::UDPStandardImplementation(){
|
||||
|
||||
cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa" << endl;
|
||||
|
||||
thread_started = 0;
|
||||
eth = NULL;
|
||||
latestData = NULL;
|
||||
guiFileName = NULL;
|
||||
guiFrameNumber = 0;
|
||||
tengigaEnable = 0;
|
||||
|
||||
for(int i=0;i<MAX_NUM_LISTENING_THREADS;i++){
|
||||
udpSocket[i] = NULL;
|
||||
server_port[i] = DEFAULT_UDP_PORTNO+i;
|
||||
@ -364,7 +368,6 @@ char* UDPStandardImplementation::getFilePath() const{
|
||||
return (char*)filePath;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
char* UDPStandardImplementation::setFilePath(const char c[]){
|
||||
if(strlen(c)){
|
||||
@ -1234,6 +1237,9 @@ int UDPStandardImplementation::createNewFile(){
|
||||
else
|
||||
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,(packetsCaught/packetsPerFrame),fileIndex);
|
||||
|
||||
|
||||
cout << filePath << " + " << fileName << endl;
|
||||
|
||||
//if filewrite and we are allowed to write
|
||||
if(enableFileWrite && cbAction > DO_NOTHING){
|
||||
//close
|
||||
|
Loading…
x
Reference in New Issue
Block a user