mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
included subframe into receiver and sends to gui
This commit is contained in:
@ -297,11 +297,10 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* Returns the buffer-current frame read by receiver
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
void readFrame(char* c,char** raw, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
@ -359,7 +358,7 @@ protected:
|
||||
* Copy frames to gui
|
||||
* uses semaphore for nth frame mode
|
||||
*/
|
||||
void copyFrameToGui(char* startbuf[], uint32_t fnum=-1, char* buf=NULL);
|
||||
void copyFrameToGui(char* startbuf[], char* buf=NULL);
|
||||
|
||||
/**
|
||||
* creates udp sockets
|
||||
@ -483,6 +482,7 @@ protected:
|
||||
//// Could be done more fine-grained... TODO
|
||||
// private:
|
||||
protected:
|
||||
|
||||
/** structure of an eiger packet*/
|
||||
typedef struct
|
||||
{
|
||||
@ -643,9 +643,6 @@ protected:
|
||||
/** points to the filename to send to gui */
|
||||
char* guiFileName;
|
||||
|
||||
/** temporary number for eiger frame number as its not included in the packet */
|
||||
uint32_t guiFrameNumber;
|
||||
|
||||
/** send every nth frame to gui or only upon gui request*/
|
||||
int nFrameToGui;
|
||||
|
||||
|
@ -338,11 +338,10 @@ class UDPInterface {
|
||||
* Returns the buffer-current frame read by receiver
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex)=0;
|
||||
virtual void readFrame(char* c,char** raw, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex)=0;
|
||||
|
||||
/** set status to transmitting and
|
||||
* when fifo is empty later, sets status to run_finished
|
||||
|
@ -294,11 +294,10 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
* Returns the buffer-current frame read by receiver
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
void readFrame(char* c,char** raw, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
@ -356,7 +355,7 @@ private:
|
||||
* Copy frames to gui
|
||||
* uses semaphore for nth frame mode
|
||||
*/
|
||||
void copyFrameToGui(char* startbuf[], uint32_t fnum=-1, char* buf=NULL);
|
||||
void copyFrameToGui(char* startbuf[], char* buf=NULL);
|
||||
|
||||
/**
|
||||
* creates udp sockets
|
||||
|
@ -567,7 +567,7 @@ void UDPBaseImplementation::setupFifoStructure(){ FILE_LOG(logDEBUG) << __AT__ <
|
||||
|
||||
|
||||
/** acquisition functions */
|
||||
void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){
|
||||
void UDPBaseImplementation::readFrame(char* c,char** raw,uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
//point to gui data
|
||||
if (guiData == NULL){
|
||||
@ -576,7 +576,6 @@ void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32
|
||||
|
||||
//copy data and filename
|
||||
strcpy(c,guiFileName);
|
||||
fnum = guiFrameNumber;
|
||||
startAcquisitionIndex = getStartAcquisitionIndex();
|
||||
startFrameIndex = getStartFrameIndex();
|
||||
|
||||
@ -601,55 +600,8 @@ void UDPBaseImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32
|
||||
|
||||
|
||||
|
||||
void UDPBaseImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
void UDPBaseImplementation::copyFrameToGui(char* startbuf[], char* buf){ FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
//random read when gui not ready
|
||||
if((!nFrameToGui) && (!guiData)){
|
||||
pthread_mutex_lock(&dataReadyMutex);
|
||||
guiDataReady=0;
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
}
|
||||
|
||||
//random read or nth frame read, gui needs data now or it is the first frame
|
||||
else{
|
||||
/*
|
||||
//nth frame read, block current process if the guireader hasnt read it yet
|
||||
if(nFrameToGui)
|
||||
sem_wait(&smp);
|
||||
*/
|
||||
pthread_mutex_lock(&dataReadyMutex);
|
||||
guiDataReady=0;
|
||||
//eiger
|
||||
if(startbuf != NULL){
|
||||
int offset = 0;
|
||||
int size = frameSize/EIGER_MAX_PORTS;
|
||||
for(int j=0;j<numListeningThreads;++j){
|
||||
memcpy((((char*)latestData)+offset) ,startbuf[j] + (HEADER_SIZE_NUM_TOT_PACKETS + EIGER_HEADER_LENGTH),size);
|
||||
offset += size;
|
||||
}
|
||||
|
||||
/*
|
||||
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*)(startbuf[1] + HEADER_SIZE_NUM_TOT_PACKETS+ EIGER_HEADER_LENGTH+8+ i))))<<endl;
|
||||
cout<<"startbuf:"<<dec<<i<<hex<<":\t0x"<<((uint16_t)(*((uint16_t*)(startbuf[1] + 2+ 48+ j*1040+8+ i))))<<endl;
|
||||
*/
|
||||
|
||||
|
||||
guiFrameNumber = fnum;
|
||||
}else//other detectors
|
||||
memcpy(latestData,buf,bufferSize);
|
||||
|
||||
|
||||
strcpy(guiFileName,savefilename);
|
||||
guiDataReady=1;
|
||||
pthread_mutex_unlock(&dataReadyMutex);
|
||||
|
||||
//nth frame read, block current process if the guireader hasnt read it yet
|
||||
if(nFrameToGui)
|
||||
sem_wait(&smp);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -880,7 +832,7 @@ int UDPBaseImplementation::setupWriter(){ FILE_LOG(logDEBUG) << __AT__ << " star
|
||||
guiData = NULL;
|
||||
guiDataReady=0;
|
||||
strcpy(guiFileName,"");
|
||||
guiFrameNumber = 0;
|
||||
|
||||
cbAction = DO_EVERYTHING;
|
||||
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
@ -1797,7 +1749,7 @@ void UDPBaseImplementation::handleDataCompression(int ithread, char* wbuffer[],
|
||||
|
||||
#endif
|
||||
if(!once){
|
||||
copyFrameToGui(NULL,-1,buff);
|
||||
copyFrameToGui(NULL,buff);
|
||||
once = 1;
|
||||
}
|
||||
}
|
||||
|
@ -30,20 +30,11 @@ using namespace std;
|
||||
#define WRITE_HEADERS
|
||||
|
||||
|
||||
UDPStandardImplementation::UDPStandardImplementation()
|
||||
//:
|
||||
//thread_started(0),
|
||||
//eth(NULL),
|
||||
//latestData(NULL),
|
||||
//guiFileName(NULL),
|
||||
//guiFrameNumber(0),
|
||||
//tengigaEnable(0)
|
||||
{
|
||||
UDPStandardImplementation::UDPStandardImplementation(){
|
||||
thread_started = 0;
|
||||
eth = NULL;
|
||||
latestData = NULL;
|
||||
guiFileName = NULL;
|
||||
guiFrameNumber = NULL;
|
||||
tengigaEnable = 0;
|
||||
footer_offset = 0;
|
||||
for(int i=0;i<MAX_NUM_LISTENING_THREADS;i++){
|
||||
@ -173,7 +164,6 @@ void UDPStandardImplementation::initializeMembers(){
|
||||
latestData = NULL;
|
||||
guiFileName = NULL;
|
||||
guiData = NULL;
|
||||
guiFrameNumber = 0;
|
||||
sfilefd = NULL;
|
||||
cmSub = NULL;
|
||||
|
||||
@ -929,7 +919,7 @@ void UDPStandardImplementation::setupFifoStructure(){
|
||||
|
||||
|
||||
/** acquisition functions */
|
||||
void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){
|
||||
void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
//point to gui data
|
||||
if (guiData == NULL){
|
||||
@ -941,7 +931,6 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
||||
|
||||
//copy data and filename
|
||||
strcpy(c,guiFileName);
|
||||
fnum = guiFrameNumber;
|
||||
startAcquisitionIndex = getStartAcquisitionIndex();
|
||||
startFrameIndex = getStartFrameIndex();
|
||||
|
||||
@ -982,7 +971,7 @@ void UDPStandardImplementation::readFrame(char* c,char** raw, uint32_t &fnum, ui
|
||||
|
||||
|
||||
|
||||
void UDPStandardImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){
|
||||
void UDPStandardImplementation::copyFrameToGui(char* startbuf[], char* buf){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "copyframe" << endl;
|
||||
@ -1011,10 +1000,10 @@ cout << "copyframe" << endl;
|
||||
#endif
|
||||
//eiger
|
||||
if(startbuf != NULL){
|
||||
|
||||
for(int j=0;j<packetsPerFrame;++j)
|
||||
memcpy((((char*)latestData)+j * onePacketSize) ,startbuf[j],onePacketSize);
|
||||
|
||||
guiFrameNumber = fnum;
|
||||
}else//other detectors
|
||||
memcpy(latestData,buf,bufferSize);
|
||||
|
||||
@ -1298,7 +1287,6 @@ int UDPStandardImplementation::setupWriter(){
|
||||
guiData = NULL;
|
||||
guiDataReady=0;
|
||||
strcpy(guiFileName,"");
|
||||
guiFrameNumber = 0;
|
||||
cbAction = DO_EVERYTHING;
|
||||
|
||||
pthread_mutex_lock(&status_mutex);
|
||||
@ -2981,7 +2969,7 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
|
||||
#ifdef VERYDEBUG
|
||||
cprintf(GREEN,"gonna copy frame\n");
|
||||
#endif
|
||||
copyFrameToGui(wbuffer,currframenum);
|
||||
copyFrameToGui(wbuffer);
|
||||
#ifdef VERYDEBUG
|
||||
cprintf(GREEN,"copied frame\n");
|
||||
#endif
|
||||
@ -2989,7 +2977,7 @@ void UDPStandardImplementation::handleWithoutDataCompression(int ithread, char*
|
||||
//copy to gui
|
||||
if(npackets >= packetsPerFrame){//min 1 frame, but neednt be
|
||||
//if(npackets == packetsPerFrame * numJobsPerThread){ //only full frames
|
||||
copyFrameToGui(NULL,-1,wbuffer[0]+HEADER_SIZE_NUM_TOT_PACKETS);
|
||||
copyFrameToGui(NULL,wbuffer[0]+HEADER_SIZE_NUM_TOT_PACKETS);
|
||||
#ifdef VERYVERBOSE
|
||||
cout << ithread << " finished copying" << endl;
|
||||
#endif
|
||||
@ -3087,7 +3075,7 @@ void UDPStandardImplementation::handleDataCompression(int ithread, char* wbuffer
|
||||
|
||||
#endif
|
||||
if(!once){
|
||||
copyFrameToGui(NULL,-1,buff);
|
||||
copyFrameToGui(NULL,buff);
|
||||
once = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
|
||||
uint32_t startAcquisitionIndex=0;
|
||||
uint32_t startFrameIndex=0;
|
||||
uint32_t index = 0,bindex = 0, offset=0;
|
||||
uint32_t index = -1,bindex = 0, offset=0;
|
||||
|
||||
strcpy(mess,"Could not read frame\n");
|
||||
|
||||
@ -1088,7 +1088,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
||||
else{
|
||||
ret = OK;
|
||||
/*startIndex=receiverBase->getStartFrameIndex();*/
|
||||
receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex);
|
||||
receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex);
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if (raw == NULL){
|
||||
@ -1253,7 +1253,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
char* raw = new char[bufferSize];
|
||||
|
||||
|
||||
uint32_t index=0,index2=0;
|
||||
uint32_t index=-1,index2=0;
|
||||
uint32_t pindex=0,pindex2=0;
|
||||
uint32_t bindex=0,bindex2=0;
|
||||
uint32_t startAcquisitionIndex=0;
|
||||
@ -1277,7 +1277,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
||||
}else{
|
||||
ret = OK;
|
||||
/*startIndex=receiverBase->getStartFrameIndex();*/
|
||||
receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex);
|
||||
receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex);
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if (raw == NULL){
|
||||
@ -1429,7 +1429,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
|
||||
for(i=0;i<rnel;i++) origVal[i]=0;
|
||||
|
||||
|
||||
uint32_t index=0,index2=0;
|
||||
uint32_t index=-1,index2=0;
|
||||
uint32_t pindex=0,pindex2=0;
|
||||
uint32_t bindex=0,bindex2=0;
|
||||
uint32_t startAcquisitionIndex=0;
|
||||
@ -1453,7 +1453,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
|
||||
}else{
|
||||
ret = OK;
|
||||
/*startIndex=receiverBase->getStartFrameIndex();*/
|
||||
receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex);
|
||||
receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex);
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if (raw == NULL){
|
||||
@ -1567,16 +1567,36 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
|
||||
|
||||
int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
ret=OK;
|
||||
|
||||
/** structure of an eiger packet*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char subframenum[4];
|
||||
unsigned char missingpacket[2];
|
||||
unsigned char portnum[1];
|
||||
unsigned char dynamicrange[1];
|
||||
} eiger_packet_header_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char framenum[6];
|
||||
unsigned char packetnum[2];
|
||||
} eiger_packet_footer_t;
|
||||
|
||||
|
||||
char fName[MAX_STR_LENGTH]="";
|
||||
int acquisitionIndex = -1;
|
||||
int frameIndex= -1;
|
||||
uint32_t index=0;
|
||||
uint32_t subframenumber=-1;
|
||||
|
||||
int frameSize = EIGER_ONE_GIGA_ONE_PACKET_SIZE * packetsPerFrame;
|
||||
int dataSize = EIGER_ONE_GIGA_ONE_DATA_SIZE * packetsPerFrame;
|
||||
int oneDataSize = EIGER_ONE_GIGA_ONE_DATA_SIZE;
|
||||
if(tenGigaEnable){
|
||||
frameSize = EIGER_TEN_GIGA_ONE_PACKET_SIZE * packetsPerFrame;
|
||||
dataSize = EIGER_TEN_GIGA_ONE_DATA_SIZE * packetsPerFrame;
|
||||
oneDataSize = EIGER_TEN_GIGA_ONE_DATA_SIZE;
|
||||
}
|
||||
char* raw = new char[frameSize];
|
||||
char* origVal = new char[frameSize];
|
||||
@ -1605,10 +1625,8 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
else{
|
||||
ret = OK;
|
||||
/** read a frame */
|
||||
receiverBase->readFrame(fName,&raw,index,startAcquisitionIndex,startFrameIndex);
|
||||
#ifdef VERBOSE
|
||||
cout << "index:" << dec << index << endl;
|
||||
#endif
|
||||
receiverBase->readFrame(fName,&raw,startAcquisitionIndex,startFrameIndex);
|
||||
|
||||
/**send garbage with -1 index to try again*/
|
||||
if (raw == NULL){
|
||||
startAcquisitionIndex = -1;
|
||||
@ -1620,6 +1638,21 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
/**proper frame*/
|
||||
else{//cout<<"**** got proper frame ******"<<endl;
|
||||
|
||||
eiger_packet_footer_t* wbuf_footer;
|
||||
wbuf_footer = (eiger_packet_footer_t*)(raw + oneDataSize + sizeof(eiger_packet_header_t));
|
||||
index =(uint32_t)(*( (uint64_t*) wbuf_footer));
|
||||
index += (startFrameIndex-1);
|
||||
if(dynamicrange == 32){
|
||||
eiger_packet_header_t* wbuf_header;
|
||||
wbuf_header = (eiger_packet_header_t*) raw;
|
||||
subframenumber = *( (uint32_t*) wbuf_header->subframenum);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "index:" << dec << index << endl;
|
||||
cout << "subframenumber:" << dec << subframenumber << endl;
|
||||
#endif
|
||||
|
||||
memcpy(origVal,raw,frameSize);
|
||||
raw=NULL;
|
||||
|
||||
@ -1740,6 +1773,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
cout << "index:" << index << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
cout << "subframenumber:" << subframenumber << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1751,6 +1785,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
cout << "frameIndex:" << frameIndex << endl;
|
||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex << endl;
|
||||
cout << "startFrameIndex:" << startFrameIndex << endl;
|
||||
cout << "subframenumber:" << subframenumber << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1773,6 +1808,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
socket->SendDataOnly(fName,MAX_STR_LENGTH);
|
||||
socket->SendDataOnly(&acquisitionIndex,sizeof(acquisitionIndex));
|
||||
socket->SendDataOnly(&frameIndex,sizeof(frameIndex));
|
||||
socket->SendDataOnly(&subframenumber,sizeof(subframenumber));
|
||||
socket->SendDataOnly(retval,dataSize);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user