fixed dimensions, fixed rate corr bug, moved rate corr to server because config resets memory and ratecorr depends on client variables

This commit is contained in:
Dhanya Maliakal 2016-07-14 16:23:03 +02:00
parent 342d4f8c30
commit 4939e47305
19 changed files with 413 additions and 358 deletions

View File

@ -100,7 +100,8 @@ enum {
F_PULSE_PIXEL_AND_MOVE, /** < pulse pixel n number of times and move relatively by x and y */
F_PULSE_CHIP, /** < pulse chip n number of times */
F_SET_RATE_CORRECT /** < set/reset rate correction tau */
F_SET_RATE_CORRECT, /** < set/reset rate correction tau */
F_GET_RATE_CORRECT, /** < get rate correction tau */
/* Always append functions hereafter!!! */

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 769ba51f2796ac8088f29a6cdb87955befbbdae2
Revision: 201
Repsitory UUID: f65bc993ef8b3548b52e677b3f42ae6229611d73
Revision: 203
Branch: developer
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 326
Last Changed Date: 2016-07-05 17:24:44 +0200
Last Changed Rev: 327
Last Changed Date: 2016-07-12 16:45:00 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/eigerDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "769ba51f2796ac8088f29a6cdb87955befbbdae2"
//#define SVNREV 0x326
#define SVNREPUUID "f65bc993ef8b3548b52e677b3f42ae6229611d73"
//#define SVNREV 0x327
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x326
#define SVNDATE 0x20160705
#define SVNREV 0x327
#define SVNDATE 0x20160712
//

View File

@ -12,6 +12,8 @@
#include "FebControl.h"
#include "Beb.h"
int default_tau_from_file= -1;
#define BEB_NUM 34
enum detectorSettings thisSettings;
@ -535,16 +537,21 @@ int getRateCorrectionEnable(){
}
int getDefaultSettingsTau_in_nsec(){
switch(thisSettings){
case STANDARD: return STANDARD_TAU;
case HIGHGAIN: return HIGHGAIN_TAU;
case LOWGAIN: return LOWGAIN_TAU;
default: return -1;
}
return default_tau_from_file;
}
int64_t getCurrentTau(){
if(!getRateCorrectionEnable())
return 0;
else
return Feb_Control_Get_RateTable_Tau_in_nsec();
}
int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay, int64_t tau_ns){
void setDefaultSettingsTau_in_nsec(int t){
default_tau_from_file = t;
}
int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay){
int retval[2];
int i;
@ -555,32 +562,6 @@ int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay, int6
//set the settings variable
setSettings( (enum detectorSettings)myMod.reg,-1);
//rate correction (ignore -2: from load settings)
if(tau_ns > -2){
//set settings, with no tau in calib file
if(tau_ns == -1){
tau_ns = getDefaultSettingsTau_in_nsec();
//incorrect settings
if(tau_ns < 0)
return -1;
}
//set the tau for all
int64_t rate_retval = setRateCorrection(tau_ns); //tau_ns will not be -1 here
if(tau_ns != rate_retval){
if(rate_retval == -1)
return -2;
else
return -3;
}
//set settings, with no tau in calib file :
//only setting tau, rate correction should be off
//(in previous "error" returns, its switched off anyway)
if(tau_ns == -1)
setRateCorrection(0);
}else cprintf(RED,"rate not changed\n");
//set the gains and offset variables locally
for(i=0;i<NGAIN;i++){
if(gain[i]>=0){
@ -629,7 +610,7 @@ int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay, int6
return FAIL;
}
return 0;
return thisSettings;
}
@ -728,6 +709,9 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
return thisSettings;
}
enum detectorSettings getSettings(){
return thisSettings;
}
int startReceiver(int d){
printf("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit());

View File

@ -40,12 +40,5 @@
enum detDacIndex{SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RXB_RB,RXB_LB,VCMP_RR,VCP,VCN,VIS,VTHRESHOLD};
enum defaultTauValues{
HIGHGAIN_TAU=410,
STANDARD_TAU=290,
LOWGAIN_TAU=180};
#endif /* SLSDETECTORSERVER_DEFS_H_ */

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 769ba51f2796ac8088f29a6cdb87955befbbdae2
Revision: 1103
Repsitory UUID: f65bc993ef8b3548b52e677b3f42ae6229611d73
Revision: 1109
Branch: developer
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 1103
Last Changed Date: 2016-07-05 17:24:44 +0200
Last Changed Rev: 1109
Last Changed Date: 2016-07-12 16:45:00 +0200

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/gotthardDetectorServer
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 769ba51f2796ac8088f29a6cdb87955befbbdae2
Revision: 193
Repsitory UUID: f65bc993ef8b3548b52e677b3f42ae6229611d73
Revision: 194
Branch: developer
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 326
Last Changed Date: 2016-07-05 17:24:44 +0200
Last Changed Rev: 327
Last Changed Date: 2016-07-12 16:45:00 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/gotthardDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "769ba51f2796ac8088f29a6cdb87955befbbdae2"
//#define SVNREV 0x326
#define SVNREPUUID "f65bc993ef8b3548b52e677b3f42ae6229611d73"
//#define SVNREV 0x327
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x326
#define SVNDATE 0x20160705
#define SVNREV 0x327
#define SVNDATE 0x20160712
//

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/moenchDetectorServer
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 769ba51f2796ac8088f29a6cdb87955befbbdae2
Revision: 76
Repsitory UUID: f65bc993ef8b3548b52e677b3f42ae6229611d73
Revision: 77
Branch: developer
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 326
Last Changed Date: 2016-07-05 17:24:44 +0200
Last Changed Rev: 327
Last Changed Date: 2016-07-12 16:45:00 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/moenchDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "769ba51f2796ac8088f29a6cdb87955befbbdae2"
//#define SVNREV 0x326
#define SVNREPUUID "f65bc993ef8b3548b52e677b3f42ae6229611d73"
//#define SVNREV 0x327
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x326
#define SVNDATE 0x20160705
#define SVNREV 0x327
#define SVNDATE 0x20160712
//

View File

@ -421,7 +421,8 @@ void multiSlsDetector::updateOffsets(){
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
cout<<"offsetY:"<<offsetY<<" prevChanY:"<<prevChanY<<" totalchan:"<< detectors[i]->getTotalNumberOfChannels(Y) <<" maxChanY:"<<maxChanY<<endl;
cout<<"offsetX:"<<offsetX<<" prevChanX:"<<prevChanX<<" offsetY:"<<offsetY<<" prevChanY:"<<prevChanY<<endl;
//cout<<" totalchan:"<< detectors[i]->getTotalNumberOfChannels(Y) <<" maxChanY:"<<maxChanY<<endl;
//incrementing in both direction
if(firstTime){
//incrementing in both directions
@ -453,7 +454,7 @@ void multiSlsDetector::updateOffsets(){
if((maxChanX > 0) && ((offsetX + prevChanX + detectors[i]->getTotalNumberOfChannels(X)) > maxChanX))
cout<<"\nDetector[" << i << "] exceeds maximum channels allowed for complete detector set in X dimension!" << endl;
offsetY = 0;
prevChanY = 0;
prevChanY = detectors[i]->getTotalNumberOfChannels(Y);;
numY = 0; //assuming symmetry with this statement. whats on 1st column should be on 2nd column
maxY = 0;
offsetX += prevChanX;
@ -1741,15 +1742,6 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){
thisMultiDetector->timerValue[index]=ret1;
if (getDetectorsType() == EIGER) {
//if subexptime set, update rate correction in server and update result in multi client
double r;
if((index == SUBFRAME_ACQUISITION_TIME) && (t>=0) && getRateCorrection(r)){
setRateCorrection(r);
}
}
return ret1;
};
@ -2547,19 +2539,31 @@ int multiSlsDetector::flatFieldCorrect(double* datain, double *errin, double* da
int multiSlsDetector::setRateCorrection(double t){
// double tdead[]=defaultTDead;
if (getDetectorsType() == MYTHEN){
#ifdef VERBOSE
std::cout<< "Setting rate correction with dead time "<< thisMultiDetector->tDead << std::endl;
#endif
if (getDetectorsType() == EIGER){
int ret = OK, ret1= OK;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
ret=detectors[idet]->setRateCorrection(t);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if (ret1 != OK)
ret1=FAIL;
}
}
return ret1; //only success/fail
}
//mythen, others
if (t==0) {
thisMultiDetector->correctionMask&=~(1<<RATE_CORRECTION);
return thisMultiDetector->correctionMask&(1<<RATE_CORRECTION);
} else
thisMultiDetector->correctionMask|=(1<<RATE_CORRECTION);
}
int ret, ret1=-100;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
@ -2574,22 +2578,15 @@ int multiSlsDetector::setRateCorrection(double t){
}
}
if (getDetectorsType() != MYTHEN){
if (ret1==0)
thisMultiDetector->correctionMask&=~(1<<RATE_CORRECTION);
else
thisMultiDetector->correctionMask|=(1<<RATE_CORRECTION);
}
return thisMultiDetector->correctionMask&(1<<RATE_CORRECTION);
}
int multiSlsDetector::getRateCorrection(double &t){
if (getDetectorsType() != MYTHEN){
if (getDetectorsType() == EIGER){
t = getRateCorrectionTau();
return getRateCorrection();
return t;
}
if (thisMultiDetector->correctionMask&(1<<RATE_CORRECTION)) {
@ -2615,22 +2612,15 @@ double multiSlsDetector::getRateCorrectionTau(){
ret1=ret;
else if (ret!=ret1){
std::cout<< "Rate correction is different for different readouts " << std::endl;
if(getDetectorsType() == EIGER)
ret1=-2;
else
ret1=-1; //same settings also return -1
ret1=-1;
}
}
}
if (getDetectorsType() != MYTHEN){
//if set by the slsDetector
if(ret1 == 0)
thisMultiDetector->correctionMask&=~(1<<RATE_CORRECTION);
else
thisMultiDetector->correctionMask|=(1<<RATE_CORRECTION);
if (getDetectorsType() == EIGER)
return ret1;
}
//only mythen
if (thisMultiDetector->correctionMask&(1<<RATE_CORRECTION)) {
@ -2651,6 +2641,10 @@ double multiSlsDetector::getRateCorrectionTau(){
int multiSlsDetector::getRateCorrection(){
if (getDetectorsType() == EIGER){
return getRateCorrectionTau();
}
if (thisMultiDetector->correctionMask&(1<<RATE_CORRECTION)) {
return 1;
} else
@ -4313,8 +4307,8 @@ int multiSlsDetector::readConfigurationFile(string const fname){
infile.close();
if(getDetectorsType() != MYTHEN)
printReceiverConfiguration();
//if(getDetectorsType() != MYTHEN)
// printReceiverConfiguration();
} else {
std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl;

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/mythenDetectorServer
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git/mythenDetectorServer
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 769ba51f2796ac8088f29a6cdb87955befbbdae2
Revision: 102
Repsitory UUID: f65bc993ef8b3548b52e677b3f42ae6229611d73
Revision: 103
Branch: developer
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 326
Last Changed Date: 2016-07-05 17:24:44 +0200
Last Changed Rev: 327
Last Changed Date: 2016-07-12 16:45:00 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@git.psi.ch:sls_detectors_software/sls_detector_software.git/mythenDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "769ba51f2796ac8088f29a6cdb87955befbbdae2"
//#define SVNREV 0x326
#define SVNREPUUID "f65bc993ef8b3548b52e677b3f42ae6229611d73"
//#define SVNREV 0x327
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Dhanya_Maliakal"
#define SVNREV 0x326
#define SVNDATE 0x20160705
#define SVNREV 0x327
#define SVNDATE 0x20160712
//

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURLLIB "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUIDLIB "769ba51f2796ac8088f29a6cdb87955befbbdae2"
//#define SVNREV 0x1103
#define SVNREPUUIDLIB "f65bc993ef8b3548b52e677b3f42ae6229611d73"
//#define SVNREV 0x1109
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTHLIB "Dhanya_Maliakal"
#define SVNREVLIB 0x1103
#define SVNDATELIB 0x20160705
#define SVNREVLIB 0x1109
#define SVNDATELIB 0x20160712
//

View File

@ -2774,15 +2774,15 @@ int slsDetector::setModule(sls_detector_module module, int* gainval, int* offset
controlSocket->SendDataOnly(gainval,sizeof(int)*thisDetector->nGain);
if((thisDetector->nOffset) && (offsetval))
controlSocket->SendDataOnly(offsetval,sizeof(int)*thisDetector->nOffset);
if(thisDetector->myDetectorType == EIGER)
if(thisDetector->myDetectorType == EIGER){
controlSocket->SendDataOnly(iodelay,sizeof(int));
if(thisDetector->myDetectorType == EIGER)
controlSocket->SendDataOnly(&tau,sizeof(tau));
}
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
if (ret!=FAIL)
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
} else {
else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
@ -2792,13 +2792,6 @@ int slsDetector::setModule(sls_detector_module module, int* gainval, int* offset
}
}
if(ret == FAIL && thisDetector->myDetectorType == EIGER && strcasestr(mess,"Rate")){
setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION));
if(strcasestr(mess,"tau/subexptime"))
setErrorMask((getErrorMask())|(RATE_CORRECTION_TAU_SUBEXPOSURE));
thisDetector->correctionMask&=~(1<<RATE_CORRECTION);
thisDetector->tDead = 0;
}
if (ret!=FAIL) {
if (detectorModules) {
@ -2850,6 +2843,7 @@ int slsDetector::setModule(sls_detector_module module, int* gainval, int* offset
for (int i=0; i<thisDetector->nOffset; i++)
offset[i+imod*thisDetector->nOffset]=offsetval[i];
}
}
#ifdef VERBOSE
@ -3956,7 +3950,10 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
setTotalProgress();
}
double r;
if((index == SUBFRAME_ACQUISITION_TIME) && (thisDetector->myDetectorType == EIGER) && (t>=0) && getRateCorrection(r)){
setRateCorrection(r);
}
//send acquisiton period/frame number to receiver
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)){
@ -5001,7 +4998,37 @@ int slsDetector::flatFieldCorrect(double* datain, double *errin, double* dataout
int slsDetector::setRateCorrection(double t){
if (getDetectorsType() == MYTHEN){
if (getDetectorsType() == EIGER){
int fnum=F_SET_RATE_CORRECT;
int ret=FAIL;
char mess[1000]="";
int64_t arg = t;
int64_t retval = -1;
#ifdef VERBOSE
std::cout<< "Setting Rate Correction to " << arg << endl;
#endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&arg,sizeof(arg));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION));
if(strcasestr(mess,"tau/subexptime"))
setErrorMask((getErrorMask())|(RATE_CORRECTION_TAU_SUBEXPOSURE));
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return ret; //only success/fail
}
//mythen
double tdead[]=defaultTDead;
if (t==0) {
#ifdef VERBOSE
@ -5023,61 +5050,18 @@ int slsDetector::setRateCorrection(double t){
#endif
}
return thisDetector->correctionMask&(1<<RATE_CORRECTION);
}
int fnum=F_SET_RATE_CORRECT;
int ret=FAIL;
char mess[1000]="";
int64_t arg = t;
int64_t retval = -1;
#ifdef VERBOSE
std::cout<< "Setting Rate Correction to " << arg << endl;
#endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&arg,sizeof(arg));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
if(retval<0){
thisDetector->correctionMask&=~(1<<RATE_CORRECTION);
thisDetector->tDead = 0;
}else{
if(retval>0){
thisDetector->correctionMask|=(1<<RATE_CORRECTION);
if(t < 0)
thisDetector->tDead = -1;
else
thisDetector->tDead = (double)retval;
}
else{
thisDetector->correctionMask&=~(1<<RATE_CORRECTION);
thisDetector->tDead = (double)retval;
}
}
} else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_SET_RATE_CORRECTION));
if(strcasestr(mess,"tau/subexptime"))
setErrorMask((getErrorMask())|(RATE_CORRECTION_TAU_SUBEXPOSURE));
thisDetector->correctionMask&=~(1<<RATE_CORRECTION);
thisDetector->tDead = 0;
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return thisDetector->correctionMask&(1<<RATE_CORRECTION);
}
int slsDetector::getRateCorrection(double &t){
if (thisDetector->myDetectorType == EIGER){
t = getRateCorrectionTau();
return t;
}
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
#ifdef VERBOSE
std::cout<< "Rate correction is enabled with dead time "<< thisDetector->tDead << std::endl;
@ -5094,6 +5078,35 @@ int slsDetector::getRateCorrection(double &t){
double slsDetector::getRateCorrectionTau(){
if(thisDetector->myDetectorType == EIGER){
int fnum=F_GET_RATE_CORRECT;
int ret=FAIL;
char mess[1000]="";
int64_t retval = -1;
#ifdef VERBOSE
std::cout<< "Setting Rate Correction to " << arg << endl;
#endif
if (setOnline(ONLINE_FLAG)==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL)
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
disconnectControl();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return double(retval);
}
//mythen only
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
#ifdef VERBOSE
std::cout<< "Rate correction is enabled with dead time "<< thisDetector->tDead << std::endl;
@ -5113,6 +5126,11 @@ double slsDetector::getRateCorrectionTau(){
int slsDetector::getRateCorrection(){
if (thisDetector->myDetectorType == EIGER){
double t = getRateCorrectionTau();
return (int)t;
}
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
return 1;
} else

View File

@ -54,6 +54,8 @@ int pulseChip(int n);
int64_t setRateCorrection(int64_t custom_tau_in_nsec);
int getRateCorrectionEnable();
int getDefaultSettingsTau_in_nsec();
void setDefaultSettingsTau_in_nsec(int t);
int64_t getCurrentTau();
#endif
#if defined(MYTHEND) || defined(GOTTHARDD)
@ -70,7 +72,7 @@ int getChip(sls_detector_chip *myChip);
#ifdef EIGERD
int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay, int64_t tau_ns);
int setModule(sls_detector_module myMod, int* gain, int* offset,int* delay);
int getModule(sls_detector_module *myMod, int* gain, int* offset);
#else
int setModule(sls_detector_module myMod);
@ -79,6 +81,7 @@ int getModule(sls_detector_module *myMod);
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
enum detectorSettings getSettings();
#if defined(MYTHEND) || defined(EIGERD)
int getThresholdEnergy(int imod);

View File

@ -180,7 +180,8 @@ int function_table() {
flist[F_PULSE_PIXEL]=&pulse_pixel;
flist[F_PULSE_PIXEL_AND_MOVE]=&pulse_pixel_and_move;
flist[F_PULSE_CHIP]=&pulse_chip;
flist[F_SET_RATE_CORRECT]=&rate_correct;
flist[F_SET_RATE_CORRECT]=&set_rate_correct;
flist[F_GET_RATE_CORRECT]=&get_rate_correct;
#ifdef VERBOSE
@ -1803,6 +1804,8 @@ int set_module(int file_des) {
int retval, n;
int ret=OK,ret1=OK;
strcpy(mess,"could not set module.");
#ifdef SLS_DETECTOR_FUNCTION_LIST
sls_detector_module myModule;
#ifdef EIGERD
@ -1905,29 +1908,43 @@ int set_module(int file_des) {
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else {
#ifdef EIGERD
ret=setModule(myModule, myGain, myOffset,myIODelay,myTau);
//rate correction errors
switch(ret){
case -1:
sprintf(mess,"Cannot set Rate correction. Rate correction Deactivated, settings %d not recognized by detector\n",thisSettings);
cprintf(RED,"%s",mess);
ret=setModule(myModule, myGain, myOffset,myIODelay);
//rate correction
if(myTau > -2){ //ignore -2: from load settings)
//set default tau value (-1 or a normal value)
setDefaultSettingsTau_in_nsec(myTau);
//switch off rate correction: no value read from load calib/load settings)
if(myTau == -1){
ret = FAIL;
break;
case -2:
strcpy(mess,"Could not set Rate correction. Rate correction Deactivated, (tau/subexptime) must be < 0.0015\n");
cprintf(RED,"%s",mess);
ret = FAIL;
break;
case -3:
strcpy(mess,"Could not set Rate correction. Rate correction Deactivated\n");
cprintf(RED,"%s",mess);
ret = FAIL;
break;
if(getRateCorrectionEnable()){
setRateCorrection(0);
strcat(mess," Cannot set Rate correction. No default tau provided. Deactivating Rate Correction\n");
}else{
strcat(mess," Cannot set Rate correction. No default tau provided\n");
}
cprintf(RED,"%s",mess);
}
//normal tau value (only if enabled)
else if (getRateCorrectionEnable()){
int64_t retvalTau = setRateCorrection(myTau); //myTau will not be -1 here
if(myTau != retvalTau){
if(retvalTau == -1)
strcat(mess," Rate correction Deactivated, (tau/subexptime) must be < 0.0015\n");
cprintf(RED,"%s",mess);
ret=FAIL;
}
}
}
retval = getSettings();
#else
ret=setModule(myModule);
#endif
retval = ret;
#endif
}
}
#endif
@ -3863,10 +3880,9 @@ int pulse_chip(int file_des) {
int rate_correct(int file_des) {
int set_rate_correct(int file_des) {
int64_t tau_ns=-1;
int n;
int64_t retval=-1;
int ret=OK,ret1=OK;
sprintf(mess,"can't set/unset rate correction\n");
@ -3886,25 +3902,33 @@ int rate_correct(int file_des) {
#ifdef SLS_DETECTOR_FUNCTION_LIST
//tau = -1, use default tau of settings
if((ret==OK)&&(tau_ns<0)){
tau_ns = getDefaultSettingsTau_in_nsec();
if(tau_ns < 0){
ret = FAIL;
sprintf(mess,"Cannot set rate correction. Settings %d not recognized by detector\n",thisSettings);
cprintf(RED,"%s",mess);
}
}
if (ret==OK) {
printf("Setting rate correction to %lld ns\n",tau_ns);
if (differentClients==1 && lockStatus==1 && tau_ns!=-1) {
if (differentClients==1 && lockStatus==1) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else {
retval = setRateCorrection(tau_ns); //tau_ns will not be -1 here
//tau = -1, use default tau of settings
if((ret==OK)&&(tau_ns<0)){
tau_ns = getDefaultSettingsTau_in_nsec();
}
//still negative (not set)
if(tau_ns < 0){
ret = FAIL;
if(getRateCorrectionEnable()){
setRateCorrection(0);
strcpy(mess,"Cannot set rate correction as default tau not provided. Switching off Rate Correction\n");
}else{
strcpy(mess,"Cannot set rate correction as default tau not provided\n");
}
cprintf(RED,"%s",mess);
}
//set rate
else{
int64_t retval = setRateCorrection(tau_ns); //tau_ns will not be -1 here
if(tau_ns != retval){
if(retval == -1)
strcpy(mess,"Rate correction Deactivated, (tau/subexptime) must be < 0.0015\n");
@ -3913,6 +3937,7 @@ int rate_correct(int file_des) {
}
}
}
}
#endif
if ((ret==OK) && (differentClients))
ret=FORCE_UPDATE;
@ -3923,8 +3948,45 @@ int rate_correct(int file_des) {
n = sendData(file_des,&ret1,sizeof(ret),INT32);
if (ret==FAIL) {
n = sendData(file_des,mess,sizeof(mess),OTHER);
} else {
n = sendData(file_des,&retval,sizeof(retval),INT64);
}
return ret;
}
int get_rate_correct(int file_des) {
int64_t retval=-1;
int ret=OK,ret1=OK;
sprintf(mess,"can't get rate correction\n");
#ifndef EIGERD
sprintf(mess,"Rate Correction not implemented for this detector\n");
cprintf(RED,"%s",mess);
ret=FAIL;
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
retval = getCurrentTau();
printf("Getting rate correction %lld\n",(long long int)retval);
}
#endif
if ((ret==OK) && (differentClients))
ret=FORCE_UPDATE;
//ret could be swapped during sendData
ret1 = ret;
sendData(file_des,&ret1,sizeof(ret),INT32);
if (ret==FAIL) {
sendData(file_des,mess,sizeof(mess),OTHER);
} else {
sendData(file_des,&retval,sizeof(retval),INT64);
}
return ret;

View File

@ -87,7 +87,7 @@ int set_counter_bit(int);
int pulse_pixel(int);
int pulse_pixel_and_move(int);
int pulse_chip(int);
int rate_correct(int);
int set_rate_correct(int);
int get_rate_correct(int);
#endif