mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-04 20:00:04 +02:00
reset counter bit in eiger detector partially or completely
This commit is contained in:
parent
11dafc6ebf
commit
8b0895add0
@ -52,6 +52,7 @@ using namespace std;
|
||||
#define COULD_NOT_SET_SPEED_PARAMETERS 0x0000000000004000ULL
|
||||
#define COULD_NOT_SET_READOUT_FLAGS 0x0000000000008000ULL
|
||||
#define COULD_NOT_SET_FIFO_DEPTH 0x0000000000010000ULL
|
||||
#define COULD_NOT_SET_COUNTER_BIT 0x0000000000020000ULL
|
||||
|
||||
// 0x00000000FFFFFFFFULL
|
||||
/** @short class returning all error messages for error mask */
|
||||
@ -161,6 +162,9 @@ public:
|
||||
if(slsErrorMask&COULD_NOT_SET_FIFO_DEPTH)
|
||||
retval.append("Could not set receiver fifo depth\n");
|
||||
|
||||
if(slsErrorMask&COULD_NOT_SET_COUNTER_BIT)
|
||||
retval.append("Could not set/reset counter bit\n");
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
@ -93,7 +93,9 @@ enum {
|
||||
F_SET_ALL_TRIMBITS, /** < set all trimbits to this value */
|
||||
|
||||
F_SET_CTB_PATTERN, /** < loads a pattern in the CTB */
|
||||
F_WRITE_ADC_REG /** < writes an ADC register */
|
||||
F_WRITE_ADC_REG, /** < writes an ADC register */
|
||||
|
||||
F_SET_COUNTER_BIT /** < set/reset counter bit in detector for eiger */
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
@ -55,6 +55,8 @@ unsigned int* Feb_Control_last_downloaded_trimbits;
|
||||
int Feb_Control_module_number;
|
||||
int Feb_Control_current_index;
|
||||
|
||||
int counter_bit = 1;
|
||||
|
||||
|
||||
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){
|
||||
unsigned int i;
|
||||
@ -1408,7 +1410,18 @@ int Feb_Control_ResetChipCompletely(){
|
||||
printf("Warning: could not ResetChipCompletely().\n");;
|
||||
return 0;
|
||||
}
|
||||
printf("Chip reset completely\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Feb_Control_ResetChipPartially(){
|
||||
if(!Feb_Control_SetCommandRegister(DAQ_RESET_PERIPHERY & DAQ_RESET_COLUMN_SELECT) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
printf("Warning: could not ResetChipPartially().\n");;
|
||||
return 0;
|
||||
}
|
||||
printf("Chip reset partially\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1524,7 +1537,12 @@ int Feb_Control_PrepareForAcquisition(){//return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!Feb_Control_ResetChipCompletely()){
|
||||
int ret=0;
|
||||
if(counter_bit)
|
||||
ret = Feb_Control_ResetChipCompletely();
|
||||
else
|
||||
ret = Feb_Control_ResetChipPartially();
|
||||
if(!ret){
|
||||
printf("Trouble resetting chips ...\n");;
|
||||
return 0;
|
||||
}
|
||||
@ -1589,3 +1607,12 @@ int Feb_Control_SaveAllTrimbitsTo(int value){
|
||||
chanregs[i] = value;
|
||||
return Feb_Control_SetTrimbits(0,chanregs);
|
||||
}
|
||||
|
||||
|
||||
void Feb_Control_Set_Counter_Bit(int value){
|
||||
counter_bit = value;
|
||||
}
|
||||
|
||||
int Feb_Control_Get_Counter_Bit(){
|
||||
return counter_bit;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us);
|
||||
|
||||
int Feb_Control_ResetChipCompletely();
|
||||
int Feb_Control_ResetChipPartially();
|
||||
|
||||
//struct sockaddr_in Feb_Control_serv_addr;
|
||||
/*
|
||||
@ -174,6 +175,8 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_SetTestModeVariable(int on);
|
||||
int Feb_Control_GetTestModeVariable();
|
||||
|
||||
void Feb_Control_Set_Counter_Bit(int value);
|
||||
int Feb_Control_Get_Counter_Bit();
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -441,6 +441,18 @@ int enableTenGigabitEthernet(int val){
|
||||
}
|
||||
|
||||
|
||||
int setCounterBit(int val){
|
||||
if(val!=-1){
|
||||
Feb_Control_Set_Counter_Bit(val);
|
||||
#ifdef VERBOSE
|
||||
printf("Counter Bit:%d\n",val);
|
||||
#endif
|
||||
}
|
||||
|
||||
return Feb_Control_Get_Counter_Bit();
|
||||
}
|
||||
|
||||
|
||||
int setModule(sls_detector_module myMod, int* gain, int* offset){
|
||||
int retval[2];
|
||||
int i;
|
||||
@ -582,12 +594,9 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
|
||||
|
||||
|
||||
int startReceiver(int d){
|
||||
|
||||
//reset frame number
|
||||
printf("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit());
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
printf("Going to reset Frame Number\n");
|
||||
|
||||
//if(master)
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
Beb_ResetFrameNumber();
|
||||
|
||||
return OK;
|
||||
|
@ -3446,6 +3446,22 @@ int multiSlsDetector::resetCounterBlock(int startACQ){
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::setCounterBit(int i){
|
||||
int ret=-100,ret1;
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
|
||||
if (detectors[idet]){
|
||||
ret1=detectors[idet]->setCounterBit(i);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if(ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::setDynamicRange(int p) {
|
||||
|
@ -1061,6 +1061,13 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
*/
|
||||
int resetCounterBlock(int startACQ=0);
|
||||
|
||||
/** set/get counter bit in detector
|
||||
* @param i is -1 to get, 0 to reset and any other value to set the counter bit
|
||||
/returns the counter bit in detector
|
||||
*/
|
||||
int setCounterBit(int i = -1);
|
||||
|
||||
|
||||
int getMoveFlag(int imod);
|
||||
|
||||
|
||||
|
@ -5721,6 +5721,41 @@ int slsDetector::resetCounterBlock(int startACQ){
|
||||
|
||||
|
||||
|
||||
int slsDetector::setCounterBit(int i){
|
||||
int fnum=F_SET_COUNTER_BIT;
|
||||
int ret = FAIL;
|
||||
int retval=-1;
|
||||
char mess[100];
|
||||
|
||||
if(thisDetector->onlineFlag==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
if(i ==-1)
|
||||
std::cout<< "Getting counter bit from detector" << endl;
|
||||
else if(i==0)
|
||||
std::cout<< "Resetting counter bit in detector " << endl;
|
||||
else
|
||||
std::cout<< "Setting counter bit in detector " << endl;
|
||||
#endif
|
||||
if (connectControl() == OK){
|
||||
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&i,sizeof(i));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL){
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Receiver returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_SET_COUNTER_BIT));
|
||||
}
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1435,6 +1435,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int resetCounterBlock(int startACQ=0);
|
||||
|
||||
/** set/get counter bit in detector
|
||||
* @param i is -1 to get, 0 to reset and any other value to set the counter bit
|
||||
/returns the counter bit in detector
|
||||
*/
|
||||
int setCounterBit(int i = -1);
|
||||
|
||||
|
||||
int getMoveFlag(int imod){if (moveFlag) return *moveFlag; else return 1;};
|
||||
|
||||
|
@ -163,6 +163,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdCounter;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="setctrbit"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdCounter;
|
||||
i++;
|
||||
|
||||
/* trim/cal directories */
|
||||
descrToFuncMap[i].m_pFuncName="trimdir"; //OK
|
||||
@ -2203,6 +2206,7 @@ string slsDetectorCommand::helpImage(int narg, char *args[], int action){
|
||||
|
||||
string slsDetectorCommand::cmdCounter(int narg, char *args[], int action){
|
||||
int ival;
|
||||
char answer[100];
|
||||
string sval;
|
||||
int retval;
|
||||
if (action==HELP_ACTION)
|
||||
@ -2229,6 +2233,16 @@ string slsDetectorCommand::cmdCounter(int narg, char *args[], int action){
|
||||
retval=myDet->resetCounterBlock(ival);
|
||||
}
|
||||
|
||||
else if (string(args[0])==string("setctrbit")){
|
||||
if (action==PUT_ACTION){
|
||||
if (!sscanf(args[1],"%d",&ival))
|
||||
return string("Could not scan resetctrbit input ")+string(args[1]);
|
||||
if(ival>=0)
|
||||
sprintf(answer,"%d",myDet->setCounterBit(ival));
|
||||
}else
|
||||
sprintf(answer,"%d",myDet->setCounterBit());
|
||||
return string(answer);
|
||||
}
|
||||
|
||||
if(retval==OK)
|
||||
return string("Counter read/reset succesfully");
|
||||
@ -2243,10 +2257,13 @@ string slsDetectorCommand::helpCounter(int narg, char *args[], int action){
|
||||
if (action==PUT_ACTION || action==HELP_ACTION){
|
||||
os << "readctr \t Cannot put"<< std::endl;
|
||||
os << "resetctr i \t resets counter in detector, restarts acquisition if i=1"<< std::endl;
|
||||
os << "setctrbit i \t sets/resets counter bit in detector"<< std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION){
|
||||
os << "readctr i fname\t reads counter in detector to file fname, restarts acquisition if i=1"<< std::endl;
|
||||
os << "resetctr \t Cannot get"<< std::endl;
|
||||
os << "setctrbit i \t gets the counter bit in detector"<< std::endl;
|
||||
}
|
||||
if (action==GET_ACTION || action==HELP_ACTION)
|
||||
os << "readctr i fname\t reads counter in detector to file fname, restarts acquisition if i=1"<< std::endl;
|
||||
os << "resetctr \t Cannot get"<< std::endl;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
@ -382,8 +382,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual int resetCounterBlock(int startACQ=0)=0;
|
||||
|
||||
|
||||
|
||||
/** set/get counter bit in detector
|
||||
* @param i is -1 to get, 0 to reset and any other value to set the counter bit
|
||||
/returns the counter bit in detector
|
||||
*/
|
||||
virtual int setCounterBit(int i = -1)=0;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,6 +47,7 @@ int setHighVolage(int val, int imod);
|
||||
#ifdef EIGERD
|
||||
int setIODelay(int val, int imod);
|
||||
int enableTenGigabitEthernet(int val);
|
||||
int setCounterBit(int val);
|
||||
#endif
|
||||
|
||||
#if defined(MYTHEND) || defined(GOTTHARDD)
|
||||
|
@ -175,6 +175,7 @@ int function_table() {
|
||||
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
|
||||
flist[F_ENABLE_TEN_GIGA]=&enable_ten_giga;
|
||||
flist[F_SET_ALL_TRIMBITS]=&set_all_trimbits;
|
||||
flist[F_SET_COUNTER_BIT]=&set_counter_bit;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -3513,7 +3514,7 @@ int calibrate_pedestal(int file_des){
|
||||
|
||||
int enable_ten_giga(int file_des) {
|
||||
int n;
|
||||
int retval;
|
||||
int retval=-1;
|
||||
int ret=OK,ret1=OK;
|
||||
int arg = -1;
|
||||
|
||||
@ -3607,3 +3608,47 @@ int set_all_trimbits(int file_des){
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int set_counter_bit(int file_des) {
|
||||
int n;
|
||||
int retval = -1;
|
||||
int ret=OK,ret1=OK;
|
||||
int arg = -1;
|
||||
|
||||
sprintf(mess,"Can't set/rest counter bit \n");
|
||||
/* receive arguments */
|
||||
n = receiveData(file_des,&arg,sizeof(arg),INT32);
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
/* execute action */
|
||||
if(ret != FAIL){
|
||||
#ifdef VERBOSE
|
||||
printf("Getting/Setting/Resetting counter bit :%d \n",arg);
|
||||
#endif
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
retval=setCounterBit(arg);
|
||||
if((arg != -1) && (retval != arg))
|
||||
ret=FAIL;
|
||||
else if (differentClients==1) {
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* send answer */
|
||||
/* send OK/failed */
|
||||
//ret could be swapped during sendData
|
||||
ret1 = ret;
|
||||
n = sendData(file_des,&ret1,sizeof(ret),INT32);
|
||||
if (ret==FAIL)
|
||||
n += sendData(file_des,mess,sizeof(mess),OTHER);
|
||||
/* send return argument */
|
||||
n += sendData(file_des,&retval,sizeof(retval),INT32);
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
@ -83,5 +83,6 @@ int stop_receiver(int);
|
||||
int calibrate_pedestal(int);
|
||||
int enable_ten_giga(int);
|
||||
int set_all_trimbits(int);
|
||||
int set_counter_bit(int);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user