got rid of egier_reciver ifdef and reorganized the slreceiverfunctionlist

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@792 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2014-03-18 15:51:58 +00:00
parent f25e016f64
commit 1191fe5674
6 changed files with 329 additions and 266 deletions

View File

@ -12,7 +12,7 @@ INCLUDES?= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSls
CC=g++
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsReceiver/slsReceiverFunctionList.cpp slsReceiver/slsReceiver_funcs.cpp slsReceiver/slsReceiverUsers.cpp
SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsReceiver/slsReceiverFunctionList.cpp slsReceiver/slsReceiver_funcs.cpp slsReceiver/slsReceiverUsers.cpp slsReceiver/eigerReceiver.cpp
OBJS = $(SRC_CLNT:.cpp=.o)

View File

@ -1,5 +1,5 @@
CC = g++
CFLAGS += -DSLS_RECEIVER_FUNCTION_LIST -O3 #-DEIGER_RECEIVER
CFLAGS += -DSLS_RECEIVER_FUNCTION_LIST -O3
CPPFLAGS = ${CFLAGS} # for MAC
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++

View File

@ -1,8 +1,3 @@
//#ifndef EIGER_RECEIVER
//#define EIGER_RECEIVER
//#endif
#ifdef EIGER_RECEIVER
#ifndef EIGERRECEIVER_H
#define EIGERRECEIVER_H
/***********************************************
@ -199,5 +194,3 @@ private:
};
#endif /* #ifndef EIGERRECEIVER_H */
#endif /* #ifdef EIGER_RECEIVER */

View File

