This commit is contained in:
l_msdetect 2015-10-28 17:40:55 +01:00
parent 5f3de2057c
commit 58bfa296be
11 changed files with 182 additions and 133 deletions

View File

@ -33,6 +33,10 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
*/
virtual ~UDPBaseImplementation();
/*
* Initialize class members
*/
void initializeMembers();
/*************************************************************************
* Getters ***************************************************************
@ -180,7 +184,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* Get Listening Status of Receiver
* @return can be idle, listening or error depending on if the receiver is listening or not
*/
slsReceiverDefs::runStatus getStatus() const;
runStatus getStatus() const;
@ -334,7 +338,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* @param d detector type
* @return OK or FAIL
*/
int setDetectorType(const slsReceiverDefs::detectorType d);
int setDetectorType(const detectorType d);
/**
* Sets detector hostname (and corresponding detector variables in derived REST class)
@ -413,14 +417,14 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* 1 callback writes file, we have to open, close it
* 2 we open, close, write file, callback does not do anything
*/
void registerCallBackStartAcquisition(int (*func)(char*, char*,uint64_t, uint32_t, void*),void *arg);
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
/**
* Call back for acquisition finished
* callback argument is
* total frames caught
*/
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
/**
* Call back for raw data
@ -431,7 +435,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* file descriptor
* guidatapointer (NULL, no data required)
*/
void registerCallBackRawDataReady(void (*func)(uint64_t, char*, uint32_t, FILE*, char*, void*),void *arg);
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);

View File

@ -407,7 +407,7 @@ class UDPInterface {
/**
* Reset acquisition parameters such as total frames caught for an entire acquisition (including all scans)
*/
void resetAcquisitionCount();
virtual void resetAcquisitionCount() = 0;
/**
* Start Listening for Packets by activating all configuration settings to receiver
@ -471,14 +471,14 @@ class UDPInterface {
* 1 callback writes file, we have to open, close it
* 2 we open, close, write file, callback does not do anything
*/
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*,uint64_t, uint32_t, void*),void *arg) = 0;
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg) = 0;
/**
* Call back for acquisition finished
* callback argument is
* total frames caught
*/
virtual void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg) = 0;
virtual void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg) = 0;
/**
* Call back for raw data
@ -489,7 +489,7 @@ class UDPInterface {
* file descriptor
* guidatapointer (NULL, no data required)
*/
virtual void registerCallBackRawDataReady(void (*func)(uint64_t, char*, uint32_t, FILE*, char*, void*),void *arg) = 0;
virtual void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg) = 0;
protected:

View File

@ -136,7 +136,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
* @param d detector type
* @return OK or FAIL
*/
int setDetectorType(const slsReceiverDefs::detectorType d);
int setDetectorType(const detectorType d);
//***acquisition functions***
/**
@ -214,11 +214,6 @@ private:
//**initial parameters***
/**
* Delete and free base member parameters
*/
void deleteBaseMembers();
/**
* Delete and free member parameters
*/
@ -409,7 +404,7 @@ private:
* @param wbuffer writing buffer popped out from FIFO
* @param npackets number of packets
*/
void handleWithoutDataCompression(int ithread, char* wbuffer[],int npackets);
void handleWithoutDataCompression(int ithread, char* wbuffer[],uint32_t npackets);
/**
* Calle by handleWithoutDataCompression
@ -417,7 +412,7 @@ private:
* @param wbuffer is the address of buffer popped out of FIFO
* @param numpackets is the number of packets
*/
void writeFileWithoutCompression(char* wbuffer[],int numpackets);
void writeFileWithoutCompression(char* wbuffer[],uint32_t numpackets);
/**
* Called by writeToFileWithoutCompression
@ -449,7 +444,7 @@ private:
* @param wbuffer writer buffer
* @param nf number of frames
*/
void handleDataCompression(int ithread, char* wbuffer[], int &nf);
void handleDataCompression(int ithread, char* wbuffer[], uint64_t &nf);

View File

@ -62,14 +62,14 @@ class slsReceiver : private virtual slsReceiverDefs {
@param func callback to be called when starting the acquisition. Its arguments are filepath filename fileindex data size
\returns 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
*/
void registerCallBackStartAcquisition(int (*func)(char*, char*,uint64_t, uint32_t, void*),void *arg);
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
/**
callback argument is
toatal farmes caught
*/
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
/**
args to raw data ready callback are
@ -79,7 +79,7 @@ class slsReceiver : private virtual slsReceiverDefs {
file descriptor
guidatapointer (NULL, no data required)
*/
void registerCallBackRawDataReady(void (*func)(uint64_t, char*, uint32_t, FILE*, char*, void*),void *arg);
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);
private:

