mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 00:00:02 +02:00
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:
parent
6ee21ba810
commit
8f7872d056
@ -340,7 +340,7 @@ enum communicationProtocol{
|
||||
socketDescriptor=-1;
|
||||
}
|
||||
file_des=-1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
#define MAXMODS 24
|
||||
/** maxmimum number of detectors ina multidetector structure*/
|
||||
#define MAXDET 100
|
||||
/** header length for data :gotthard*/
|
||||
#define HEADERLENGTH 12
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
@ -503,6 +505,8 @@ enum angleConversionParameter {
|
||||
SAMPLE_Y /**< sample displacement orthogonal to the beam */
|
||||
};
|
||||
|
||||
|
||||
|
||||
//typedef struct {
|
||||
//float center; /**< center of the module (channel at which the radius is perpendicular to the module surface) */
|
||||
//float ecenter; /**< error in the center determination */
|
||||
|
@ -124,7 +124,9 @@ enum {
|
||||
|
||||
F_LOCK_RECEIVER, /**< locks receiver */
|
||||
|
||||
F_GET_FRAME_INDEX /**< gets the frame index */
|
||||
F_GET_FRAME_INDEX, /**< gets the frame index */
|
||||
|
||||
F_RESET_FRAMES_CAUGHT /**< resets the frames caught */
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
@ -1939,7 +1939,7 @@ int read_frame(int file_des) {
|
||||
return OK;
|
||||
} else {
|
||||
//might add delay????
|
||||
if(getFrames()>-2) {printf("in hereeee: frames:%d\n",getFrames());
|
||||
if(getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||
printf("%s\n",mess);
|
||||
|
@ -123,7 +123,8 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
strcpy(thisMultiDetector->fileName,"run");
|
||||
/** set fileIndex to default to 0*/
|
||||
thisMultiDetector->fileIndex=0;
|
||||
|
||||
/** set frames per file to default to 1*/
|
||||
thisMultiDetector->framesPerFile=1;
|
||||
|
||||
/** set progress Index to default to 0*/
|
||||
thisMultiDetector->progressIndex=0;
|
||||
@ -229,7 +230,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
||||
filePath=thisMultiDetector->filePath;
|
||||
fileName=thisMultiDetector->fileName;
|
||||
fileIndex=&thisMultiDetector->fileIndex;
|
||||
|
||||
framesPerFile=&thisMultiDetector->framesPerFile;
|
||||
|
||||
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
@ -3714,6 +3715,52 @@ int multiSlsDetector::getCurrentFrameIndex() {
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::resetFramesCaught(int index) {
|
||||
int ret=-100, ret1;
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++){
|
||||
if (detectors[i]){
|
||||
ret1=detectors[i]->resetFramesCaught(index);
|
||||
if (ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int* multiSlsDetector::readFrameFromReceiver(){
|
||||
int nel=(thisMultiDetector->dataBytes)/sizeof(int);
|
||||
int n;
|
||||
int* retval=new int[nel];
|
||||
int *retdet, *p=retval;
|
||||
|
||||
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||
if (detectors[id]) {
|
||||
retdet=detectors[id]->readFrameFromReceiver();
|
||||
if (retdet) {
|
||||
n=detectors[id]->getDataBytes();
|
||||
memcpy(p,retdet,n);
|
||||
delete [] retdet;
|
||||
p+=n/sizeof(int);
|
||||
}else {
|
||||
#ifdef VERBOSE
|
||||
cout << "Receiver for detector " << id << " does not have data left " << endl;
|
||||
#endif
|
||||
delete [] retval;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::lockReceiver(int lock) {
|
||||
|
||||
int ret=-100, ret1;
|
||||
|
@ -111,6 +111,8 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
char fileName[MAX_STR_LENGTH];
|
||||
/** path of the output files */
|
||||
char filePath[MAX_STR_LENGTH];
|
||||
/** max frames per file */
|
||||
int framesPerFile;
|
||||
|
||||
/** corrections to be applied to the data \see ::correctionFlags */
|
||||
int correctionMask;
|
||||
@ -1084,6 +1086,17 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
int getCurrentFrameIndex();
|
||||
|
||||
/**
|
||||
* resets framescaught
|
||||
* @param index frames caught by receiver
|
||||
* @param index if frame index is needed
|
||||
*/
|
||||
int resetFramesCaught(int index=-1);
|
||||
|
||||
/**
|
||||
/returns a frame read from recever
|
||||
*/
|
||||
int* readFrameFromReceiver();
|
||||
|
||||
/** Locks/Unlocks the connection to the receiver
|
||||
/param lock sets (1), usets (0), gets (-1) the lock
|
||||
|
@ -442,7 +442,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(int id) {
|
||||
int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
char *goff;
|
||||
goff=(char*)thisDetector;
|
||||
|
||||
|
||||
// cout << "init detector size" << endl;
|
||||
|
||||
/** if the shared memory has newly be created, initialize the detector variables */
|
||||
@ -674,6 +674,9 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
filePath=thisDetector->filePath;
|
||||
fileName=parentDet->fileName;
|
||||
fileIndex=parentDet->fileIndex;
|
||||
framesPerFile=parentDet->framesPerFile;
|
||||
if(thisDetector->myDetectorType==GOTTHARD)
|
||||
setFramesPerFile(20000);
|
||||
|
||||
thisReceiver = new receiverInterface(dataSocket);
|
||||
|
||||
@ -3946,7 +3949,7 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){
|
||||
};
|
||||
|
||||
double* slsDetector::decodeData(int *datain, double *fdata) {
|
||||
|
||||
|
||||
double *dataout;
|
||||
if (fdata)
|
||||
dataout=fdata;
|
||||
@ -5557,12 +5560,6 @@ int slsDetector::stopReceiver(){
|
||||
ret=updateReceiver();
|
||||
}
|
||||
|
||||
//increment file index
|
||||
if(ret==OK){
|
||||
fileIO::setFileIndex(fileIO::getFileIndex()+1);
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -5665,6 +5662,81 @@ int slsDetector::getCurrentFrameIndex(){
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::resetFramesCaught(int index){
|
||||
int fnum=F_RESET_FRAMES_CAUGHT;
|
||||
int ret = FAIL;
|
||||
int retval=-1;
|
||||
int arg=index;
|
||||
|
||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Reset Frames Caught by Receiver:" << arg << std::endl;
|
||||
#endif
|
||||
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||
if(ret==FORCE_UPDATE)
|
||||
ret=updateReceiver();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int* slsDetector::readFrameFromReceiver(){
|
||||
int fnum=F_READ_FRAME;
|
||||
int nel=(thisDetector->dataBytes+HEADERLENGTH)/sizeof(int);//2572/
|
||||
int* retval=new int[nel];
|
||||
int* origVal=new int[nel];
|
||||
int ret=FAIL;
|
||||
int n;
|
||||
char mess[100]="Nothing";
|
||||
|
||||
|
||||
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes+HEADERLENGTH << " " <<nel <<std::endl;
|
||||
#endif
|
||||
if (dataSocket) {
|
||||
if (dataSocket->Connect()>=0) {
|
||||
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
|
||||
if (ret==FAIL) {
|
||||
n= dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned: " << mess << " " << n << std::endl;
|
||||
delete [] origVal;
|
||||
delete [] retval;
|
||||
return NULL;
|
||||
} else {
|
||||
n=dataSocket->ReceiveDataOnly(origVal,thisDetector->dataBytes+HEADERLENGTH);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
||||
#endif
|
||||
if (n!=thisDetector->dataBytes+HEADERLENGTH) {
|
||||
std::cout<<endl<< "wrong data size received: received " << n << " but expected " << thisDetector->dataBytes+HEADERLENGTH << std::endl;
|
||||
ret=FAIL;
|
||||
delete [] origVal;
|
||||
delete [] retval;
|
||||
return NULL;
|
||||
}//worked
|
||||
else{
|
||||
memcpy(retval,((char*) origVal)+2, getDataBytes()/2);
|
||||
memcpy((((char*)retval)+getDataBytes()/2), ((char*) origVal)+8+getDataBytes()/2, getDataBytes()/2);
|
||||
}
|
||||
}
|
||||
dataSocket->Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] origVal;
|
||||
return retval;//(retval+HEADERLENGTH/sizeof(int));
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::lockReceiver(int lock){
|
||||
int fnum=F_LOCK_RECEIVER;
|
||||
int ret = FAIL;
|
||||
|
@ -1459,6 +1459,18 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int getCurrentFrameIndex();
|
||||
|
||||
/**
|
||||
* resets framescaught
|
||||
* @param index frames caught by receiver
|
||||
* @param index if frame index is needed
|
||||
*/
|
||||
int resetFramesCaught(int index=-1);
|
||||
|
||||
/**
|
||||
/returns a frame read from recever
|
||||
*/
|
||||
int* readFrameFromReceiver();
|
||||
|
||||
/** Locks/Unlocks the connection to the receiver
|
||||
/param lock sets (1), usets (0), gets (-1) the lock
|
||||
/returns lock status of the receiver
|
||||
|
@ -462,6 +462,11 @@ class slsDetectorBase : public virtual slsDetectorDefs {
|
||||
virtual int lockReceiver(int lock=-1)=0;
|
||||
|
||||
|
||||
/**
|
||||
/returns a frame read from recever
|
||||
*/
|
||||
virtual int* readFrameFromReceiver()=0;
|
||||
|
||||
/** returns detector type string from detector type index
|
||||
\param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown
|
||||
\returns MYTHEN, PILATUS, EIGER, GOTTHARD, AGIPD, GENERIC
|
||||
|
@ -778,19 +778,8 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
|
||||
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
bool receiver=(myDet->setReceiverOnline()==ONLINE_FLAG);
|
||||
|
||||
if(receiver)
|
||||
if(myDet->startReceiver()==OK)
|
||||
usleep(2000000);
|
||||
else return string("could not start receiver");
|
||||
|
||||
myDet->acquire();
|
||||
|
||||
if(receiver)
|
||||
myDet->stopReceiver();
|
||||
|
||||
|
||||
return string("");
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ slsDetectorUtils::slsDetectorUtils() {
|
||||
|
||||
void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
bool receiver = (setReceiverOnline()==ONLINE_FLAG);
|
||||
|
||||
// setTotalProgress();
|
||||
//moved these 2 here for measurement change
|
||||
progressIndex=0;
|
||||
@ -109,6 +111,25 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
ns1=1;
|
||||
}
|
||||
|
||||
if(receiver){
|
||||
if(getReceiverStatus()!=IDLE)
|
||||
stopReceiver();
|
||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||
*stoppedFlag=1;
|
||||
|
||||
|
||||
//resets frames caught in receiver
|
||||
if ((timerValue[FRAME_NUMBER]*timerValue[CYCLES_NUMBER])>1)
|
||||
resetFramesCaught(1);
|
||||
else
|
||||
resetFramesCaught(0);
|
||||
|
||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||
*stoppedFlag=1;
|
||||
else
|
||||
setReceiverAcquiring(1);
|
||||
}
|
||||
|
||||
|
||||
if (*threadedProcessing) {
|
||||
startThread(delflag);
|
||||
@ -178,7 +199,7 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
createFileName();
|
||||
createFileName();
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
if (*stoppedFlag==0) {
|
||||
@ -192,9 +213,6 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
if (*stoppedFlag==0) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
executeAction(headerBefore);
|
||||
|
||||
if (*correctionMask&(1<< ANGULAR_CONVERSION) || aclog || eclog) {
|
||||
@ -202,27 +220,43 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
setCurrentPosition(getDetectorPosition());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (aclog)
|
||||
aclog->addStep(getCurrentPosition(), getCurrentFileName());
|
||||
|
||||
|
||||
aclog->addStep(getCurrentPosition(), getCurrentFileName());
|
||||
|
||||
if (eclog)
|
||||
eclog->addStep(setDAC(-1,THRESHOLD), getCurrentFileName());
|
||||
|
||||
eclog->addStep(setDAC(-1,THRESHOLD), getCurrentFileName());
|
||||
|
||||
|
||||
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
||||
if (get_i0)
|
||||
get_i0(0, IOarg);
|
||||
}
|
||||
|
||||
|
||||
if ((timerValue[FRAME_NUMBER]*timerValue[CYCLES_NUMBER])>1) {
|
||||
setFrameIndex(0);
|
||||
} else {
|
||||
setFrameIndex(-1);
|
||||
}
|
||||
|
||||
if(receiver){
|
||||
//send receiver file name
|
||||
pthread_mutex_lock(&mp);
|
||||
createFileName();
|
||||
pthread_mutex_unlock(&mp);
|
||||
setFileName(fileIO::getFileName());
|
||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||
stopReceiver();
|
||||
break;
|
||||
}
|
||||
//start receiver
|
||||
startReceiver();
|
||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||
stopReceiver();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
startAndReadAll();
|
||||
#ifdef VERBOSE
|
||||
cout << "returned! " << endl;
|
||||
@ -244,18 +278,19 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
cout << "done! " << endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (*threadedProcessing==0){
|
||||
#ifdef VERBOSE
|
||||
cout << "start unthreaded process data " << endl;
|
||||
#endif
|
||||
|
||||
processData(delflag);
|
||||
}
|
||||
|
||||
} else
|
||||
break;
|
||||
|
||||
|
||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||
// wait until data processing thread has finished the data
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -268,19 +303,27 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
closeDataFile();
|
||||
if((*correctionMask)&(1<<WRITE_FILE))
|
||||
closeDataFile();
|
||||
|
||||
}else{
|
||||
while(stopReceiver()!=OK);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
if (*stoppedFlag==0) {
|
||||
executeAction(headerAfter);
|
||||
executeAction(headerAfter);
|
||||
|
||||
pthread_mutex_unlock(&mp);
|
||||
// setLastIndex(*fileIndex);
|
||||
} else {
|
||||
// setLastIndex(*fileIndex);
|
||||
|
||||
pthread_mutex_unlock(&mp);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
|
||||
if (*stoppedFlag) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "exiting since the detector has been stopped" << std::endl;
|
||||
@ -292,7 +335,7 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
// pthread_mutex_unlock(&mp);
|
||||
}
|
||||
} // loop on position finished
|
||||
|
||||
|
||||
//script after
|
||||
if (*stoppedFlag==0) {
|
||||
executeAction(scriptAfter);
|
||||
@ -311,7 +354,7 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
// pthread_mutex_unlock(&mp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//end scan1 loop is1
|
||||
|
||||
|
||||
@ -345,27 +388,29 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
if(*correctionMask&(1<<WRITE_FILE))
|
||||
IncrementFileIndex();
|
||||
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
|
||||
|
||||
|
||||
if (measurement_finished)
|
||||
measurement_finished(im,*fileIndex,measFinished_p);
|
||||
|
||||
|
||||
if (*stoppedFlag) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// loop measurements
|
||||
}
|
||||
|
||||
setReceiverAcquiring(0);
|
||||
|
||||
// waiting for the data processing thread to finish!
|
||||
if (*threadedProcessing) {
|
||||
if (*threadedProcessing) {
|
||||
setJoinThread(1);
|
||||
pthread_join(dataProcessingThread, &status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (connectChannels) {
|
||||
if (disconnect_channels)
|
||||
@ -378,7 +423,6 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
if (eclog)
|
||||
delete eclog;
|
||||
|
||||
|
||||
if (acquisition_finished)
|
||||
acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p);
|
||||
|
||||
@ -542,87 +586,6 @@ void slsDetectorUtils::incrementProgress(int i) {
|
||||
|
||||
|
||||
int slsDetectorUtils::testFunction(int times) {
|
||||
int i,count=0;
|
||||
runStatus s;
|
||||
char controlval[1000];
|
||||
char statusval[1000];
|
||||
|
||||
int nchans = getTotalNumberOfChannels();
|
||||
short int dataVals[nchans];
|
||||
|
||||
for(i=0;i<times;i++){
|
||||
sprintf(statusval,"%x",readRegister(0x25));
|
||||
std::cout<<std::endl<<dec<<i+1<<": stat:\t"<<statusval<<"\t";
|
||||
sprintf(controlval,"%x",readRegister(0x24));
|
||||
std::cout<<"cont:"<<controlval<<"\t"<<std::endl;
|
||||
|
||||
startAcquisition();
|
||||
|
||||
sprintf(controlval,"%x",readRegister(0x24));
|
||||
std::cout<<"cont:"<<controlval<<"\t"<<std::endl;
|
||||
//sprintf(statusval,"%x",readRegister(0x25));
|
||||
//std::cout<<statusval<<std::endl;
|
||||
s = getRunStatus();
|
||||
if(s==IDLE){
|
||||
std::cout<<"IDLE\t"<<std::endl;
|
||||
s = getRunStatus();
|
||||
if(s==IDLE){
|
||||
std::cout<<"IDLE"<<std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
;
|
||||
}
|
||||
else {
|
||||
if (s==RUNNING){
|
||||
count=0;
|
||||
while(s==RUNNING){
|
||||
count++;//std::cout<<"count:"<<count<<std::endl;
|
||||
if(count==4){
|
||||
sprintf(statusval,"%x",readRegister(0x25));
|
||||
|
||||
|
||||
std::cout<<"STUCK: stat"<<statusval<<std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
usleep(50000);
|
||||
//val=readRegister(0x25);
|
||||
s = getRunStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* else{
|
||||
std::cout<<"\nWeird Status. "<<runStatusType(s)<<" Exit\n";
|
||||
exit(-1);
|
||||
}*/
|
||||
system("rm ~/wORKSPACE/scratch/run* ");
|
||||
//system("more ~/wORKSPACE/scratch/run* ");
|
||||
usleep(1000000);
|
||||
|
||||
setFileIndex(0);
|
||||
int b;
|
||||
|
||||
b=setThreadedProcessing(-1);
|
||||
setThreadedProcessing(0);
|
||||
readAll();
|
||||
processData(1);
|
||||
setThreadedProcessing(b);
|
||||
|
||||
|
||||
if(!readDataFile("/home/l_maliakal_d/wORKSPACE/scratch/run_1.raw",dataVals)){
|
||||
std::cout<< "Could not open file "<< std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
std::cout<<std::endl;
|
||||
for(int j=1277;j< (nchans);j++)
|
||||
std::cout<<"\t"<<j<<":"<<dataVals[j];
|
||||
|
||||
if(dataVals[1278]!=2558){
|
||||
std::cout<< "DATA ERROR!! "<< std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -621,6 +621,19 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual int getCurrentFrameIndex()=0;
|
||||
|
||||
/**
|
||||
* resets framescaught
|
||||
* @param index frames caught by receiver
|
||||
* @param index if frame index is needed
|
||||
*/
|
||||
virtual int resetFramesCaught(int index=-1)=0;
|
||||
|
||||
/**
|
||||
/returns a frame read from recever
|
||||
*/
|
||||
virtual int* readFrameFromReceiver()=0;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static const int64_t thisSoftwareVersion=0x20120124;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
||||
|
@ -40,7 +40,10 @@ int err = 0;
|
||||
pthread_t gui_acquisition_thread;
|
||||
|
||||
|
||||
char buffer[BUFFER_LENGTH];
|
||||
char buffer[BUFFER_LENGTH*2];
|
||||
char sendbuffer[BUFFER_LENGTH*2];
|
||||
|
||||
char onebuffer[BUFFER_LENGTH];
|
||||
int sd = -1;
|
||||
int sockfd, sfilefd;
|
||||
|
||||
@ -49,11 +52,24 @@ int sockfd, sfilefd;
|
||||
char filePath[MAX_STR_LENGTH]="";
|
||||
char fileName[MAX_STR_LENGTH]="run";
|
||||
int fileIndex=0;
|
||||
int frameIndexNeeded=1;
|
||||
|
||||
//for each scan
|
||||
int frameIndex=0;
|
||||
int startFrameIndex=-1;
|
||||
int framesInFile=0;
|
||||
int framesCaught=0;
|
||||
|
||||
//for each acquisition
|
||||
int acquisitionIndex=0;
|
||||
int startAcquisitionIndex=-1;//to remember progress for scans
|
||||
int totalFramesCaught=0;
|
||||
|
||||
int framesInFile=0;//to know when to start next file
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum runStatus status = IDLE;
|
||||
|
||||
|
||||
@ -124,9 +140,7 @@ int setFileIndex(int index){
|
||||
|
||||
|
||||
|
||||
int getFramesCaught(){
|
||||
return framesCaught;
|
||||
}
|
||||
|
||||
|
||||
int getFrameIndex(){
|
||||
if(startFrameIndex==-1)
|
||||
@ -137,6 +151,33 @@ int getFrameIndex(){
|
||||
}
|
||||
|
||||
|
||||
int getAcquisitionIndex(){
|
||||
if(startAcquisitionIndex==-1)
|
||||
acquisitionIndex=0;
|
||||
else
|
||||
acquisitionIndex=((int)(*((int*)buffer)) - startAcquisitionIndex)/2;
|
||||
return acquisitionIndex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int getFramesCaught(){
|
||||
return framesCaught;
|
||||
}
|
||||
|
||||
|
||||
int getTotalFramesCaught(){
|
||||
return totalFramesCaught;
|
||||
}
|
||||
|
||||
|
||||
int resetTotalFramesCaught(int index){
|
||||
startAcquisitionIndex=-1;
|
||||
totalFramesCaught=0;
|
||||
frameIndexNeeded=index;
|
||||
return frameIndexNeeded;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void* startListening(void *arg){
|
||||
@ -149,16 +190,17 @@ void* startListening(void *arg){
|
||||
sd = -1;
|
||||
int rc1, rc2, rc;
|
||||
int currframenum, prevframenum;
|
||||
char buffer2[BUFFER_LENGTH];
|
||||
// char buffer2[BUFFER_LENGTH];
|
||||
char savefilename[128];
|
||||
struct sockaddr_in serveraddr;
|
||||
struct sockaddr_in clientaddr;
|
||||
|
||||
int clientaddrlen = sizeof(clientaddr);
|
||||
framesInFile=0;
|
||||
framesCaught=0;
|
||||
frameIndex = 0;
|
||||
frameIndex=0;
|
||||
startFrameIndex=-1;
|
||||
framesCaught=0;
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/* Catch signal SIGINT to close files properly */
|
||||
@ -167,7 +209,10 @@ void* startListening(void *arg){
|
||||
|
||||
|
||||
//create file name
|
||||
sprintf(savefilename, "%s/%s_f%09d_%d.dat", filePath,fileName,frameIndex,fileIndex);
|
||||
if(!frameIndexNeeded)
|
||||
sprintf(savefilename, "%s/%s_%d.dat", filePath,fileName,fileIndex);
|
||||
else
|
||||
sprintf(savefilename, "%s/%s_f%012d_%d.dat", filePath,fileName,framesCaught,fileIndex);
|
||||
|
||||
/***********************************************************************/
|
||||
/* A do/while(FALSE) loop is used to make error cleanup easier. The */
|
||||
@ -221,7 +266,11 @@ void* startListening(void *arg){
|
||||
|
||||
currframenum=(int)(*((int*)buffer));
|
||||
getFrameIndex();
|
||||
sprintf(savefilename, "%s/%s_f%09d_%d.dat", filePath,fileName,frameIndex,fileIndex);
|
||||
//create file name
|
||||
if(!frameIndexNeeded)
|
||||
sprintf(savefilename, "%s/%s_%d.dat", filePath,fileName,fileIndex);
|
||||
else
|
||||
sprintf(savefilename, "%s/%s_f%012d_%d.dat", filePath,fileName,framesCaught,fileIndex);
|
||||
|
||||
printf("saving to %s\t\tpacket loss %f \%\t\tframenum %d\n", savefilename,((currframenum-prevframenum-(2*framesInFile))/(double)(2*framesInFile))*100.000,currframenum);
|
||||
sfilefd = fopen((const char *) (savefilename), "w");
|
||||
@ -230,16 +279,22 @@ void* startListening(void *arg){
|
||||
}
|
||||
status = RUNNING;
|
||||
|
||||
rc1 = recvfrom(sd, buffer, sizeof(buffer), 0,
|
||||
rc1 = recvfrom(sd, buffer, sizeof(onebuffer), 0,
|
||||
(struct sockaddr *) &clientaddr, &clientaddrlen);
|
||||
//printf("rc1 done\n");
|
||||
rc2 = recvfrom(sd, buffer2, sizeof(buffer2), 0,
|
||||
rc2 = recvfrom(sd, buffer+sizeof(onebuffer), sizeof(onebuffer), 0,
|
||||
(struct sockaddr *) &clientaddr, &clientaddrlen);
|
||||
|
||||
|
||||
//for each scan
|
||||
if(startFrameIndex==-1){
|
||||
startFrameIndex=(int)(*((int*)buffer))-2;
|
||||
prevframenum=startFrameIndex;
|
||||
}
|
||||
//start of acquisition
|
||||
if(startAcquisitionIndex==-1)
|
||||
startAcquisitionIndex=startFrameIndex;
|
||||
|
||||
//printf("rc2 done\n");
|
||||
if ((rc1 < 0) || (rc2 < 0)) {
|
||||
perror("recvfrom() failed");
|
||||
@ -249,9 +304,10 @@ void* startListening(void *arg){
|
||||
//so that it doesnt write the last frame twice
|
||||
if(gui_acquisition_thread_running){
|
||||
fwrite(buffer, 1, rc1, sfilefd);
|
||||
fwrite(buffer2, 1, rc2, sfilefd);
|
||||
fwrite(buffer+sizeof(onebuffer), 1, rc2, sfilefd);
|
||||
framesInFile++;
|
||||
framesCaught++;
|
||||
totalFramesCaught++;
|
||||
//printf("saving\n");
|
||||
}
|
||||
}
|
||||
@ -332,6 +388,22 @@ int stopReceiver(){
|
||||
}
|
||||
|
||||
|
||||
char* readFrame(){
|
||||
// volatile char* now_ptr=NULL;
|
||||
//u_int32_t* ram_values=NULL;
|
||||
|
||||
// now_ptr=(char*)ram_values;
|
||||
|
||||
//memcpy(now_ptr,buffer ,sizeof(buffer));
|
||||
|
||||
// memcpy(sendbuffer,buffer ,sizeof(buffer));
|
||||
|
||||
while (((int)*((int*)buffer))%2==0) ;//usleep(20000);
|
||||
|
||||
// memcpy(sendbuffer,buffer ,sizeof(buffer));
|
||||
|
||||
//printf("freamenum%d\n",*((int*) sendbuffer));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -13,13 +13,17 @@ char* getFilePath();
|
||||
char* setFilePath(char fName[]);
|
||||
int getFileIndex();
|
||||
int setFileIndex(int index);
|
||||
int getFramesCaught();
|
||||
int getFrameIndex();
|
||||
int getAcquisitionIndex();
|
||||
int getFramesCaught();
|
||||
int getTotalFramesCaught();
|
||||
int resetTotalFramesCaught(int index);
|
||||
|
||||
void* startListening(void *arg);
|
||||
|
||||
int startReceiver();
|
||||
int stopReceiver();
|
||||
|
||||
char* readFrame();
|
||||
|
||||
#endif
|
||||
|
@ -105,6 +105,8 @@ int function_table() {
|
||||
flist[F_GET_RECEIVER_STATUS]=&get_receiver_status;
|
||||
flist[F_GET_FRAMES_CAUGHT]=&get_frames_caught;
|
||||
flist[F_GET_FRAME_INDEX]=&get_frame_index;
|
||||
flist[F_RESET_FRAMES_CAUGHT]=&reset_frames_caught;
|
||||
flist[F_READ_FRAME]=&read_frame;
|
||||
|
||||
flist[F_LOCK_RECEIVER]=&lock_receiver;
|
||||
flist[F_SET_PORT]=&set_port;
|
||||
@ -148,11 +150,11 @@ int set_file_name(int file_des) {
|
||||
sprintf(mess,"Receiver locked by %s\n", lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else if((strlen(fName))&&(getReceiverStatus()==RUNNING)){
|
||||
/* else if((strlen(fName))&&(getReceiverStatus()==RUNNING)){
|
||||
strcpy(mess,"Can not set file name while receiver running");
|
||||
ret = FAIL;
|
||||
}
|
||||
else
|
||||
*/ else
|
||||
strcpy(retval,setFileName(fName));
|
||||
}
|
||||
|
||||
@ -275,11 +277,11 @@ int set_file_index(int file_des) {
|
||||
sprintf(mess,"Receiver locked by %s\n", lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else if((index>=0)&&(getReceiverStatus()==RUNNING)){
|
||||
/* else if((index>=0)&&(getReceiverStatus()==RUNNING)){
|
||||
strcpy(mess,"Can not set file index while receiver running\n");
|
||||
ret = FAIL;
|
||||
}
|
||||
else
|
||||
*/ else
|
||||
retval=setFileIndex(index);
|
||||
}
|
||||
|
||||
@ -423,7 +425,7 @@ int get_frames_caught(int file_des) {
|
||||
|
||||
/* execute action if the arguments correctly arrived*/
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
retval=getFramesCaught();
|
||||
retval=getTotalFramesCaught();
|
||||
#endif
|
||||
|
||||
if(ret==OK && differentClients){
|
||||
@ -447,14 +449,14 @@ int get_frames_caught(int file_des) {
|
||||
|
||||
|
||||
|
||||
int get_frame_index(int file_des) {
|
||||
int get_frame_index(int file_des) {printf("Getting frame Index\n");fflush(stdout);
|
||||
int ret=OK;
|
||||
int n=0;
|
||||
int retval=-1;
|
||||
|
||||
/* execute action if the arguments correctly arrived*/
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
retval=getFrameIndex();
|
||||
retval=getAcquisitionIndex();
|
||||
#endif
|
||||
|
||||
if(ret==OK && differentClients){
|
||||
@ -465,6 +467,55 @@ int get_frame_index(int file_des) {
|
||||
/* send answer */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
n = sendDataOnly(file_des,&retval,sizeof(retval));
|
||||
printf("returnrdf:%d\n",retval);
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int reset_frames_caught(int file_des) {
|
||||
int ret=OK;
|
||||
int n=0;
|
||||
int retval=-1;
|
||||
int index=-1;
|
||||
|
||||
strcpy(mess,"Could not reset frames caught\n");
|
||||
|
||||
|
||||
/* receive arguments */
|
||||
n = receiveDataOnly(file_des,&index,sizeof(index));
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
if (ret==OK) {
|
||||
/* execute action if the arguments correctly arrived*/
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (lockStatus==1 && differentClients==1){//necessary???
|
||||
sprintf(mess,"Receiver locked by %s\n", lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else
|
||||
retval=resetTotalFramesCaught(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(ret==OK && differentClients){
|
||||
printf("Force update\n");
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
/* send answer */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if(ret==FAIL)
|
||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||
n = sendDataOnly(file_des,&retval,sizeof(retval));
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
@ -475,6 +526,37 @@ int get_frame_index(int file_des) {
|
||||
|
||||
|
||||
|
||||
int read_frame(int file_des) {
|
||||
int ret=OK;
|
||||
int n=0;
|
||||
char* retval=NULL;
|
||||
char buffer[1286*2];
|
||||
|
||||
strcpy(mess,"Could not read frame\n");
|
||||
|
||||
|
||||
/* execute action if the arguments correctly arrived*/
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
retval=readFrame();
|
||||
#endif
|
||||
|
||||
|
||||
if(ret==OK && differentClients){
|
||||
printf("Force update\n");
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
if(getReceiverStatus==IDLE){
|
||||
ret=FAIL;
|
||||
printf("*************STOPPPED***\n");
|
||||
}
|
||||
/* send answer */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if(ret==FAIL)
|
||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||
n = sendDataOnly(file_des,retval,sizeof(buffer));
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -36,6 +36,9 @@ int stop_receiver(int);
|
||||
int get_receiver_status(int);
|
||||
int get_frames_caught(int);
|
||||
int get_frame_index(int);
|
||||
int reset_frame_index(int);
|
||||
int reset_frames_caught(int);
|
||||
int read_frame(int);
|
||||
|
||||
|
||||
|
||||
|
@ -118,141 +118,7 @@ int receiverInterface::executeFunction(int fnum){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
set or read the acquisition timers
|
||||
enum timerIndex {
|
||||
FRAME_NUMBER,
|
||||
ACQUISITION_TIME,
|
||||
FRAME_PERIOD,
|
||||
DELAY_AFTER_TRIGGER,
|
||||
GATES_NUMBER,
|
||||
PROBES_NUMBER
|
||||
CYCLES_NUMBER,
|
||||
GATE_INTEGRATED_TIME
|
||||
}
|
||||
*/
|
||||
/*
|
||||
int64_t receiverInterface::setTimer(timerIndex index, int64_t t){
|
||||
|
||||
|
||||
int fnum=F_SET_TIMER;
|
||||
int64_t retval;
|
||||
uint64_t ut;
|
||||
char mess[100];
|
||||
int ret=OK;
|
||||
int n=0;
|
||||
|
||||
if (index!=MEASUREMENTS_NUMBER) {
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Setting timer "<< index << " to " << t << "ns" << std::endl;
|
||||
#endif
|
||||
ut=t;
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (controlSocket) {
|
||||
if (controlSocket->Connect()>=0) {
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&index,sizeof(index));
|
||||
n=controlSocket->SendDataOnly(&t,sizeof(t));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
} else {
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
thisDetector->timerValue[index]=retval;
|
||||
}
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE) {
|
||||
updateDetector();
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Updated!" << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//std::cout<< "offline " << std::endl;
|
||||
if (t>=0)
|
||||
thisDetector->timerValue[index]=t;
|
||||
}
|
||||
} else {
|
||||
if (t>=0)
|
||||
thisDetector->timerValue[index]=t;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] << "ns" << std::endl;
|
||||
#endif
|
||||
if (index==PROBES_NUMBER) {
|
||||
setDynamicRange();
|
||||
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
|
||||
}
|
||||
|
||||
// set progress
|
||||
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
|
||||
|
||||
setTotalProgress();
|
||||
|
||||
|
||||
}
|
||||
|
||||
return thisDetector->timerValue[index];
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
int64_t receiverInterface::getTimeLeft(timerIndex index){
|
||||
|
||||
|
||||
int fnum=F_GET_TIME_LEFT;
|
||||
int64_t retval;
|
||||
char mess[100];
|
||||
int ret=OK;
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Getting timer "<< index << std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (stopSocket) {
|
||||
if (stopSocket->Connect()>=0) {
|
||||
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
stopSocket->SendDataOnly(&index,sizeof(index));
|
||||
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==slsDetectorDefs::FAIL) {
|
||||
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
} else {
|
||||
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
}
|
||||
stopSocket->Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Time left is "<< retval << std::endl;
|
||||
#endif
|
||||
return retval;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
int receiverInterface::exitServer(){
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* Send a string to receiver
|
||||
* Send an integer to receiver
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* @param arg value to send
|
||||
@ -63,7 +63,7 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* Send a string to receiver
|
||||
* Get an integer value from receiver
|
||||
* @param fnum function enum to determine what parameter
|
||||
* @param retval return value
|
||||
* \returns success of operation
|
||||
@ -72,7 +72,7 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* Send a string to receiver
|
||||
* Get last client ip connected to receiver
|
||||
* @param fnum function enum to get last client up
|
||||
* @param retval return value
|
||||
* \returns success of operation
|
||||
@ -81,7 +81,7 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
* Send a string to receiver
|
||||
* Send a function number to execute function
|
||||
* @param fnum function enum to determine which function to execute
|
||||
* \returns success of operation
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user