mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
compiles after merging
This commit is contained in:
parent
68b13a0ecd
commit
3eea80a121
@ -5319,7 +5319,7 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int* multiframe=new int[nel]();
|
int* multiframe=new int[nel]();
|
||||||
|
int nch;
|
||||||
|
|
||||||
volatile uint64_t dataThreadMask = 0x0;
|
volatile uint64_t dataThreadMask = 0x0;
|
||||||
|
|
||||||
@ -5395,7 +5395,7 @@ void multiSlsDetector::readFrameFromReceiver(){
|
|||||||
|
|
||||||
//send data to callback
|
//send data to callback
|
||||||
if(running){
|
if(running){
|
||||||
fdata = decodeData(multiframe);
|
fdata = decodeData(multiframe,nch);
|
||||||
if ((fdata) && (dataReady)){
|
if ((fdata) && (dataReady)){
|
||||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentFileName.c_str(),nx,ny);
|
||||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
||||||
|
@ -7663,54 +7663,54 @@ int slsDetector::resetFramesCaught(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int* slsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex, int &frameIndex, int &subFrameIndex){
|
// int* slsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex, int &frameIndex, int &subFrameIndex){
|
||||||
int fnum=F_READ_RECEIVER_FRAME;
|
// int fnum=F_READ_RECEIVER_FRAME;
|
||||||
int nel=thisDetector->dataBytes/sizeof(int);
|
// int nel=thisDetector->dataBytes/sizeof(int);
|
||||||
int* retval=new int[nel];
|
// int* retval=new int[nel];
|
||||||
int ret=FAIL;
|
// int ret=FAIL;
|
||||||
int n;
|
// int n;
|
||||||
char mess[MAX_STR_LENGTH]="Nothing";
|
// char mess[MAX_STR_LENGTH]="Nothing";
|
||||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
// if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <<nel <<std::endl;
|
// std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <<nel <<std::endl;
|
||||||
#endif
|
// #endif
|
||||||
if (connectData() == OK){
|
// if (connectData() == OK){
|
||||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
// dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
// dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
if (ret==FAIL) {
|
// if (ret==FAIL) {
|
||||||
n= dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
// n= dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||||
std::cout<< "Detector returned: " << mess << " " << n << std::endl;
|
// std::cout<< "Detector returned: " << mess << " " << n << std::endl;
|
||||||
delete [] retval;
|
// delete [] retval;
|
||||||
disconnectData();
|
// disconnectData();
|
||||||
return NULL;
|
// return NULL;
|
||||||
} else {
|
// } else {
|
||||||
n=dataSocket->ReceiveDataOnly(fName,MAX_STR_LENGTH);
|
// n=dataSocket->ReceiveDataOnly(fName,MAX_STR_LENGTH);
|
||||||
n=dataSocket->ReceiveDataOnly(&acquisitionIndex,sizeof(acquisitionIndex));
|
// n=dataSocket->ReceiveDataOnly(&acquisitionIndex,sizeof(acquisitionIndex));
|
||||||
n=dataSocket->ReceiveDataOnly(&frameIndex,sizeof(frameIndex));
|
// n=dataSocket->ReceiveDataOnly(&frameIndex,sizeof(frameIndex));
|
||||||
if(thisDetector->myDetectorType == EIGER)
|
// if(thisDetector->myDetectorType == EIGER)
|
||||||
n=dataSocket->ReceiveDataOnly(&subFrameIndex,sizeof(subFrameIndex));
|
// n=dataSocket->ReceiveDataOnly(&subFrameIndex,sizeof(subFrameIndex));
|
||||||
n=dataSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
// n=dataSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
||||||
#ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
// std::cout<< "Received "<< n << " data bytes" << std::endl;
|
||||||
#endif
|
// #endif
|
||||||
if (n!=thisDetector->dataBytes) {
|
// if (n!=thisDetector->dataBytes) {
|
||||||
std::cout<<endl<< "wrong data size received: received " << n << " but expected from receiver " << thisDetector->dataBytes << std::endl;
|
// std::cout<<endl<< "wrong data size received: received " << n << " but expected from receiver " << thisDetector->dataBytes << std::endl;
|
||||||
ret=FAIL;
|
// ret=FAIL;
|
||||||
delete [] retval;
|
// delete [] retval;
|
||||||
disconnectData();
|
// disconnectData();
|
||||||
return NULL; }
|
// return NULL; }
|
||||||
//jungfrau masking adcval
|
// //jungfrau masking adcval
|
||||||
if(thisDetector->myDetectorType == JUNGFRAU){
|
// if(thisDetector->myDetectorType == JUNGFRAU){
|
||||||
for(unsigned int i=0;i<nel;i++){
|
// for(unsigned int i=0;i<nel;i++){
|
||||||
retval[i] = (retval[i] & 0x3FFF3FFF);
|
// retval[i] = (retval[i] & 0x3FFF3FFF);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
disconnectData();
|
// disconnectData();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return retval;
|
// return retval;
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -508,8 +508,8 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
|||||||
|
|
||||||
/** Reads frames from receiver through a constant socket
|
/** Reads frames from receiver through a constant socket
|
||||||
*/
|
*/
|
||||||
virtual int* readFrameFromReceiver(char* fName, int &acquisitionIndex, int &frameIndex, int &subFrameIndex)=0;
|
// virtual int* readFrameFromReceiver(char* fName, int &acquisitionIndex, int &frameIndex, int &subFrameIndex)=0;
|
||||||
|
virtual void readFrameFromReceiver()=0;
|
||||||
|
|
||||||
/** Sets the read receiver frequency
|
/** Sets the read receiver frequency
|
||||||
if data required from receiver randomly readRxrFrequency=0,
|
if data required from receiver randomly readRxrFrequency=0,
|
||||||
|
@ -501,27 +501,27 @@ void* postProcessing::processData(int delflag) {
|
|||||||
else{
|
else{
|
||||||
|
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
// //cprintf(RED,"In post processing threads\n");
|
//cprintf(RED,"In post processing threads\n");
|
||||||
|
|
||||||
|
|
||||||
// if(dataReady){
|
if(dataReady){
|
||||||
// readFrameFromReceiver();
|
readFrameFromReceiver();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //only update progress
|
//only update progress
|
||||||
// else{
|
else{
|
||||||
// int caught = -1;
|
int caught = -1;
|
||||||
// char c;
|
char c;
|
||||||
// int ifp;
|
int ifp;
|
||||||
// while(true){
|
while(true){
|
||||||
|
|
||||||
// //cout.flush();
|
//cout.flush();
|
||||||
// //cout<<flush;
|
//cout<<flush;
|
||||||
// usleep(100 * 1000); //20ms need this else connecting error to receiver (too fast)
|
usleep(100 * 1000); //20ms need this else connecting error to receiver (too fast)
|
||||||
|
|
||||||
// if (checkJoinThread()){
|
if (checkJoinThread()){
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -536,55 +536,14 @@ void* postProcessing::processData(int delflag) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// //get progress
|
|
||||||
// pthread_mutex_lock(&mg);
|
|
||||||
// if(setReceiverOnline() == ONLINE_FLAG){
|
|
||||||
// caught = getFramesCaughtByReceiver();
|
|
||||||
// }
|
|
||||||
// pthread_mutex_unlock(&mg);
|
|
||||||
|
|
||||||
|
|
||||||
// //updating progress
|
|
||||||
// if(caught!= -1){
|
|
||||||
// setCurrentProgress(caught);
|
|
||||||
// #ifdef VERY_VERY_DEBUG
|
|
||||||
// cout << "caught:" << caught << endl;
|
|
||||||
// #endif
|
|
||||||
// }
|
|
||||||
// if (checkJoinThread()){
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//cout<<"exiting from proccessing thread"<<endl;
|
|
||||||
int progress = 0;
|
|
||||||
char currentfName[MAX_STR_LENGTH]="";
|
|
||||||
int caught = -1;
|
|
||||||
int currentAcquisitionIndex = -1;
|
|
||||||
int currentFrameIndex = -1;
|
|
||||||
int currentSubFrameIndex = -1;
|
|
||||||
bool newData = false;
|
|
||||||
int nthframe = setReadReceiverFrequency(0);
|
|
||||||
int nx =getTotalNumberOfChannels(slsDetectorDefs::X);
|
|
||||||
int ny =getTotalNumberOfChannels(slsDetectorDefs::Y);
|
|
||||||
int nn;
|
|
||||||
#ifdef VERBOSE
|
|
||||||
std::cout << "receiver read freq:" << nthframe << std::endl;
|
|
||||||
#endif
|
|
||||||
//repeat forever until joined by the calling thread
|
|
||||||
while(1){
|
|
||||||
cout.flush();
|
|
||||||
//cout<<flush;
|
|
||||||
usleep(20000); //20ms need this else connecting error to receiver (too fast)
|
|
||||||
//get progress
|
//get progress
|
||||||
if(setReceiverOnline() == ONLINE_FLAG){
|
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
|
if(setReceiverOnline() == ONLINE_FLAG){
|
||||||
caught = getFramesCaughtByReceiver();
|
caught = getFramesCaughtByReceiver();
|
||||||
pthread_mutex_unlock(&mg); }
|
}
|
||||||
|
pthread_mutex_unlock(&mg);
|
||||||
|
|
||||||
|
|
||||||
//updating progress
|
//updating progress
|
||||||
if(caught!= -1){
|
if(caught!= -1){
|
||||||
setCurrentProgress(caught);
|
setCurrentProgress(caught);
|
||||||
@ -592,128 +551,15 @@ void* postProcessing::processData(int delflag) {
|
|||||||
cout << "caught:" << caught << endl;
|
cout << "caught:" << caught << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
//detector acquistion done, wait for all frames received
|
|
||||||
if(acquiringDone > 0){
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
if(acquiringDone == 1)
|
|
||||||
cout << "acquiring seems to be done" << endl;
|
|
||||||
#endif
|
|
||||||
//IF GUI, check for last frames (counter upto 5)
|
|
||||||
if(dataReady){
|
|
||||||
pthread_mutex_lock(&mg);
|
|
||||||
acquiringDone++;
|
|
||||||
pthread_mutex_unlock(&mg);
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "acquiringDone :" << acquiringDone << endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
//post to stopReceiver in acquire(), but continue reading frames
|
|
||||||
if (!dataReady || (acquiringDone >= 5)){
|
|
||||||
if(!dataReady || (!nthframe) ||(!newData)){
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "gonna post for it to end" << endl;
|
|
||||||
#endif
|
|
||||||
sem_post(&sem_queue);
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "Sem posted" << endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//random reads and for nthframe, checks if there is no new data
|
|
||||||
else if((!nthframe) ||(!newData)){
|
|
||||||
//cout <<"cecking now" << endl;
|
|
||||||
if (checkJoinThread()){
|
if (checkJoinThread()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//for random reads, ask only if it has new data
|
|
||||||
if(!newData){
|
|
||||||
if(caught > progress){
|
|
||||||
newData = true; // If new data and acquiringDone>0 (= det acq over), reset to get more frames
|
|
||||||
if(dataReady && (acquiringDone > 0)){
|
|
||||||
pthread_mutex_lock(&mg);
|
|
||||||
acquiringDone = 1;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "Keeping acquiringDone at 1 " << endl;
|
|
||||||
#endif
|
|
||||||
pthread_mutex_unlock(&mg);
|
|
||||||
}
|
|
||||||
} }
|
|
||||||
|
|
||||||
if(newData){
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "new data" << endl;
|
|
||||||
#endif
|
|
||||||
//no gui
|
|
||||||
if (!dataReady){
|
|
||||||
progress = caught;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "progress:" << progress << endl;
|
|
||||||
#endif
|
|
||||||
newData = false;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "newData set to false" << endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
//gui
|
|
||||||
else{
|
|
||||||
if(setReceiverOnline()==ONLINE_FLAG){
|
|
||||||
//get data
|
|
||||||
strcpy(currentfName,"");
|
|
||||||
pthread_mutex_lock(&mg);
|
|
||||||
//int* receiverData = new int [getTotalNumberOfChannels()];
|
|
||||||
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex);
|
|
||||||
pthread_mutex_unlock(&mg);
|
|
||||||
|
|
||||||
//if detector returned null
|
|
||||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
|
||||||
receiverData = NULL;
|
|
||||||
|
|
||||||
//no data or wrong data for print out
|
|
||||||
if(receiverData == NULL){
|
|
||||||
currentAcquisitionIndex = -1;
|
|
||||||
cout<<"****Detector Data returned is NULL***"<<endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// garbage frame
|
|
||||||
if(currentAcquisitionIndex < 0){
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
|
|
||||||
#endif
|
|
||||||
if(receiverData)
|
|
||||||
delete [] receiverData;
|
|
||||||
}
|
|
||||||
//not garbage frame
|
|
||||||
else{// if (currentAcquisitionIndex > progress){
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "GOT data" << endl;
|
|
||||||
#endif
|
|
||||||
fdata = decodeData(receiverData, nn);
|
|
||||||
delete [] receiverData;
|
|
||||||
if ((fdata) && (dataReady)){
|
|
||||||
// cout << "DATAREADY 3" << endl;
|
|
||||||
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,nx,ny);
|
|
||||||
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
|
|
||||||
delete thisData;
|
|
||||||
fdata = NULL;
|
|
||||||
progress = caught;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "progress:" << progress << endl;
|
|
||||||
#endif
|
|
||||||
newData = false;
|
|
||||||
#ifdef VERY_VERY_DEBUG
|
|
||||||
cout << "newData set to false" << endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//cprintf(RED,"Exiting post processing thread\n");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user