diff --git a/slsReceiverSoftware/include/receiver_defs.h b/slsReceiverSoftware/include/receiver_defs.h index 6a28654b3..701b4e382 100755 --- a/slsReceiverSoftware/include/receiver_defs.h +++ b/slsReceiverSoftware/include/receiver_defs.h @@ -51,6 +51,26 @@ + +#define PROPIX_PIXELS_IN_ROW 22 +#define PROPIX_PIXELS_IN_COL 22 +#define PROPIX_DATABYTES_PER_PIXEL 2 + +#define PROPIX_FIFO_SIZE 25000 //cannot be less than max jobs per thread = 1000 +#define PROPIX_PACKETS_PER_FRAME 2 +#define PROPIX_ONE_PACKET_SIZE 1286 +#define PROPIX_BUFFER_SIZE (PROPIX_ONE_PACKET_SIZE*PROPIX_PACKETS_PER_FRAME) //1286*2 +//#define PROPIX_DATA_BYTES (1280*PROPIX_PACKETS_PER_FRAME) //1280*2 +#define PROPIX_DATA_BYTES (PROPIX_PIXELS_IN_ROW * PROPIX_PIXELS_IN_COL * PROPIX_DATABYTES_PER_PIXEL) //22 * 22 * 2 + +#define PROPIX_FRAME_INDEX_MASK 0xFFFFFFFE +#define PROPIX_FRAME_INDEX_OFFSET 1 +#define PROPIX_PACKET_INDEX_MASK 0x1 + + + + + #define MOENCH_FIFO_SIZE 2500 //cannot be less than max jobs per thread = 1000 /*#define MOENCH_ALIGNED_FRAME_SIZE 65536*/ #define MOENCH_PACKETS_PER_FRAME 40 @@ -68,19 +88,19 @@ -#define JCTB_FIFO_SIZE 2500 //cannot be less than max jobs per thread = 1000 +#define JCTB_FIFO_SIZE 2500 //cannot be less than max jobs per thread = 1000 /*#define MOENCH_ALIGNED_FRAME_SIZE 65536*/ -#define JCTB_PACKETS_PER_FRAME 50 +#define JCTB_PACKETS_PER_FRAME 50 #define JCTB_ONE_PACKET_SIZE 8214 -#define JCTB_BUFFER_SIZE (MOENCH_ONE_PACKET_SIZE*MOENCH_PACKETS_PER_FRAME) -#define JCTB_DATA_BYTES (JCTB_BUFFER_PER_FRAME) +#define JCTB_BUFFER_SIZE (MOENCH_ONE_PACKET_SIZE*MOENCH_PACKETS_PER_FRAME) +#define JCTB_DATA_BYTES (JCTB_BUFFER_PER_FRAME) -#define JCTB_FRAME_INDEX_MASK 0xFFFFFF00 -#define JCTB_FRAME_INDEX_OFFSET 8 -#define JCTB_PACKET_INDEX_MASK 0xFF +#define JCTB_FRAME_INDEX_MASK 0xFFFFFF00 +#define JCTB_FRAME_INDEX_OFFSET 8 +#define JCTB_PACKET_INDEX_MASK 0xFF -#define JCTB_BYTES_PER_ADC (2) -#define JCTB_PIXELS_IN_ONE_ROW 32 +#define JCTB_BYTES_PER_ADC (2) +#define JCTB_PIXELS_IN_ONE_ROW 32 #define JCTB_BYTES_IN_ONE_ROW (JCTB_PIXELS_IN_ONE_ROW*2) diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index ea0e1a3d0..83d9416aa 100644 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -170,6 +170,9 @@ private: /** gotthard specific read frame */ int gotthard_read_frame(); + /** propix specific read frame */ + int propix_read_frame(); + /** moench specific read frame */ int moench_read_frame(); diff --git a/slsReceiverSoftware/include/sls_receiver_defs.h b/slsReceiverSoftware/include/sls_receiver_defs.h index a9f6d30c2..12958612f 100755 --- a/slsReceiverSoftware/include/sls_receiver_defs.h +++ b/slsReceiverSoftware/include/sls_receiver_defs.h @@ -58,7 +58,8 @@ public: AGIPD, /**< agipd */ MOENCH, /**< moench */ JUNGFRAU, /**< jungfrau */ - JUNGFRAUCTB /**< jungfrauCTBversion */ + JUNGFRAUCTB, /**< jungfrauCTBversion */ + PROPIX /**< propix */ }; diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index 48d53098e..3f18ddea9 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -263,6 +263,9 @@ int UDPStandardImplementation::setDetectorType(detectorType det){ FILE_LOG(logD case GOTTHARD: cout << endl << "***** This is a GOTTHARD Receiver *****" << endl << endl; break; + case PROPIX: + cout << endl << "***** This is a PROPIX Receiver *****" << endl << endl; + break; case MOENCH: cout << endl << "***** This is a MOENCH Receiver *****" << endl << endl; break; @@ -281,7 +284,7 @@ int UDPStandardImplementation::setDetectorType(detectorType det){ FILE_LOG(logD break; } - //moench variables + //detector specific variables if(myDetectorType == GOTTHARD){ fifosize = GOTTHARD_FIFO_SIZE; packetsPerFrame = GOTTHARD_PACKETS_PER_FRAME; @@ -292,6 +295,16 @@ int UDPStandardImplementation::setDetectorType(detectorType det){ FILE_LOG(logD frameIndexMask = GOTTHARD_FRAME_INDEX_MASK; frameIndexOffset = GOTTHARD_FRAME_INDEX_OFFSET; packetIndexMask = GOTTHARD_PACKET_INDEX_MASK; + }else if(myDetectorType == PROPIX){ + fifosize = PROPIX_FIFO_SIZE; + packetsPerFrame = PROPIX_PACKETS_PER_FRAME; + onePacketSize = PROPIX_ONE_PACKET_SIZE; + frameSize = PROPIX_BUFFER_SIZE; + bufferSize = PROPIX_BUFFER_SIZE; + maxPacketsPerFile = MAX_FRAMES_PER_FILE * PROPIX_PACKETS_PER_FRAME; + frameIndexMask = PROPIX_FRAME_INDEX_MASK; + frameIndexOffset = PROPIX_FRAME_INDEX_OFFSET; + packetIndexMask = PROPIX_PACKET_INDEX_MASK; }else if(myDetectorType == MOENCH){ fifosize = MOENCH_FIFO_SIZE; packetsPerFrame = MOENCH_PACKETS_PER_FRAME; @@ -828,6 +841,8 @@ void UDPStandardImplementation::setupFifoStructure(){ fifosize = GOTTHARD_FIFO_SIZE; if(myDetectorType == MOENCH) fifosize = MOENCH_FIFO_SIZE; + if(myDetectorType == PROPIX) + fifosize = PROPIX_FIFO_SIZE; else if(myDetectorType == EIGER) fifosize = EIGER_FIFO_SIZE * packetsPerFrame; @@ -1811,6 +1826,7 @@ int UDPStandardImplementation::startListening(){ break; case GOTTHARD: + case PROPIX: if(shortFrame == -1){ lastpacketoffset = (((numJobsPerThread * packetsPerFrame - 1) * onePacketSize) + HEADER_SIZE_NUM_TOT_PACKETS); #ifdef VERYDEBUG @@ -2031,9 +2047,11 @@ int UDPStandardImplementation::startWriting(){ if(myDetectorType == EIGER){ + //trying to find a full frame for(i=0;i> frameIndexOffset); else tempframenum[0] = ((((uint32_t)(*((uint32_t*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))& (frameIndexMask)) >> frameIndexOffset); @@ -2254,7 +2272,7 @@ void UDPStandardImplementation::startFrameIndices(int ithread, int numbytes){ startFrameIndex = 0; } //gotthard has +1 for frame number and not a short frame - else if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) + else if ((myDetectorType == PROPIX) || ((myDetectorType == GOTTHARD) && (shortFrame == -1))) startFrameIndex = (((((uint32_t)(*((uint32_t*)(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))+1) & (frameIndexMask)) >> frameIndexOffset); else @@ -2540,7 +2558,7 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num //for progress and packet loss calculation(new files) if(myDetectorType == EIGER); - else if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) + else if ((myDetectorType == PROPIX)||((myDetectorType == GOTTHARD) && (shortFrame == -1))) tempframenum = (((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset); else tempframenum = ((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))& (frameIndexMask)) >> frameIndexOffset); @@ -2576,8 +2594,10 @@ void UDPStandardImplementation::writeToFile_withoutCompression(char* buf,int num if(packetsInFile >= maxPacketsPerFile){ //for packet loss lastpacket = (((packetsToSave - 1) * onePacketSize) + offset); + if(myDetectorType == EIGER);//because currframenum is the latest one for eiger - else if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) + else if ((myDetectorType == PROPIX)||((myDetectorType == GOTTHARD) && (shortFrame == -1))) + tempframenum = (((((uint32_t)(*((uint32_t*)(buf + lastpacket))))+1)& (frameIndexMask)) >> frameIndexOffset); else tempframenum = ((((uint32_t)(*((uint32_t*)(buf + lastpacket))))& (frameIndexMask)) >> frameIndexOffset); diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index bcefc85d8..69feec4aa 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -1029,6 +1029,8 @@ int slsReceiverTCPIPInterface::read_frame(){ return moench_read_frame(); case EIGER: return eiger_read_frame(); + case PROPIX: + return propix_read_frame(); default: return gotthard_read_frame(); } @@ -1395,6 +1397,162 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){ +int slsReceiverTCPIPInterface::propix_read_frame(){ + ret=OK; + char fName[MAX_STR_LENGTH]=""; + int acquisitionIndex = -1; + int frameIndex= -1; + int i; + + + //retval is a full frame + int bufferSize = PROPIX_BUFFER_SIZE; + int onebuffersize = bufferSize/PROPIX_PACKETS_PER_FRAME; + int onedatasize = PROPIX_DATA_BYTES; + + char* raw = new char[bufferSize]; + int rnel = bufferSize/(sizeof(int)); + int* retval = new int[rnel]; + int* origVal = new int[rnel]; + //all initialized to 0 + for(i=0;igetFramesCaught()){ + startAcquisitionIndex=-1; + cout<<"haven't caught any frame yet"<getStartFrameIndex();*/ + receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex); + + /**send garbage with -1 index to try again*/ + if (raw == NULL){ + startAcquisitionIndex = -1; +#ifdef VERBOSE + cout<<"data not ready for gui yet"<> PROPIX_FRAME_INDEX_OFFSET); + bindex2 = ((uint32_t)(*((uint32_t*)((char*)(raw+onebuffersize)))))+1; + pindex2 =(bindex2 & PROPIX_PACKET_INDEX_MASK); + index2 =((bindex2 & PROPIX_FRAME_INDEX_MASK) >> PROPIX_FRAME_INDEX_OFFSET); +#ifdef VERBOSE + cout << "index1:" << hex << index << endl; + cout << "index2:" << hex << index << endl; +#endif + + memcpy(origVal,raw,bufferSize); + raw=NULL; + + /*//ignore if half frame is missing + if ((bindex != 0xFFFFFFFF) && (bindex2 != 0xFFFFFFFF)){*/ + + //should be same frame + if (index == index2){ + //ideal situation (should be odd, even(index+1)) + if(!pindex){ + memcpy(retval,((char*) origVal)+4, onedatasize); + memcpy((((char*)retval)+onedatasize), ((char*) origVal)+10+onedatasize, onedatasize); + } + //swap to even,odd + else{ + memcpy((((char*)retval)+onedatasize),((char*) origVal)+4, onedatasize); + memcpy(retval, ((char*) origVal)+10+onedatasize, onedatasize); + index=index2; + } + }else + cout << "different frames caught. frame1:"<< hex << index << ":"<differentClients){ + cout << "Force update" << endl; + ret=FORCE_UPDATE; + } + + // send answer + socket->SendDataOnly(&ret,sizeof(ret)); + if(ret==FAIL){ + cout << "mess:" << mess << endl; + socket->SendDataOnly(mess,sizeof(mess)); + } + else{ + socket->SendDataOnly(fName,MAX_STR_LENGTH); + socket->SendDataOnly(&acquisitionIndex,sizeof(acquisitionIndex)); + socket->SendDataOnly(&frameIndex,sizeof(frameIndex)); + socket->SendDataOnly(retval,PROPIX_DATA_BYTES); + } + + delete [] retval; + delete [] origVal; + delete [] raw; + + return ret; +} + + + + + + + + int slsReceiverTCPIPInterface::eiger_read_frame(){