This commit is contained in:
Dhanya Maliakal 2016-10-31 16:43:45 +01:00
parent 5cc17a77c7
commit 58228ed00f
2 changed files with 65 additions and 58 deletions

View File

@ -3978,7 +3978,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
int fnum=F_SET_TIMER,fnum2=F_SET_RECEIVER_TIMER;
int64_t retval = -1;
int64_t ut = -2;
char mess[MAX_STR_LENGTH]="";
int ret=OK;
int n=0;
@ -4015,91 +4014,99 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
} else {
//std::cout<< "offline " << std::endl;
if (t>=0)
thisDetector->timerValue[index]=t;
thisDetector->timerValue[index]=t;
if((thisDetector->myDetectorType==GOTTHARD)||
(thisDetector->myDetectorType==PROPIX)||
(thisDetector->myDetectorType==JUNGFRAU)||
(thisDetector->myDetectorType==MOENCH))
thisDetector->timerValue[PROBES_NUMBER]=0;
(thisDetector->myDetectorType==PROPIX)||
(thisDetector->myDetectorType==JUNGFRAU)||
(thisDetector->myDetectorType==MOENCH))
thisDetector->timerValue[PROBES_NUMBER]=0;
}
} else {
if (t>=0)
thisDetector->timerValue[index]=t;
if (t>=0)
thisDetector->timerValue[index]=t;
}
#ifdef VERBOSE
std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] << "ns" << std::endl;
#endif
if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) {
setDynamicRange();
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
setDynamicRange();
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
}
/* set progress */
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
setTotalProgress();
setTotalProgress();
}
//if eiger, rate corr on, a put statement, dr=32 &setting subexp or dr =16 & setting exptime, set ratecorr to update table
double r;
if( (thisDetector->myDetectorType == EIGER) &&
getRateCorrection(r) &&
(t>=0) &&
getRateCorrection(r) &&
(t>=0) &&
(((index == SUBFRAME_ACQUISITION_TIME) && (thisDetector->dynamicRange == 32))||
((index == ACQUISITION_TIME) && (thisDetector->dynamicRange == 16)))
((index == ACQUISITION_TIME) && (thisDetector->dynamicRange == 16)))
&& (t>=0) && getRateCorrection(r)){
&& (t>=0) && getRateCorrection(r)){
setRateCorrection(r);
}
//send acquisiton period/frame number to receiver
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)){
if(ret != FAIL){
retval = thisDetector->timerValue[index];
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
int64_t args[2];
args[1] = retval;
if((t == -1) && (ret!= FORCE_UPDATE)) args[1] = -1;
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){
#ifdef VERBOSE
std::cout << "Setting/Getting number of frames " << index <<" to/from receiver " << args[1] << std::endl;
#endif
args[0] = FRAME_NUMBER;
retval = abs(thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER]);
if(args[1] != -1) args[1]=retval;
}else{
#ifdef VERBOSE
std::cout << "Setting/Getting acquisition period " << index << " to/from receiver " << args[1] << 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(ret != FAIL){
int64_t args[2];
retval = -1;
args[0] = index;
args[1] = thisDetector->timerValue[index];
if (connectData() == OK)
ret=thisReceiver->sendIntArray(fnum2,ut,args);
disconnectData();
if((ut != retval)|| (ret==FAIL)){
ret = FAIL;
if(index==FRAME_PERIOD){
//exptime sent if acq period = 0
if(retval){
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << thisDetector->timerValue[index] << endl;
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
}
}else{
cout << "ERROR:Number of Frames (* Number of cycles) in receiver set incorrectly to " << ut << " instead of " << thisDetector->timerValue[index] << endl;
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
//set #frames, #cycles
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){
#ifdef VERBOSE
std::cout << "Setting/Getting number of frames " << index <<" to/from receiver " << args[1] << std::endl;
#endif
if(thisDetector->timerValue[CYCLES_NUMBER]==0)
args[1] = thisDetector->timerValue[FRAME_NUMBER];
else
args[1] = thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER];
}
//set period
else{
#ifdef VERBOSE
std::cout << "Setting/Getting acquisition period " << index << " to/from receiver " << args[1] << std::endl;
#endif
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period
if(!args[1])
args[1] = timerValue[ACQUISITION_TIME];
}
if (connectData() == OK)
ret=thisReceiver->sendIntArray(fnum2,retval,args);
disconnectData();
if((args[1] != retval)|| (ret==FAIL)){
ret = FAIL;
if(index==FRAME_PERIOD){
//exptime sent if acq period = 0
if(retval){
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
}
}else{
cout << "ERROR:Number of Frames (* Number of cycles) in receiver set incorrectly to " << retval << " instead of " << args[1] << endl;
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
}
}
if(ret==FORCE_UPDATE)
updateReceiver();
}
}
}
if(ret==FORCE_UPDATE)
updateReceiver();
}
}
}
return thisDetector->timerValue[index];
};