set settings for eiger drafts

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@811 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2014-04-01 08:43:39 +00:00
parent ac350640f3
commit 5ab4a88ec5
4 changed files with 48 additions and 33 deletions

View File

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> //to gethostname
#include <string.h> #include <string.h>
@ -33,16 +34,8 @@ int getNModBoard(enum dimension arg){
int64_t getModuleId(enum idMode arg, int imod){ int64_t getModuleId(enum idMode arg, int imod){
/*
switch(arg){ /**/
case MODULE_SERIAL_NUMBER:
return getDetectorNumber();
case MODULE_FIRMWARE_VERSION:
return FIRMWAREREV;
default:
break;
}
*/
return -1; return -1;
} }
@ -51,13 +44,13 @@ int64_t getModuleId(enum idMode arg, int imod){
int64_t getDetectorId(enum idMode arg){ int64_t getDetectorId(enum idMode arg){
int64_t retval = -1; int64_t retval = -1;
/*
switch(arg){ switch(arg){
case DETECTOR_SERIAL_NUMBER: case DETECTOR_SERIAL_NUMBER:
retval = getDetectorMAC(); retval = getDetectorNumber();/** to be implemented with mac? */
break; break;
case DETECTOR_FIRMWARE_VERSION: case DETECTOR_FIRMWARE_VERSION:
return FIRMWAREREV; return FIRMWAREREV;/** to be implemented */
case DETECTOR_SOFTWARE_VERSION: case DETECTOR_SOFTWARE_VERSION:
retval= SVNREV; retval= SVNREV;
retval= (retval <<32) | SVNDATE; retval= (retval <<32) | SVNDATE;
@ -65,13 +58,23 @@ int64_t getDetectorId(enum idMode arg){
default: default:
break; break;
} }
*/
return retval; return retval;
} }
int getDetectorNumber(){ int getDetectorNumber(){
int res=0;
char hostname[100];
if (gethostname(hostname, sizeof hostname) == 0)
puts(hostname);
else
perror("gethostname");
sscanf(hostname,"%x",&res);
return res;
/* /*
char output[255]=""; char output[255]="";
int res=0; int res=0;
@ -81,7 +84,7 @@ int getDetectorNumber(){
sscanf(output,"%x",&res); sscanf(output,"%x",&res);
return res; return res;
*/ */
return 0;
} }
@ -166,20 +169,17 @@ int getADC(enum detDacIndex ind, int imod){
int setModule(sls_detector_module myMod){ int setModule(sls_detector_module myMod){
/*
#ifdef VERBOSE #ifdef VERBOSE
printf("Setting module with settings %d\n",myMod.reg); printf("Setting module with settings %d\n",myMod.reg);
#endif #endif
//int nchip = myMod.nchip;
//int nchan = (myMod.nchan)/nchip;
int i; int i;
for(i=0;i<myMod.ndac;i++) for(i=0;i<myMod.ndac;i++)
setDAC((detDacIndex)i,myMod.dacs[i],myMod.module); setDAC((detDacIndex)i,myMod.dacs[i],myMod.module);
thisSettings = (detectorSettings)myMod.reg; thisSettings = (detectorSettings)myMod.reg;
*/
return 0; return 0;
} }
@ -209,9 +209,9 @@ int setThresholdEnergy(int thr, int imod){
enum detectorSettings setSettings(enum detectorSettings sett, int imod){ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
//template setSettings() from mcb_funcs.c
//reads the dac registers from fpga to confirm which settings, if weird, undefined
if(sett != GET_SETTINGS)
printf("trying to set settings!\n");
return thisSettings; return thisSettings;
} }

View File

@ -3572,7 +3572,7 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
#ifdef VERBOSE #ifdef VERBOSE
cout << " A---------" << id << " position " << im << endl; cout << " A---------" << id << " position " << im << endl;
#endif #endif
cout<<"decodeNMod:-1"<<endl;
return -1; return -1;
} }
int nm; int nm;
@ -3585,6 +3585,7 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
#ifdef VERBOSE #ifdef VERBOSE
cout << " B---------" <<id << " position " << im << endl; cout << " B---------" <<id << " position " << im << endl;
#endif #endif
cout<<"decodeNMod:"<<im<<endl;
return im; return im;
} else { } else {
i-=nm; i-=nm;
@ -3596,6 +3597,7 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
#ifdef VERBOSE #ifdef VERBOSE
cout <<" C---------" << id << " position " << im << endl; cout <<" C---------" << id << " position " << im << endl;
#endif #endif
cout<<"decodeNMod:-1"<<endl;
return -1; return -1;

View File

@ -2892,8 +2892,8 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
case EIGER: case EIGER:
//settings is saved in myMod.reg //settings is saved in myMod.reg
myMod->reg=thisDetector->currentSettings; myMod->reg=thisDetector->currentSettings;
ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn"<< setw(6) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10); ostfn << thisDetector->settingsDir << ssettings <<"/settings."<< setw(6) << hex << getId(DETECTOR_SERIAL_NUMBER) << setbase(10);
oscfn << thisDetector->calDir << ssettings << "/calibration.sn"<<setw(6) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10); oscfn << thisDetector->calDir << ssettings << "/calibration."<<setw(6) << hex << getId(DETECTOR_SERIAL_NUMBER) << setbase(10);
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl; std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl;
#endif #endif
@ -2914,14 +2914,14 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
} }
settingsfname=ostfn.str(); settingsfname=ostfn.str();
#ifdef VERBOSE //#ifdef VERBOSE
cout << "the settings file name is "<<settingsfname << endl; cout << "the settings file name is "<<settingsfname << endl;
#endif //#endif
if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) { if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) {
calfname=oscfn.str(); calfname=oscfn.str();
#ifdef VERBOSE //#ifdef VERBOSE
cout << calfname << endl; cout << calfname << endl;
#endif //#endif
readCalibrationFile(calfname,myMod->gain, myMod->offset); readCalibrationFile(calfname,myMod->gain, myMod->offset);
setModule(*myMod); setModule(*myMod);
} else { } else {
@ -5623,6 +5623,10 @@ int slsDetector::loadSettingsFile(string fname, int imod) {
ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
fn=ostfn.str(); fn=ostfn.str();
} }
if (fname.find(".beb")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) {
ostfn << "." << setw(6) << hex << getId(DETECTOR_SERIAL_NUMBER, im);
fn=ostfn.str();
}
myMod=readSettingsFile(fn, thisDetector->myDetectorType); myMod=readSettingsFile(fn, thisDetector->myDetectorType);
if (myMod) { if (myMod) {
myMod->module=im; myMod->module=im;
@ -5651,7 +5655,10 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
} }
for (int im=mmin; im<mmax; im++) { for (int im=mmin; im<mmax; im++) {
ostringstream ostfn; ostringstream ostfn;
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); if(thisDetector->myDetectorType == EIGER)
ostfn << fname << "." << setw(6) << hex << getId(DETECTOR_SERIAL_NUMBER);
else
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER);
if ((myMod=getModule(im))) { if ((myMod=getModule(im))) {
ret=writeSettingsFile(ostfn.str(), thisDetector->myDetectorType, *myMod); ret=writeSettingsFile(ostfn.str(), thisDetector->myDetectorType, *myMod);
deleteModule(myMod); deleteModule(myMod);
@ -5680,6 +5687,9 @@ int slsDetector::loadCalibrationFile(string fname, int imod) {
if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) { if (fname.find(".sn")==string::npos && fname.find(".cal")==string::npos) {
ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
} }
if (fname.find(".beb")==string::npos && fname.find(".cal")==string::npos) {
ostfn << "." << setw(6) << hex << getId(DETECTOR_SERIAL_NUMBER);
}
fn=ostfn.str(); fn=ostfn.str();
if((myMod=getModule(im))){ if((myMod=getModule(im))){
if(readCalibrationFile(fn, myMod->gain, myMod->offset)==FAIL) if(readCalibrationFile(fn, myMod->gain, myMod->offset)==FAIL)
@ -5706,6 +5716,9 @@ int slsDetector::saveCalibrationFile(string fname, int imod) {
} }
for (int im=mmin; im<mmax; im++) { for (int im=mmin; im<mmax; im++) {
ostringstream ostfn; ostringstream ostfn;
if(thisDetector->myDetectorType == EIGER)
ostfn << fname << "." << setw(6) << hex << getId(DETECTOR_SERIAL_NUMBER);
else
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im); ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER,im);
if ((myMod=getModule(im))) { if ((myMod=getModule(im))) {
ret=writeCalibrationFile(ostfn.str(), myMod->gain, myMod->offset); ret=writeCalibrationFile(ostfn.str(), myMod->gain, myMod->offset);