View File

@ -61,7 +61,7 @@ public:
*/
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename,uint64_t fileindex, uint32_t datasize, void*),void *arg);
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename,int fileindex, int datasize, void*),void *arg);
/**
@ -71,7 +71,7 @@ public:
*/
void registerCallBackAcquisitionFinished(void (*func)(uint64_t nf, void*),void *arg);
void registerCallBackAcquisitionFinished(void (*func)(int nf, void*),void *arg);
@ -81,7 +81,7 @@ public:
\returns nothing
*/
void registerCallBackRawDataReady(void (*func)(uint64_t framenumber, char* datapointer, uint32_t datasize, FILE* filedescriptor, char* guidatapointer, void*),void *arg);
void registerCallBackRawDataReady(void (*func)(int framenumber, char* datapointer, int datasize, FILE* filedescriptor, char* guidatapointer, void*),void *arg);
// made static to close thread files with ctrl+c
static slsReceiver* receiver;

View File

@ -122,6 +122,55 @@ public:
else return std::string("disabled"); \
};
/** returns detector type string from detector type index
\param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
\returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, MÖNCH, GENERIC
*/
static std::string getDetectorType(detectorType t){ \
switch (t) { \
case MYTHEN: return std::string("Mythen"); \
case PILATUS: return std::string("Pilatus"); \
case EIGER: return std::string("Eiger"); \
case GOTTHARD: return std::string("Gotthard"); \
case AGIPD: return std::string("Agipd"); \
case MOENCH: return std::string("Moench"); \
case JUNGFRAU: return std::string("Jungfrau"); \
case JUNGFRAUCTB: return std::string("JungfrauCTB"); \
case PROPIX: return std::string("Propix"); \
default: return std::string("Unknown"); \
}};
/** returns detector type index from detector type string
\param type can be MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC
\returns Mythen, Pilatus, Eiger, Gotthard, Agipd, Mönch, Unknown
*/
static detectorType getDetectorType(std::string const type){\
if (type=="Mythen") return MYTHEN; \
if (type=="Pilatus") return PILATUS; \
if (type=="Eiger") return EIGER; \
if (type=="Gotthard") return GOTTHARD; \
if (type=="Agipd") return AGIPD; \
if (type=="Moench") return MOENCH; \
if (type=="Jungfrau") return JUNGFRAU; \
if (type=="JungfrauCTB") return JUNGFRAUCTB; \
if (type=="Propix") return PROPIX; \
return GENERIC; \
};
/** returns string from run status index
\param s can be ERROR, WAITING, RUNNING, TRANSMITTING, RUN_FINISHED
\returns string error, waiting, running, data, finished
*/
static std::string runStatusType(runStatus s){\
switch (s) { \
case ERROR: return std::string("error"); \
case WAITING: return std::string("waiting"); \
case RUNNING: return std::string("running"); \
case TRANSMITTING: return std::string("data"); \
case RUN_FINISHED: return std::string("finished"); \
default: return std::string("idle"); \
}};
#ifdef __cplusplus

View File

@ -21,6 +21,20 @@ using namespace std;
UDPBaseImplementation::UDPBaseImplementation(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
initializeMembers();
//***callback parameters***
startAcquisitionCallBack = NULL;
pStartAcquisition = NULL;
acquisitionFinishedCallBack = NULL;
pAcquisitionFinished = NULL;
rawDataReadyCallBack = NULL;
pRawDataReady = NULL;
}
void UDPBaseImplementation::initializeMembers(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
cout << "Info: Initializing base members" << endl;
//**detector parameters***
myDetectorType = GENERIC;
@ -61,21 +75,9 @@ UDPBaseImplementation::UDPBaseImplementation(){
//***acquisition parameters***
shortFrameEnable = -1;
FrameToGuiFrequency = 0;
//***callback parameters***
startAcquisitionCallBack = NULL;
pStartAcquisition = NULL;
acquisitionFinishedCallBack = NULL;
pAcquisitionFinished = NULL;
rawDataReadyCallBack = NULL;
pRawDataReady = NULL;
}
UDPBaseImplementation::~UDPBaseImplementation(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
cout << "Info: Deleting base member pointers" << endl;
}
UDPBaseImplementation::~UDPBaseImplementation(){}
/*************************************************************************
@ -364,12 +366,12 @@ int UDPBaseImplementation::setTenGigaEnable(const bool b){
/***initial functions***/
int UDPBaseImplementation::setDetectorType(const slsReceiverDefs::detectorType d){
int UDPBaseImplementation::setDetectorType(const detectorType d){
FILE_LOG(logDEBUG) << __AT__ << " starting";
myDetectorType = d;
//if eiger, set numberofListeningThreads = 2;
FILE_LOG(logINFO) << "Detector Type:" << slsDetectorBase::getDetectorType(d);
FILE_LOG(logINFO) << "Detector Type:" << getDetectorType(d);
return OK;
}
@ -409,6 +411,9 @@ void UDPBaseImplementation::startReadout(){
int UDPBaseImplementation::shutDownUDPSockets(){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
//overridden functions might return FAIL
return OK;
}
void UDPBaseImplementation::readFrame(char* c,char** raw, uint64_t &startAcquisitionIndex, uint64_t &startFrameIndex){
@ -429,17 +434,17 @@ void UDPBaseImplementation::closeFile(int i){
/***callback functions***/
void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*,uint64_t, uint32_t, void*),void *arg){
void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
startAcquisitionCallBack=func;
pStartAcquisition=arg;
}
void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
acquisitionFinishedCallBack=func;
pAcquisitionFinished=arg;
}
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t, char*, uint32_t, FILE*, char*, void*),void *arg){
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
rawDataReadyCallBack=func;
pRawDataReady=arg;
}