@ -30,9 +30,7 @@ using namespace std;
slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
#ifdef EIGER_RECEIVER_H
receiver(NULL),
#endif
myDetectorType(det),
status(IDLE),
udpSocket(NULL),
@ -90,6 +88,8 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
pRawDataReady(NULL){
maxPacketsPerFile = MAX_FRAMES_PER_FILE * packetsPerFrame;
//moench variables
if(myDetectorType == MOENCH){
fifosize = MOENCH_FIFO_SIZE;
@ -100,10 +100,9 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
frameIndexOffset = MOENCH_FRAME_INDEX_OFFSET;
packetIndexMask = MOENCH_PACKET_INDEX_MASK;
}
else if(myDetectorType == EIGER){
#ifdef EIGER_RECEIVER_H
receiver = new EigerReceiver::create();
#endif
receiver = EigerReceiver::create();
}
//variable initialization
@ -193,12 +192,21 @@ slsReceiverFunctionList::~slsReceiverFunctionList(){
void slsReceiverFunctionList::setEthernetInterface(char* c){
strcpy(eth,c);
}
/*Frame indices and numbers caught*/
bool slsReceiverFunctionList::getAcquistionStarted(){return acqStarted;};
bool slsReceiverFunctionList::getMeasurementStarted(){return measurementStarted;};
int slsReceiverFunctionList::getFramesCaught(){return (packetsCaught/packetsPerFrame);}
int slsReceiverFunctionList::getTotalFramesCaught(){return (totalPacketsCaught/packetsPerFrame);}
uint32_t slsReceiverFunctionList::getStartFrameIndex(){return startFrameIndex;}
uint32_t slsReceiverFunctionList::getFrameIndex(){
if(!packetsCaught)
frameIndex=0;
@ -207,8 +215,6 @@ uint32_t slsReceiverFunctionList::getFrameIndex(){
return frameIndex;
}
uint32_t slsReceiverFunctionList::getAcquisitionIndex(){
if(!totalPacketsCaught)
acquisitionIndex=0;
@ -218,8 +224,134 @@ uint32_t slsReceiverFunctionList::getAcquisitionIndex(){
}
void slsReceiverFunctionList::resetTotalFramesCaught(){
acqStarted = false;
startAcquisitionIndex = 0;
totalPacketsCaught = 0;
}
/*file parameters*/
char* slsReceiverFunctionList::getFilePath(){
return filePath;
}
char* slsReceiverFunctionList::setFilePath(char c[]){
if(strlen(c)){
//check if filepath exists
struct stat st;
if(stat(c,&st) == 0){
if(myDetectorType == EIGER)
receiver->setFileName(c);
else
strcpy(filePath,c);
}else{
strcpy(filePath,"");
cout<<"FilePath does not exist:"<<filePath<<endl;
}
}
if(myDetectorType == EIGER)
return receiver->getFilePath();
else
return getFilePath();
}
char* slsReceiverFunctionList::getFileName(){
return fileName;
}
char* slsReceiverFunctionList::setFileName(char c[]){
if(strlen(c)){
if(myDetectorType == EIGER)
receiver->setFileName(c);
else
strcpy(fileName,c);
}
if(myDetectorType == EIGER)
return receiver->getFileName();
else
return getFileName();
}
int slsReceiverFunctionList::getFileIndex(){
return fileIndex;
}
int slsReceiverFunctionList::setFileIndex(int i){
if(i>=0)
fileIndex = i;
return getFileIndex();
}
int slsReceiverFunctionList::setFrameIndexNeeded(int i){
frameIndexNeeded = i;
return frameIndexNeeded;
}
int slsReceiverFunctionList::setEnableFileWrite(int i){
if(i!=-1){
if(myDetectorType == EIGER)
receiver->setEnableFileWrite(i);
else
enableFileWrite=i;
}
if(myDetectorType == EIGER)
return receiver->getEnableFileWrite();
else
return enableFileWrite;
}
/*other parameters*/
slsDetectorDefs::runStatus slsReceiverFunctionList::getStatus(){
return status;
}
char* slsReceiverFunctionList::setDetectorHostname(char c[]){
if(strlen(c)){
char *c0 = receiver->getDetectorHostname();
if(c0== NULL)
receiver->initialize(c);
delete[] c0;
}
return receiver->getDetectorHostname();
}
void slsReceiverFunctionList::setEthernetInterface(char* c){
strcpy(eth,c);
}
void slsReceiverFunctionList::setUDPPortNo(int p){
server_port = p;
}
#ifdef EIGER_RECEIVER_H
int32_t slsReceiverFunctionList::setNumberOfFrames(int32_t fnum){
if(fnum >= 0)
@ -240,92 +372,6 @@ int32_t slsReceiverFunctionList::setDynamicRange(int32_t dr){
}
char* slsReceiverFunctionList::setDetectorHostname(char c[]){
if((strlen(c))&& (receiver->getDetectorHostname() == NULL))
receiver->initialize(c);
}
return receiver->getDetectorHostname();
}
#endif
char* slsReceiverFunctionList::setFileName(char c[]){
if(strlen(c)){
#ifdef EIGER_RECEIVER_H
receiver->setFileName(c);
#else
strcpy(fileName,c);
#endif
}
#ifdef EIGER_RECEIVER_H
return receiver->getFileName();
#else
return getFileName();
#endif
}
char* slsReceiverFunctionList::setFilePath(char c[]){
if(strlen(c)){
//check if filepath exists
struct stat st;
if(stat(c,&st) == 0){
#ifdef EIGER_RECEIVER_H
receiver->setFileName(c);
#else
strcpy(filePath,c);
#endif
}else{
strcpy(filePath,"");
cout<<"FilePath does not exist:"<<filePath<<endl;
}
}
#ifdef EIGER_RECEIVER_H
return receiver->getFilePath();
#else
return getFilePath();
#endif
}
int slsReceiverFunctionList::setFileIndex(int i){
if(i>=0)
fileIndex = i;
return getFileIndex();
}
int slsReceiverFunctionList::setEnableFileWrite(int i){
if(i!=-1){
#ifdef EIGER_RECEIVER_H
receiver->setEnableFileWrite(i);
#else
enableFileWrite=i;
#endif
}
#ifdef EIGER_RECEIVER_H
return receiver->getEnableFileWrite();
#else
return enableFileWrite;
#endif
}
void slsReceiverFunctionList::resetTotalFramesCaught(){
acqStarted = false;
startAcquisitionIndex = 0;
totalPacketsCaught = 0;
}
int slsReceiverFunctionList::setShortFrame(int i){
shortFrame=i;
@ -345,7 +391,6 @@ int slsReceiverFunctionList::setShortFrame(int i){
frameIndexOffset = GOTTHARD_FRAME_INDEX_OFFSET;
}
onePacketSize = bufferSize/packetsPerFrame;
deleteFilter();
@ -356,10 +401,6 @@ int slsReceiverFunctionList::setShortFrame(int i){
}
int slsReceiverFunctionList::setNFrameToGui(int i){
if(i>=0){
nFrameToGui = i;
@ -370,7 +411,6 @@ int slsReceiverFunctionList::setNFrameToGui(int i){
int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){
if(index >= 0){
if(index != acquisitionPeriod){
@ -382,6 +422,7 @@ int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){
}
bool slsReceiverFunctionList::getDataCompression(){return dataCompression;}
int slsReceiverFunctionList::enableDataCompression(bool enable){
cout << "Data compression ";
@ -420,6 +461,17 @@ int slsReceiverFunctionList::enableDataCompression(bool enable){
/*other functions*/
void slsReceiverFunctionList::deleteFilter(){
int i;
cmSub=NULL;
@ -437,7 +489,6 @@ void slsReceiverFunctionList::deleteFilter(){
}
void slsReceiverFunctionList::setupFilter(){
double hc = 0;
double sigma = 5;
@ -472,63 +523,6 @@ void slsReceiverFunctionList::setupFilter(){
}
void slsReceiverFunctionList::readFrame(char* c,char** raw){
//point to gui data
if (guiData == NULL)
guiData = latestData;
//copy data and filename
strcpy(c,guiFileName);
//could not get gui data
if(!guiDataReady){
*raw = NULL;
}
//data ready, set guidata to receive new data
else{
*raw = guiData;
guiData = NULL;
pthread_mutex_lock(&dataReadyMutex);
guiDataReady = 0;
pthread_mutex_unlock(&dataReadyMutex);
if((nFrameToGui) && (writerthreads_mask)){
//release after getting data
sem_post(&smp);
}
}
}
void slsReceiverFunctionList::copyFrameToGui(char* startbuf){
//random read when gui not ready
if((!nFrameToGui) && (!guiData)){
pthread_mutex_lock(&dataReadyMutex);
guiDataReady=0;
pthread_mutex_unlock(&dataReadyMutex);
}
//random read or nth frame read, gui needs data now
else{
//nth frame read, block current process if the guireader hasnt read it yet
if(nFrameToGui)
sem_wait(&smp);
pthread_mutex_lock(&dataReadyMutex);
guiDataReady=0;
//send the first one
memcpy(latestData,startbuf,bufferSize);
strcpy(guiFileName,savefilename);
guiDataReady=1;
pthread_mutex_unlock(&dataReadyMutex);
}
}
void slsReceiverFunctionList::setupFifoStructure(){
@ -611,6 +605,69 @@ void slsReceiverFunctionList::setupFifoStructure(){
/** acquisition functions */
void slsReceiverFunctionList::readFrame(char* c,char** raw){
//point to gui data
if (guiData == NULL)
guiData = latestData;
//copy data and filename
strcpy(c,guiFileName);
//could not get gui data
if(!guiDataReady){
*raw = NULL;
}
//data ready, set guidata to receive new data
else{
*raw = guiData;
guiData = NULL;
pthread_mutex_lock(&dataReadyMutex);
guiDataReady = 0;
pthread_mutex_unlock(&dataReadyMutex);
if((nFrameToGui) && (writerthreads_mask)){
//release after getting data
sem_post(&smp);
}
}
}
void slsReceiverFunctionList::copyFrameToGui(char* startbuf){
//random read when gui not ready
if((!nFrameToGui) && (!guiData)){
pthread_mutex_lock(&dataReadyMutex);
guiDataReady=0;
pthread_mutex_unlock(&dataReadyMutex);
}
//random read or nth frame read, gui needs data now
else{
//nth frame read, block current process if the guireader hasnt read it yet
if(nFrameToGui)
sem_wait(&smp);
pthread_mutex_lock(&dataReadyMutex);
guiDataReady=0;
//send the first one
memcpy(latestData,startbuf,bufferSize);
strcpy(guiFileName,savefilename);
guiDataReady=1;
pthread_mutex_unlock(&dataReadyMutex);
}
}
int slsReceiverFunctionList::createUDPSocket(){
if(udpSocket)
udpSocket->ShutDownSocket();

View File

@ -12,11 +12,10 @@
#include "receiver_defs.h"
#include "genericSocket.h"
#include "circularFifo.h"
#include "singlePhotonDetector.h"
#include "slsReceiverData.h"
#include "moenchCommonMode.h"
#include "eigerReceiver.h"
#ifdef MYROOT1
#include <TTree.h>
@ -47,92 +46,70 @@ public:
*/
virtual ~slsReceiverFunctionList();
//Frame indices and numbers caught
/**
* Set UDP Port Number
* Returns current Frame Index Caught for an entire acquisition (including all scans)
*/
void setUDPPortNo(int p){server_port = p;};
uint32_t getAcquisitionIndex();
/**
* Set Ethernet Interface or IP to listen to
* Returns if acquisition started
*/
void setEthernetInterface(char* c);
#ifdef EIGER_RECEIVER_H
/** set frame number if a positive number
*/
int32_t setNumberOfFrames(int32_t fnum);
/** set scan tag if its is a positive number
*/
int32_t setScanTag(int32_t stag);
/** set dynamic range if its is a positive number
*/
int32_t setDynamicRange(int32_t dr);
#endif
/**
* Returns status of receiver: idle, running or error
*/
runStatus getStatus(){ return status;};
/**
* Returns File Name
*/
char* getFileName(){return fileName;};
/**
* Returns File Path
*/
char* getFilePath(){return filePath;};
/**
* Returns File Index
*/
int getFileIndex(){return fileIndex;};
bool getAcquistionStarted();
/**
* Returns Frames Caught for each real time acquisition (eg. for each scan)
*/
int getFramesCaught(){return (packetsCaught/packetsPerFrame);};
int getFramesCaught();
/**
* Returns Total Frames Caught for an entire acquisition (including all scans)
*/
int getTotalFramesCaught(){return (totalPacketsCaught/packetsPerFrame);};
int getTotalFramesCaught();
/**
* Returns the frame index at start of each real time acquisition (eg. for each scan)
*/
uint32_t getStartFrameIndex(){return startFrameIndex;};
uint32_t getStartFrameIndex();
/**
* Returns current Frame Index for each real time acquisition (eg. for each scan)
*/
uint32_t getFrameIndex();
/**
* Returns current Frame Index Caught for an entire acquisition (including all scans)
*/
uint32_t getAcquisitionIndex();
/**
* Returns if acquisition started
*/
bool getAcquistionStarted(){return acqStarted;};
/**
* Returns if measurement started
*/
bool getMeasurementStarted(){return measurementStarted;};
bool getMeasurementStarted();
/**
* Set detector hostname
* @param c hostname
* Resets the Total Frames Caught
* This is how the receiver differentiates between entire acquisitions
* Returns 0
*/
char* setDetectorHostname(char c[]);
void resetTotalFramesCaught();
//file parameters
/**
* Returns File Path
*/
char* getFilePath();
/**
* Set File Path
* @param c file path
*/
char* setFilePath(char c[]);
/**
* Returns File Name
*/
char* getFileName();
/**
* Set File Name (without frame index, file index and extension)
@ -141,10 +118,9 @@ public:
char* setFileName(char c[]);
/**
* Set File Path
* @param c file path
* Returns File Index
*/
char* setFilePath(char c[]);
int getFileIndex();
/**
* Set File Index
@ -156,7 +132,7 @@ public:
* Set Frame Index Needed
* @param i frame index needed
*/
int setFrameIndexNeeded(int i){frameIndexNeeded = i; return frameIndexNeeded;};
int setFrameIndexNeeded(int i);
/**
* Set enable file write
@ -165,12 +141,48 @@ public:
*/
int setEnableFileWrite(int i);
//other parameters
/**
* Resets the Total Frames Caught
* This is how the receiver differentiates between entire acquisitions
* Returns 0
* Returns status of receiver: idle, running or error
*/
void resetTotalFramesCaught();
runStatus getStatus();
/**
* Set detector hostname
* @param c hostname
*/
char* setDetectorHostname(char c[]);
/**
* Set Ethernet Interface or IP to listen to
*/
void setEthernetInterface(char* c);
/**
* Set UDP Port Number
*/
void setUDPPortNo(int p);
/**
* set frame number if a positive number
*/
int32_t setNumberOfFrames(int32_t fnum);
/**
* set scan tag if its is a positive number
*/
int32_t setScanTag(int32_t stag);
/**
* set dynamic range if its is a positive number
*/
int32_t setDynamicRange(int32_t dr);
/**
* Set short frame
@ -188,19 +200,21 @@ public:
*/
int64_t setAcquisitionPeriod(int64_t index);
/** get data compression, by saving only hits
*/
bool getDataCompression();
/** enabl data compression, by saving only hits
/returns if failed
*/
int enableDataCompression(bool enable);
/** get data compression, by saving only hits
*/
bool getDataCompression(){ return dataCompression;};
/** set status to transmitting and
* when fifo is empty later, sets status to run_finished
*/
void startReadout();
//other functions
/**
* Returns the buffer-current frame read by receiver
@ -209,6 +223,12 @@ public:
*/
void readFrame(char* c,char** raw);
/**
* Closes all files
* @param ithr thread index
*/
void closeFile(int ithr = -1);
/**
* Starts Receiver - starts to listen for packets
* @param message is the error message if there is an error
@ -222,11 +242,11 @@ public:
*/
int stopReceiver();
/**
* Closes all files
* @param ithr thread index
/** set status to transmitting and
* when fifo is empty later, sets status to run_finished
*/
void closeFile(int ithr = -1);
void startReadout();
private:
/**
@ -239,17 +259,17 @@ private:
*/
void setupFilter();
/**
* set up fifo according to the new numjobsperthread
*/
void setupFifoStructure ();
/**
* Copy frames to gui
* uses semaphore for nth frame mode
*/
void copyFrameToGui(char* startbuf);
/**
* set up fifo according to the new numjobsperthread
*/
void setupFifoStructure ();
/**
* creates udp socket
* \returns if success or fail
@ -332,10 +352,9 @@ private:
#ifdef EIGER_RECEIVER_H
EigerReceiver receiver;
#endif
/** Eiger Receiver */
EigerReceiver *receiver;
/** detector type */
detectorType myDetectorType;

View File

@ -1467,19 +1467,16 @@ int slsReceiverFuncs::set_timer() {
else{
if(index[0] == slsDetectorDefs::FRAME_PERIOD)
retval=slsReceiverList->setAcquisitionPeriod(index[1]);
#ifdef EIGER_RECEIVER_H
else
retval=slsReceiverList->setNumberOfFrames(index[1]);
#endif
}
}
#ifdef VERBOSE
if(ret!=FAIL){
if(index[0] == slsDetectorDefs::FRAME_PERIOD)
cout << "acquisition period:" << retval << endl;
#ifdef EIGER_RECEIVER_H
else
cout << "frame number:" << retval << endl;
#endif
}else
cout << mess << endl;
#endif
@ -1576,11 +1573,8 @@ int slsReceiverFuncs::set_detector_hostname() {
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
ret=FAIL;
}
#ifdef EIGER_RECEIVER_H
else
strcpy(retval,slsReceiverList->setDetectorHostname(hostname));
#endif
}
#ifdef VERBOSE
if(ret!=FAIL)
@ -1781,9 +1775,9 @@ int slsReceiverFuncs::send_update() {
//index
#ifdef SLS_RECEIVER_FUNCTION_LIST
#ifndef EIGER_RECEIVER
if(myDetectorType != EIGER)
ind=slsReceiverList->getFileIndex();
#endif
socket->SendDataOnly(&ind,sizeof(ind));
#endif