gotthard receiver works so far without cpu file write and tcp generic socket lock

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@337 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2012-11-12 15:48:28 +00:00
parent 6ee21ba810
commit 8f7872d056
21 changed files with 516 additions and 344 deletions

View File

@ -80,36 +80,50 @@ int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){
int fileIO::writeDataFile(void *data, int iframe) {
if (iframe>=0)
frameIndex=iframe;
cout <<"iframe " << iframe << endl;
if (*framesPerFile<2)
frameIndex=-1;
if (iframe<0)
iframe=frameIndex;
//if (iframe>=0)
// frameIndex=iframe;
if ((frameIndex%(*framesPerFile))==0 || (frameIndex<0)) {
createFileName();
filefd = fopen(currentFileName.c_str(), "w");
}
if (filefd){
if (iframe%(*framesPerFile)) {
fileIOStatic::writeBinaryDataFile(filefd,getDataBytes() , data);
frameIndex++;
}
}
if ((frameIndex%(*framesPerFile)==0) || (frameIndex<0)) {
if (filefd)
fclose(filefd);
filefd=NULL;
}
if ((*framesPerFile)<2)
iframe=-1;
//frameIndex=-1;
if ((iframe%(*framesPerFile))==0 || (iframe<0)) {
//if ((frameIndex%(*framesPerFile))==0 || (frameIndex<0)) {
createFileName();
filefd = fopen((currentFileName+string(".raw")).c_str(), "w");
}
if (filefd){
//if (iframe%(*framesPerFile)) {
/*if(setDynamicRange(-1)==16){
fileIOStatic::writeBinaryDataFile(filefd,getDataBytes()*2, data);
frameIndex+=2;
}
else{*/
fileIOStatic::writeBinaryDataFile(filefd,getDataBytes(), data);cout<<"write frameIndex:"<<iframe<<endl;
//}
iframe++;
//frameIndex++;
//}
}
if ((iframe%(*framesPerFile)==0) || (iframe<0)) {
//if ((frameIndex%(*framesPerFile)==0) || (frameIndex<0)) {
if (filefd)
fclose(filefd);
filefd=NULL;
}
return 0;
}
int fileIO::closeDataFile() {
int fileIO::closeDataFile() {fflush(stdout);
if (filefd)
fclose(filefd);
filefd=NULL;
return 0;
}

View File

@ -14,7 +14,7 @@ postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL)
mp=mp1;
pthread_mutex_init(&mp, NULL);
// mg=mp1;
// pthread_mutex_init(&mg, NULL);
// pthread_mutex_init(&mg, NULL);
//cout << "reg callback "<< endl;
dataReady = 0;
pCallbackArg = 0;
@ -65,14 +65,14 @@ void postProcessing::processFrame(int *myData, int delflag) {
/** decode data */
if (getDetectorsType()==MYTHEN) {
// if (getDetectorsType()==MYTHEN) {
fdata=decodeData(myData, fdata);
#ifdef VERBOSE
cout << "decode"<< endl;
#endif
} else
fdata=NULL;
//} else
// fdata=NULL;
if (rawDataReady) {
//#ifdef VERBOSE
@ -85,36 +85,36 @@ void postProcessing::processFrame(int *myData, int delflag) {
//#endif
} else {
pthread_mutex_lock(&mp);
fname=createFileName();
pthread_mutex_unlock(&mp);
#ifdef VERBOSE
cout << "fname is " << fname << endl;
#endif
//Checking for write flag
if((*correctionMask)&(1<<WRITE_FILE)) {
#ifdef VERBOSE
cout << "writing raw data " << endl;
#endif
if (fdata) {
if (getDetectorsType()==MYTHEN){
// if (fdata) {
//uses static function?!?!?!?
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
} else {
writeDataFile ((void*)myData);
writeDataFile ((void*)myData, frameIndex);
}
#ifdef VERBOSE
cout << "done " << endl;
#endif
}
}
if ((*correctionMask) & ~(1<<WRITE_FILE)) {
doProcessing(fdata,delflag, fname);
} else
if (dataReady) {
} else
if (dataReady){
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
dataReady(thisData, pCallbackArg);
delete thisData;
@ -131,6 +131,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
incrementFrameIndex();
delete [] myData;
if (fdata)
delete [] fdata;
@ -151,7 +152,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
#ifdef VERBOSE
cout << "process frame returning " << endl;
#endif
}
@ -374,26 +375,35 @@ void* postProcessing::processData(int delflag) {
}
//receiver
else{
int prevCaught=getCurrentFrameIndex();
int caught=0;
while(getRunStatus()!=IDLE){
caught=getCurrentFrameIndex();
incrementProgress(caught-prevCaught);
prevCaught=caught;
usleep(1000000);
if(progress_call)
progress_call(getCurrentProgress(),pProgressCallArg);
}
/*
if (dataReady) {
// can add get frame from receiver and send it to GUI
thisData=new detectorData(val,err,ang,getCurrentProgress(),(fname+ext).c_str(),np);
dataReady(thisData, pCallbackArg);
delete thisData;
}
*/
int prevCaught=getCurrentFrameIndex();
int caught=0;
while(1){
if (checkJoinThread()) break;
usleep(200000);
caught=getCurrentFrameIndex();
incrementProgress(caught-prevCaught);
prevCaught=caught;
if (checkJoinThread()) break;
//if(progress_call)
// progress_call(getCurrentProgress(),pProgressCallArg);
int* receiverData = readFrameFromReceiver();
if(!receiverData)
return 0;
fdata=decodeData(receiverData);
delete [] receiverData;
if(fdata){
if (dataReady) {
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(getCurrentFileName()+string(".raw")).c_str(),getTotalNumberOfChannels());
dataReady(thisData, pCallbackArg);
delete thisData;
fdata=NULL;
}
}
}
}
return 0;
}

View File

@ -323,6 +323,7 @@ s
int arraySize;
void setReceiverAcquiring(int acq){receiverAcquiring=acq;};
private:
double *fdata;
@ -348,7 +349,7 @@ s
int numberOfChannels;
int receiverAcquiring;