mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10:40 +02:00
Merge branch 'master' of gitorious.psi.ch:sls_det_software/sls_receiver_software
This commit is contained in:
commit
cd67991357
@ -79,8 +79,9 @@ mysocket_test:
|
|||||||
|
|
||||||
clean: buildclean
|
clean: buildclean
|
||||||
make testclean
|
make testclean
|
||||||
rm $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so
|
if test -e $(DESTDIR)/libSlsReceiver.a; then rm $(DESTDIR)/libSlsReceiver.a;fi
|
||||||
rm $(PROGS)
|
if test -e $(DESTDIR)/libSlsReceiver.so; then rm $(DESTDIR)/libSlsReceiver.so;fi
|
||||||
|
if test -e $(PROGS); then rm $(PROGS);fi
|
||||||
|
|
||||||
builddir:
|
builddir:
|
||||||
if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi
|
if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Path: slsDetectorsPackage/slsReceiverSoftware
|
Path: slsDetectorsPackage/slsReceiverSoftware
|
||||||
URL: origin git@gitorious.psi.ch:sls_det_software/sls_receiver_software.git
|
URL: origin git@gitorious.psi.ch:sls_det_software/sls_receiver_software.git
|
||||||
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_receiver_software.git
|
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_receiver_software.git
|
||||||
Repsitory UUID: e019a6ce7d96d4ac9cb5762b7137245aedb4d5b8
|
Repsitory UUID: 879c5e2ee129acfd70aba4ae6fab829cc5409350
|
||||||
Revision: 22
|
Revision: 67
|
||||||
Branch: master
|
Branch: gemma
|
||||||
Last Changed Author: Anna_Bergamaschi
|
Last Changed Author: Maliakal_Dhanya
|
||||||
Last Changed Rev: 22
|
Last Changed Rev: 67
|
||||||
Last Changed Date: 2014-10-15 09:22:40 +0200
|
Last Changed Date: 2014-12-08 09:17:56 +0100
|
||||||
|
@ -47,7 +47,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
|||||||
*/
|
*/
|
||||||
virtual ~UDPStandardImplementation();
|
virtual ~UDPStandardImplementation();
|
||||||
|
|
||||||
|
void configure(map<string, string> config_map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete and free member parameters
|
* delete and free member parameters
|
||||||
|
59
slsReceiverSoftware/include/ansi.h
Normal file
59
slsReceiverSoftware/include/ansi.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#define RED "\x1b[31m"
|
||||||
|
#define GREEN "\x1b[32m"
|
||||||
|
#define YELLOW "\x1b[33m"
|
||||||
|
#define BLUE "\x1b[34m"
|
||||||
|
#define MAGENTA "\x1b[35m"
|
||||||
|
#define CYAN "\x1b[36m"
|
||||||
|
#define BG_RED "\x1b[41m"
|
||||||
|
#define BG_GREEN "\x1b[42m"
|
||||||
|
#define BG_YELLOW "\x1b[43m"
|
||||||
|
#define BG_BLUE "\x1b[44m"
|
||||||
|
#define BG_MAGENTA "\x1b[45m"
|
||||||
|
#define BG_CYAN "\x1b[46m"
|
||||||
|
#define RESET "\x1b[0m"
|
||||||
|
#define BOLD "\x1b[1m"
|
||||||
|
|
||||||
|
#define cprintf(code, format, ...) printf(code format RESET, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Code examples
|
||||||
|
|
||||||
|
example 1 (a snippet):
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MARTIN
|
||||||
|
cprintf(BLUE, "LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base);
|
||||||
|
for (i=0; i < buffer_len/4; i++)
|
||||||
|
cprintf(BLUE, "%.8X ",*(((unsigned *) buffer)+i));
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MARTIN
|
||||||
|
cprintf(CYAN, "LL Read - If: %X - Data: ",ll->ll_fifo_base);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
example 2:
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int i=1;
|
||||||
|
printf("Normal %i\n", i);
|
||||||
|
cprintf(RED, "Red\n");
|
||||||
|
cprintf(GREEN, "Green\n");
|
||||||
|
cprintf(YELLOW, "Yellow\n");
|
||||||
|
cprintf(BLUE, "Blue\n");
|
||||||
|
cprintf(MAGENTA, "Mangenta %i\n", i);
|
||||||
|
cprintf(CYAN, "Cyan %i\n", i);
|
||||||
|
cprintf(BOLD, "White %i\n", i);
|
||||||
|
cprintf(RED BOLD, "Red %i\n", i);
|
||||||
|
cprintf(GREEN BOLD, "Green\n");
|
||||||
|
cprintf(YELLOW BOLD, "Yellow\n");
|
||||||
|
cprintf(BLUE BOLD, "Blue\n");
|
||||||
|
cprintf(MAGENTA BOLD, "Mangenta %i\n", i);
|
||||||
|
cprintf(CYAN BOLD, "Cyan %i\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
@ -103,7 +103,10 @@ enum communicationProtocol{
|
|||||||
nsent(0),
|
nsent(0),
|
||||||
total_sent(0)// sender (client): where to? ip
|
total_sent(0)// sender (client): where to? ip
|
||||||
{
|
{
|
||||||
|
//memset(&serverAddress, 0, sizeof(sockaddr_in));
|
||||||
|
//memset(&clientAddress, 0, sizeof(sockaddr_in));
|
||||||
|
// serverAddress = {0};
|
||||||
|
// clientAddress = {0};
|
||||||
// strcpy(hostname,host_ip_or_name);
|
// strcpy(hostname,host_ip_or_name);
|
||||||
struct hostent *hostInfo = gethostbyname(host_ip_or_name);
|
struct hostent *hostInfo = gethostbyname(host_ip_or_name);
|
||||||
if (hostInfo == NULL){
|
if (hostInfo == NULL){
|
||||||
@ -159,7 +162,10 @@ enum communicationProtocol{
|
|||||||
nsent(0),
|
nsent(0),
|
||||||
total_sent(0)
|
total_sent(0)
|
||||||
{
|
{
|
||||||
|
//memset(&serverAddress, 0, sizeof(sockaddr_in));
|
||||||
|
// memset(&clientAddress, 0, sizeof(sockaddr_in));
|
||||||
|
// serverAddress = {0};
|
||||||
|
// clientAddress = {0};
|
||||||
/* // you can specify an IP address: */
|
/* // you can specify an IP address: */
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "ansi.h"
|
||||||
|
|
||||||
typedef double double32_t;
|
typedef double double32_t;
|
||||||
typedef float float32_t;
|
typedef float float32_t;
|
||||||
|
@ -171,6 +171,7 @@ uint32_t UDPBaseImplementation::getAcquisitionIndex(){ FILE_LOG(logDEBUG) << __A
|
|||||||
acquisitionIndex=-1;
|
acquisitionIndex=-1;
|
||||||
else
|
else
|
||||||
acquisitionIndex = currframenum - startAcquisitionIndex;
|
acquisitionIndex = currframenum - startAcquisitionIndex;
|
||||||
|
//cout<<"acquisitionIndex:"<<acquisitionIndex <<" currframenum:"<<currframenum <<" startAcquisitionIndex:" <<startAcquisitionIndex<<endl;
|
||||||
return acquisitionIndex;
|
return acquisitionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +204,9 @@ inline char* UDPBaseImplementation::setFilePath(const char c[]){ FILE_LOG(logDEB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FILE_LOG(logDEBUG) << __AT__ << getFilePath();
|
FILE_LOG(logDEBUG) << __AT__ << getFilePath();
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << getFilePath() << " " << filePath << endl;
|
cout << getFilePath() << " " << filePath << endl;
|
||||||
|
#endif
|
||||||
return getFilePath();
|
return getFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,12 +374,12 @@ int32_t UDPBaseImplementation::setDynamicRange(int32_t dr){ FILE_LOG(logDEBUG) <
|
|||||||
setupFifoStructure();
|
setupFifoStructure();
|
||||||
|
|
||||||
if(createListeningThreads() == FAIL){
|
if(createListeningThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create listening thread" << endl;
|
cprintf(BG_RED,"ERROR: Could not create listening thread\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(createWriterThreads() == FAIL){
|
if(createWriterThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create writer threads" << endl;
|
cprintf(BG_RED,"ERROR: Could not create writer threads\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +475,7 @@ int UDPBaseImplementation::enableDataCompression(bool enable){ FILE_LOG(logDEBUG
|
|||||||
numWriterThreads = 1;
|
numWriterThreads = 1;
|
||||||
|
|
||||||
if(createWriterThreads() == FAIL){
|
if(createWriterThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create writer threads" << endl;
|
cprintf(BG_RED,"ERROR: Could not create writer threads\n");
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
setThreadPriorities();
|
setThreadPriorities();
|
||||||
@ -760,7 +763,7 @@ int UDPBaseImplementation::createUDPSockets(){ FILE_LOG(logDEBUG) << __AT__ << "
|
|||||||
iret = udpSocket[i]->getErrorStatus();
|
iret = udpSocket[i]->getErrorStatus();
|
||||||
if(iret){
|
if(iret){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Could not create UDP socket on port " << server_port[i] << " error:" << iret << endl;
|
cprintf(BG_RED,"Could not create UDP socket on port %d error: %d\n",server_port[i], iret);
|
||||||
#endif
|
#endif
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -1326,8 +1329,8 @@ int UDPBaseImplementation::startListening(){ FILE_LOG(logDEBUG) << __AT__ << " s
|
|||||||
|
|
||||||
thread_started = 1;
|
thread_started = 1;
|
||||||
|
|
||||||
int i,total;
|
int total;
|
||||||
int lastpacketoffset, expected, rc, rc1,packetcount, maxBufferSize, carryonBufferSize;
|
int lastpacketoffset, expected, rc,packetcount, maxBufferSize, carryonBufferSize;
|
||||||
uint32_t lastframeheader;// for moench to check for all the packets in last frame
|
uint32_t lastframeheader;// for moench to check for all the packets in last frame
|
||||||
char* tempchar = NULL;
|
char* tempchar = NULL;
|
||||||
int imageheader = 0;
|
int imageheader = 0;
|
||||||
@ -1532,9 +1535,8 @@ int UDPBaseImplementation::startWriting(){ FILE_LOG(logDEBUG) << __AT__ << " sta
|
|||||||
char* wbuf[numListeningThreads];//interleaved
|
char* wbuf[numListeningThreads];//interleaved
|
||||||
char *d=new char[bufferSize*numListeningThreads];
|
char *d=new char[bufferSize*numListeningThreads];
|
||||||
int xmax=0,ymax=0;
|
int xmax=0,ymax=0;
|
||||||
int ret,i,j;
|
int ret,i;
|
||||||
int packetsPerThread = packetsPerFrame/numListeningThreads;
|
int packetsPerThread = packetsPerFrame/numListeningThreads;
|
||||||
int loop;
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ UDPStandardImplementation::UDPStandardImplementation()
|
|||||||
rawDataReadyCallBack = NULL;
|
rawDataReadyCallBack = NULL;
|
||||||
pRawDataReady = NULL;
|
pRawDataReady = NULL;
|
||||||
|
|
||||||
initializeMembers();
|
|
||||||
|
|
||||||
//mutex
|
//mutex
|
||||||
pthread_mutex_init(&dataReadyMutex,NULL);
|
pthread_mutex_init(&dataReadyMutex,NULL);
|
||||||
@ -75,6 +74,8 @@ UDPStandardImplementation::UDPStandardImplementation()
|
|||||||
pthread_mutex_init(&progress_mutex,NULL);
|
pthread_mutex_init(&progress_mutex,NULL);
|
||||||
pthread_mutex_init(&write_mutex,NULL);
|
pthread_mutex_init(&write_mutex,NULL);
|
||||||
|
|
||||||
|
initializeMembers();
|
||||||
|
|
||||||
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
|
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
|
||||||
if(system("echo $((100*1024*1024)) > /proc/sys/net/core/rmem_max"))
|
if(system("echo $((100*1024*1024)) > /proc/sys/net/core/rmem_max"))
|
||||||
cout << "\nWARNING: Could not change socket receiver buffer size in file /proc/sys/net/core/rmem_max" << endl;
|
cout << "\nWARNING: Could not change socket receiver buffer size in file /proc/sys/net/core/rmem_max" << endl;
|
||||||
@ -91,6 +92,22 @@ UDPStandardImplementation::UDPStandardImplementation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UDPStandardImplementation::configure(map<string, string> config_map){
|
||||||
|
FILE_LOG(logWARNING) << __AT__ << " called";
|
||||||
|
|
||||||
|
map<string, string>::const_iterator pos;
|
||||||
|
pos = config_map.find("mode");
|
||||||
|
if (pos != config_map.end() ){
|
||||||
|
int b;
|
||||||
|
if(!sscanf(pos->second.c_str(), "%d", &b)){
|
||||||
|
cout << "Warning: Could not parse mode. Assuming top mode." << endl;
|
||||||
|
b = 0;
|
||||||
|
}
|
||||||
|
bottom = b!= 0;
|
||||||
|
cout << "bottom:"<< bottom << endl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void UDPStandardImplementation::initializeMembers(){
|
void UDPStandardImplementation::initializeMembers(){
|
||||||
myDetectorType = GENERIC;
|
myDetectorType = GENERIC;
|
||||||
maxPacketsPerFile = 0;
|
maxPacketsPerFile = 0;
|
||||||
@ -305,12 +322,12 @@ int UDPStandardImplementation::setDetectorType(detectorType det){ FILE_LOG(logD
|
|||||||
setupFifoStructure();
|
setupFifoStructure();
|
||||||
|
|
||||||
if(createListeningThreads() == FAIL){
|
if(createListeningThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create listening thread" << endl;
|
cprintf(BG_RED,"ERROR: Could not create listening thread\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(createWriterThreads() == FAIL){
|
if(createWriterThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create writer threads" << endl;
|
cprintf(BG_RED,"ERROR: Could not create writer threads\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,12 +585,12 @@ int32_t UDPStandardImplementation::setDynamicRange(int32_t dr){ FILE_LOG(logDEB
|
|||||||
setupFifoStructure();
|
setupFifoStructure();
|
||||||
|
|
||||||
if(createListeningThreads() == FAIL){
|
if(createListeningThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create listening thread" << endl;
|
cprintf(BG_RED,"ERROR: Could not create listening thread\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(createWriterThreads() == FAIL){
|
if(createWriterThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create writer threads" << endl;
|
cprintf(BG_RED,"ERROR: Could not create writer threads\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,7 +691,7 @@ int UDPStandardImplementation::enableDataCompression(bool enable){ FILE_LOG(log
|
|||||||
numWriterThreads = 1;
|
numWriterThreads = 1;
|
||||||
|
|
||||||
if(createWriterThreads() == FAIL){
|
if(createWriterThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create writer threads" << endl;
|
cprintf(BG_RED,"ERROR: Could not create writer threads\n");
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
setThreadPriorities();
|
setThreadPriorities();
|
||||||
@ -813,6 +830,9 @@ void UDPStandardImplementation::setupFifoStructure(){
|
|||||||
if(fifoFree[i]){
|
if(fifoFree[i]){
|
||||||
while(!fifoFree[i]->isEmpty())
|
while(!fifoFree[i]->isEmpty())
|
||||||
fifoFree[i]->pop(buffer[i]);
|
fifoFree[i]->pop(buffer[i]);
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
//cprintf(GREEN,"%d fifostructure popped from fifofree %x\n", i, (void*)(buffer[i]));
|
||||||
|
#endif
|
||||||
delete fifoFree[i];
|
delete fifoFree[i];
|
||||||
}
|
}
|
||||||
if(fifo[i]) delete fifo[i];
|
if(fifo[i]) delete fifo[i];
|
||||||
@ -832,6 +852,9 @@ void UDPStandardImplementation::setupFifoStructure(){
|
|||||||
//push the addresses into freed fifoFree and writingFifoFree
|
//push the addresses into freed fifoFree and writingFifoFree
|
||||||
while (buffer[i]<(mem0[i]+(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*(fifosize-1))) {
|
while (buffer[i]<(mem0[i]+(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*(fifosize-1))) {
|
||||||
fifoFree[i]->push(buffer[i]);
|
fifoFree[i]->push(buffer[i]);
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
cprintf(BLUE,"%d fifostructure free pushed into fifofree %x\n", i, (void*)(buffer[i]));
|
||||||
|
#endif
|
||||||
buffer[i]+=(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS);
|
buffer[i]+=(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -848,8 +871,12 @@ void UDPStandardImplementation::setupFifoStructure(){
|
|||||||
void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind){
|
void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
//point to gui data
|
//point to gui data
|
||||||
if (guiData == NULL)
|
if (guiData == NULL){
|
||||||
guiData = latestData;
|
guiData = latestData;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout <<"gui data not null anymore" << endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//copy data and filename
|
//copy data and filename
|
||||||
strcpy(c,guiFileName);
|
strcpy(c,guiFileName);
|
||||||
@ -858,21 +885,33 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
|||||||
|
|
||||||
//could not get gui data
|
//could not get gui data
|
||||||
if(!guiDataReady){
|
if(!guiDataReady){
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout<<"gui data not ready"<<endl;
|
||||||
|
#endif
|
||||||
*raw = NULL;
|
*raw = NULL;
|
||||||
}
|
}
|
||||||
//data ready, set guidata to receive new data
|
//data ready, set guidata to receive new data
|
||||||
else{
|
else{
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout<<"gui data ready"<<endl;
|
||||||
|
#endif
|
||||||
*raw = guiData;
|
*raw = guiData;
|
||||||
guiData = NULL;
|
guiData = NULL;
|
||||||
|
|
||||||
pthread_mutex_lock(&dataReadyMutex);
|
/*pthread_mutex_lock(&dataReadyMutex); WHY WAS THIS HERE IN THE FIRST PLACE
|
||||||
guiDataReady = 0;
|
guiDataReady = 0;
|
||||||
pthread_mutex_unlock(&dataReadyMutex);
|
pthread_mutex_unlock(&dataReadyMutex);*/
|
||||||
if((nFrameToGui) && (writerthreads_mask)){
|
if((nFrameToGui) && (writerthreads_mask)){
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout<<"gonna post"<<endl;
|
||||||
|
#endif
|
||||||
/*if(nFrameToGui){*/
|
/*if(nFrameToGui){*/
|
||||||
//release after getting data
|
//release after getting data
|
||||||
sem_post(&smp);
|
sem_post(&smp);
|
||||||
}
|
}
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout<<"done post"<<endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,7 +923,7 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
|||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
|
|
||||||
//random read when gui not ready
|
//random read when gui not ready , also command line doesnt have nthframetogui
|
||||||
if((!nFrameToGui) && (!guiData)){
|
if((!nFrameToGui) && (!guiData)){
|
||||||
pthread_mutex_lock(&dataReadyMutex);
|
pthread_mutex_lock(&dataReadyMutex);
|
||||||
guiDataReady=0;
|
guiDataReady=0;
|
||||||
@ -893,6 +932,7 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
|||||||
|
|
||||||
//random read or nth frame read, gui needs data now
|
//random read or nth frame read, gui needs data now
|
||||||
else{
|
else{
|
||||||
|
//cout <<"gui needs data now"<<endl;
|
||||||
/*
|
/*
|
||||||
//nth frame read, block current process if the guireader hasnt read it yet
|
//nth frame read, block current process if the guireader hasnt read it yet
|
||||||
if(nFrameToGui)
|
if(nFrameToGui)
|
||||||
@ -927,8 +967,11 @@ void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum,
|
|||||||
pthread_mutex_unlock(&dataReadyMutex);
|
pthread_mutex_unlock(&dataReadyMutex);
|
||||||
|
|
||||||
//nth frame read, block current process if the guireader hasnt read it yet
|
//nth frame read, block current process if the guireader hasnt read it yet
|
||||||
if(nFrameToGui)
|
if(nFrameToGui){
|
||||||
|
//cout<<"waiting after copying"<<endl;
|
||||||
sem_wait(&smp);
|
sem_wait(&smp);
|
||||||
|
//cout<<"done waiting"<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -945,12 +988,12 @@ int UDPStandardImplementation::createUDPSockets(){
|
|||||||
port[1] = server_port[1];
|
port[1] = server_port[1];
|
||||||
|
|
||||||
/** eiger specific */
|
/** eiger specific */
|
||||||
/*
|
|
||||||
if(bottom){
|
if(bottom){
|
||||||
port[0] = server_port[1];
|
port[0] = server_port[1];
|
||||||
port[1] = server_port[0];
|
port[1] = server_port[0];
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
//if eth is mistaken with ip address
|
//if eth is mistaken with ip address
|
||||||
if (strchr(eth,'.')!=NULL)
|
if (strchr(eth,'.')!=NULL)
|
||||||
strcpy(eth,"");
|
strcpy(eth,"");
|
||||||
@ -980,7 +1023,7 @@ int UDPStandardImplementation::createUDPSockets(){
|
|||||||
cout << "UDP port opened at port " << port[i] << endl;
|
cout << "UDP port opened at port " << port[i] << endl;
|
||||||
else{
|
else{
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Could not create UDP socket on port " << port[i] << " error:" << iret << endl;
|
cprintf(BG_RED,"Could not create UDP socket on port %d error: %d\n", port[i], iret);
|
||||||
#endif
|
#endif
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -1298,8 +1341,9 @@ int UDPStandardImplementation::createNewFile(){
|
|||||||
else
|
else
|
||||||
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,(packetsCaught/packetsPerFrame),fileIndex);
|
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,(packetsCaught/packetsPerFrame),fileIndex);
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
cout << filePath << " + " << fileName << endl;
|
cout << filePath << " + " << fileName << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
//if filewrite and we are allowed to write
|
//if filewrite and we are allowed to write
|
||||||
if(enableFileWrite && cbAction > DO_NOTHING){
|
if(enableFileWrite && cbAction > DO_NOTHING){
|
||||||
@ -1311,11 +1355,11 @@ int UDPStandardImplementation::createNewFile(){
|
|||||||
//open file
|
//open file
|
||||||
if(!overwrite){
|
if(!overwrite){
|
||||||
if (NULL == (sfilefd = fopen((const char *) (savefilename), "wx"))){
|
if (NULL == (sfilefd = fopen((const char *) (savefilename), "wx"))){
|
||||||
cout << "Error: Could not create new file " << savefilename << endl;
|
cprintf(BG_RED,"Error: Could not create new file %s\n",savefilename);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}else if (NULL == (sfilefd = fopen((const char *) (savefilename), "w"))){
|
}else if (NULL == (sfilefd = fopen((const char *) (savefilename), "w"))){
|
||||||
cout << "Error: Could not create file " << savefilename << endl;
|
cprintf(BG_RED,"Error: Could not create file %s\n",savefilename);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
//setting buffer
|
//setting buffer
|
||||||
@ -1410,7 +1454,10 @@ void UDPStandardImplementation::closeFile(int ithr){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre:
|
||||||
|
* Post: eiger req. time for 32bit before acq start
|
||||||
|
* */
|
||||||
|
|
||||||
int UDPStandardImplementation::startReceiver(char message[]){
|
int UDPStandardImplementation::startReceiver(char message[]){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
@ -1473,46 +1520,54 @@ int UDPStandardImplementation::startReceiver(char message[]){
|
|||||||
for(i=0; i < numWriterThreads; ++i)
|
for(i=0; i < numWriterThreads; ++i)
|
||||||
sem_post(&writersmp[i]);
|
sem_post(&writersmp[i]);
|
||||||
|
|
||||||
|
//usleep(5000000);
|
||||||
cout << "Receiver Started.\nStatus:" << status << endl;
|
cout << "Receiver Started.\nStatus:" << status << endl;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre: status is running, semaphores have been instantiated,
|
||||||
|
* Post: udp sockets shut down, status is idle, sempahores destroyed
|
||||||
|
* */
|
||||||
|
|
||||||
int UDPStandardImplementation::stopReceiver(){
|
int UDPStandardImplementation::stopReceiver(){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
|
if(status != IDLE){
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
cout << "Stopping Receiver" << endl;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#ifdef VERBOSE
|
|
||||||
cout << "Stopping Receiver" << endl;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
if(status == RUNNING)
|
|
||||||
startReadout();
|
startReadout();
|
||||||
|
|
||||||
while(status == TRANSMITTING)
|
while(status == TRANSMITTING)
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
|
|
||||||
//semaphore destroy
|
//semaphore destroy
|
||||||
sem_post(&smp);
|
sem_post(&smp);
|
||||||
sem_destroy(&smp);
|
sem_destroy(&smp);
|
||||||
|
|
||||||
//change status
|
//change status
|
||||||
pthread_mutex_lock(&status_mutex);
|
pthread_mutex_lock(&status_mutex);
|
||||||
status = IDLE;
|
status = IDLE;
|
||||||
pthread_mutex_unlock(&(status_mutex));
|
pthread_mutex_unlock(&(status_mutex));
|
||||||
|
|
||||||
|
cout << "Receiver Stopped.\nStatus:" << status << endl << endl;
|
||||||
|
}else cout <<" Not idle to stop receiver" << endl;
|
||||||
|
|
||||||
cout << "Receiver Stopped.\nStatus:" << status << endl << endl;
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre: status is running, udp sockets have been initialized,
|
||||||
|
* stop receiver initiated
|
||||||
|
* Post:udp sockets closed, status is transmitting
|
||||||
|
* */
|
||||||
void UDPStandardImplementation::startReadout(){
|
void UDPStandardImplementation::startReadout(){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
@ -1520,15 +1575,20 @@ void UDPStandardImplementation::startReadout(){
|
|||||||
cout << "Start Receiver Readout" << endl;
|
cout << "Start Receiver Readout" << endl;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//wait so that all packets which take time has arrived
|
if(status == RUNNING){
|
||||||
usleep(50000);
|
|
||||||
|
|
||||||
/********************************************/
|
//wait so that all packets which take time has arrived
|
||||||
usleep(2000000);
|
usleep(5000);
|
||||||
pthread_mutex_lock(&status_mutex);
|
|
||||||
status = TRANSMITTING;
|
/********************************************/
|
||||||
pthread_mutex_unlock(&status_mutex);
|
//usleep(10000000);
|
||||||
cout << "Status: Transmitting" << endl;
|
//usleep(2000000);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&status_mutex);
|
||||||
|
status = TRANSMITTING;
|
||||||
|
pthread_mutex_unlock(&status_mutex);
|
||||||
|
cout << "Status: Transmitting" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
//kill udp socket to tell the listening thread to push last packet
|
//kill udp socket to tell the listening thread to push last packet
|
||||||
shutDownUDPSockets();
|
shutDownUDPSockets();
|
||||||
@ -1566,8 +1626,8 @@ int UDPStandardImplementation::startListening(){
|
|||||||
|
|
||||||
thread_started = 1;
|
thread_started = 1;
|
||||||
|
|
||||||
int i,total;
|
int total;
|
||||||
int lastpacketoffset, expected, rc, rc1,packetcount, maxBufferSize, carryonBufferSize;
|
int lastpacketoffset, expected, rc,packetcount, maxBufferSize, carryonBufferSize;
|
||||||
uint32_t lastframeheader;// for moench to check for all the packets in last frame
|
uint32_t lastframeheader;// for moench to check for all the packets in last frame
|
||||||
char* tempchar = NULL;
|
char* tempchar = NULL;
|
||||||
int imageheader = 0;
|
int imageheader = 0;
|
||||||
@ -1596,8 +1656,8 @@ int UDPStandardImplementation::startListening(){
|
|||||||
#endif
|
#endif
|
||||||
//pop
|
//pop
|
||||||
fifoFree[ithread]->pop(buffer[ithread]);
|
fifoFree[ithread]->pop(buffer[ithread]);
|
||||||
#ifdef VERYDEBUG
|
#ifdef FIFO_DEBUG
|
||||||
cout << ithread << " *** popped from fifo free" << (void*)buffer[ithread] << endl;
|
cprintf(GREEN,"%d listener popped from fifofree %x\n", ithread, (void*)(buffer[ithread]));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -1611,6 +1671,7 @@ int UDPStandardImplementation::startListening(){
|
|||||||
|
|
||||||
/* if(!ithread){*/
|
/* if(!ithread){*/
|
||||||
rc = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, maxBufferSize);
|
rc = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, maxBufferSize);
|
||||||
|
//cout<<"value:"<<htonl(*(unsigned int*)((eiger_image_header *)((char*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum)<<endl;
|
||||||
expected = maxBufferSize;
|
expected = maxBufferSize;
|
||||||
/*}else{
|
/*}else{
|
||||||
while(1) usleep(100000000);
|
while(1) usleep(100000000);
|
||||||
@ -1632,26 +1693,32 @@ int UDPStandardImplementation::startListening(){
|
|||||||
expected = maxBufferSize - carryonBufferSize;
|
expected = maxBufferSize - carryonBufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef VERYDEBUG
|
//#ifdef VERDEBUG
|
||||||
cout << ithread << " *** rc:" << dec << rc << ". expected:" << dec << expected << endl;
|
cout << ithread << " *** rc:" << dec << rc << ". expected:" << dec << expected << endl;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
/*
|
||||||
//start indices for each start of scan/acquisition - eiger does it before
|
//start indices for each start of scan/acquisition - eiger does it before
|
||||||
if((!measurementStarted) && (rc > 0) && (!ithread))
|
if((!measurementStarted) && (rc > 0) && (!ithread))
|
||||||
startFrameIndices(ithread);
|
startFrameIndices(ithread);
|
||||||
|
*/
|
||||||
|
|
||||||
//problem in receiving or end of acquisition
|
//problem in receiving or end of acquisition
|
||||||
if((rc < expected)||(rc <= 0)){
|
if((rc < expected)||(rc <= 0)){
|
||||||
|
if(myDetectorType != EIGER){
|
||||||
|
//start indices for each start of scan/acquisition - this should be done earlier for normal detectors
|
||||||
|
if((!measurementStarted) && (rc > 0) && (!ithread))
|
||||||
|
startFrameIndices(ithread);
|
||||||
|
}
|
||||||
stopListening(ithread,rc,packetcount,total);
|
stopListening(ithread,rc,packetcount,total);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
//start indices for each start of scan/acquisition - eiger does it before
|
///*
|
||||||
|
//eiger - start indices for each start of scan/acquisition - this should be done after to ignore first incomplete frames
|
||||||
if((!measurementStarted) && (rc > 0) && (!ithread))
|
if((!measurementStarted) && (rc > 0) && (!ithread))
|
||||||
startFrameIndices(ithread);
|
startFrameIndices(ithread);
|
||||||
*/
|
//*/
|
||||||
|
|
||||||
//reset
|
//reset
|
||||||
packetcount = (packetsPerFrame/numListeningThreads) * numJobsPerThread;
|
packetcount = (packetsPerFrame/numListeningThreads) * numJobsPerThread;
|
||||||
@ -1735,8 +1802,9 @@ int UDPStandardImplementation::startListening(){
|
|||||||
cout<<dec<<ithread<<" listener going to push fifo:"<<(void*)(buffer[ithread])<<endl;
|
cout<<dec<<ithread<<" listener going to push fifo:"<<(void*)(buffer[ithread])<<endl;
|
||||||
#endif
|
#endif
|
||||||
while(!fifo[ithread]->push(buffer[ithread]));
|
while(!fifo[ithread]->push(buffer[ithread]));
|
||||||
#ifdef VERYDEBUG
|
#ifdef FIFO_DEBUG
|
||||||
if(!ithread) cout << ithread << " *** pushed into listening fifo" << endl;
|
//if(!ithread)
|
||||||
|
cprintf(RED, "%d listener pushed into fifo %x\n",ithread, (void*)(buffer[ithread]));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1748,6 +1816,8 @@ int UDPStandardImplementation::startListening(){
|
|||||||
if(tempchar) {delete [] tempchar;tempchar = NULL;}
|
if(tempchar) {delete [] tempchar;tempchar = NULL;}
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tempchar) {delete [] tempchar;tempchar = NULL;}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@ -1780,9 +1850,8 @@ int UDPStandardImplementation::startWriting(){
|
|||||||
char* wbuf[numListeningThreads];//interleaved
|
char* wbuf[numListeningThreads];//interleaved
|
||||||
char *d=new char[bufferSize*numListeningThreads];
|
char *d=new char[bufferSize*numListeningThreads];
|
||||||
int xmax=0,ymax=0;
|
int xmax=0,ymax=0;
|
||||||
int ret,i,j;
|
int ret,i;
|
||||||
int packetsPerThread = packetsPerFrame/numListeningThreads;
|
int packetsPerThread = packetsPerFrame/numListeningThreads;
|
||||||
int loop;
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
|
|
||||||
@ -1790,17 +1859,17 @@ int loop;
|
|||||||
nf = 0;
|
nf = 0;
|
||||||
packetsPerThread = packetsPerFrame/numListeningThreads;
|
packetsPerThread = packetsPerFrame/numListeningThreads;
|
||||||
if(myDetectorType == MOENCH){
|
if(myDetectorType == MOENCH){
|
||||||
xmax = MOENCH_PIXELS_IN_ONE_ROW-1;
|
xmax = MOENCH_PIXELS_IN_ONE_ROW-1;
|
||||||
ymax = MOENCH_PIXELS_IN_ONE_ROW-1;
|
ymax = MOENCH_PIXELS_IN_ONE_ROW-1;
|
||||||
}else{
|
}else{
|
||||||
if(shortFrame == -1){
|
if(shortFrame == -1){
|
||||||
xmax = GOTTHARD_PIXELS_IN_ROW-1;
|
xmax = GOTTHARD_PIXELS_IN_ROW-1;
|
||||||
ymax = GOTTHARD_PIXELS_IN_COL-1;
|
ymax = GOTTHARD_PIXELS_IN_COL-1;
|
||||||
}else{
|
}else{
|
||||||
xmax = GOTTHARD_SHORT_PIXELS_IN_ROW-1;
|
xmax = GOTTHARD_SHORT_PIXELS_IN_ROW-1;
|
||||||
ymax = GOTTHARD_SHORT_PIXELS_IN_COL-1;
|
ymax = GOTTHARD_SHORT_PIXELS_IN_COL-1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1811,26 +1880,31 @@ int loop;
|
|||||||
#endif
|
#endif
|
||||||
//pop
|
//pop
|
||||||
for(i=0;i<numListeningThreads;++i){
|
for(i=0;i<numListeningThreads;++i){
|
||||||
|
#ifdef VERYDEBUG
|
||||||
|
cout << "writer gonna pop from fifo:" << i << endl;
|
||||||
|
#endif
|
||||||
fifo[i]->pop(wbuf[i]);
|
fifo[i]->pop(wbuf[i]);
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
cprintf(MAGENTA,"%d writer poped from fifo %x\n", ithread, (void*)(wbuf[i]));
|
||||||
|
#endif
|
||||||
numpackets = (uint16_t)(*((uint16_t*)wbuf[i]));
|
numpackets = (uint16_t)(*((uint16_t*)wbuf[i]));
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << " numpackets:" << dec << numpackets << endl;
|
cout << i << " numpackets:" << dec << numpackets << "for fifo :"<< i << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERYDEBUG
|
|
||||||
cout << ithread << " numpackets:" << dec << numpackets << endl;
|
|
||||||
cout << ithread << " *** writer popped from fifo " << (void*) wbuf[0]<< endl;
|
|
||||||
cout << ithread << " *** writer popped from fifo " << (void*) wbuf[1]<< endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//last dummy packet
|
//last dummy packet
|
||||||
if(numpackets == 0xFFFF){
|
if(numpackets == 0xFFFF){
|
||||||
|
//#ifdef VERYDEBUG
|
||||||
|
cout << "**LAST dummy packet" << endl;
|
||||||
|
//#endif
|
||||||
stopWriting(ithread,wbuf);
|
stopWriting(ithread,wbuf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
//#ifdef VERYDEBUG
|
||||||
|
else cout <<"**NOT a dummy packet"<<endl;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1856,7 +1930,7 @@ int loop;
|
|||||||
}
|
}
|
||||||
//#ifdef VERYDEBUG
|
//#ifdef VERYDEBUG
|
||||||
if(myDetectorType == EIGER)
|
if(myDetectorType == EIGER)
|
||||||
cout << endl <<ithread << " tempframenum:" << hex << tempframenum << " curframenum:" << currframenum << endl;
|
cout << endl <<ithread << " tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
@ -1870,15 +1944,24 @@ int loop;
|
|||||||
}else if (numpackets > 0){
|
}else if (numpackets > 0){
|
||||||
for(i=0;i<numListeningThreads;++i)
|
for(i=0;i<numListeningThreads;++i)
|
||||||
writeToFile_withoutCompression(wbuf[i], numpackets,currframenum);
|
writeToFile_withoutCompression(wbuf[i], numpackets,currframenum);
|
||||||
|
#ifdef VERYDEBUG
|
||||||
|
cout << "written everyting" << endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(myDetectorType == EIGER) {
|
if(myDetectorType == EIGER) {
|
||||||
|
#ifdef VERYDEBUG
|
||||||
|
cout << "gonna copy frame" << endl;
|
||||||
|
#endif
|
||||||
copyFrameToGui(wbuf,currframenum);
|
copyFrameToGui(wbuf,currframenum);
|
||||||
|
#ifdef VERYDEBUG
|
||||||
|
cout << "copied frame" << endl;
|
||||||
|
#endif
|
||||||
for(i=0;i<numListeningThreads;++i){
|
for(i=0;i<numListeningThreads;++i){
|
||||||
while(!fifoFree[i]->push(wbuf[i]));
|
while(!fifoFree[i]->push(wbuf[i]));
|
||||||
#ifdef VERYDEBUG
|
#ifdef FIFO_DEBUG
|
||||||
cout << ithread << ":" << i+j << " fifo freed:" << (void*)wbuf[i] << endl;
|
cprintf(BLUE,"%d writer freed pushed into fifofree %x for listener %d\n",ithread, (void*)(wbuf[i]),i);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1886,13 +1969,15 @@ int loop;
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//copy to gui
|
//copy to gui
|
||||||
copyFrameToGui(NULL,-1,wbuf[0]+HEADER_SIZE_NUM_TOT_PACKETS);
|
if(numpackets == packetsPerFrame * numJobsPerThread){ //only full frames
|
||||||
|
copyFrameToGui(NULL,-1,wbuf[0]+HEADER_SIZE_NUM_TOT_PACKETS);
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cout << ithread << " finished copying" << endl;
|
cout << ithread << " finished copying" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
}//else cout << "unfinished buffersize" << endl;
|
||||||
while(!fifoFree[0]->push(wbuf[0]));
|
while(!fifoFree[0]->push(wbuf[0]));
|
||||||
#ifdef VERYVERBOSE
|
#ifdef FIFO_DEBUG
|
||||||
cout<<"buf freed:"<<(void*)wbuf[0]<<endl;
|
cprintf(BLUE,"%d writer freed pushed into fifofree %x for listener 0\n",ithread, (void*)(wbuf[0]));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1957,6 +2042,7 @@ int loop;
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete [] d;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -1984,7 +2070,7 @@ void UDPStandardImplementation::startFrameIndices(int ithread){
|
|||||||
startAcquisitionIndex=startFrameIndex;
|
startAcquisitionIndex=startFrameIndex;
|
||||||
currframenum = startAcquisitionIndex;
|
currframenum = startAcquisitionIndex;
|
||||||
acqStarted = true;
|
acqStarted = true;
|
||||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex<<endl;
|
cout << "startAcquisitionIndex:" << hex << startAcquisitionIndex<<endl;
|
||||||
}
|
}
|
||||||
//for scans, cuz currfraenum resets
|
//for scans, cuz currfraenum resets
|
||||||
else if (myDetectorType == EIGER){
|
else if (myDetectorType == EIGER){
|
||||||
@ -2016,34 +2102,63 @@ int i;
|
|||||||
if(status != TRANSMITTING){
|
if(status != TRANSMITTING){
|
||||||
cout << ithread << " *** shoule never be here********* status not transmitting***********************"<<endl;/**/
|
cout << ithread << " *** shoule never be here********* status not transmitting***********************"<<endl;/**/
|
||||||
fifoFree[ithread]->push(buffer[ithread]);
|
fifoFree[ithread]->push(buffer[ithread]);
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
cprintf(BLUE,"%d listener not txm free pushed into fifofree %x\n", ithread,(void*)(buffer[ithread]));
|
||||||
|
#endif
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//push the last buffer into fifo
|
//push the last buffer into fifo
|
||||||
if((myDetectorType != EIGER) && (rc > 0)){ //for eiger throw away incomplete frames
|
if(rc > 0){
|
||||||
pc = (rc/onePacketSize);
|
//eiger (incomplete frames) - throw away
|
||||||
#ifdef VERYDEBUG
|
if((myDetectorType == EIGER) && (rc < (bufferSize * numJobsPerThread)) ){
|
||||||
cout << ithread << " *** last packetcount:" << pc << endl;
|
if(rc == 266240)
|
||||||
|
cout << ithread << " Start of detector: Received test frame of 266240 bytes." << endl;
|
||||||
|
cout << ithread << "Discarding incomplete frame" << endl;
|
||||||
|
fifoFree[ithread]->push(buffer[ithread]);
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
cprintf(BLUE,"%d listener last buffer free pushed into fifofree %x\n", ithread,(void*)(buffer[ithread]));
|
||||||
#endif
|
#endif
|
||||||
(*((uint16_t*)(buffer[ithread]))) = pc;
|
}
|
||||||
totalListeningFrameCount[ithread] += pc;
|
//eiger (complete frames) + other detectors
|
||||||
while(!fifo[ithread]->push(buffer[ithread]));
|
else{
|
||||||
|
pc = (rc/onePacketSize);
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << " *** last lbuf1:" << (void*)buffer[ithread] << endl;
|
cout << ithread << " last rc:"<<rc<<endl;
|
||||||
|
cout << ithread << " *** last packetcount:" << pc << endl;
|
||||||
#endif
|
#endif
|
||||||
}else
|
(*((uint16_t*)(buffer[ithread]))) = pc;
|
||||||
fifoFree[ithread]->push(buffer[ithread]);//for all detectors too. why was this not there? for rc=0?
|
totalListeningFrameCount[ithread] += pc;
|
||||||
|
while(!fifo[ithread]->push(buffer[ithread]));
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
cprintf(RED,"%d listener last buffer pushed into fifo %x\n", ithread,(void*)(buffer[ithread]));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//free buffer
|
||||||
|
else{
|
||||||
|
cout << ithread << "Discarding empty frame" << endl;
|
||||||
|
fifoFree[ithread]->push(buffer[ithread]);
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
cprintf(BLUE,"%d listener empty buffer pushed into fifofree %x\n", ithread, (void*)(buffer[ithread]));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//push dummy buffer to all writer threads
|
//push dummy buffer to all writer threads
|
||||||
for(i=0;i<numWriterThreads;++i){
|
for(i=0;i<numWriterThreads;++i){
|
||||||
fifoFree[ithread]->pop(buffer[ithread]);
|
fifoFree[ithread]->pop(buffer[ithread]);
|
||||||
|
#ifdef FIFO_DEBUG
|
||||||
|
cprintf(GREEN,"%d listener popped dummy buffer from fifofree %x\n", ithread,(void*)(buffer[ithread]));
|
||||||
|
#endif
|
||||||
(*((uint16_t*)(buffer[ithread]))) = 0xFFFF;
|
(*((uint16_t*)(buffer[ithread]))) = 0xFFFF;
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << " going to push in dummy buffer:" << (void*)buffer[ithread] << " with num packets:"<< (*((uint16_t*)(buffer[ithread]))) << endl;
|
cout << ithread << " dummy buffer num packets:"<< (*((uint16_t*)(buffer[ithread]))) << endl;
|
||||||
#endif
|
#endif
|
||||||
while(!fifo[ithread]->push(buffer[ithread]));
|
while(!fifo[ithread]->push(buffer[ithread]));
|
||||||
#ifdef VERYDEBUG
|
#ifdef FIFO_DEBUG
|
||||||
cout << ithread << " pushed in dummy buffer:" << (void*)buffer[ithread] << endl;
|
cprintf(RED,"%d listener pushed dummy buffer into fifo %x\n", ithread,(void*)(buffer[ithread]));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2055,9 +2170,9 @@ int i;
|
|||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&(status_mutex));
|
pthread_mutex_unlock(&(status_mutex));
|
||||||
|
|
||||||
//#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << ": Frames listened to " << dec << ((totalListeningFrameCount[ithread]*numListeningThreads)/packetsPerFrame) << endl;
|
cout << ithread << ": Frames listened to " << dec << ((totalListeningFrameCount[ithread]*numListeningThreads)/packetsPerFrame) << endl;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
//waiting for all listening threads to be done, to print final count of frames listened to
|
//waiting for all listening threads to be done, to print final count of frames listened to
|
||||||
if(ithread == 0){
|
if(ithread == 0){
|
||||||
@ -2091,14 +2206,14 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
|
|||||||
|
|
||||||
int i,j;
|
int i,j;
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << " **********************popped last dummy frame:" << (void*)wbuffer[wIndex] << endl;
|
cout << ithread << " **********************popped last dummy frame:" << (void*)wbuffer[0] << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//free fifo
|
//free fifo
|
||||||
for(i=0;i<numListeningThreads;++i){
|
for(i=0;i<numListeningThreads;++i){
|
||||||
while(!fifoFree[i]->push(wbuffer[i]));
|
while(!fifoFree[i]->push(wbuffer[i]));
|
||||||
#ifdef VERYDEBUG
|
#ifdef FIFO_DEBUG
|
||||||
cout << ithread << ":" << i<< " fifo freed:" << (void*)wbuffer[i] << endl;
|
cprintf(BLUE,"%d writer free dummy pushed into fifofree %x for listener %d\n", ithread,(void*)(wbuffer[i]),i);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2135,9 +2250,10 @@ void UDPStandardImplementation::stopWriting(int ithread, char* wbuffer[]){
|
|||||||
status = RUN_FINISHED;
|
status = RUN_FINISHED;
|
||||||
pthread_mutex_unlock(&(status_mutex));
|
pthread_mutex_unlock(&(status_mutex));
|
||||||
//report
|
//report
|
||||||
cout << "Status: Run Finished" << endl;
|
|
||||||
cout << "Total Packets Caught:" << dec << totalPacketsCaught << endl;
|
cprintf(GREEN, "Status: Run Finished\n");
|
||||||
cout << "Total Frames Caught:"<< dec << (totalPacketsCaught/packetsPerFrame) << endl;
|
cprintf(GREEN, "Total Packets Caught:%d\n", totalPacketsCaught);
|
||||||
|
cprintf(GREEN, "Total Frames Caught:%d\n",(totalPacketsCaught/packetsPerFrame));
|
||||||
//acquisition end
|
//acquisition end
|
||||||
if (acquisitionFinishedCallBack)
|
if (acquisitionFinishedCallBack)
|
||||||
acquisitionFinishedCallBack((totalPacketsCaught/packetsPerFrame), pAcquisitionFinished);
|
acquisitionFinishedCallBack((totalPacketsCaught/packetsPerFrame), pAcquisitionFinished);
|
||||||
@ -2200,8 +2316,9 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num
|
|||||||
packetsInFile += packetsToSave;
|
packetsInFile += packetsToSave;
|
||||||
packetsCaught += packetsToSave;
|
packetsCaught += packetsToSave;
|
||||||
totalPacketsCaught += packetsToSave;
|
totalPacketsCaught += packetsToSave;
|
||||||
|
#ifdef VERYDEBUG
|
||||||
|
cout << "/totalPacketsCaught:" << dec << totalPacketsCaught <<endl;
|
||||||
|
#endif
|
||||||
//new file
|
//new file
|
||||||
if(packetsInFile >= maxPacketsPerFile){
|
if(packetsInFile >= maxPacketsPerFile){
|
||||||
//for packet loss
|
//for packet loss
|
||||||
@ -2343,16 +2460,15 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer
|
|||||||
remainingsize -= ((buff + ndata) - data);
|
remainingsize -= ((buff + ndata) - data);
|
||||||
data = buff + ndata;
|
data = buff + ndata;
|
||||||
if(data > (wbuffer[0] + HEADER_SIZE_NUM_TOT_PACKETS + npackets * onePacketSize) )
|
if(data > (wbuffer[0] + HEADER_SIZE_NUM_TOT_PACKETS + npackets * onePacketSize) )
|
||||||
cout <<" **************ERROR SHOULD NOT COME HERE, Error 142536!"<<endl;
|
cprintf(BG_RED,"ERROR SHOULD NOT COME HERE, Error 142536!\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!fifoFree[0]->push(wbuffer[0]));
|
while(!fifoFree[0]->push(wbuffer[0]));
|
||||||
#ifdef VERYVERBOSE
|
#ifdef FIFO_DEBUG
|
||||||
cout<<"buf freed:"<<(void*)wbuffer[0]<<endl;
|
cprintf(BLUE,"%d writer compression free pushed into fifofree %x for listerner 0\n", ithread, (void*)(wbuffer[0]));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2412,12 +2528,12 @@ int UDPStandardImplementation::enableTenGiga(int enable){
|
|||||||
setupFifoStructure();
|
setupFifoStructure();
|
||||||
|
|
||||||
if(createListeningThreads() == FAIL){
|
if(createListeningThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create listening thread" << endl;
|
cprintf(BG_RED,"ERROR: Could not create listening thread\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(createWriterThreads() == FAIL){
|
if(createWriterThreads() == FAIL){
|
||||||
cout << "ERROR: Could not create writer threads" << endl;
|
cprintf(BG_RED,"ERROR: Could not create writer threads\n");
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ int main(int argc, char *argv[]) {
|
|||||||
user->stop();
|
user->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete user;
|
||||||
cout << "Goodbye!" << endl;
|
cout << "Goodbye!" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,13 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
|||||||
|
|
||||||
switch(c){
|
switch(c){
|
||||||
|
|
||||||
|
case 'm':
|
||||||
|
int b;
|
||||||
|
sscanf(optarg, "%d", &b);
|
||||||
|
bottom = b != 0;
|
||||||
|
configuration_map["mode"] = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
fname = optarg;
|
fname = optarg;
|
||||||
//cout << long_options[option_index].name << " " << optarg << endl;
|
//cout << long_options[option_index].name << " " << optarg << endl;
|
||||||
@ -86,7 +93,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
|||||||
string help_message = """\nSLS Receiver Server\n\n""";
|
string help_message = """\nSLS Receiver Server\n\n""";
|
||||||
help_message += """usage: slsReceiver --config config_fname [--rx_tcpport port]\n\n""";
|
help_message += """usage: slsReceiver --config config_fname [--rx_tcpport port]\n\n""";
|
||||||
help_message += """\t--config:\t configuration filename for SLS Detector receiver\n""";
|
help_message += """\t--config:\t configuration filename for SLS Detector receiver\n""";
|
||||||
help_message += """\t--mode:\t ???\n""";
|
help_message += """\t--mode:\t 1 for bottom and 0 for top\n""";
|
||||||
help_message += """\t--rx_tcpport:\t TCP Communication Port with the client. Default: 1954.\n\n""";
|
help_message += """\t--rx_tcpport:\t TCP Communication Port with the client. Default: 1954.\n\n""";
|
||||||
help_message += """\t--rest_hostname:\t Receiver hostname:port. It applies only to REST receivers, and indicates the hostname of the REST backend. Default: localhost:8081.\n\n""";
|
help_message += """\t--rest_hostname:\t Receiver hostname:port. It applies only to REST receivers, and indicates the hostname of the REST backend. Default: localhost:8081.\n\n""";
|
||||||
|
|
||||||
@ -120,10 +127,10 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (success==OK){
|
if (success==OK){
|
||||||
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << endl;
|
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << " with mode " << bottom << endl;
|
||||||
udp_interface = UDPInterface::create(udp_interface_type);
|
udp_interface = UDPInterface::create(udp_interface_type);
|
||||||
udp_interface->configure(configuration_map);
|
udp_interface->configure(configuration_map);
|
||||||
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no);
|
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no, bottom);
|
||||||
//tcp ip interface
|
//tcp ip interface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
||||||
if(socket) delete socket;
|
if(socket) {delete socket; socket=NULL;}
|
||||||
|
if(receiverBase) {delete receiverBase; receiverBase=NULL;}
|
||||||
closeFile(0);
|
closeFile(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1221,8 +1222,8 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
|||||||
}
|
}
|
||||||
//all adc
|
//all adc
|
||||||
else{
|
else{
|
||||||
//ignore if half frame is missing
|
/*//ignore if half frame is missing
|
||||||
if ((bindex != 0xFFFFFFFF) && (bindex2 != 0xFFFFFFFF)){
|
if ((bindex != 0xFFFFFFFF) && (bindex2 != 0xFFFFFFFF)){*/
|
||||||
|
|
||||||
//should be same frame
|
//should be same frame
|
||||||
if (index == index2){
|
if (index == index2){
|
||||||
@ -1239,11 +1240,11 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
|||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
cout << "different frames caught. frame1:"<< hex << index << ":"<<pindex<<" frame2:" << hex << index2 << ":"<<pindex2<<endl;
|
cout << "different frames caught. frame1:"<< hex << index << ":"<<pindex<<" frame2:" << hex << index2 << ":"<<pindex2<<endl;
|
||||||
}
|
/*}
|
||||||
else{
|
else{
|
||||||
index = startIndex - 1;
|
index = startIndex - 1;
|
||||||
cout << "Missing Packet,Not sending to gui" << endl;
|
cout << "Missing Packet,Not sending to gui" << endl;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
arg = (index - startIndex);
|
arg = (index - startIndex);
|
||||||
@ -1463,14 +1464,18 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
arg = index-startIndex;
|
arg = index-startIndex;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "arg calculated is:"<<arg<<endl;
|
||||||
|
cout <<"index:"<<index<<" startindex:"<<startIndex<<endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
if(arg!=-1){
|
//if(arg!=-1){
|
||||||
cout << "fName:" << fName << endl;
|
cout << "fName:" << fName << endl;
|
||||||
cout << "findex:" << arg << endl;
|
cout << "findex:" << dec << arg << endl;
|
||||||
}
|
//}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user