start and stop receiver for eiger doesnt include transmitting stage. set timer sends to anz type of receiver the num frames and acq period

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@796 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2014-03-20 10:23:19 +00:00
parent b6d18131e8
commit 1607ddb096
5 changed files with 77 additions and 67 deletions

View File

@ -3536,56 +3536,46 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
//send acquisiton period/frame number to receiver
switch(thisDetector->myDetectorType){
case EIGER:
if(index != FRAME_NUMBER)
return thisDetector->timerValue[index];
break;
//for gotthard and moench, mythen returns anyway because of no rxr
default:
if(index != FRAME_PERIOD)
return thisDetector->timerValue[index];
break;
}
if((ret != FAIL) && (t != -1)){
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
int64_t args[2];
args[1] = retval;
if(index==FRAME_NUMBER)
args[0] = FRAME_NUMBER;
else{
args[0] = FRAME_PERIOD;
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period
if(!retval)
args[1] = timerValue[ACQUISITION_TIME];
}
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD))
{
if((ret != FAIL) && (t != -1)){
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
int64_t args[2];
args[1] = retval;
if(index==FRAME_NUMBER){
#ifdef VERBOSE
if(index==FRAME_PERIOD)
std::cout << "Sending/Getting acquisition period to/from receiver " << retval << std::endl;
else
std::cout << "Sending/Getting number of frames to/from receiver " << retval << std::endl;
std::cout << "Sending/Getting number of frames to/from receiver " << retval << std::endl;
#endif
if (connectData() == OK)
ret=thisReceiver->sendIntArray(fnum,ut,args);
if((ut != retval)|| (ret==FAIL)){
ret = FAIL;
if(index==FRAME_PERIOD){
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl;
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
}else{
cout << "ERROR:Number of Frames in receiver set incorrectly to " << ut << " instead of " << retval << endl;
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
args[0] = FRAME_NUMBER;
}else{
#ifdef VERBOSE
std::cout << "Sending/Getting acquisition period to/from receiver " << retval << std::endl;
#endif
args[0] = FRAME_PERIOD;
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period
if(!retval)
args[1] = timerValue[ACQUISITION_TIME];
}
if (connectData() == OK)
ret=thisReceiver->sendIntArray(fnum,ut,args);
if((ut != retval)|| (ret==FAIL)){
ret = FAIL;
if(index==FRAME_PERIOD){
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << retval << endl;
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
}else{
cout << "ERROR:Number of Frames in receiver set incorrectly to " << ut << " instead of " << retval << endl;
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
}
}
if(ret==FORCE_UPDATE)
updateReceiver();
}
}
if(ret==FORCE_UPDATE)
updateReceiver();
}
}
}
return thisDetector->timerValue[index];
};

View File

@ -3975,9 +3975,11 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
myDet->startReceiver();
else if(!strcasecmp(args[1],"stop")){
myDet->startReceiverReadout();
while(myDet->getReceiverStatus() != RUN_FINISHED)
runStatus s = myDet->getReceiverStatus();
while((s != RUN_FINISHED)&&(s != IDLE))
usleep(50000);
myDet->stopReceiver();
if(s != IDLE)
myDet->stopReceiver();
}
else
return helpReceiver(narg, args, action);

View File

