diff --git a/slsDetectorCalibration/eigerHalfModuleData.h b/slsDetectorCalibration/eigerHalfModuleData.h index 381456a54..3b698c966 100644 --- a/slsDetectorCalibration/eigerHalfModuleData.h +++ b/slsDetectorCalibration/eigerHalfModuleData.h @@ -172,7 +172,7 @@ public: \returns frame number */ int getFrameNumber(char *buff){ - return(*(unsigned int*)(((eiger_packet_header *)((char*)buff))->num1)); + return(*(unsigned int*)(((eiger_packet_header *)((char*)buff))->num1)); }; diff --git a/slsDetectorCalibration/slsReceiverData.h b/slsDetectorCalibration/slsReceiverData.h index 15d324ef6..505d9264a 100644 --- a/slsDetectorCalibration/slsReceiverData.h +++ b/slsDetectorCalibration/slsReceiverData.h @@ -162,6 +162,61 @@ public: }; + /** + + Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! + \param filebin input file stream (binary) + \param fnum frame number of frame returned + \returns pointer to the first packet of the last good frame, NULL if no frame is found or last frame is incomplete + + */ + + virtual char *readNextFrame(ifstream &filebin, int& fnum) { + char *data=new char[packetSize*nPackets]; + char *retval=0; + int np=0, nd; + fnum = -1; + + if (filebin.is_open()) { + while (filebin.read(data+np*packetSize,packetSize)) { + + if (np==(nPackets-1)) { + + fnum=getFrameNumber(data); cout << "fnum:"<nPackets) { + cout << "too many packets!!!!!!!!!!" << endl; + delete [] data; + return NULL; + } else if (retval!=NULL) { + // cout << "+" << endl;; + for (int ip=0; ipnPackets) { + cout << "*******too many packets!!!!!!!!!!" << endl; + delete [] data; + return NULL; + } else { + // cout << "." << endl;; + np++; + } + } + } + delete [] data; + return NULL; + }; + + private: const int nPackets; /**