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 <unistd.h> //to gethostname
#include <string.h>
@ -33,16 +34,8 @@ int getNModBoard(enum dimension arg){
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;
}
@ -51,13 +44,13 @@ int64_t getModuleId(enum idMode arg, int imod){
int64_t getDetectorId(enum idMode arg){
int64_t retval = -1;
/*
switch(arg){
case DETECTOR_SERIAL_NUMBER:
retval = getDetectorMAC();
retval = getDetectorNumber();/** to be implemented with mac? */
break;
case DETECTOR_FIRMWARE_VERSION:
return FIRMWAREREV;
return FIRMWAREREV;/** to be implemented */
case DETECTOR_SOFTWARE_VERSION:
retval= SVNREV;
retval= (retval <<32) | SVNDATE;
@ -65,14 +58,24 @@ int64_t getDetectorId(enum idMode arg){
default:
break;
}
*/
return retval;
}
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]="";
int res=0;
FILE* sysFile = popen("hostname", "r");
@ -80,8 +83,8 @@ int getDetectorNumber(){
pclose(sysFile);
sscanf(output,"%x",&res);
return res;
*/
return 0;
*/
}
@ -166,20 +169,17 @@ int getADC(enum detDacIndex ind, int imod){
int setModule(sls_detector_module myMod){
/*
#ifdef VERBOSE
printf("Setting module with settings %d\n",myMod.reg);
#endif
//int nchip = myMod.nchip;
//int nchan = (myMod.nchan)/nchip;
int i;
for(i=0;i<myMod.ndac;i++)
setDAC((detDacIndex)i,myMod.dacs[i],myMod.module);
thisSettings = (detectorSettings)myMod.reg;
*/
return 0;
}
@ -209,9 +209,9 @@ int setThresholdEnergy(int thr, 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;
}

View File

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

View File

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