mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
added trimval function, but sending trimbits from char to int bug
This commit is contained in:
parent
e15d6077df
commit
7e46a407c6
@ -49,6 +49,7 @@ using namespace std;
|
||||
#define RECEIVER_FRAME_NUM_NOT_SET 0x0000000000000400ULL
|
||||
#define RECEIVER_DYNAMIC_RANGE 0x0000000000000800ULL
|
||||
#define RECEIVER_TEN_GIGA 0x0000000000001000ULL
|
||||
#define ALLTIMBITS_NOT_SET 0x0000000000002000ULL
|
||||
|
||||
// 0x00000000FFFFFFFFULL
|
||||
/** @short class returning all error messages for error mask */
|
||||
@ -146,6 +147,9 @@ public:
|
||||
if(slsErrorMask&RECEIVER_TEN_GIGA)
|
||||
retval.append("Could not enable/disable 10GbE in the receiver.\n");
|
||||
|
||||
if(slsErrorMask&ALLTIMBITS_NOT_SET)
|
||||
retval.append("Could not set all trimbits to value.\n");
|
||||
|
||||
|
||||
|
||||
return retval;
|
||||
|
@ -89,7 +89,8 @@ enum {
|
||||
F_RESET_COUNTER_BLOCK, /**< resets the counter block memory for gotthard */
|
||||
F_CALIBRATE_PEDESTAL, /**< starts acquistion, calibrates pedestal and write back to fpga */
|
||||
|
||||
F_ENABLE_TEN_GIGA /**< enable 10Gbe */
|
||||
F_ENABLE_TEN_GIGA, /**< enable 10Gbe */
|
||||
F_SET_ALL_TRIMBITS /** < set all trimbits to this value */
|
||||
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "slsDetectorServer_defs.h" //include port number
|
||||
|
||||
struct sockaddr_in eiger_socket_addr;
|
||||
int eiger_max_message_length = 1024;
|
||||
char eiger_message[1024];
|
||||
int eiger_max_message_length = 270000;//263681
|
||||
char eiger_message[270000];//263681
|
||||
int eiger_message_length = 0;
|
||||
int eiger_ret_val=0;
|
||||
|
||||
@ -55,6 +55,8 @@ int EigerGetExternalGating(){return eiger_extgating;}
|
||||
int EigerGetExternalGatingPolarity(){return eiger_extgatingpolarity;}
|
||||
|
||||
int EigerInit(){
|
||||
saved_trimbits[0] = -1;
|
||||
|
||||
static int passed = 0;
|
||||
|
||||
if(!passed){
|
||||
@ -145,7 +147,7 @@ int EigerSetTrimbits(const int *data){
|
||||
int ichip;
|
||||
|
||||
// convert the trimbits from int32 to chars and add border pixels.
|
||||
for(iy=0;iy<256;y++) {
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=(char)(data[ich++]&(0x3f));
|
||||
@ -170,12 +172,13 @@ int EigerSetAllTrimbits(unsigned int value){
|
||||
int ip=0, ich=0;
|
||||
int iy, ix;
|
||||
int ichip;
|
||||
int sl=0;
|
||||
|
||||
// convert the trimbits from int32 to chars and add border pixels.
|
||||
for(iy=0;iy<256;y++) {
|
||||
for(iy=0;iy<256;iy++) {
|
||||
for (ichip=0; ichip<4; ichip++) {
|
||||
for(ix=0;ix<256;ix++) {
|
||||
tt[ip++]=value&0x3f;
|
||||
tt[ip++]=(char)(value&0x3f);
|
||||
}
|
||||
if (ichip<3) {
|
||||
tt[ip++]=0;
|
||||
@ -183,30 +186,27 @@ int EigerSetAllTrimbits(unsigned int value){
|
||||
}
|
||||
}
|
||||
}
|
||||
eiger_message_length = sprintf(eiger_message,"settrimbits %s", tt);
|
||||
memcpy(saved_trimbits,data,256*256*4*sizeof(int));
|
||||
|
||||
char s2[270000];
|
||||
strcpy(s2,"settrimbits ");
|
||||
//for()
|
||||
sl=strlen(s2);
|
||||
strncpy(s2+sl,tt, 263680);
|
||||
s2[263680+sl]='\0';
|
||||
|
||||
eiger_message_length = strlen(s2);
|
||||
//eiger_message_length = sprintf(eiger_message,"settrimbits %s", tt);
|
||||
for (iy=0;iy<263680;++iy)
|
||||
printf("%d:%c\t\t",iy,tt[iy]);
|
||||
printf("tfggt:%s , length :%d\n",tt, strlen(tt));
|
||||
printf("Command sent:%s , length :%d\n",s2, eiger_message_length);
|
||||
for(iy=0;iy<256*256*4;++iy)
|
||||
saved_trimbits[iy] = value;
|
||||
return EigerSendCMD();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* int EigerGetTrimbits(const int *data){ */
|
||||
/* eiger_ret_val=0; */
|
||||
/* char tt[263681]; */
|
||||
/* tt[263680]='\0'; */
|
||||
/* int ip=0, ich=0; */
|
||||
/* int iy, ix; */
|
||||
/* int ichip; */
|
||||
|
||||
/* eiger_message_length = sprintf(eiger_message,"settrimbits %s", tt); */
|
||||
/* memcpy(data,saved_trimbits,256*256*4*sizeof(int)); */
|
||||
/* return EigerSendCMD(); */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
|
||||
int EigerGetTrimbits(const int *data){
|
||||
eiger_ret_val=0;
|
||||
char tt[263681];
|
||||
@ -222,9 +222,6 @@ int EigerSetAllTrimbits(unsigned int value){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int EigerGetDAC(const char* iname){
|
||||
eiger_ret_val=1;
|
||||
eiger_message_length = sprintf(eiger_message,"getdacvalue %s",iname);
|
||||
|
@ -698,62 +698,62 @@ float FebControl::GetDAC(string s){
|
||||
*/
|
||||
|
||||
bool FebControl::SetTrimbits(unsigned int module_num, unsigned char *trimbits){
|
||||
|
||||
unsigned int module_index=0;
|
||||
if(!GetModuleIndex(module_num,module_index)){
|
||||
cout<<"Warning could not set trimbits, bad module number."<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!Reset()) cout<<"Warning could not reset DAQ."<<endl;
|
||||
|
||||
for(int l_r=0;l_r<2;l_r++){ // l_r loop
|
||||
unsigned int disable_chip_mask = l_r ? DAQ_CS_BAR_LEFT : DAQ_CS_BAR_RIGHT;
|
||||
|
||||
if(!(WriteRegister(0xfff,DAQ_REG_STATIC_BITS,disable_chip_mask|DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_M8)&&SetCommandRegister(DAQ_SET_STATIC_BIT)&&StartDAQOnlyNWaitForFinish())){
|
||||
cout<<"Could not select chips"<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(int row_set=0;row_set<16;row_set++){ //16 rows at a time
|
||||
if(row_set==0){
|
||||
if(!SetCommandRegister(DAQ_RESET_COMPLETELY|DAQ_SEND_A_TOKEN_IN|DAQ_LOAD_16ROWS_OF_TRIMBITS)){
|
||||
cout<<"Warning: Could not SetCommandRegister for loading trim bits."<<endl;
|
||||
return 0;
|
||||
printf("aaa\n");
|
||||
unsigned int module_index=0;
|
||||
if(!GetModuleIndex(module_num,module_index)){
|
||||
cout<<"Warning could not set trimbits, bad module number."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}else{
|
||||
if(!SetCommandRegister(DAQ_LOAD_16ROWS_OF_TRIMBITS)){
|
||||
cout<<"Warning: Could not SetCommandRegister for loading trim bits."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
printf("bbb\n");
|
||||
if(!Reset()) cout<<"Warning could not reset DAQ."<<endl;
|
||||
printf("ccc\n");
|
||||
for(int l_r=0;l_r<2;l_r++){ // l_r loop
|
||||
unsigned int disable_chip_mask = l_r ? DAQ_CS_BAR_LEFT : DAQ_CS_BAR_RIGHT;
|
||||
|
||||
static unsigned int trimbits_to_load_l[1024];
|
||||
static unsigned int trimbits_to_load_r[1024];
|
||||
for(int row=0;row<16;row++){ //row loop
|
||||
int offset = 2*32*row;
|
||||
for(int sc=0;sc<32;sc++){ //supercolumn loop sc
|
||||
int super_column_start_position_l = 1030*row + l_r *258 + sc*8;
|
||||
int super_column_start_position_r = 1030*row + 516 + l_r *258 + sc*8;
|
||||
int chip_sc = 31 - sc;
|
||||
trimbits_to_load_l[offset+chip_sc] = 0;
|
||||
trimbits_to_load_r[offset+chip_sc] = 0;
|
||||
for(int i=0;i<8;i++){ // column loop i
|
||||
trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])>>3)<<((7-i)*4);//upper
|
||||
trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_r[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])>>3)<<((7-i)*4);//upper
|
||||
} // end column loop i
|
||||
} //end supercolumn loop sc
|
||||
} //end row loop
|
||||
if(!(WriteRegister(0xfff,DAQ_REG_STATIC_BITS,disable_chip_mask|DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_M8)&&SetCommandRegister(DAQ_SET_STATIC_BIT)&&StartDAQOnlyNWaitForFinish())){
|
||||
cout<<"Could not select chips"<<endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!WriteMemory(modules[0]->GetTopLeftAddress(),0,0,1024,trimbits_to_load_r)||!WriteMemory(modules[0]->GetTopRightAddress(),0,0,1024,trimbits_to_load_l)||!StartDAQOnlyNWaitForFinish()) return 0;
|
||||
} //end row_set loop (groups of 16 rows)
|
||||
} // end l_r loop
|
||||
for(int row_set=0;row_set<16;row_set++){ //16 rows at a time
|
||||
if(row_set==0){
|
||||
if(!SetCommandRegister(DAQ_RESET_COMPLETELY|DAQ_SEND_A_TOKEN_IN|DAQ_LOAD_16ROWS_OF_TRIMBITS)){
|
||||
cout<<"Warning: Could not SetCommandRegister for loading trim bits."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}else{
|
||||
if(!SetCommandRegister(DAQ_LOAD_16ROWS_OF_TRIMBITS)){
|
||||
cout<<"Warning: Could not SetCommandRegister for loading trim bits."<<endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(last_downloaded_trimbits,trimbits,trimbit_size*sizeof(unsigned char));
|
||||
static unsigned int trimbits_to_load_l[1024];
|
||||
static unsigned int trimbits_to_load_r[1024];
|
||||
for(int row=0;row<16;row++){ //row loop
|
||||
int offset = 2*32*row;
|
||||
for(int sc=0;sc<32;sc++){ //supercolumn loop sc
|
||||
int super_column_start_position_l = 1030*row + l_r *258 + sc*8;
|
||||
int super_column_start_position_r = 1030*row + 516 + l_r *258 + sc*8;
|
||||
int chip_sc = 31 - sc;
|
||||
trimbits_to_load_l[offset+chip_sc] = 0;
|
||||
trimbits_to_load_r[offset+chip_sc] = 0;
|
||||
for(int i=0;i<8;i++){ // column loop i
|
||||
trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])>>3)<<((7-i)*4);//upper
|
||||
trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_r[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])>>3)<<((7-i)*4);//upper
|
||||
} // end column loop i
|
||||
} //end supercolumn loop sc
|
||||
} //end row loop
|
||||
|
||||
return SetStaticBits(); //send the static bits
|
||||
if(!WriteMemory(modules[0]->GetTopLeftAddress(),0,0,1024,trimbits_to_load_r)||!WriteMemory(modules[0]->GetTopRightAddress(),0,0,1024,trimbits_to_load_l)||!StartDAQOnlyNWaitForFinish()) return 0;
|
||||
} //end row_set loop (groups of 16 rows)
|
||||
} // end l_r loop
|
||||
|
||||
memcpy(last_downloaded_trimbits,trimbits,trimbit_size*sizeof(unsigned char));
|
||||
|
||||
return SetStaticBits(); //send the static bits
|
||||
}
|
||||
|
||||
|
||||
|
@ -259,7 +259,12 @@ int main(int argc, char* argv[]){
|
||||
break;
|
||||
|
||||
case evSetTrimBits :
|
||||
feb_controler->SetTrimbits(0,(unsigned char*)data);
|
||||
tmp_str[0] = GetNextString(data);
|
||||
/*char tt[263681];*/
|
||||
for(int i=0;i<10;i++)
|
||||
cout <<i<<":"<<tmp_str[0][i]<<"\t\t";
|
||||
printf("Cjhgkfdjg :%s\n",tmp_str[0].c_str());
|
||||
feb_controler->SetTrimbits(0,(unsigned char*)(tmp_str[0].c_str()));
|
||||
return_message.append("\tExecuted: SetTrimBits "); AddNumber(return_message,n[0]); return_message.append("\n");
|
||||
ret_val = 0;
|
||||
break;
|
||||
|
Binary file not shown.
Binary file not shown.
@ -141,6 +141,7 @@ int64_t getDetectorId(enum idMode arg){
|
||||
|
||||
|
||||
int getDetectorNumber(){
|
||||
|
||||
int res=0;
|
||||
char hostname[100];
|
||||
if (gethostname(hostname, sizeof hostname) == 0)
|
||||
@ -159,8 +160,13 @@ int getDetectorNumber(){
|
||||
pclose(sysFile);
|
||||
sscanf(output,"%x",&res);
|
||||
return res;
|
||||
*/
|
||||
/*
|
||||
int res=0;
|
||||
char hostname[100] = "beb000";
|
||||
sscanf(hostname,"%x",&res);
|
||||
return res;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -291,8 +297,9 @@ int setModule(sls_detector_module myMod){
|
||||
// thisSettings = (enum detectorSettings)myMod.reg;
|
||||
// thisSettings = 0;
|
||||
|
||||
setSettings( (enum detectorSettings)myMod.reg); // put the settings in the module register?!?!?
|
||||
/** set trimbits*/
|
||||
setSettings( (enum detectorSettings)myMod.reg,-1); // put the settings in the module register?!?!?
|
||||
EigerSetTrimbits(myMod.chanregs);
|
||||
|
||||
if (detectorModules)
|
||||
copyModule(detectorModules,&myMod);
|
||||
return 0;
|
||||
@ -598,6 +605,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
|
||||
}
|
||||
|
||||
|
||||
|
||||
int getTotalNumberOfChannels(){return getNumberOfChannelsPerModule();};//NCHIP*NCHAN*nModBoard;}
|
||||
int getTotalNumberOfChips(){return 4;};//NCHIP*nModBoard;}
|
||||
int getTotalNumberOfModules(){return 1;}//nModBoard;}
|
||||
@ -675,6 +683,21 @@ enum synchronizationMode setSynchronization(enum synchronizationMode arg){
|
||||
return NO_SYNCHRONIZATION;
|
||||
}
|
||||
|
||||
void setAllTrimbits(int val){
|
||||
int ichan;
|
||||
EigerSetAllTrimbits(val);
|
||||
#ifdef VERBOSE
|
||||
printf("Copying register %x value %d\n",destMod->reg,val);
|
||||
#endif
|
||||
if (detectorModules){
|
||||
for (ichan=0; ichan<(detectorModules->nchan); ichan++) {
|
||||
*((detectorModules->chanregs)+ichan)=val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getAllTrimbits(){
|
||||
return *((detectorModules->chanregs));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -3721,6 +3721,36 @@ int multiSlsDetector::saveSettingsFile(string fname, int imod) {
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::setAllTrimbits(int val, int imod){
|
||||
|
||||
int ret=-100, ret1,id, im;
|
||||
|
||||
if (decodeNMod(imod, id, im)>=0) {
|
||||
if (detectors[id]) {
|
||||
ret1=detectors[id]->setAllTrimbits(val,im);
|
||||
if(detectors[id]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<id));
|
||||
}
|
||||
}
|
||||
else if (imod<0) {
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret1=detectors[idet]->setAllTrimbits(val,imod);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
int id, im, ret;
|
||||
|
@ -474,6 +474,14 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
int saveSettingsFile(string fname, int nmod=0);
|
||||
|
||||
|
||||
/** sets all the trimbits to a particular value
|
||||
\param val trimbit value
|
||||
\param imod module number, -1 means all modules
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int setAllTrimbits(int val, int imod=-1);
|
||||
|
||||
|
||||
/** loads the modules calibration data reading from a file - file name extension is automatically generated! */
|
||||
int loadCalibrationFile(string fname, int nmod=0);
|
||||
|
||||
|
@ -5719,6 +5719,41 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
|
||||
|
||||
|
||||
|
||||
int slsDetector::setAllTrimbits(int val, int imod){
|
||||
int fnum=F_SET_ALL_TRIMBITS;
|
||||
int retval;
|
||||
char mess[100];
|
||||
int ret=OK;
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Setting all trimbits to "<< val << std::endl;
|
||||
#endif
|
||||
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(&val,sizeof(val));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL) {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(ALLTIMBITS_NOT_SET));
|
||||
} else {
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
}
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "All trimbits were set to "<< retval << std::endl;
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::loadCalibrationFile(string fname, int imod) {
|
||||
|
@ -510,6 +510,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int saveSettingsFile(string fname, int imod=-1);
|
||||
|
||||
/** sets all the trimbits to a particular value
|
||||
\param val trimbit value
|
||||
\param imod module number, -1 means all modules
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
int setAllTrimbits(int val, int imod=-1);
|
||||
|
||||
|
||||
/** loads the modules calibration data reading from a file
|
||||
\param fname file name . If not specified, extension is automatically generated!
|
||||
|
@ -497,6 +497,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="trimval"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="pedestal"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
|
||||
@ -2912,6 +2915,15 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
|
||||
myDet->saveSettingsFile(sval, -1);
|
||||
return string("done");
|
||||
|
||||
} else if (cmd=="trimval") {
|
||||
if (action==PUT_ACTION){
|
||||
if (sscanf(args[1],"%d",&val))
|
||||
myDet->setAllTrimbits(val);
|
||||
else
|
||||
return string("invalid trimbit value ")+cmd;
|
||||
}
|
||||
sprintf(ans,"%d",myDet->setAllTrimbits(-1));
|
||||
return ans;
|
||||
} else if (cmd=="pedestal") {
|
||||
if (action==GET_ACTION)
|
||||
return string("cannot get");
|
||||
@ -2935,6 +2947,7 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
|
||||
os << "threshold eV\n sets the detector threshold in eV"<< std::endl;
|
||||
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
|
||||
os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl;
|
||||
os << "trimval i \n sets all the trimbits to i" << std::endl;
|
||||
os << "pedestal i \n starts acquisition for i frames, calculates pedestal and writes back to fpga."<< std::endl;
|
||||
|
||||
}
|
||||
@ -2942,6 +2955,7 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
|
||||
os << "settings \n gets the settings of the detector"<< std::endl;
|
||||
os << "threshold V\n gets the detector threshold"<< std::endl;
|
||||
os << "trimbits [fname]\n returns the trimfile loaded on the detector. If fname is specified the trimbits are saved to file. If no extension is specified, the serial number of each module will be attached."<< std::endl;
|
||||
os << "trimval \n returns the value all trimbits are set to. If they are different, returns -1." << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
|
||||
|
@ -490,6 +490,14 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
*/
|
||||
virtual int saveSettingsFile(string fname, int imod=-1)=0;
|
||||
|
||||
/** sets all the trimbits to a particular value
|
||||
\param val trimbit value
|
||||
\param imod module number, -1 means all modules
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int setAllTrimbits(int val, int imod=-1)=0;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -128,6 +128,8 @@ enum synchronizationMode setSynchronization(enum synchronizationMode arg);
|
||||
|
||||
#ifdef EIGERD
|
||||
void setExternalGating(int enable[]);
|
||||
void setAllTrimbits(int val);
|
||||
int getAllTrimbits();
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -157,7 +157,7 @@ int function_table() {
|
||||
flist[F_STOP_RECEIVER]=&stop_receiver;
|
||||
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
|
||||
flist[F_ENABLE_TEN_GIGA]=&enable_ten_giga;
|
||||
|
||||
flist[F_SET_ALL_TRIMBITS]=&set_all_trimbits;
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -3420,3 +3420,60 @@ int enable_ten_giga(int file_des) {
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int set_all_trimbits(int file_des){
|
||||
|
||||
|
||||
int retval;
|
||||
int arg;
|
||||
int n;
|
||||
int ret=OK,ret1=OK;
|
||||
|
||||
sprintf(mess,"can't set sll trimbits\n");
|
||||
|
||||
n = receiveData(file_des,&arg,sizeof(arg),INT32);
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("setting all trimbits to %d\n",arg);
|
||||
#endif
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else {
|
||||
if(arg < -1){
|
||||
ret = FAIL;
|
||||
strcpy(mess,"Cant set trimbits to this value\n");
|
||||
}else {
|
||||
if(arg >= 0)
|
||||
setAllTrimbits(arg);
|
||||
retval = getAllTrimbits();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ret==OK) {
|
||||
if (arg!=-1 && arg!=retval) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Could not set all trimbits: should be %d but is %d\n", arg, retval);
|
||||
}else if (differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
|
||||
//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);
|
||||
} else {
|
||||
n = sendData(file_des,&retval,sizeof(retval),INT32);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
@ -81,5 +81,6 @@ int start_receiver(int);
|
||||
int stop_receiver(int);
|
||||
int calibrate_pedestal(int);
|
||||
int enable_ten_giga(int);
|
||||
int set_all_trimbits(int);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user