View File

@ -69,11 +69,6 @@ UDPStandardImplementation::~UDPStandardImplementation(){
*************************************************************************/
/***initial parameters***/
void UDPStandardImplementation::deleteBaseMembers(){
FILE_LOG(logDEBUG1) << __AT__ << " starting";
UDPBaseImplementation::~UDPBaseImplementation();
}
void UDPStandardImplementation::deleteMembers(){
FILE_LOG(logDEBUG1) << __AT__ << " starting";
@ -116,7 +111,7 @@ void UDPStandardImplementation::deleteFilter(){
void UDPStandardImplementation::initializeBaseMembers(){
FILE_LOG(logDEBUG1) << __AT__ << " starting";
UDPBaseImplementation::UDPBaseImplementation();
UDPBaseImplementation::initializeMembers();
acquisitionPeriod = SAMPLE_TIME_IN_NS;
}
@ -216,6 +211,7 @@ void UDPStandardImplementation::initializeFilter(){
int sign = 1, csize, i;
//common mode initialization
moenchCommonModeSubtraction = NULL;
if (commonModeSubtractionEnable){
if(myDetectorType == MOENCH)
moenchCommonModeSubtraction=new moenchCommonMode();
@ -244,7 +240,7 @@ void UDPStandardImplementation::initializeFilter(){
//single photon detector initialization
for(i=0; i<numberofWriterThreads; i++)
singlePhotonDetectorObject[i]=new singlePhotonDetector<uint16_t>(receiverData[i], csize, sigma, sign, commonModeSubtractionEnable);
singlePhotonDetectorObject[i]=new singlePhotonDetector<uint16_t>(receiverData[i], csize, sigma, sign, moenchCommonModeSubtraction);
}
@ -255,7 +251,7 @@ int UDPStandardImplementation::setupFifoStructure(){
int64_t i;
int oldNumberofJobsPerBuffer = numberofJobsPerBuffer;
int oldFifoSize = fifoSize;
uint32_t oldFifoSize = fifoSize;
//eiger always listens to 1 packet at a time
if(myDetectorType == EIGER){
@ -349,6 +345,7 @@ int UDPStandardImplementation::setupFifoStructure(){
}
}
cout << "Info: Fifo structure(s) reconstructed" << endl;
return OK;
}
@ -458,11 +455,9 @@ void UDPStandardImplementation::setShortFrameEnable(const int i){
int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t i){
FILE_LOG(logDEBUG1) << __AT__ << " called";
if(i >= 0){
FrameToGuiFrequency = i;
if(setupFifoStructure() == FAIL)
return FAIL;
}
cout << "Info: Frame to Gui Frequency set to " << FrameToGuiFrequency << endl;
@ -470,14 +465,12 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t i){
}
int UDPStandardImplementation::setAcquisitionPeriod(int64_t i){
int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i){
FILE_LOG(logDEBUG1) << __AT__ << " called";
if(i >= 0){
acquisitionPeriod = i;
if(setupFifoStructure() == FAIL)
return FAIL;
}
cout << "Info: Acquisition Period set to " << acquisitionPeriod << endl;
@ -488,7 +481,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(int64_t i){
int UDPStandardImplementation::setDynamicRange(const uint32_t i){
FILE_LOG(logDEBUG1) << __AT__ << " called";
int oldDynamicRange = dynamicRange;
uint32_t oldDynamicRange = dynamicRange;
cout << "Info: Setting Dynamic Range to " << i << endl;
dynamicRange = i;
@ -542,7 +535,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i){
int UDPStandardImplementation::setTenGigaEnable(const bool b){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Info: Setting Ten Giga to " << string(b) << endl;
cout << "Info: Setting Ten Giga to " << stringEnable(b) << endl;
bool oldTenGigaEnable = tengigaEnable;
tengigaEnable = b;
@ -603,7 +596,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
}
cout << "Info: Ten Giga " << string(tengigaEnable) << endl;
cout << "Info: Ten Giga " << stringEnable(tengigaEnable) << endl;
return OK;
}
@ -621,12 +614,11 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b){
/***initial functions***/
int UDPStandardImplementation::setDetectorType(const slsReceiverDefs::detectorType d){
int UDPStandardImplementation::setDetectorType(const detectorType d){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Setting receiver type ..." << endl;
deleteBaseMembers();
deleteMembers();
initializeBaseMembers();
initializeMembers();
@ -639,7 +631,7 @@ int UDPStandardImplementation::setDetectorType(const slsReceiverDefs::detectorTy
case EIGER:
case JUNGFRAUCTB:
case JUNGFRAU:
cout << "Info: ***** This is a " << slsDetectorBase::getDetectorType(d) << " Receiver *****" << endl;
cout << "Info: ***** This is a " << getDetectorType(d) << " Receiver *****" << endl;
break;
default:
cprintf(BG_RED, "Error: This is an unknown receiver type %d\n", (int)d);
@ -715,6 +707,9 @@ int UDPStandardImplementation::setDetectorType(const slsReceiverDefs::detectorTy
fifoSize = JCTB_FIFO_SIZE;
//footerOffset = Not applicable;
break;
default:
cprintf(BG_RED, "Error: This is an unknown receiver type %d\n", (int)d);
return FAIL;
}
//delete threads and set number of listening threads
@ -745,7 +740,7 @@ int UDPStandardImplementation::setDetectorType(const slsReceiverDefs::detectorTy
//allocate for latest data (frame copy for gui)
latestData = new char[frameSize];
cout << " Detector type set to " << slsDetectorBase::getDetectorType(d) << endl;
cout << " Detector type set to " << getDetectorType(d) << endl;
cout << "Ready..." << endl;
return OK;
@ -837,7 +832,7 @@ int UDPStandardImplementation::startReceiver(char *c){
//For compression, just for gui purposes
if(dataCompressionEnable)
sprintf(completeFileName, "%s/%s_fxxx_%d_xx.root", filePath,fileName,fileIndex);
sprintf(completeFileName, "%s/%s_fxxx_%lld_xx.root", filePath,fileName,(long long int)fileIndex);
//initialize semaphore to synchronize between writer and gui reader threads
sem_init(&writerGuiSemaphore,1,0);
@ -856,7 +851,7 @@ int UDPStandardImplementation::startReceiver(char *c){
//usleep(5000000);
cout << "Info: Receiver Started." << endl;
cout << "Info: Status:" << slsDetectorBase::runStatusType(status) << endl;
cout << "Info: Status:" << runStatusType(status) << endl;
return OK;
}
@ -889,7 +884,7 @@ void UDPStandardImplementation::stopReceiver(){
pthread_mutex_unlock(&(statusMutex));
cout << "Info: Receiver Stopped" << endl;
cout << "Info: Status:" << slsDetectorBase::runStatusType(status) << endl;
cout << "Info: Status:" << runStatusType(status) << endl;
cout << endl;
}
@ -1210,8 +1205,10 @@ int UDPStandardImplementation::createUDPSockets(){
FILE_LOG(logDEBUG1) << __AT__ << " called";
//switching ports if bottom enabled
int port[2];
port = udpPortNum;
uint32_t port[2];
port[0]= udpPortNum[0];
port[1]= udpPortNum[1];
//port = udpPortNum;
if(bottomEnable){
port[0] = udpPortNum[1];
port[1] = udpPortNum[0];
@ -1266,7 +1263,7 @@ int UDPStandardImplementation::setupWriter(){
//acquisition start call back returns enable write
cbAction = DO_EVERYTHING;
if (startAcquisitionCallBack)
cbAction=startAcquisitionCallBack(filePath,fileName,fileIndex,bufferSize,pStartAcquisition);
cbAction=startAcquisitionCallBack(filePath,fileName,(int)fileIndex,bufferSize,pStartAcquisition);
if(cbAction < DO_EVERYTHING){
cout << "Info: Call back activated. Data saving must be taken care of by user in call back." << endl;
@ -1318,11 +1315,11 @@ int UDPStandardImplementation::createNewFile(){
//create file name
if(!frameIndexEnable)
sprintf(completeFileName, "%s/%s_%d.raw", filePath,fileName,fileIndex);
sprintf(completeFileName, "%s/%s_%lld.raw", filePath,fileName,(long long int)fileIndex);
else if (myDetectorType == EIGER)
sprintf(completeFileName, "%s/%s_f%012d_%d.raw", filePath,fileName,currentFrameNumber,fileIndex);
sprintf(completeFileName, "%s/%s_f%012lld_%lld.raw", filePath,fileName,(long long int)currentFrameNumber,(long long int)fileIndex);
else
sprintf(completeFileName, "%s/%s_f%012d_%d.raw", filePath,fileName,(packetsCaught/packetsPerFrame),fileIndex);
sprintf(completeFileName, "%s/%s_f%012lld_%lld.raw", filePath,fileName,(long long int)(packetsCaught/packetsPerFrame),(long long int)fileIndex);
#ifdef DEBUG4
cout << "Info: " << completefileName << endl;
@ -1534,7 +1531,7 @@ int UDPStandardImplementation::prepareAndListenBuffer(int ithread, int lSize, in
//throw away packets that is not one packet size, need to check status if socket is shut down
while(status != TRANSMITTING && myDetectorType == EIGER && receivedSize != onePacketSize) {
if(receivedSize != EIGER_HEADER_LENGTH)
cprintf(RED,"Listening_Thread %d: Listened to a weird packet size %d\n",receivedSize);
cprintf(RED,"Listening_Thread %d: Listened to a weird packet size %d\n",ithread, receivedSize);
#ifdef DEBUG
else
cprintf(BLUE,"Listening_Thread %d: Listened to a header packet\n",ithread);
@ -1576,11 +1573,11 @@ void UDPStandardImplementation::startFrameIndices(int ithread){
if(!acqStarted){
startAcquisitionIndex = startFrameIndex;
acqStarted = true;
cprintf(BLUE,"Info: Thread %d: startAcquisitionIndex:%d\n",ithread,startAcquisitionIndex);
cprintf(BLUE,"Info: Thread %d: startAcquisitionIndex:%lld\n",ithread,(long long int)startAcquisitionIndex);
}
//set start of scan/real time measurement
cprintf(BLUE,"Info: Thread %d: startFrameIndex: %d\n", ithread,startFrameIndex);
cprintf(BLUE,"Info: Thread %d: startFrameIndex: %lld\n", ithread,(long long int)startFrameIndex);
measurementStarted = true;
}
@ -1593,7 +1590,7 @@ void UDPStandardImplementation::startFrameIndices(int ithread){
void UDPStandardImplementation::stopListening(int ithread, int numbytes){
FILE_LOG(logDEBUG1) << __AT__ << " called";
cout << "Info: Stop Listening. Status:" << slsDetectorBase::runStatusType(status) << endl;
cout << "Info: Stop Listening. Status:" << runStatusType(status) << endl;
//less than 1 packet size (especially for eiger), ignore the buffer (so that 2 dummy buffers are not sent with pc=0)
@ -1672,7 +1669,7 @@ uint32_t UDPStandardImplementation::processListeningBuffer(int ithread, int cSiz
FILE_LOG(logDEBUG1) << __AT__ << " called";
int lastPacketOffset; //the offset of the last packet
int lastFrameHeader; //frame number of last packet in buffer
uint32_t lastFrameHeader; //frame number of last packet in buffer
uint32_t packetCount = (packetsPerFrame/numberofListeningThreads) * numberofJobsPerBuffer; //packets received
cSize = 0; //reset size
@ -1735,8 +1732,8 @@ uint32_t UDPStandardImplementation::processListeningBuffer(int ithread, int cSiz
break;
default:
cprintf(RED,"Listening_Thread %d: Error: This detector is not implemented in the receiver" +
slsDetectorBase::getDetectorType(myDetectorType).c_str() + "\n");
cprintf(RED,"Listening_Thread %d: Error: This detector %s is not implemented in the receiver\n",
ithread, getDetectorType(myDetectorType).c_str());
break;
}
@ -1779,7 +1776,7 @@ void UDPStandardImplementation::processWritingBuffer(int ithread){
//variable definitions
char* wbuf[numberofListeningThreads]; //buffer popped from FIFO
sfilefd = NULL; //file pointer
int nf; //for compression, number of frames
uint64_t nf; //for compression, number of frames
/* outer loop - loops once for each acquisition */
@ -1799,7 +1796,7 @@ void UDPStandardImplementation::processWritingBuffer(int ithread){
#ifdef FIFODEBUG
cprintf(GREEN,"Writing_Thread %d: Popped %p from FIFO %d\n", ithread, (void*)(wbuf[0]),0);
#endif
int numPackets = (uint32_t)(*((uint32_t*)wbuf[0]));
uint32_t numPackets = (uint32_t)(*((uint32_t*)wbuf[0]));
if(numPackets < 0)
cprintf(BG_RED,"Error: Negative packet numbers: %d for FIFO %d\n",numPackets,0);
#ifdef DEBUG4
@ -1896,7 +1893,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//blank frame - initializing with missing packet values
blankoffset = 0;
unsigned char* blankframe_data=0;
for(int i=0; i<packetsPerFrame; ++i){
for(uint32_t i=0; i<packetsPerFrame; ++i){
if(blankframe[i]){delete [] blankframe[i]; blankframe[i] = 0;}
blankframe[i] = new char[onePacketSize];
//set missing packet to 0xff
@ -1924,7 +1921,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
cprintf(GREEN,"Writing_Thread All dummy-end buffers popped\n", ithread);
#endif
//finish missing packets
if(((frameBufferoffset[0]!=0) || (frameBufferoffset[1]!=(packetsPerFrame/numberofListeningThreads))));
if(((frameBufferoffset[0]!=0) || (frameBufferoffset[1]!=((int)packetsPerFrame/numberofListeningThreads))));
else{
stopWriting(ithread,packetBuffer);
continue;
@ -1939,7 +1936,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//dummy done-----------------------------------------------------------------------------------------------------------
if(numPackets[i] == dummyPacketValue && frameBufferoffset[i] == (((i+1)*packetsPerFrame/numberofListeningThreads)))
if(numPackets[i] == dummyPacketValue && frameBufferoffset[i] == (((i+1)*(int)packetsPerFrame/numberofListeningThreads)))
continue;
@ -1953,8 +1950,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//update frame number and packet number
if(numPackets[i] != dummyPacketValue){
if(!((uint32_t)(*( (uint64_t*) packetBuffer_footer)))){
cprintf(BG_RED,"Fifo %d: Error: Frame Number is zero from firmware. popready[%d]:%d\n",
i,(uint32_t)(*( (uint64_t*) packetBuffer_footer)),i,popReady[i]);
cprintf(BG_RED,"Fifo %d: Error: Frame Number is zero from firmware. popready[%d]:%d\n",i,i,popReady[i]);
popReady[i]=true;
continue;
}
@ -2065,7 +2061,7 @@ void UDPStandardImplementation::processWritingBufferPacketByPacket(int ithread){
//full frame
if(fullframe[0] && fullframe[1]){
currentPacketNumber = presentFrameNumber;
currentFrameNumber = presentFrameNumber;
numTotMissingPacketsInFile += numMissingPackets;
numTotMissingPackets += numMissingPackets;
#ifdef FNUM_DEBUG
@ -2307,22 +2303,21 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
cprintf(RED, "Total Frames Caught: 0\n");
}else{
cprintf(GREEN, "Total Missing Packets padded:%d\n",numTotMissingPackets);
cprintf(GREEN, "Total Packets Caught:%d\n", totalPacketsCaught);
cprintf(GREEN, "Total Frames Caught:%d\n",(totalPacketsCaught/packetsPerFrame));
cprintf(GREEN, "Total Packets Caught:%lld\n", (long long int)totalPacketsCaught);
cprintf(GREEN, "Total Frames Caught:%lld\n",(long long int)(totalPacketsCaught/packetsPerFrame));
}
//acquisition end
if (acquisitionFinishedCallBack)
acquisitionFinishedCallBack((totalPacketsCaught/packetsPerFrame), pAcquisitionFinished);
acquisitionFinishedCallBack((int)(totalPacketsCaught/packetsPerFrame), pAcquisitionFinished);
}
}
void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* wbuffer[],int npackets){
void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char* wbuffer[],uint32_t npackets){
FILE_LOG(logDEBUG1) << __AT__ << " called";
int i;
//get frame number (eiger already gets it when it does packet to packet processing)
if (myDetectorType != EIGER){
@ -2342,11 +2337,11 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
if (cbAction < DO_EVERYTHING){
switch(myDetectorType){
case EIGER:
for(i=0;i<npackets;++i)
rawDataReadyCallBack(currentFrameNumber, wbuffer[i], onePacketSize, sfilefd, guiData, pRawDataReady);
for(uint32_t i=0;i<npackets;++i)
rawDataReadyCallBack((int)currentFrameNumber, wbuffer[i], onePacketSize, sfilefd, guiData, pRawDataReady);
break;
default:
rawDataReadyCallBack(currentFrameNumber, wbuffer[0] + HEADER_SIZE_NUM_TOT_PACKETS, npackets * onePacketSize,
rawDataReadyCallBack((int)currentFrameNumber, wbuffer[0] + HEADER_SIZE_NUM_TOT_PACKETS, npackets * onePacketSize,
sfilefd, guiData,pRawDataReady);
break;
}
@ -2380,10 +2375,9 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
void UDPStandardImplementation::writeFileWithoutCompression(char* wbuffer[],int numpackets){
void UDPStandardImplementation::writeFileWithoutCompression(char* wbuffer[],uint32_t numpackets){
FILE_LOG(logDEBUG1) << __AT__ << " called";
int i;
//create headers for eiger
#ifdef WRITE_HEADERS
@ -2394,7 +2388,7 @@ void UDPStandardImplementation::writeFileWithoutCompression(char* wbuffer[],int
//if write enabled
if((fileWriteEnable) && (sfilefd)){
int offset = HEADER_SIZE_NUM_TOT_PACKETS; //offset (not eiger) to keep track of how many packets saved
int packetsToSave; //how many packets to save at a time
uint32_t packetsToSave; //how many packets to save at a time
volatile uint64_t tempframenumber;
int lastpacket;
@ -2410,7 +2404,7 @@ void UDPStandardImplementation::writeFileWithoutCompression(char* wbuffer[],int
if(cbAction == DO_EVERYTHING){
switch(myDetectorType){
case EIGER:
for(i=0; i<packetsToSave; ++i)
for(uint32_t i=0; i<packetsToSave; ++i)
fwrite((void*)wbuffer[i], 1, onePacketSize, sfilefd);
break;
default:
@ -2484,7 +2478,7 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){
eiger_packet_footer_t* wbuf_footer=0;
int port = 0, missingPacket;
for (int i = 0; i < packetsPerFrame; i++){
for (uint32_t i = 0; i < packetsPerFrame; i++){
wbuf_header = (eiger_packet_header_t*) wbuffer[i];
wbuf_footer = (eiger_packet_footer_t*)(wbuffer[i] + footerOffset);
@ -2512,8 +2506,9 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){
}
//DEBUGGING
if(*( (uint16_t*) wbuf_footer->packetNumber) != (i+1)){
cprintf(BG_RED, "Packet Number Mismatch! i:%d pnum:%d fnum:%d missingPacket:%d\n",
i,*( (uint16_t*) wbuf_footer->packetNumber),currentFrameNumber,*( (uint16_t*) wbuf_header->missingPacket));
cprintf(BG_RED, "Writing_Thread: Packet Number Mismatch! "
"i %d, pnum %d, fnum %lld, missingPacket 0x%x\n",
i,*( (uint16_t*) wbuf_footer->packetNumber),(long long int)currentFrameNumber,*( (uint16_t*) wbuf_header->missingPacket));
exit(-1);
}
//overwriting port number and dynamic range
@ -2526,7 +2521,6 @@ void UDPStandardImplementation::createHeaders(char* wbuffer[]){
void UDPStandardImplementation::copyFrameToGui(char* buffer[]){
FILE_LOG(logDEBUG1) << __AT__ << " called";
int i;
//random read (gui not ready)
//need to toggle guiDataReady or the second frame wont be copied
@ -2551,7 +2545,7 @@ void UDPStandardImplementation::copyFrameToGui(char* buffer[]){
#endif
switch(myDetectorType){
case EIGER:
for(int i=0; i<packetsPerFrame; ++i)
for(uint32_t i=0; i<packetsPerFrame; ++i)
memcpy((((char*)latestData)+i * onePacketSize) ,buffer[i],onePacketSize);
break;
default:
@ -2584,7 +2578,7 @@ void UDPStandardImplementation::copyFrameToGui(char* buffer[]){
void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer[], int &nf){
void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer[], uint64_t &nf){
FILE_LOG(logDEBUG1) << __AT__ << " called";
//frame number
@ -2605,11 +2599,11 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer
//variable definitions
char* buff[2] = 0; //an array just to be compatible with copyframetogui
char* buff[2]={0,0}; //an array just to be compatible with copyframetogui
char* data = wbuffer[0]+ HEADER_SIZE_NUM_TOT_PACKETS; //data pointer to the next memory to be analysed
int ndata; //size of data returned
int np; //remaining number of packets returned
int npackets = (uint32_t)(*((uint32_t*)wbuffer[0])); //number of total packets
uint32_t np; //remaining number of packets returned
uint32_t npackets = (uint32_t)(*((uint32_t*)wbuffer[0])); //number of total packets
int remainingsize = npackets * onePacketSize; //size of the memory slot to be analyzed
eventType thisEvent = PEDESTAL;
@ -2633,6 +2627,8 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer
ymax = GOTTHARD_SHORT_PIXELS_IN_COL-1;
}
break;
default:
break;
}
while(buff[0] = receiverData[ithread]->findNextFrame(data,ndata,remainingsize)){

View File

@ -166,20 +166,20 @@ int64_t slsReceiver::getReceiverVersion(){
}
void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*,uint64_t, uint32_t, void*),void *arg){
void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
//tcpipInterface
udp_interface->registerCallBackStartAcquisition(func,arg);
}
void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
//tcpipInterface
udp_interface->registerCallBackAcquisitionFinished(func,arg);
}
void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, char*, uint32_t, FILE*, char*, void*),void *arg){
void slsReceiver::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
//tcpipInterface
udp_interface->registerCallBackRawDataReady(func,arg);
}

View File

@ -185,7 +185,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){
#ifdef VERYVERBOSE
cout << "Starting Receiver TCP Server" << endl;
#endif
int v=slsReceiverDefs::OK;
int v=OK;
while(1) {
#ifdef VERBOSE
@ -832,7 +832,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
if(s == IDLE)
ret=receiverBase->startReceiver(mess);
else{
sprintf(mess,"Cannot start Receiver as it is in %s state\n",slsDetectorBase::runStatusType(s).c_str());
sprintf(mess,"Cannot start Receiver as it is in %s state\n",runStatusType(s).c_str());
ret=FAIL;
}
}
@ -878,7 +878,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
if(s==IDLE)
ret = OK;
else{
sprintf(mess,"Could not stop receiver. It is in %s state\n",slsDetectorBase::runStatusType(s).c_str());
sprintf(mess,"Could not stop receiver. It is in %s state\n",runStatusType(s).c_str());
ret = FAIL;
}
}
@ -1138,8 +1138,8 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
char* raw = new char[bufferSize];
uint32_t startAcquisitionIndex=0;
uint32_t startFrameIndex=0;
uint64_t startAcquisitionIndex=0;
uint64_t startFrameIndex=0;
uint32_t index = -1,bindex = 0, offset=0;
strcpy(mess,"Could not read frame\n");
@ -1327,8 +1327,8 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
uint32_t index=-1,index2=0;
uint32_t pindex=0,pindex2=0;
uint32_t bindex=0,bindex2=0;
uint32_t startAcquisitionIndex=0;
uint32_t startFrameIndex=0;
uint64_t startAcquisitionIndex=0;
uint64_t startFrameIndex=0;
strcpy(mess,"Could not read frame\n");
@ -1502,8 +1502,8 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
uint32_t index=-1,index2=0;
uint32_t pindex=0,pindex2=0;
uint32_t bindex=0,bindex2=0;
uint32_t startAcquisitionIndex=0;
uint32_t startFrameIndex=0;
uint64_t startAcquisitionIndex=0;
uint64_t startFrameIndex=0;
strcpy(mess,"Could not read frame\n");
@ -1670,8 +1670,8 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
char* raw = new char[frameSize];
char* origVal = new char[frameSize];
char* retval = new char[dataSize];
uint32_t startAcquisitionIndex=0;
uint32_t startFrameIndex=0;
uint64_t startAcquisitionIndex=0;
uint64_t startFrameIndex=0;
strcpy(mess,"Could not read frame\n");
@ -2111,11 +2111,11 @@ int slsReceiverTCPIPInterface::set_timer() {
ret=FAIL;
}
else{
if(index[0] == slsReceiverDefs::FRAME_PERIOD){
if(index[0] == FRAME_PERIOD){
if(index[1]>=0){
ret = receiverBase->setAcquisitionPeriod(index[1]);
if(ret == FAIL)
strcpy(mess,"Could not allocate memory for listening fifo\n")
strcpy(mess,"Could not allocate memory for listening fifo\n");
}
retval=receiverBase->getAcquisitionPeriod();
}else{
@ -2129,7 +2129,7 @@ int slsReceiverTCPIPInterface::set_timer() {
}
#ifdef VERBOSE
if(ret!=FAIL){
if(index[0] == slsReceiverDefs::FRAME_PERIOD)
if(index[0] == FRAME_PERIOD)
cout << "acquisition period:" << retval << endl;
else
cout << "frame number:" << retval << endl;

View File

@ -29,18 +29,18 @@ int64_t slsReceiverUsers::getReceiverVersion(){
}
void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*,uint64_t, uint32_t, void*),void *arg){
void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
slsReceiverUsers::receiver->registerCallBackStartAcquisition(func,arg);
}
void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
slsReceiverUsers::receiver->registerCallBackAcquisitionFinished(func,arg);
}
void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(uint64_t, char*, uint32_t, FILE*, char*, void*),void *arg){
void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
slsReceiverUsers::receiver->registerCallBackRawDataReady(func,arg);
}