@ -54,6 +54,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
packetIndexMask(GOTTHARD_PACKET_INDEX_MASK),
frameIndexOffset(GOTTHARD_FRAME_INDEX_OFFSET),
acquisitionPeriod(SAMPLE_TIME_IN_NS),
numberOfFrames(0),
shortFrame(-1),
currframenum(0),
prevframenum(0),
@ -74,18 +75,18 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
thread_started(0),
currentWriterThreadIndex(-1),
totalListeningFrameCount(0),
sfilefd(NULL),
writerthreads_mask(0x0),
listening_thread_running(0),
killListeningThread(0),
killAllWritingThreads(0),
cbAction(DO_EVERYTHING),
sfilefd(NULL),
startAcquisitionCallBack(NULL),
pStartAcquisition(NULL),
acquisitionFinishedCallBack(NULL),
pAcquisitionFinished(NULL),
rawDataReadyCallBack(NULL),
pRawDataReady(NULL){
pRawDataReady(NULL),
cbAction(DO_EVERYTHING){
maxPacketsPerFile = MAX_FRAMES_PER_FILE * packetsPerFrame;
@ -261,7 +262,7 @@ char* slsReceiverFunctionList::setFilePath(char c[]){
strcpy(filePath,c);
}else{
strcpy(filePath,"");
cout<<"FilePath does not exist:"<<filePath<<endl;
cout << "FilePath does not exist:" << filePath << endl;
}
}
return getFilePath();
@ -270,7 +271,7 @@ char* slsReceiverFunctionList::setFilePath(char c[]){
char* slsReceiverFunctionList::getFileName(){
if(myDetectorType == EIGER)
receiver->getFileName();
return receiver->getFileName();
else
return fileName;
}
@ -339,12 +340,9 @@ slsDetectorDefs::runStatus slsReceiverFunctionList::getStatus(){
char* slsReceiverFunctionList::setDetectorHostname(char c[]){
if(strlen(c)){
char *c0 = receiver->getDetectorHostname();
if(c0== NULL)
if(receiver->getDetectorHostname()== NULL)
receiver->initialize(c);
delete[] c0;
}
return receiver->getDetectorHostname();
}
@ -360,9 +358,17 @@ void slsReceiverFunctionList::setUDPPortNo(int p){
int32_t slsReceiverFunctionList::setNumberOfFrames(int32_t fnum){
if(fnum >= 0)
receiver->setNumberOfFrames(fnum);
return receiver->getNumberOfFrames();
if(fnum >= 0){
if(myDetectorType == EIGER)
receiver->setNumberOfFrames(fnum);
else
numberOfFrames = fnum;
}
if(myDetectorType == EIGER)
return receiver->getNumberOfFrames();
else
return numberOfFrames;
}
int32_t slsReceiverFunctionList::setScanTag(int32_t stag){
@ -418,6 +424,7 @@ int slsReceiverFunctionList::setNFrameToGui(int i){
int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){
if(index >= 0){
if(index != acquisitionPeriod){
acquisitionPeriod = index;
@ -1161,6 +1168,13 @@ int slsReceiverFunctionList::stopReceiver(){
void slsReceiverFunctionList::startReadout(){
if(myDetectorType == EIGER){
receiver->stopReceiver();
return;
}
//wait so that all packets which take time has arrived
usleep(50000);
@ -1201,7 +1215,7 @@ int slsReceiverFunctionList::startListening(){
#endif
int lastpacketoffset, expected, rc, packetcount, maxBufferSize, carryonBufferSize;
int lastframeheader;// for moench to check for all the packets in last frame
uint32_t lastframeheader;// for moench to check for all the packets in last frame
char* tempchar = NULL;
@ -1358,7 +1372,7 @@ int slsReceiverFunctionList::startListening(){
cout << "last packet offset:" << lastpacketoffset << endl;
#endif
if((packetsPerFrame -1) != ((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))+1) & (packetIndexMask))){
if((unsigned int)(packetsPerFrame -1) != ((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))+1) & (packetIndexMask))){
memcpy(tempchar,buffer+lastpacketoffset, onePacketSize);
#ifdef VERYDEBUG
cout << "tempchar header:" << (((((uint32_t)(*((uint32_t*)(tempchar))))+1)
@ -1422,7 +1436,8 @@ int slsReceiverFunctionList::startWriting(){
thread_started = 1;
int numpackets,tempframenum, nf;
int numpackets, nf;
uint32_t tempframenum;
char* wbuf;
char *data=new char[bufferSize];
int iFrame = 0;
@ -1576,15 +1591,14 @@ int slsReceiverFunctionList::startWriting(){
int ndata;
char* buff = 0;
data = wbuf+ HEADER_SIZE_NUM_TOT_PACKETS;
int ir, ic;
int remainingsize = numpackets * onePacketSize;
int np;
int once = 0;
double tot, tl, tr, bl, br, v;
double tot, tl, tr, bl, br;
int xmin = 1, ymin = 1, ix, iy;
while(buff = receiverdata[ithread]->findNextFrame(data,ndata,remainingsize )){
while(buff = receiverdata[ithread]->findNextFrame(data,ndata,remainingsize)){
np = ndata/onePacketSize;
//cout<<"buff framnum:"<<ithread <<":"<< ((((uint32_t)(*((uint32_t*)buff)))& (frameIndexMask)) >> frameIndexOffset)<<endl;
@ -1730,7 +1744,8 @@ int slsReceiverFunctionList::startWriting(){
void slsReceiverFunctionList::writeToFile_withoutCompression(char* buf,int numpackets){
int packetsToSave, offset,tempframenum,lastpacket;
int packetsToSave, offset,lastpacket;
uint32_t tempframenum;
//file write
if((enableFileWrite) && (sfilefd)){

View File

@ -434,6 +434,9 @@ private:
/** acquisition period */
int64_t acquisitionPeriod;
/** frame number */
int32_t numberOfFrames;
/** short frames */
int shortFrame;

View File

@ -1420,7 +1420,7 @@ int slsReceiverFuncs::start_readout(){
#ifdef SLS_RECEIVER_FUNCTION_LIST
slsReceiverList->startReadout();
retval = slsReceiverList->getStatus();
if((retval == TRANSMITTING) || (retval == RUN_FINISHED))
if((retval == TRANSMITTING) || (retval == RUN_FINISHED) || (retval == IDLE))
ret = OK;
else
ret = FAIL;