incorporating ten giga into the receiver

This commit is contained in:
Maliakal Dhanya
2014-07-11 12:53:53 +02:00
parent 8369153d60
commit bbb0a05fca
5 changed files with 228 additions and 129 deletions

View File

@@ -74,11 +74,15 @@
#define EIGER_FIFO_SIZE 250 //cannot be less than max jobs per thread = 1000 #define EIGER_FIFO_SIZE 250 //cannot be less than max jobs per thread = 1000
/*#define EIGER_ALIGNED_FRAME_SIZE 65536*/ /*#define EIGER_ALIGNED_FRAME_SIZE 65536*/
#define EIGER_PACKETS_PER_FRAME_COSTANT (16*EIGER_MAX_PORTS)//*bit mode 4*16=64, 8*16=128, 16*16=256, 32*16=512 #define EIGER_ONE_GIGA_CONSTANT 16
#define EIGER_ONE_PACKET_SIZE 1040 #define EIGER_TEN_GIGA_CONSTANT 4
#define EIGER_ONE_DATA_SIZE 1024 //#define EIGER_PACKETS_PER_FRAME_COSTANT (16*EIGER_MAX_PORTS)//*bit mode 4*16=64, 8*16=128, 16*16=256, 32*16=512
#define EIGER_BUFFER_SIZE_CONSTANT (EIGER_ONE_PACKET_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT)//1040*16*2//*bit mode #define EIGER_ONE_GIGA_ONE_PACKET_SIZE 1040
#define EIGER_DATA_BYTES_CONSTANT (EIGER_ONE_DATA_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT) //1024*16*2//*bit mode #define EIGER_ONE_GIGA_ONE_DATA_SIZE 1024
#define EIGER_TEN_GIGA_ONE_PACKET_SIZE 4112
#define EIGER_TEN_GIGA_ONE_DATA_SIZE 4096
//#define EIGER_BUFFER_SIZE_CONSTANT (EIGER_ONE_PACKET_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT)//1040*16*2//*bit mode
//#define EIGER_DATA_BYTES_CONSTANT (EIGER_ONE_DATA_SIZE*EIGER_PACKETS_PER_FRAME_COSTANT) //1024*16*2//*bit mode
#define EIGER_FRAME_INDEX_MASK 0xFFFF #define EIGER_FRAME_INDEX_MASK 0xFFFF
#define EIGER_FRAME_INDEX_OFFSET 0 #define EIGER_FRAME_INDEX_OFFSET 0
@@ -87,7 +91,7 @@
#define EIGER_IMAGE_HEADER_SIZE 48 #define EIGER_IMAGE_HEADER_SIZE 48
#define EIGER_PIXELS_IN_ONE_ROW (256*4) #define EIGER_PIXELS_IN_ONE_ROW (256*4)
#define EIGER_PIXELS_IN_ONE_COL (256)
#endif #endif

View File

@@ -36,7 +36,8 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int argc, char *argv[], int
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME), packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
dynamicrange(16), dynamicrange(16),
socket(NULL), socket(NULL),
killTCPServerThread(0){ killTCPServerThread(0),
tenGigaEnable(0){
int port_no = DEFAULT_PORTNO+2; int port_no = DEFAULT_PORTNO+2;
ifstream infile; ifstream infile;
@@ -316,6 +317,9 @@ int slsReceiverTCPIPInterface::function_table(){
flist[F_ENABLE_RECEIVER_COMPRESSION] = &slsReceiverTCPIPInterface::enable_compression; flist[F_ENABLE_RECEIVER_COMPRESSION] = &slsReceiverTCPIPInterface::enable_compression;
flist[F_ENABLE_RECEIVER_OVERWRITE] = &slsReceiverTCPIPInterface::enable_overwrite; flist[F_ENABLE_RECEIVER_OVERWRITE] = &slsReceiverTCPIPInterface::enable_overwrite;
flist[F_ENABLE_RECEIVER_TEN_GIGA] = &slsReceiverTCPIPInterface::enable_tengiga;
#ifdef VERBOSE #ifdef VERBOSE
for (int i=0;i<numberOfFunctions;i++) for (int i=0;i<numberOfFunctions;i++)
cout << "function " << i << "located at " << flist[i] << endl; cout << "function " << i << "located at " << flist[i] << endl;
@@ -1348,23 +1352,25 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
int arg = -1,i; int arg = -1,i;
uint32_t index=0; uint32_t index=0;
int bufferSize = EIGER_BUFFER_SIZE_CONSTANT * dynamicrange; int frameSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE * packetsPerFrame;
char* raw = new char[bufferSize]; int dataSize = EIGER_ONE_GIGA_ONE_DATA_SIZE * packetsPerFrame;
char* origVal = new char[bufferSize]; if(tenGigaEnable){
char* retval = new char[(EIGER_DATA_BYTES_CONSTANT*dynamicrange)]; frameSize = EIGER_TEN_GIGA_ONE_PACKET_SIZE * packetsPerFrame;
dataSize = EIGER_TEN_GIGA_ONE_DATA_SIZE * packetsPerFrame;
}
char* raw = new char[frameSize];
char* origVal = new char[frameSize];
char* retval = new char[dataSize];
strcpy(mess,"Could not read frame\n"); strcpy(mess,"Could not read frame\n");
/* typedef struct{
typedef struct
{
unsigned char num1[4]; unsigned char num1[4];
unsigned char num2[4]; unsigned char num2[4];
} eiger_packet_header; } eiger_packet_header;*/
// execute action if the arguments correctly arrived // execute action if the arguments correctly arrived
//#ifdef SLS_RECEIVER_UDP_FUNCTIONS #ifdef SLS_RECEIVER_UDP_FUNCTIONS
@@ -1391,42 +1397,40 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
/**proper frame*/ /**proper frame*/
else{ else{
memcpy(origVal,raw,frameSize);
memcpy(origVal,raw,bufferSize);
raw=NULL; raw=NULL;
int c1=8;//first port
int c2=(frameSize/2) + 8; //second port
int c1=8;
int c2=(bufferSize/2) + 8; //only 2 ports
int retindex=0; int retindex=0;
int irow,ibytesperpacket,irepeat; int irow,ibytesperpacket,irepeat;
int repeat=1; int repeat=1;
int linesperpacket = 16/dynamicrange;// 16:1 line, 8:2 lines, 4:4 lines, 32: 0.5 int linesperpacket = (16/dynamicrange)* 1;// 16:1 line, 8:2 lines, 4:4 lines, 32: 0.5
int numbytesperlineperport=(EIGER_PIXELS_IN_ONE_ROW/EIGER_MAX_PORTS)*dynamicrange/8;//16:1024,8:512,4:256,32:2048 int numbytesperlineperport=(EIGER_PIXELS_IN_ONE_ROW/EIGER_MAX_PORTS)*dynamicrange/8;//16:1024,8:512,4:256,32:2048
if(dynamicrange == 32){ int datapacketlength = EIGER_ONE_GIGA_ONE_DATA_SIZE;
if(tenGigaEnable){
linesperpacket = (16/dynamicrange)* 4;// 16:4 line, 8:8 lines, 4:16 lines, 32: 2
datapacketlength = EIGER_TEN_GIGA_ONE_DATA_SIZE;
}
//if 1GbE, one line is split into two packets for 32 bit mode, so its special
else if(dynamicrange == 32){
repeat=2; repeat=2;
numbytesperlineperport = 1024; numbytesperlineperport = 1024;
linesperpacket = 1; //we repeat this twice anyway linesperpacket = 1; //we repeat this twice anyway for 32 bit
} }
//cout <<"linesperpacket:" <<dec<<linesperpacket <<" numbytesperlineperport:"<<numbytesperlineperport<<endl;
//for each for(irow=0;irow<EIGER_PIXELS_IN_ONE_COL/linesperpacket;++irow){
for(irow=0;irow<256/linesperpacket;++irow){
//cout <<"irow:"<<irow<<endl;
ibytesperpacket=0; ibytesperpacket=0;
while(ibytesperpacket<1024){ while(ibytesperpacket<datapacketlength){
//cout <<"ibytesperpacket:"<<ibytesperpacket<<endl;
for(irepeat=0;irepeat<repeat;irepeat++){//only for 32 bit mode, take 2 packets from same port for(irepeat=0;irepeat<repeat;irepeat++){//only for 32 bit mode, take 2 packets from same port
//cout <<"irepeat:"<<irepeat<<" c1:"<<c1<<" retindex:"<<retindex<<endl;
memcpy(retval+retindex ,origVal+c1 ,numbytesperlineperport); memcpy(retval+retindex ,origVal+c1 ,numbytesperlineperport);
retindex += numbytesperlineperport; retindex += numbytesperlineperport;
c1 += numbytesperlineperport; c1 += numbytesperlineperport;
} }
for(irepeat=0;irepeat<repeat;irepeat++){//only for 32 bit mode, take 2 packets from same port for(irepeat=0;irepeat<repeat;irepeat++){//only for 32 bit mode, take 2 packets from same port
//cout <<"irepeat:"<<irepeat<<" c2:"<<c2<<" retindex:"<<retindex<<endl;
memcpy(retval+retindex ,origVal+c2 ,numbytesperlineperport); memcpy(retval+retindex ,origVal+c2 ,numbytesperlineperport);
retindex += numbytesperlineperport; retindex += numbytesperlineperport;
c2 += numbytesperlineperport; c2 += numbytesperlineperport;
@@ -1438,36 +1442,24 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
} }
int64_t temp;
for(i=0;i<(1024*(16*dynamicrange)*2)/8;i++){
temp = ((uint64_t)(*(((uint64_t*)retval)+i)));
temp = ((temp << 8) & 0xFF00FF00FF00FF00ULL ) | ((temp >> 8) & 0x00FF00FF00FF00FFULL );
temp = ((temp << 16) & 0xFFFF0000FFFF0000ULL ) | ((temp >> 16) & 0x0000FFFF0000FFFFULL );
/* temp = (temp << 32) | ((temp >> 32) & 0xFFFFFFFFULL);
for(i=0;i<(packetsPerFrame/EIGER_MAX_PORTS);++i){ (*(((uint64_t*)retval)+i)) = temp;
//cout<<i<<" p1:"<<dec<<(htonl(*(uint32_t*)((eiger_packet_header *)((uint32_t*)(origVal + (c1-8))))->num2)&0xff)<<"\t\t";
memcpy(retval+retindex ,origVal+c1 ,EIGER_ONE_DATA_SIZE);
c1 += 16+EIGER_ONE_DATA_SIZE;
retindex += EIGER_ONE_DATA_SIZE;
//cout<<i<<" p2:"<<dec<<(htonl(*(uint32_t*)((eiger_packet_header *)((uint32_t*)(origVal + (c2-8))))->num2)&0xff)<<endl;
memcpy(retval+retindex ,origVal+c2 ,EIGER_ONE_DATA_SIZE);
c2 += 16+EIGER_ONE_DATA_SIZE;
retindex += EIGER_ONE_DATA_SIZE;
} }
/*
*/ ( (((val) >> 56) & 0x00000000000000FF) | (((val) >> 40) & 0x000000000000FF00) | \
(((val) >> 24) & 0x0000000000FF0000) | (((val) >> 8) & 0x00000000FF000000) | \
(((val) << 8) & 0x000000FF00000000) | (((val) << 24) & 0x0000FF0000000000) | \
for(i=0;i<(1024*(16*dynamicrange)*2)/4;i++) (((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000) )
(*((uint32_t*)retval+i)) = htonl((uint32_t)(*((uint32_t*)retval+i))); */
/* /*
for(int j=25;j<27;++j) for(i=0;i<(1024*(16*dynamicrange)*2)/4;i++)
for(int i=1000;i<1010;i=i+2) (*(((uint32_t*)retval)+i)) = htonl((uint32_t)(*(((uint32_t*)retval)+i)));
//cout<<"retval:"<<dec<<i<<hex<<":\t0x"<<htonl((uint32_t)(*((uint32_t*)(retval+ (EIGER_ONE_DATA_SIZE)+i))))<<endl; */
cout<<"retval:"<<dec<<i<<hex<<":\t0x"<<((uint16_t)(*((uint16_t*)(retval+ j* 2048+(1024)+i))))<<endl;
*/
arg = index-1; arg = index-1;
} }
} }
@@ -1481,7 +1473,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
//#endif #endif
if(ret==OK && socket->differentClients){ if(ret==OK && socket->differentClients){
cout << "Force update" << endl; cout << "Force update" << endl;
@@ -1497,7 +1489,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
else{ else{
socket->SendDataOnly(fName,MAX_STR_LENGTH); socket->SendDataOnly(fName,MAX_STR_LENGTH);
socket->SendDataOnly(&arg,sizeof(arg)); socket->SendDataOnly(&arg,sizeof(arg));
socket->SendDataOnly(retval,(EIGER_DATA_BYTES_CONSTANT*dynamicrange)); socket->SendDataOnly(retval,dataSize);
} }
delete [] retval; delete [] retval;
@@ -1508,6 +1500,11 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
} }
int slsReceiverTCPIPInterface::set_read_frequency(){ int slsReceiverTCPIPInterface::set_read_frequency(){
ret=OK; ret=OK;
int retval=-1; int retval=-1;
@@ -1864,8 +1861,12 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
if(ret!=FAIL){ if(ret!=FAIL){
retval=slsReceiverFunctions->setDynamicRange(dr); retval=slsReceiverFunctions->setDynamicRange(dr);
dynamicrange = dr; dynamicrange = dr;
if(myDetectorType == EIGER) if(myDetectorType == EIGER){
packetsPerFrame = dr*EIGER_PACKETS_PER_FRAME_COSTANT; if(!tenGigaEnable)
packetsPerFrame = EIGER_ONE_GIGA_CONSTANT * dynamicrange * EIGER_MAX_PORTS;
else
packetsPerFrame = EIGER_TEN_GIGA_CONSTANT * dynamicrange * EIGER_MAX_PORTS;
}
} }
} }
#ifdef VERBOSE #ifdef VERBOSE
@@ -1969,8 +1970,13 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
ret=FAIL; ret=FAIL;
} }
else{
retval=slsReceiverFunctions->enableTenGiga(val);
if((val!=-1) && (val != retval))
ret = FAIL;
else else
;//retval=slsReceiverFunctions->enable10GbE(val); tenGigaEnable = retval;
}
} }
#ifdef VERBOSE #ifdef VERBOSE
if(ret!=FAIL) if(ret!=FAIL)

View File

@@ -257,6 +257,9 @@ private:
/** thread for TCP server */ /** thread for TCP server */
pthread_t TCPServer_thread; pthread_t TCPServer_thread;
/** size of one frame*/
int tenGigaEnable;
protected: protected:
/** Socket */ /** Socket */
MySocketTCP* socket; MySocketTCP* socket;

View File

@@ -1,4 +1,4 @@
#ifdef SLS_RECEIVER_UDP_FUNCTIONS //#ifdef SLS_RECEIVER_UDP_FUNCTIONS
/********************************************//** /********************************************//**
* @file slsReceiverUDPFunctions.cpp * @file slsReceiverUDPFunctions.cpp
* @short does all the functions for a receiver, set/get parameters, start/stop etc. * @short does all the functions for a receiver, set/get parameters, start/stop etc.
@@ -35,7 +35,8 @@ slsReceiverUDPFunctions::slsReceiverUDPFunctions():
eth(NULL), eth(NULL),
latestData(NULL), latestData(NULL),
guiFileName(NULL), guiFileName(NULL),
guiFrameNumber(0){ guiFrameNumber(0),
tengigaEnable(0){
for(int i=0;i<MAX_NUM_LISTENING_THREADS;i++){ for(int i=0;i<MAX_NUM_LISTENING_THREADS;i++){
udpSocket[i] = NULL; udpSocket[i] = NULL;
server_port[i] = DEFAULT_UDP_PORTNO+i; server_port[i] = DEFAULT_UDP_PORTNO+i;
@@ -167,6 +168,7 @@ void slsReceiverUDPFunctions::initializeMembers(){
killAllListeningThreads = 0; killAllListeningThreads = 0;
killAllWritingThreads = 0; killAllWritingThreads = 0;
cbAction = DO_EVERYTHING; cbAction = DO_EVERYTHING;
tengigaEnable = 0;
for(int i=0;i<numListeningThreads;i++){ for(int i=0;i<numListeningThreads;i++){
udpSocket[i] = NULL; udpSocket[i] = NULL;
@@ -262,10 +264,10 @@ int slsReceiverUDPFunctions::setDetectorType(detectorType det){
#ifndef EIGERSLS #ifndef EIGERSLS
cout << "SLS Eiger Receiver" << endl; cout << "SLS Eiger Receiver" << endl;
fifosize = EIGER_FIFO_SIZE; fifosize = EIGER_FIFO_SIZE;
packetsPerFrame = EIGER_PACKETS_PER_FRAME_COSTANT * dynamicRange; packetsPerFrame = EIGER_ONE_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
onePacketSize = EIGER_ONE_PACKET_SIZE; onePacketSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE;
frameSize = EIGER_BUFFER_SIZE_CONSTANT * dynamicRange; frameSize = onePacketSize * packetsPerFrame;
bufferSize = (frameSize/EIGER_MAX_PORTS) + EIGER_HEADER_LENGTH;//for only one port bufferSize = (frameSize/EIGER_MAX_PORTS) + EIGER_HEADER_LENGTH;//everything one port gets (img header plus packets)
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame; maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
frameIndexMask = EIGER_FRAME_INDEX_MASK; frameIndexMask = EIGER_FRAME_INDEX_MASK;
frameIndexOffset = EIGER_FRAME_INDEX_OFFSET; frameIndexOffset = EIGER_FRAME_INDEX_OFFSET;
@@ -530,11 +532,20 @@ int32_t slsReceiverUDPFunctions::setDynamicRange(int32_t dr){
receiver->setDynamicRange(dr); receiver->setDynamicRange(dr);
else{ else{
dynamicRange = dr; dynamicRange = dr;
packetsPerFrame = EIGER_PACKETS_PER_FRAME_COSTANT * dynamicRange;
frameSize = EIGER_BUFFER_SIZE_CONSTANT * dynamicRange; if(myDetectorType == EIGER){
bufferSize = (frameSize/EIGER_MAX_PORTS) + EIGER_HEADER_LENGTH;//for only one port
if(!tengigaEnable)
packetsPerFrame = EIGER_ONE_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
else
packetsPerFrame = EIGER_TEN_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
frameSize = onePacketSize * packetsPerFrame;
bufferSize = (frameSize/EIGER_MAX_PORTS) + EIGER_HEADER_LENGTH;//everything one port gets (img header plus packets)
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame; maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
if(olddr != dr){ if(olddr != dr){
//del //del
@@ -566,7 +577,7 @@ int32_t slsReceiverUDPFunctions::setDynamicRange(int32_t dr){
setThreadPriorities(); setThreadPriorities();
} }
}
} }
} }
@@ -1527,7 +1538,7 @@ int slsReceiverUDPFunctions::startListening(){
#endif #endif
if(tempchar) {delete [] tempchar;tempchar = NULL;} if(tempchar) {delete [] tempchar;tempchar = NULL;}
if(myDetectorType == EIGER) if(myDetectorType != EIGER)
tempchar = new char[onePacketSize * ((packetsPerFrame/numListeningThreads) - 1)]; //gotthard: 1packet size, moench:39 packet size tempchar = new char[onePacketSize * ((packetsPerFrame/numListeningThreads) - 1)]; //gotthard: 1packet size, moench:39 packet size
@@ -1574,14 +1585,6 @@ int slsReceiverUDPFunctions::startListening(){
cout << ithread << " *** rc:" << dec << rc << ". expected:" << dec << expected << endl; cout << ithread << " *** rc:" << dec << rc << ". expected:" << dec << expected << endl;
#endif #endif
/*
if(ithread){
for(int j=25;j<27;++j)
for(int i=1000;i<1010;i=i+2)
//cout<<"startbuf:"<<dec<<i<<hex<<":\t0x"<<htonl((uint32_t)(*((uint32_t*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS+ EIGER_HEADER_LENGTH+ 8+i))))<<endl;
cout<<"startbuf:"<<dec<<i<<hex<<":\t0x"<<((uint16_t)(*((uint16_t*)(buffer[ithread] + 2+ 48+ j*1040+8+i))))<<endl;
}
*/
@@ -1665,6 +1668,7 @@ int slsReceiverUDPFunctions::startListening(){
} }
// cout<<"*********** "<<ithread<<" tempnum:"<< htonl(*(unsigned int*)((eiger_image_header *)((char*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum)<<endl;
@@ -1792,6 +1796,7 @@ int loop;
pthread_mutex_unlock(&progress_mutex); pthread_mutex_unlock(&progress_mutex);
} }
//#ifdef VERYDEBUG //#ifdef VERYDEBUG
if(myDetectorType == EIGER)
cout << endl <<ithread << " tempframenum:" << hex << tempframenum << " curframenum:" << currframenum << endl; cout << endl <<ithread << " tempframenum:" << hex << tempframenum << " curframenum:" << currframenum << endl;
//#endif //#endif
@@ -1929,9 +1934,9 @@ void slsReceiverUDPFunctions::startFrameIndices(int ithread){
void slsReceiverUDPFunctions::stopListening(int ithread, int rc, int &pc, int &t){ void slsReceiverUDPFunctions::stopListening(int ithread, int rc, int &pc, int &t){
int i; int i;
#ifdef VERYVERBOSE //#ifdef VERYVERBOSE
cerr << ithread << " recvfrom() failed:"<<endl; cerr << ithread << " recvfrom() failed:"<<endl;
#endif //#endif
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]);
@@ -1960,37 +1965,37 @@ int i;
cout << ithread << " going to push in dummy buffer:" << (void*)buffer[ithread] << " with num packets:"<< (*((uint16_t*)(buffer[ithread]))) << endl; cout << ithread << " going to push in dummy buffer:" << (void*)buffer[ithread] << " with num packets:"<< (*((uint16_t*)(buffer[ithread]))) << endl;
#endif #endif
while(!fifo[ithread]->push(buffer[ithread])); while(!fifo[ithread]->push(buffer[ithread]));
#ifdef VERYDEBUG //#ifdef VERYDEBUG
cout << ithread << " pushed in dummy buffer:" << (void*)buffer[ithread] << endl; cout << ithread << " pushed in dummy buffer:" << (void*)buffer[ithread] << endl;
#endif //#endif
} }
//reset mask and exit loop //reset mask and exit loop
pthread_mutex_lock(&status_mutex); pthread_mutex_lock(&status_mutex);
listeningthreads_mask^=(1<<ithread); listeningthreads_mask^=(1<<ithread);
#ifdef VERYDEBUG //#ifdef VERYDEBUG
cout << ithread << " Resetting mask of current listening thread. New Mask: " << listeningthreads_mask << endl; cout << ithread << " Resetting mask of current listening thread. New Mask: " << listeningthreads_mask << endl;
#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){
#ifdef VERYDEBUG //#ifdef VERYDEBUG
if(numListeningThreads > 1) if(numListeningThreads > 1)
cout << "Waiting for listening to be done.. current mask:" << hex << listeningthreads_mask << endl; cout << "Waiting for listening to be done.. current mask:" << hex << listeningthreads_mask << endl;
#endif //#endif
while(listeningthreads_mask) while(listeningthreads_mask)
usleep(5000); usleep(5000);
#ifdef VERYDEBUG //#ifdef VERYDEBUG
t = 0; t = 0;
for(i=0;i<numListeningThreads;++i) for(i=0;i<numListeningThreads;++i)
t += totalListeningFrameCount[i]; t += totalListeningFrameCount[i];
cout << "Total frames listened to " << dec <<(t/packetsPerFrame) << endl; cout << "Total frames listened to " << dec <<(t/packetsPerFrame) << endl;
#endif //#endif
} }
} }
@@ -2272,6 +2277,81 @@ void slsReceiverUDPFunctions::handleDataCompression(int ithread, char* wbuffer[]
int slsReceiverUDPFunctions::enableTenGiga(int enable){
cout << "Enabling 10Gbe to" << enable << endl;
int oldtengiga = tengigaEnable;
if(enable >= 0){
if(receiver != NULL)
;/*receiver->setTenGigaBitEthernet(enable);*/
else{
tengigaEnable = enable;
if(myDetectorType == EIGER){
if(!tengigaEnable){
packetsPerFrame = EIGER_ONE_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
onePacketSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE;
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
}else{
packetsPerFrame = EIGER_TEN_GIGA_CONSTANT * dynamicRange * EIGER_MAX_PORTS;
onePacketSize = EIGER_TEN_GIGA_ONE_PACKET_SIZE;
maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame*4;
}
frameSize = onePacketSize * packetsPerFrame;
bufferSize = (frameSize/EIGER_MAX_PORTS) + EIGER_HEADER_LENGTH;//everything one port gets (img header plus packets)
//maxPacketsPerFile = EIGER_MAX_FRAMES_PER_FILE * packetsPerFrame;
cout<<"packetsPerFrame:"<<dec<<packetsPerFrame<<endl;
cout<<"onePacketSize:"<<onePacketSize<<endl;
cout<<"framsize:"<<frameSize<<endl;
cout<<"bufferSize:"<<bufferSize<<endl;
cout<<"maxPacketsPerFile:"<<maxPacketsPerFile<<endl;
if(oldtengiga != enable){
//del
if(thread_started){
createListeningThreads(true);
createWriterThreads(true);
}
for(int i=0;i<numListeningThreads;i++){
if(mem0[i]) {free(mem0[i]); mem0[i] = NULL;}
if(fifo[i]) {delete fifo[i]; fifo[i] = NULL;}
if(fifoFree[i]) {delete fifoFree[i]; fifoFree[i] = NULL;}
buffer[i] = NULL;
}
if(latestData) {delete [] latestData; latestData = NULL;}
latestData = new char[frameSize];
numJobsPerThread = -1;
setupFifoStructure();
if(createListeningThreads() == FAIL){
cout << "ERROR: Could not create listening thread" << endl;
exit (-1);
}
if(createWriterThreads() == FAIL){
cout << "ERROR: Could not create writer threads" << endl;
exit (-1);
}
setThreadPriorities();
}
}
}
}
if(receiver != NULL)
;/*return receiver->getTenGigaBitEthernet();*/
else
return tengigaEnable;
}
@@ -2285,5 +2365,4 @@ void slsReceiverUDPFunctions::handleDataCompression(int ithread, char* wbuffer[]
//#endif
#endif

View File

@@ -1,4 +1,4 @@
#ifdef SLS_RECEIVER_UDP_FUNCTIONS //#ifdef SLS_RECEIVER_UDP_FUNCTIONS
#ifndef SLS_RECEIVER_UDP_FUNCTIONS_H #ifndef SLS_RECEIVER_UDP_FUNCTIONS_H
#define SLS_RECEIVER_UDP_FUNCTIONS_H #define SLS_RECEIVER_UDP_FUNCTIONS_H
/********************************************//** /********************************************//**
@@ -228,8 +228,12 @@ public:
*/ */
int enableDataCompression(bool enable); int enableDataCompression(bool enable);
/**
* enable 10Gbe
@param enable 1 for 10Gbe or 0 for 1 Gbe, -1 to read out
\returns enable for 10Gbe
*/
int enableTenGiga(int enable = -1);
@@ -631,6 +635,9 @@ private:
/** variable used to self terminate threads waiting for semaphores */ /** variable used to self terminate threads waiting for semaphores */
int killAllWritingThreads; int killAllWritingThreads;
/** 10Gbe enable*/
int tengigaEnable;
@@ -755,4 +762,4 @@ public:
#endif #endif
#endif //#endif