mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 16:27:13 +02:00
functions splitted in many sub-files
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@167 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -41,12 +41,12 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
||||
nd=13; // dacs+adcs
|
||||
break;
|
||||
case EIGER:
|
||||
nch=65535; // one EIGER module
|
||||
nch=65536; // one EIGER half module
|
||||
nm=1; //modules/detector
|
||||
nc=8; //chips
|
||||
nc=4; //chips
|
||||
nd=16; //dacs+adcs
|
||||
default:
|
||||
nch=0; // one EIGER module
|
||||
nch=0; // dum!
|
||||
nm=0; //modules/detector
|
||||
nc=0; //chips
|
||||
nd=0; //dacs+adcs
|
||||
@ -81,9 +81,6 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
shm_id returns -1 is shared memory initialization fails
|
||||
*/
|
||||
@ -111,20 +108,6 @@ int slsDetector::freeSharedMemory() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
slsDetector::slsDetector(int id) :slsDetectorUtils(),
|
||||
thisDetector(NULL),
|
||||
detId(id),
|
||||
@ -480,6 +463,7 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
thisDetector->nModMax[X]=24;
|
||||
thisDetector->nModMax[Y]=1;
|
||||
thisDetector->dynamicRange=24;
|
||||
thisDetector->moveFlag=1;
|
||||
break;
|
||||
case PICASSO:
|
||||
thisDetector->nChans=128;
|
||||
@ -635,36 +619,69 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
cout << "passing pointers" << endl;
|
||||
#endif
|
||||
|
||||
getPointers(&thisDetector->stoppedFlag, \
|
||||
&thisDetector->threadedProcessing, \
|
||||
&thisDetector->actionMask, \
|
||||
thisDetector->actionScript, \
|
||||
thisDetector->actionParameter, \
|
||||
thisDetector->nScanSteps, \
|
||||
thisDetector->scanMode, \
|
||||
thisDetector->scanScript, \
|
||||
thisDetector->scanParameter, \
|
||||
thisDetector->scanSteps, \
|
||||
thisDetector->scanPrecision, \
|
||||
&thisDetector->numberOfPositions, \
|
||||
thisDetector->detPositions, \
|
||||
thisDetector->angConvFile, \
|
||||
&thisDetector->correctionMask, \
|
||||
&thisDetector->binSize, \
|
||||
&thisDetector->fineOffset, \
|
||||
&thisDetector->globalOffset, \
|
||||
&thisDetector->angDirection, \
|
||||
thisDetector->flatFieldDir, \
|
||||
thisDetector->flatFieldFile, \
|
||||
thisDetector->badChanFile, \
|
||||
thisDetector->timerValue, \
|
||||
&thisDetector->currentSettings, \
|
||||
&thisDetector->currentThresholdEV, \
|
||||
thisDetector->filePath, \
|
||||
thisDetector->fileName, \
|
||||
&thisDetector->fileIndex);
|
||||
|
||||
// getPointers(&thisDetector->stoppedFlag, \
|
||||
// &thisDetector->threadedProcessing, \
|
||||
// &thisDetector->actionMask, \
|
||||
// thisDetector->actionScript, \
|
||||
// thisDetector->actionParameter, \
|
||||
// thisDetector->nScanSteps, \
|
||||
// thisDetector->scanMode, \
|
||||
// thisDetector->scanScript, \
|
||||
// thisDetector->scanParameter, \
|
||||
// thisDetector->scanSteps, \
|
||||
// thisDetector->scanPrecision, \
|
||||
// &thisDetector->numberOfPositions, \
|
||||
// thisDetector->detPositions, \
|
||||
// thisDetector->angConvFile, \
|
||||
// &thisDetector->correctionMask, \
|
||||
// &thisDetector->binSize, \
|
||||
// &thisDetector->fineOffset, \
|
||||
// &thisDetector->globalOffset, \
|
||||
// &thisDetector->angDirection, \
|
||||
// thisDetector->flatFieldDir, \
|
||||
// thisDetector->flatFieldFile, \
|
||||
// thisDetector->badChanFile, \
|
||||
// thisDetector->timerValue, \
|
||||
// &thisDetector->currentSettings, \
|
||||
// &thisDetector->currentThresholdEV, \
|
||||
// thisDetector->filePath, \
|
||||
// thisDetector->fileName, \
|
||||
// &thisDetector->fileIndex);
|
||||
|
||||
stoppedFlag=&thisDetector->stoppedFlag;
|
||||
threadedProcessing=&thisDetector->threadedProcessing;
|
||||
actionMask=&thisDetector->actionMask;
|
||||
actionScript=thisDetector->actionScript;
|
||||
actionParameter=thisDetector->actionParameter;
|
||||
nScanSteps=thisDetector->nScanSteps;
|
||||
scanMode=thisDetector->scanMode;
|
||||
scanScript=thisDetector->scanScript;
|
||||
scanParameter=thisDetector->scanParameter;
|
||||
scanSteps=thisDetector->scanSteps;
|
||||
scanPrecision=thisDetector->scanPrecision;
|
||||
numberOfPositions=&thisDetector->numberOfPositions;
|
||||
detPositions=thisDetector->detPositions;
|
||||
angConvFile=thisDetector->angConvFile;
|
||||
correctionMask=&thisDetector->correctionMask;
|
||||
binSize=&thisDetector->binSize;
|
||||
fineOffset=&thisDetector->fineOffset;
|
||||
globalOffset=&thisDetector->globalOffset;
|
||||
angDirection=&thisDetector->angDirection;
|
||||
flatFieldDir=thisDetector->flatFieldDir;
|
||||
flatFieldFile=thisDetector->flatFieldFile;
|
||||
badChanFile=thisDetector->badChanFile;
|
||||
timerValue=thisDetector->timerValue;
|
||||
currentSettings=&thisDetector->currentSettings;
|
||||
currentThresholdEV=&thisDetector->currentThresholdEV;
|
||||
filePath=thisDetector->filePath;
|
||||
fileName=thisDetector->fileName;
|
||||
fileIndex=&thisDetector->fileIndex;
|
||||
moveFlag=&thisDetector->moveFlag;
|
||||
|
||||
settingsFile=thisDetector->settingsFile;
|
||||
|
||||
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "done" << endl;
|
||||
@ -741,17 +758,55 @@ int slsDetector::initializeDetectorStructure() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
slsDetectorDefs::sls_detector_module* slsDetector::createModule() {
|
||||
slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) {
|
||||
|
||||
sls_detector_module *myMod=(sls_detector_module*)malloc(sizeof(sls_detector_module));
|
||||
float *dacs=new float[thisDetector->nDacs];
|
||||
float *adcs=new float[thisDetector->nAdcs];
|
||||
int *chipregs=new int[thisDetector->nChips];
|
||||
int *chanregs=new int[thisDetector->nChips*thisDetector->nChans];
|
||||
myMod->ndac=thisDetector->nDacs;
|
||||
myMod->nadc=thisDetector->nAdcs;
|
||||
myMod->nchip=thisDetector->nChips;
|
||||
myMod->nchan=thisDetector->nChips*thisDetector->nChans;
|
||||
|
||||
|
||||
int nch, nm, nc, nd, na=0;
|
||||
|
||||
switch(t) {
|
||||
case MYTHEN:
|
||||
nch=128; // complete mythen system
|
||||
nm=24;
|
||||
nc=10;
|
||||
nd=6; // dacs
|
||||
break;
|
||||
case PICASSO:
|
||||
nch=128; // complete mythen system
|
||||
nm=24;
|
||||
nc=12;
|
||||
nd=6; // dacs+adcs
|
||||
break;
|
||||
case GOTTHARD:
|
||||
nch=128;
|
||||
nm=1;
|
||||
nc=10;
|
||||
nd=8; // dacs+adcs
|
||||
na=5;
|
||||
break;
|
||||
case EIGER:
|
||||
nch=65536; // one EIGER half module
|
||||
nm=1; //modules/detector
|
||||
nc=4; //chips
|
||||
nd=16; //dacs
|
||||
na=16;
|
||||
default:
|
||||
nch=0; // dum!
|
||||
nm=0; //modules/detector
|
||||
nc=0; //chips
|
||||
nd=0; //dacs+adcs
|
||||
na=0;
|
||||
}
|
||||
|
||||
float *dacs=new float[nd];
|
||||
float *adcs=new float[na];
|
||||
int *chipregs=new int[nc];
|
||||
int *chanregs=new int[nch*nc];
|
||||
myMod->ndac=nd;
|
||||
myMod->nadc=na;
|
||||
myMod->nchip=nc;
|
||||
myMod->nchan=nch*nc;
|
||||
|
||||
myMod->dacs=dacs;
|
||||
myMod->adcs=adcs;
|
||||
@ -2727,7 +2782,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
|
||||
#ifdef VERBOSE
|
||||
cout << "the settings name is "<<settingsfname << endl;
|
||||
#endif
|
||||
if (readSettingsFile(settingsfname,myMod)) {
|
||||
if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) {
|
||||
calfname=oscfn.str();
|
||||
#ifdef VERBOSE
|
||||
cout << calfname << endl;
|
||||
@ -2750,7 +2805,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
|
||||
cout << settingsfname << endl;
|
||||
cout << calfname << endl;
|
||||
#endif
|
||||
if (readSettingsFile(settingsfname,myMod)) {
|
||||
if (readSettingsFile(settingsfname,thisDetector->myDetectorType, myMod)) {
|
||||
calfname=oscfn.str();
|
||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||
setModule(*myMod);
|
||||
@ -4499,29 +4554,6 @@ int slsDetector::configureMAC(){
|
||||
|
||||
//Corrections
|
||||
|
||||
int slsDetector::setAngularConversion(string fname) {
|
||||
if (fname=="") {
|
||||
thisDetector->correctionMask&=~(1<< ANGULAR_CONVERSION);
|
||||
//strcpy(thisDetector->angConvFile,"none");
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Unsetting angular conversion" << std::endl;
|
||||
#endif
|
||||
} else {
|
||||
if (fname=="default") {
|
||||
fname=string(thisDetector->angConvFile);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Setting angular conversion to" << fname << std:: endl;
|
||||
#endif
|
||||
if (readAngularConversion(fname)>=0) {
|
||||
thisDetector->correctionMask|=(1<< ANGULAR_CONVERSION);
|
||||
strcpy(thisDetector->angConvFile,fname.c_str());
|
||||
}
|
||||
}
|
||||
return thisDetector->correctionMask&(1<< ANGULAR_CONVERSION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -4550,7 +4582,7 @@ int slsDetector::getAngularConversion(int &direction, angleConversionConstant *
|
||||
|
||||
|
||||
|
||||
int slsDetector::readAngularConversion(string fname) {
|
||||
int slsDetector::readAngularConversionFile(string fname) {
|
||||
|
||||
return readAngularConversion(fname,thisDetector->nModsMax, thisDetector->angOff);
|
||||
|
||||
@ -4573,24 +4605,23 @@ int slsDetector::getAngularConversion(int &direction, angleConversionConstant *
|
||||
|
||||
|
||||
|
||||
float* slsDetector::convertAngles(float pos) {
|
||||
int imod;
|
||||
float *ang=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||
for (int ip=0; ip<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ip++) {
|
||||
imod=ip/(thisDetector->nChans*thisDetector->nChips);
|
||||
ang[ip]=angle(ip%(thisDetector->nChans*thisDetector->nChips),\
|
||||
pos, \
|
||||
thisDetector->fineOffset+thisDetector->globalOffset, \
|
||||
thisDetector->angOff[imod].r_conversion, \
|
||||
thisDetector->angOff[imod].center, \
|
||||
thisDetector->angOff[imod].offset, \
|
||||
thisDetector->angOff[imod].tilt, \
|
||||
thisDetector->angDirection
|
||||
);
|
||||
// cout << imod << " " << thisDetector->angOff[imod].offset << " " << ang[ip] << endl;
|
||||
}
|
||||
return ang;
|
||||
}
|
||||
// float* slsDetector::convertAngles(float pos) {
|
||||
// int imod;
|
||||
// float *ang=new float[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||
// for (int ip=0; ip<thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; ip++) {
|
||||
// imod=ip/(thisDetector->nChans*thisDetector->nChips);
|
||||
// ang[ip]=angle(ip%(thisDetector->nChans*thisDetector->nChips),\
|
||||
// pos, \
|
||||
// thisDetector->fineOffset+thisDetector->globalOffset, \
|
||||
// thisDetector->angOff[imod].r_conversion, \
|
||||
// thisDetector->angOff[imod].center, \
|
||||
// thisDetector->angOff[imod].offset, \
|
||||
// thisDetector->angOff[imod].tilt, \
|
||||
// thisDetector->angDirection
|
||||
// );
|
||||
// }
|
||||
// return ang;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -5191,293 +5222,9 @@ int slsDetector::retrieveDetectorSetup(string fname1, int level){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* I/O */
|
||||
|
||||
|
||||
slsDetectorDefs::sls_detector_module* slsDetector::readSettingsFile(string fname, sls_detector_module *myMod){
|
||||
|
||||
int nflag=0;
|
||||
|
||||
|
||||
if (myMod==NULL) {
|
||||
myMod=createModule();
|
||||
nflag=1;
|
||||
}
|
||||
|
||||
string myfname;
|
||||
string str;
|
||||
ifstream infile;
|
||||
ostringstream oss;
|
||||
int iline=0;
|
||||
// string names[]={"Vtrim", "Vthresh", "Rgsh1", "Rgsh2", "Rgpr", "Vcal", "outBuffEnable"};
|
||||
string sargname;
|
||||
int ival;
|
||||
int ichan=0, ichip=0, idac=0;
|
||||
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "reading settings file for module number "<< myMod->module << std::endl;
|
||||
#endif
|
||||
myfname=fname;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "file name is "<< myfname << std::endl;
|
||||
#endif
|
||||
infile.open(myfname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
|
||||
|
||||
switch (thisDetector->myDetectorType) {
|
||||
|
||||
case MYTHEN:
|
||||
|
||||
for (int iarg=0; iarg<thisDetector->nDacs; iarg++) {
|
||||
getline(infile,str);
|
||||
iline++;
|
||||
istringstream ssstr(str);
|
||||
ssstr >> sargname >> ival;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl;
|
||||
#endif
|
||||
myMod->dacs[idac]=ival;
|
||||
idac++;
|
||||
}
|
||||
for (ichip=0; ichip<thisDetector->nChips; ichip++) {
|
||||
getline(infile,str);
|
||||
iline++;
|
||||
#ifdef VERBOSE
|
||||
// std::cout<< str << std::endl;
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
ssstr >> sargname >> ival;
|
||||
#ifdef VERBOSE
|
||||
// std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl;
|
||||
#endif
|
||||
|
||||
myMod->chipregs[ichip]=ival;
|
||||
for (ichan=0; ichan<thisDetector->nChans; ichan++) {
|
||||
getline(infile,str);
|
||||
#ifdef VERBOSE
|
||||
// std::cout<< str << std::endl;
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
|
||||
#ifdef VERBOSE
|
||||
// std::cout<< "channel " << ichan+ichip*thisDetector->nChans <<" iline " << iline<< std::endl;
|
||||
#endif
|
||||
iline++;
|
||||
myMod->chanregs[ichip*thisDetector->nChans+ichan]=0;
|
||||
for (int iarg=0; iarg<6 ; iarg++) {
|
||||
ssstr >> ival;
|
||||
//if (ssstr.good()) {
|
||||
switch (iarg) {
|
||||
case 0:
|
||||
#ifdef VERBOSE
|
||||
// std::cout<< "trimbits " << ival ;
|
||||
#endif
|
||||
myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival&0x3f;
|
||||
break;
|
||||
case 1:
|
||||
#ifdef VERBOSE
|
||||
//std::cout<< " compen " << ival ;
|
||||
#endif
|
||||
myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<9;
|
||||
break;
|
||||
case 2:
|
||||
#ifdef VERBOSE
|
||||
//std::cout<< " anen " << ival ;
|
||||
#endif
|
||||
myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<8;
|
||||
break;
|
||||
case 3:
|
||||
#ifdef VERBOSE
|
||||
//std::cout<< " calen " << ival ;
|
||||
#endif
|
||||
myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<7;
|
||||
break;
|
||||
case 4:
|
||||
#ifdef VERBOSE
|
||||
//std::cout<< " outcomp " << ival ;
|
||||
#endif
|
||||
myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<10;
|
||||
break;
|
||||
case 5:
|
||||
#ifdef VERBOSE
|
||||
//std::cout<< " counts " << ival << std::endl;
|
||||
#endif
|
||||
myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<11;
|
||||
break;
|
||||
default:
|
||||
std::cout<< " too many columns" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "read " << ichan*ichip << " channels" <<std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case GOTTHARD:
|
||||
//---------------dacs---------------
|
||||
for (int iarg=0; iarg<thisDetector->nDacs; iarg++) {
|
||||
getline(infile,str);
|
||||
iline++;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< str << std::endl;
|
||||
#endif
|
||||
istringstream ssstr(str);
|
||||
ssstr >> sargname >> ival;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl;
|
||||
#endif
|
||||
myMod->dacs[idac]=ival;
|
||||
idac++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
std::cout<< "Unknown detector type - don't know how to read file" << myfname << std::endl;
|
||||
infile.close();
|
||||
deleteModule(myMod);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
infile.close();
|
||||
strcpy(thisDetector->settingsFile,fname.c_str());
|
||||
return myMod;
|
||||
|
||||
} else {
|
||||
std::cout<< "could not open settings file " << myfname << std::endl;
|
||||
|
||||
if (nflag)
|
||||
deleteModule(myMod);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
int slsDetector::writeSettingsFile(string fname, sls_detector_module mod){
|
||||
|
||||
ofstream outfile;
|
||||
|
||||
string names[100];
|
||||
int id=0;
|
||||
switch (thisDetector->myDetectorType) {
|
||||
case MYTHEN:
|
||||
names[id++]="Vtrim";
|
||||
names[id++]="Vthresh";
|
||||
names[id++]="Rgsh1";
|
||||
names[id++]="Rgsh2";
|
||||
names[id++]="Rgpr";
|
||||
names[id++]="Vcal";
|
||||
names[id++]="outBuffEnable";
|
||||
break;
|
||||
case GOTTHARD:
|
||||
names[id++]="Vref";
|
||||
names[id++]="VcascN";
|
||||
names[id++]="VcascP";
|
||||
names[id++]="Vout";
|
||||
names[id++]="Vcasc";
|
||||
names[id++]="Vin";
|
||||
names[id++]="Vref_comp";
|
||||
names[id++]="Vib_test";
|
||||
names[id++]="config";
|
||||
names[id++]="HV";
|
||||
names[id++]="macaddress";
|
||||
names[id++]="ipaddress";
|
||||
break;
|
||||
default:
|
||||
cout << "Unknown detector type - unknown format for settings file" << endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int iv, ichan, ichip;
|
||||
int iv1, idac;
|
||||
int nb;
|
||||
outfile.open(fname.c_str(), ios_base::out);
|
||||
|
||||
if (outfile.is_open()) {
|
||||
for (idac=0; idac<mod.ndac; idac++) {
|
||||
iv=(int)mod.dacs[idac];
|
||||
outfile << names[idac] << " " << iv << std::endl;
|
||||
}
|
||||
|
||||
for (ichip=0; ichip<mod.nchip; ichip++) {
|
||||
iv1=mod.chipregs[ichip]&1;
|
||||
outfile << names[idac] << " " << iv1 << std::endl;
|
||||
for (ichan=0; ichan<thisDetector->nChans; ichan++) {
|
||||
iv=mod.chanregs[ichip*thisDetector->nChans+ichan];
|
||||
iv1= (iv&0x3f);
|
||||
outfile <<iv1 << " ";
|
||||
nb=9;
|
||||
iv1=((iv&(1<<nb))>>nb);
|
||||
outfile << iv1 << " ";
|
||||
nb=8;
|
||||
iv1=((iv&(1<<nb))>>nb);
|
||||
outfile << iv1 << " ";
|
||||
nb=7;
|
||||
iv1=((iv&(1<<nb))>>nb);
|
||||
outfile <<iv1 << " ";
|
||||
nb=10;
|
||||
iv1=((iv&(1<<nb))>>nb);
|
||||
outfile << iv1 << " ";
|
||||
nb=11;
|
||||
iv1= ((iv&0xfffff800)>>nb);
|
||||
outfile << iv1 << std::endl;
|
||||
}
|
||||
}
|
||||
outfile.close();
|
||||
return OK;
|
||||
} else {
|
||||
std::cout<< "could not open SETTINGS file " << fname << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
int slsDetector::writeSettingsFile(string fname, int imod){
|
||||
|
||||
return writeSettingsFile(fname,detectorModules[imod]);
|
||||
return writeSettingsFile(fname,thisDetector->myDetectorType, detectorModules[imod]);
|
||||
|
||||
};
|
||||
|
||||
@ -5500,7 +5247,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) {
|
||||
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
|
||||
fn=ostfn.str();
|
||||
}
|
||||
myMod=readSettingsFile(fn);
|
||||
myMod=readSettingsFile(fn, thisDetector->myDetectorType);
|
||||
if (myMod) {
|
||||
myMod->module=im;
|
||||
setModule(*myMod);
|
||||
@ -5527,7 +5274,7 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
|
||||
ostringstream ostfn;
|
||||
ostfn << fname << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im);
|
||||
if ((myMod=getModule(im))) {
|
||||
ret=writeSettingsFile(ostfn.str(),*myMod);
|
||||
ret=writeSettingsFile(ostfn.str(), thisDetector->myDetectorType, *myMod);
|
||||
deleteModule(myMod);
|
||||
}
|
||||
}
|
||||
|
@ -5,17 +5,9 @@
|
||||
#define SLS_DETECTOR_H
|
||||
|
||||
|
||||
class MySocketTCP;
|
||||
|
||||
#include "slsDetectorUtils.h"
|
||||
#include "MySocketTCP.h"
|
||||
//#include "slsDetectorCommand.h"
|
||||
|
||||
|
||||
//enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//using namespace std;
|
||||
@ -54,17 +46,20 @@ Then in your software you should use the class related to the detector you want
|
||||
* @short This is the base class for all SLS detector functionalities
|
||||
* @author Anna Bergamaschi
|
||||
* @version 0.1alpha
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class slsDetector : public slsDetectorUtils {
|
||||
#define NMODMAXX 24
|
||||
#define NMODMAXY 24
|
||||
#define NCHIPSMAX 10
|
||||
#define NCHANSMAX 65536
|
||||
#define NDACSMAX 16
|
||||
|
||||
class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/* /\** online flags enum \sa setOnline*\/ */
|
||||
/* enum {GET_ONLINE_FLAG=-1, /\**< returns wether the detector is in online or offline state *\/ */
|
||||
/* OFFLINE_FLAG=0, /\**< detector in offline state (i.e. no communication to the detector - using only local structure - no data acquisition possible!) *\/ */
|
||||
@ -180,27 +175,32 @@ typedef struct sharedSlsDetector {
|
||||
/** file with the angular conversion factors */
|
||||
char angConvFile[MAX_STR_LENGTH];
|
||||
/** array of angular conversion constants for each module \see ::angleConversionConstant */
|
||||
angleConversionConstant angOff[MAXMODS];
|
||||
angleConversionConstant angOff[MAXMODS];
|
||||
/** angular direction (1 if it corresponds to the encoder direction i.e. channel 0 is 0, maxchan is positive high angle, 0 otherwise */
|
||||
int angDirection;
|
||||
/** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */
|
||||
float fineOffset;
|
||||
int angDirection;
|
||||
/** beamline fine offset (of the order of mdeg, might be adjusted for each measurements) */
|
||||
float fineOffset;
|
||||
/** beamline offset (might be a few degrees beacuse of encoder offset - normally it is kept fixed for a long period of time) */
|
||||
float globalOffset;
|
||||
float globalOffset;
|
||||
/** number of positions at which the detector should acquire */
|
||||
int numberOfPositions;
|
||||
int numberOfPositions;
|
||||
/** list of encoder positions at which the detector should acquire */
|
||||
float detPositions[MAXPOS];
|
||||
float detPositions[MAXPOS];
|
||||
/** bin size for data merging */
|
||||
float binSize;
|
||||
/** add encoder value flag (i.e. wether the detector is moving - 1 - or stationary - 0) */
|
||||
int moveFlag;
|
||||
|
||||
|
||||
/* infos necessary for the readout to determine the size of the data */
|
||||
/** number of rois defined */
|
||||
int nROI;
|
||||
/** list of rois */
|
||||
ROI roiLimits[MAX_ROIS];
|
||||
/** readout flags */
|
||||
readOutFlags roFlags;
|
||||
|
||||
/** number of rois defined */
|
||||
int nROI;
|
||||
/** list of rois */
|
||||
ROI roiLimits[MAX_ROIS];
|
||||
|
||||
/** readout flags */
|
||||
readOutFlags roFlags;
|
||||
|
||||
|
||||
/* detector setup - not needed */
|
||||
@ -268,17 +268,19 @@ typedef struct sharedSlsDetector {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
using slsDetectorUtils::getDetectorType;
|
||||
|
||||
using slsDetectorUtils::flatFieldCorrect;
|
||||
using slsDetectorUtils::rateCorrect;
|
||||
using slsDetectorUtils::setBadChannelCorrection;
|
||||
using postProcessing::flatFieldCorrect;
|
||||
using postProcessing::rateCorrect;
|
||||
using postProcessing::setBadChannelCorrection;
|
||||
|
||||
using angularConversion::readAngularConversion;
|
||||
using angularConversion::writeAngularConversion;
|
||||
|
||||
using slsDetectorUtils::getAngularConversion;
|
||||
|
||||
|
||||
|
||||
using slsDetectorUtils::readAngularConversion;
|
||||
using slsDetectorUtils::writeAngularConversion;
|
||||
// using slsDetectorBase::getDataFromDetector;
|
||||
|
||||
|
||||
|
||||
@ -487,40 +489,17 @@ typedef struct sharedSlsDetector {
|
||||
*/
|
||||
int setTrimEn(int nen, int *en=NULL) {if (en) {for (int ien=0; ien<nen; ien++) thisDetector->trimEnergies[ien]=en[ien]; thisDetector->nTrimEn=nen;} return (thisDetector->nTrimEn);};
|
||||
|
||||
/**
|
||||
Pure virtual function
|
||||
reads a trim/settings file
|
||||
\param fname name of the file to be read
|
||||
\param myMod pointer to the module structure which has to be set. <BR> If it is NULL a new module structure will be created
|
||||
\returns the pointer to myMod or NULL if reading the file failed
|
||||
\sa mythenDetector::readSettingsFile
|
||||
*/
|
||||
|
||||
sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
|
||||
//virtual sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
|
||||
|
||||
/**
|
||||
Pure virtual function
|
||||
writes a trim/settings file
|
||||
\param fname name of the file to be written
|
||||
\param mod module structure which has to be written to file
|
||||
\returns OK or FAIL if the file could not be written
|
||||
|
||||
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
|
||||
*/
|
||||
int writeSettingsFile(string fname, sls_detector_module mod);
|
||||
|
||||
|
||||
//virtual int writeSettingsFile(string fname, sls_detector_module mod);
|
||||
|
||||
/**
|
||||
Pure virtual function
|
||||
writes a trim/settings file for module number imod - the values will be read from the current detector structure
|
||||
\param fname name of the file to be written
|
||||
\param imod module number
|
||||
\returns OK or FAIL if the file could not be written
|
||||
\sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
||||
*/
|
||||
using energyConversion::writeSettingsFile;
|
||||
int writeSettingsFile(string fname, int imod);
|
||||
|
||||
|
||||
@ -560,7 +539,7 @@ typedef struct sharedSlsDetector {
|
||||
\param fname file to be read
|
||||
\sa angleConversionConstant mythenDetector::readAngularConversion
|
||||
*/
|
||||
int readAngularConversion(string fname="");
|
||||
int readAngularConversionFile(string fname="");
|
||||
|
||||
|
||||
/**
|
||||
@ -603,6 +582,8 @@ typedef struct sharedSlsDetector {
|
||||
|
||||
/** Returns the number of modules (without connecting to the detector) */
|
||||
int getNMods(){return thisDetector->nMods;}; //
|
||||
|
||||
int getChansPerMod(int imod=0){return thisDetector->nChans*thisDetector->nChips;};
|
||||
|
||||
/** Returns the number of modules (without connecting to the detector) */
|
||||
int getMaxMods(){return thisDetector->nModsMax;}; //
|
||||
@ -1161,14 +1142,7 @@ typedef struct sharedSlsDetector {
|
||||
*/
|
||||
int getBadChannelCorrection(int *bad=NULL);
|
||||
|
||||
|
||||
/**
|
||||
set angular conversion
|
||||
\param fname file with angular conversion constants ("" disable)
|
||||
\returns 0 if angular conversion disabled, >0 otherwise
|
||||
\sa mythenDetector::setAngularConversion
|
||||
*/
|
||||
int setAngularConversion(string fname="");
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
get angular conversion
|
||||
@ -1179,7 +1153,7 @@ typedef struct sharedSlsDetector {
|
||||
*/
|
||||
int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL) ;
|
||||
|
||||
|
||||
angleConversionConstant *getAngularConversionPointer(int imod=0) {return &thisDetector->angOff[imod];};
|
||||
|
||||
|
||||
|
||||
@ -1218,43 +1192,43 @@ typedef struct sharedSlsDetector {
|
||||
int rateCorrect(float* datain, float *errin, float* dataout, float *errout);
|
||||
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize();
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\returns OK or FAIL
|
||||
\sa mythenDetector::resetMerging
|
||||
*/
|
||||
/* /\** */
|
||||
/* pure virtual function */
|
||||
/* sets the arrays of the merged data to 0. NB The array should be created with size >= 360./getBinSize(); */
|
||||
/* \param mp already merged postions */
|
||||
/* \param mv already merged data */
|
||||
/* \param me already merged errors (squared sum) */
|
||||
/* \param mm multiplicity of merged arrays */
|
||||
/* \returns OK or FAIL */
|
||||
/* \sa mythenDetector::resetMerging */
|
||||
/* *\/ */
|
||||
|
||||
int resetMerging(float *mp, float *mv,float *me, int *mm);
|
||||
/* int resetMerging(float *mp, float *mv,float *me, int *mm); */
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
merge dataset
|
||||
\param p1 angular positions of dataset
|
||||
\param v1 data
|
||||
\param e1 errors
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\sa mythenDetector::addToMerging
|
||||
*/
|
||||
int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm);
|
||||
/* /\** */
|
||||
/* pure virtual function */
|
||||
/* merge dataset */
|
||||
/* \param p1 angular positions of dataset */
|
||||
/* \param v1 data */
|
||||
/* \param e1 errors */
|
||||
/* \param mp already merged postions */
|
||||
/* \param mv already merged data */
|
||||
/* \param me already merged errors (squared sum) */
|
||||
/* \param mm multiplicity of merged arrays */
|
||||
/* \sa mythenDetector::addToMerging */
|
||||
/* *\/ */
|
||||
/* int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm); */
|
||||
|
||||
/** pure virtual function
|
||||
calculates the "final" positions, data value and errors for the emrged data
|
||||
\param mp already merged postions
|
||||
\param mv already merged data
|
||||
\param me already merged errors (squared sum)
|
||||
\param mm multiplicity of merged arrays
|
||||
\returns FAIL or the number of non empty bins (i.e. points belonging to the pattern)
|
||||
\sa mythenDetector::finalizeMerging
|
||||
*/
|
||||
int finalizeMerging(float *mp, float *mv,float *me, int *mm);
|
||||
/* /\** pure virtual function */
|
||||
/* calculates the "final" positions, data value and errors for the emrged data */
|
||||
/* \param mp already merged postions */
|
||||
/* \param mv already merged data */
|
||||
/* \param me already merged errors (squared sum) */
|
||||
/* \param mm multiplicity of merged arrays */
|
||||
/* \returns FAIL or the number of non empty bins (i.e. points belonging to the pattern) */
|
||||
/* \sa mythenDetector::finalizeMerging */
|
||||
/* *\/ */
|
||||
/* int finalizeMerging(float *mp, float *mv,float *me, int *mm); */
|
||||
|
||||
/**
|
||||
turns off server
|
||||
@ -1266,7 +1240,15 @@ typedef struct sharedSlsDetector {
|
||||
\returns myMod the pointer to the allocate dmemory location
|
||||
|
||||
*/
|
||||
sls_detector_module* createModule();
|
||||
sls_detector_module* createModule(){return createModule(thisDetector->myDetectorType);};
|
||||
|
||||
|
||||
/** Allocates the memory for a sls_detector_module structure and initializes it
|
||||
\returns myMod the pointer to the allocate dmemory location
|
||||
|
||||
*/
|
||||
sls_detector_module* createModule(detectorType myDetectorType);
|
||||
|
||||
/** frees the memory for a sls_detector_module structure
|
||||
\param myMod the pointer to the memory to be freed
|
||||
|
||||
@ -1284,7 +1266,7 @@ typedef struct sharedSlsDetector {
|
||||
float getCurrentProgress();
|
||||
|
||||
|
||||
float* convertAngles(float pos);
|
||||
// float* convertAngles(float pos);
|
||||
|
||||
|
||||
|
||||
@ -1376,6 +1358,8 @@ typedef struct sharedSlsDetector {
|
||||
int resetCounterBlock(int startACQ=0);
|
||||
|
||||
|
||||
int getMoveFlag(int imod){if (moveFlag) return *moveFlag; else return 1;};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
401
slsDetectorSoftware/slsDetector/slsDetectorActions.cpp
Normal file
401
slsDetectorSoftware/slsDetector/slsDetectorActions.cpp
Normal file
@ -0,0 +1,401 @@
|
||||
#include "slsDetectorActions.h"
|
||||
|
||||
|
||||
/**
|
||||
set action
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||
\param fname for script ("" disable but leaves script unchanged, "none" disables and overwrites)
|
||||
\returns 0 if action disabled, >0 otherwise
|
||||
*/
|
||||
int slsDetectorActions::setAction(int iaction, string fname, string par) {
|
||||
|
||||
int am;
|
||||
|
||||
|
||||
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||
|
||||
if (fname=="") {
|
||||
am=0;
|
||||
} else if (fname=="none") {
|
||||
am=0;
|
||||
strcpy(actionScript[iaction],fname.c_str());
|
||||
} else {
|
||||
strcpy(actionScript[iaction],fname.c_str());
|
||||
am=1;
|
||||
}
|
||||
|
||||
if (par!="") {
|
||||
strcpy(actionParameter[iaction],par.c_str());
|
||||
}
|
||||
|
||||
if (am) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << iaction << " " << hex << (1 << iaction) << " " << *actionMask << dec;
|
||||
#endif
|
||||
|
||||
*actionMask |= (1 << iaction);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << " set " << hex << *actionMask << dec << endl;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
cout << iaction << " " << hex << *actionMask << dec;
|
||||
#endif
|
||||
|
||||
*actionMask &= ~(1 << iaction);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << " unset " << hex << *actionMask << dec << endl;
|
||||
#endif
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << iaction << " Action mask set to " << hex << *actionMask << dec << endl;
|
||||
#endif
|
||||
|
||||
return am;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int slsDetectorActions::setActionScript(int iaction, string fname) {
|
||||
#ifdef VERBOSE
|
||||
|
||||
#endif
|
||||
return setAction(iaction,fname,"");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsDetectorActions::setActionParameter(int iaction, string par) {
|
||||
int am;
|
||||
|
||||
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||
am= 1& ( (*actionMask) << iaction);
|
||||
|
||||
if (par!="") {
|
||||
strcpy(actionParameter[iaction],par.c_str());
|
||||
}
|
||||
|
||||
if ((*actionMask) & (1 << iaction))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
returns action script
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action script
|
||||
*/
|
||||
string slsDetectorActions::getActionScript(int iaction){
|
||||
if (iaction>=0 && iaction<MAX_ACTIONS)
|
||||
return string(actionScript[iaction]);
|
||||
else
|
||||
return string("wrong index");
|
||||
};
|
||||
|
||||
/**
|
||||
returns action parameter
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action parameter
|
||||
*/
|
||||
string slsDetectorActions::getActionParameter(int iaction){
|
||||
if (iaction>=0 && iaction<MAX_ACTIONS)
|
||||
return string(actionParameter[iaction]);
|
||||
else
|
||||
return string("wrong index");
|
||||
}
|
||||
|
||||
/**
|
||||
returns action mode
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action mode
|
||||
*/
|
||||
int slsDetectorActions::getActionMode(int iaction){
|
||||
if (iaction>=0 && iaction<MAX_ACTIONS) {
|
||||
|
||||
if ((*actionMask) & (1 << iaction))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
cout << "slsDetetctor : wrong action index " << iaction << endl;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
set scan
|
||||
\param index of the scan (0,1)
|
||||
\param fname for script ("" disable)
|
||||
\returns 0 if scan disabled, >0 otherwise
|
||||
*/
|
||||
int slsDetectorActions::setScan(int iscan, string script, int nvalues, float *values, string par, int precision) {
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
|
||||
if (script=="") {
|
||||
scanMode[iscan]=0;
|
||||
} else {
|
||||
strcpy(scanScript[iscan],script.c_str());
|
||||
if (script=="none") {
|
||||
scanMode[iscan]=0;
|
||||
} else if (script=="energy") {
|
||||
scanMode[iscan]=1;
|
||||
} else if (script=="threshold") {
|
||||
scanMode[iscan]=2;
|
||||
} else if (script=="trimbits") {
|
||||
scanMode[iscan]=3;
|
||||
} else {
|
||||
scanMode[iscan]=4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (par!="")
|
||||
strcpy(scanParameter[iscan],par.c_str());
|
||||
|
||||
if (nvalues>=0) {
|
||||
if (nvalues==0)
|
||||
scanMode[iscan]=0;
|
||||
else {
|
||||
nScanSteps[iscan]=nvalues;
|
||||
if (nvalues>MAX_SCAN_STEPS)
|
||||
nScanSteps[iscan]=MAX_SCAN_STEPS;
|
||||
}
|
||||
}
|
||||
|
||||
if (values && scanMode[iscan]>0 ) {
|
||||
for (int iv=0; iv<nScanSteps[iscan]; iv++) {
|
||||
scanSteps[iscan][iv]=values[iv];
|
||||
}
|
||||
}
|
||||
|
||||
if (precision>=0)
|
||||
scanPrecision[iscan]=precision;
|
||||
|
||||
if (scanMode[iscan]>0){
|
||||
*actionMask |= 1<< (iscan+MAX_ACTIONS);
|
||||
} else {
|
||||
*actionMask &= ~(1 << (iscan+MAX_ACTIONS));
|
||||
}
|
||||
|
||||
|
||||
|
||||
setTotalProgress();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return scanMode[iscan];
|
||||
} else
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
int slsDetectorActions::setScanScript(int iscan, string script) {
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
if (script=="") {
|
||||
scanMode[iscan]=0;
|
||||
} else {
|
||||
strcpy(scanScript[iscan],script.c_str());
|
||||
if (script=="none") {
|
||||
scanMode[iscan]=0;
|
||||
} else if (script=="energy") {
|
||||
scanMode[iscan]=1;
|
||||
} else if (script=="threshold") {
|
||||
scanMode[iscan]=2;
|
||||
} else if (script=="trimbits") {
|
||||
scanMode[iscan]=3;
|
||||
} else {
|
||||
scanMode[iscan]=4;
|
||||
}
|
||||
}
|
||||
|
||||
if (scanMode[iscan]>0){
|
||||
*actionMask |= (1 << (iscan+MAX_ACTIONS));
|
||||
} else {
|
||||
*actionMask &= ~(1 << (iscan+MAX_ACTIONS));
|
||||
}
|
||||
|
||||
setTotalProgress();
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Action mask is " << hex << actionMask << dec << endl;
|
||||
#endif
|
||||
return scanMode[iscan];
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsDetectorActions::setScanParameter(int iscan, string par) {
|
||||
|
||||
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
if (par!="")
|
||||
strcpy(scanParameter[iscan],par.c_str());
|
||||
return scanMode[iscan];
|
||||
} else
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int slsDetectorActions::setScanPrecision(int iscan, int precision) {
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
if (precision>=0)
|
||||
scanPrecision[iscan]=precision;
|
||||
return scanMode[iscan];
|
||||
} else
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
int slsDetectorActions::setScanSteps(int iscan, int nvalues, float *values) {
|
||||
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
|
||||
if (nvalues>=0) {
|
||||
if (nvalues==0)
|
||||
scanMode[iscan]=0;
|
||||
else {
|
||||
nScanSteps[iscan]=nvalues;
|
||||
if (nvalues>MAX_SCAN_STEPS)
|
||||
nScanSteps[iscan]=MAX_SCAN_STEPS;
|
||||
}
|
||||
}
|
||||
|
||||
if (values) {
|
||||
for (int iv=0; iv<nScanSteps[iscan]; iv++) {
|
||||
scanSteps[iscan][iv]=values[iv];
|
||||
}
|
||||
}
|
||||
|
||||
if (scanMode[iscan]>0){
|
||||
*actionMask |= (1 << (iscan+MAX_ACTIONS));
|
||||
} else {
|
||||
*actionMask &= ~(1 << (iscan+MAX_ACTIONS));
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Action mask is " << hex << actionMask << dec << endl;
|
||||
#endif
|
||||
setTotalProgress();
|
||||
|
||||
|
||||
|
||||
|
||||
return scanMode[iscan];
|
||||
|
||||
|
||||
} else
|
||||
return -1;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
returns scan script
|
||||
\param iscan can be (0,1)
|
||||
\returns scan script
|
||||
*/
|
||||
string slsDetectorActions::getScanScript(int iscan){
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
if (scanMode[iscan])
|
||||
return string(scanScript[iscan]);
|
||||
else
|
||||
return string("none");
|
||||
} else
|
||||
return string("wrong index");
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
returns scan parameter
|
||||
\param iscan can be (0,1)
|
||||
\returns scan parameter
|
||||
*/
|
||||
string slsDetectorActions::getScanParameter(int iscan){
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
if (scanMode[iscan])
|
||||
return string(scanParameter[iscan]);
|
||||
else
|
||||
return string("none");
|
||||
} else
|
||||
return string("wrong index");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
returns scan mode
|
||||
\param iscan can be (0,1)
|
||||
\returns scan mode
|
||||
*/
|
||||
int slsDetectorActions::getScanMode(int iscan){
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS)
|
||||
return scanMode[iscan];
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
returns scan steps
|
||||
\param iscan can be (0,1)
|
||||
\param v is the pointer to the scan steps
|
||||
\returns scan steps
|
||||
*/
|
||||
int slsDetectorActions::getScanSteps(int iscan, float *v) {
|
||||
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
if (v) {
|
||||
for (int iv=0; iv<nScanSteps[iscan]; iv++) {
|
||||
v[iv]=scanSteps[iscan][iv];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setTotalProgress();
|
||||
|
||||
|
||||
if (scanMode[iscan])
|
||||
return nScanSteps[iscan];
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int slsDetectorActions::getScanPrecision(int iscan){
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
return scanPrecision[iscan];
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
173
slsDetectorSoftware/slsDetector/slsDetectorActions.h
Normal file
173
slsDetectorSoftware/slsDetector/slsDetectorActions.h
Normal file
@ -0,0 +1,173 @@
|
||||
#ifndef SLS_DETECTOR_ACTIONS_H
|
||||
#define SLS_DETECTOR_ACTIONS_H
|
||||
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
|
||||
#define MAX_SCAN_LEVELS 2
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
|
||||
class implementing the script and scan utilities of the detectors
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class slsDetectorActions : public slsDetectorDefs {
|
||||
public :
|
||||
slsDetectorActions(){};
|
||||
virtual ~slsDetectorActions(){};
|
||||
|
||||
/**
|
||||
set action
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||
\param fname for script ("" disable)
|
||||
\param par for script
|
||||
\returns 0 if action disabled, >0 otherwise
|
||||
*/
|
||||
int setAction(int iaction, string fname="", string par="");
|
||||
|
||||
/**
|
||||
set action
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||
\param fname for script ("" disable)
|
||||
\returns 0 if action disabled, >0 otherwise
|
||||
*/
|
||||
int setActionScript(int iaction, string fname="");
|
||||
/**
|
||||
set action
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||
\param par for script ("" disable)
|
||||
\returns 0 if action disabled, >0 otherwise
|
||||
*/
|
||||
int setActionParameter(int iaction, string par="");
|
||||
|
||||
/**
|
||||
returns action script
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action script
|
||||
*/
|
||||
string getActionScript(int iaction);
|
||||
|
||||
/**
|
||||
returns action parameter
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action parameter
|
||||
*/
|
||||
string getActionParameter(int iaction);
|
||||
|
||||
/**
|
||||
returns action mode
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action mode
|
||||
*/
|
||||
int getActionMode(int iaction);
|
||||
|
||||
|
||||
/**
|
||||
set scan
|
||||
\param index of the scan (0,1)
|
||||
\param fname for script ("" disables, "none" disables and overwrites current)
|
||||
\param nvalues number of steps (0 disables, -1 leaves current value)
|
||||
\param values pointer to steps (if NULL leaves current values)
|
||||
\param par parameter for the scan script ("" leaves unchanged)
|
||||
\returns 0 is scan disabled, >0 otherwise
|
||||
*/
|
||||
int setScan(int index, string script="", int nvalues=-1, float *values=NULL, string par="", int precision=-1);
|
||||
|
||||
int setScanScript(int index, string script="");
|
||||
int setScanParameter(int index, string par="");
|
||||
int setScanPrecision(int index, int precision=-1);
|
||||
int setScanSteps(int index, int nvalues=-1, float *values=NULL);
|
||||
float getScanStep(int index, int istep){if (index<MAX_SCAN_LEVELS && istep<MAX_SCAN_STEPS) return scanSteps[index][istep]; else return -1;};
|
||||
/**
|
||||
returns scan script
|
||||
\param iscan can be (0,1)
|
||||
\returns scan script
|
||||
*/
|
||||
string getScanScript(int iscan);
|
||||
|
||||
/**
|
||||
returns scan parameter
|
||||
\param iscan can be (0,1)
|
||||
\returns scan parameter
|
||||
*/
|
||||
string getScanParameter(int iscan);
|
||||
|
||||
/**
|
||||
returns scan mode
|
||||
\param iscan can be (0,1)
|
||||
\returns scan mode
|
||||
*/
|
||||
int getScanMode(int iscan);
|
||||
|
||||
/**
|
||||
returns scan steps
|
||||
\param iscan can be (0,1)
|
||||
\param v is the pointer to the scan steps
|
||||
\returns scan steps
|
||||
*/
|
||||
int getScanSteps(int iscan, float *v=NULL);
|
||||
|
||||
|
||||
/**
|
||||
returns scan precision
|
||||
\param iscan can be (0,1)
|
||||
\returns scan precision
|
||||
*/
|
||||
int getScanPrecision(int iscan);
|
||||
|
||||
|
||||
virtual int setTotalProgress()=0;
|
||||
|
||||
int getActionMask() {if (actionMask) return *actionMask; return 0;};
|
||||
|
||||
float getCurrentScanVariable(int index) {return currentScanVariable[index];};
|
||||
// int getScanPrecision(int index) {return scanPrecision[index];};
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
int *actionMask;
|
||||
mystring *actionScript;
|
||||
mystring *actionParameter;
|
||||
|
||||
int *nScanSteps;
|
||||
mysteps *scanSteps;
|
||||
int *scanMode;
|
||||
int *scanPrecision;
|
||||
mystring *scanScript;
|
||||
mystring *scanParameter;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
current scan variable of the detector
|
||||
*/
|
||||
float currentScanVariable[MAX_SCAN_LEVELS];
|
||||
|
||||
/**
|
||||
current scan variable index of the detector
|
||||
*/
|
||||
int currentScanIndex[MAX_SCAN_LEVELS];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
#endif
|
@ -47,18 +47,9 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
*/
|
||||
virtual void acquire(int delflag)=0;
|
||||
|
||||
|
||||
/**
|
||||
asks and receives all data from the detector and puts them in a data queue
|
||||
\returns pointer to the front of the queue or NULL.
|
||||
\sa getDataFromDetector dataQueue
|
||||
*/
|
||||
virtual int* readAll()=0;
|
||||
|
||||
/**
|
||||
asks and receives a data frame from the detector and puts it in the data queue
|
||||
\returns pointer to the data or NULL.
|
||||
\sa getDataFromDetector
|
||||
asks and receives a data frame from the detector, writes it to disk and processes the data
|
||||
\returns pointer to the data or NULL (unused!!!).
|
||||
*/
|
||||
virtual int* readFrame()=0;
|
||||
|
||||
@ -69,12 +60,6 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
/* *\/ */
|
||||
/* virtual void* processData(int delflag)=0; */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
start detector acquisition
|
||||
\returns OK/FAIL
|
||||
@ -125,87 +110,27 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
/* virtual int removeSlsDetector(char* name){return -1;}; */
|
||||
|
||||
|
||||
|
||||
/** returns the detector hostname
|
||||
\param pos position in the multi detector structure (is -1 returns concatenated hostnames divided by a +)
|
||||
\returns hostname
|
||||
*/
|
||||
virtual string getHostname(int pos=-1)=0;
|
||||
|
||||
|
||||
/** sets the detector hostname
|
||||
\param name hostname
|
||||
\param pos position in the multi detector structure (is -1 expects concatenated hostnames divided by a +)
|
||||
\returns hostname
|
||||
*/
|
||||
virtual string setHostname(char* name, int pos=-1)=0;
|
||||
|
||||
/** Gets the detector id (shared memory id) of an slsDetector
|
||||
\param i position in the multiSlsDetector structure
|
||||
\return id or -1 if FAIL
|
||||
*/
|
||||
virtual int getDetectorId(int i=-1) =0;
|
||||
|
||||
/** Sets the detector id (shared memory id) of an slsDetector in a multiSlsDetector structure
|
||||
\param ival id to be set
|
||||
\param i position in the multiSlsDetector structure
|
||||
\return id or -1 if FAIL (e.g. in case of an slsDetector)
|
||||
*/
|
||||
virtual int setDetectorId(int ival, int i=-1){return -1;};
|
||||
|
||||
/** sets/gets position of the master in a multi detector structure
|
||||
\param i position of the detector in the multidetector structure
|
||||
\returns position of the master in a multi detector structure (-1 no master or always in slsDetector)
|
||||
*/
|
||||
virtual int setMaster(int i=-1){return -1;};
|
||||
|
||||
/**
|
||||
Sets/gets the synchronization mode of the various detectors
|
||||
\param sync syncronization mode
|
||||
\returns current syncronization mode
|
||||
*/
|
||||
virtual synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE)=0;
|
||||
|
||||
|
||||
/**
|
||||
returns the detector trimbit/settings directory
|
||||
*/
|
||||
virtual char* getSettingsDir()=0;
|
||||
|
||||
/** sets the detector trimbit/settings directory */
|
||||
virtual char* setSettingsDir(string s)=0;
|
||||
|
||||
/**
|
||||
returns the location of the calibration files
|
||||
*/
|
||||
virtual char* getCalDir()=0;
|
||||
|
||||
/**
|
||||
sets the location of the calibration files
|
||||
*/
|
||||
virtual char* setCalDir(string s)=0;
|
||||
|
||||
/**
|
||||
returns the default output files path
|
||||
*/
|
||||
virtual char* getFilePath()=0;
|
||||
virtual string getFilePath()=0;
|
||||
|
||||
/**
|
||||
sets the default output files path
|
||||
\param s file path
|
||||
\returns file path
|
||||
*/
|
||||
virtual char* setFilePath(string s)=0;
|
||||
virtual string setFilePath(string s)=0;
|
||||
|
||||
/**
|
||||
returns the default output files root name
|
||||
*/
|
||||
virtual char* getFileName()=0;
|
||||
virtual string getFileName()=0;
|
||||
|
||||
/**
|
||||
sets the default output files path
|
||||
*/
|
||||
virtual char* setFileName(string s)=0;
|
||||
virtual string setFileName(string s)=0;
|
||||
|
||||
/**
|
||||
returns the default output file index
|
||||
@ -221,20 +146,20 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
get flat field corrections file directory
|
||||
\returns flat field correction file directory
|
||||
*/
|
||||
virtual char *getFlatFieldCorrectionDir()=0;
|
||||
virtual string getFlatFieldCorrectionDir()=0;
|
||||
|
||||
/**
|
||||
set flat field corrections file directory
|
||||
\param dir flat field correction file directory
|
||||
\returns flat field correction file directory
|
||||
*/
|
||||
virtual char *setFlatFieldCorrectionDir(string dir)=0;
|
||||
virtual string setFlatFieldCorrectionDir(string dir)=0;
|
||||
|
||||
/**
|
||||
get flat field corrections file name
|
||||
\returns flat field correction file name
|
||||
*/
|
||||
virtual char *getFlatFieldCorrectionFile()=0;
|
||||
virtual string getFlatFieldCorrectionFile()=0;
|
||||
|
||||
/**
|
||||
set flat field corrections
|
||||
@ -243,22 +168,6 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
*/
|
||||
virtual int setFlatFieldCorrection(string fname="")=0;
|
||||
|
||||
/**
|
||||
get flat field corrections
|
||||
\param corr if !=NULL will be filled with the correction coefficients
|
||||
\param ecorr if !=NULL will be filled with the correction coefficients errors
|
||||
\returns 0 if ff correction disabled, >0 otherwise
|
||||
*/
|
||||
virtual int getFlatFieldCorrection(float *corr=NULL, float *ecorr=NULL)=0;
|
||||
|
||||
/**
|
||||
set flat field corrections
|
||||
\param corr if !=NULL the flat field corrections will be filled with corr (NULL usets ff corrections)
|
||||
\param ecorr if !=NULL the flat field correction errors will be filled with ecorr (1 otherwise)
|
||||
\returns 0 if ff correction disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setFlatFieldCorrection(float *corr, float *ecorr=NULL)=0;
|
||||
|
||||
/**
|
||||
set rate correction
|
||||
\param t dead time in ns - if 0 disable correction, if >0 set dead time to t, if <0 set deadtime to default dead time for current settings
|
||||
@ -273,111 +182,40 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
*/
|
||||
virtual int getRateCorrection(float &t)=0;
|
||||
|
||||
/**
|
||||
get rate correction tau
|
||||
\returns 0 if rate correction disabled, otherwise the tau used for the correction
|
||||
*/
|
||||
virtual float getRateCorrectionTau()=0;
|
||||
|
||||
/**
|
||||
get rate correction
|
||||
\returns 0 if rate correction disabled, >0 otherwise
|
||||
*/
|
||||
virtual int getRateCorrection()=0;
|
||||
|
||||
/**
|
||||
set bad channels correction
|
||||
\param fname file with bad channel list ("" disable)
|
||||
\returns 0 if bad channel disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setBadChannelCorrection(string fname="")=0;
|
||||
|
||||
/**
|
||||
set bad channels correction
|
||||
\param nch number of bad channels
|
||||
\param chs array of channels
|
||||
\param ff 0 if normal bad channels, 1 if ff bad channels
|
||||
\returns 0 if bad channel disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setBadChannelCorrection(int nch, int *chs, int ff=0)=0;
|
||||
|
||||
/**
|
||||
get bad channels correction
|
||||
\param bad pointer to array that if bad!=NULL will be filled with the bad channel list
|
||||
\returns 0 if bad channel disabled or no bad channels, >0 otherwise
|
||||
*/
|
||||
virtual int getBadChannelCorrection(int *bad=NULL)=0;
|
||||
|
||||
/**
|
||||
returns the bad channel list file
|
||||
*/
|
||||
virtual string getBadChannelCorrectionFile()=0;
|
||||
|
||||
/**
|
||||
set angular conversion
|
||||
\param fname file with angular conversion constants ("" disable)
|
||||
\returns 0 if angular conversion disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setAngularConversion(string fname="")=0;
|
||||
|
||||
/**
|
||||
get angular conversion
|
||||
\param direction reference to diffractometer direction
|
||||
\param angconv array that will be filled with the angular conversion constants
|
||||
\returns 0 if angular conversion disabled, >0 otherwise
|
||||
*/
|
||||
virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL)=0;
|
||||
|
||||
/**
|
||||
pure virtual function
|
||||
returns the angular conversion file
|
||||
*/
|
||||
virtual string getAngularConversion()=0;
|
||||
|
||||
|
||||
/**
|
||||
sets the value of s angular conversion parameter
|
||||
\param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE
|
||||
\param v the value to be set
|
||||
\returns the actual value
|
||||
*/
|
||||
|
||||
virtual float setAngularConversionParameter(angleConversionParameter c, float v)=0;
|
||||
|
||||
/**
|
||||
returns the value of an angular conversion parameter
|
||||
\param c can be ANGULAR_DIRECTION, GLOBAL_OFFSET, FINE_OFFSET, BIN_SIZE
|
||||
\returns the actual value
|
||||
*/
|
||||
virtual float getAngularConversionParameter(angleConversionParameter c)=0;
|
||||
|
||||
/* /\** */
|
||||
/* writes a data file */
|
||||
/* \param name of the file to be written */
|
||||
/* \param data array of data values */
|
||||
/* \param err array of arrors on the data. If NULL no errors will be written */
|
||||
|
||||
/* \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) */
|
||||
/* \param dataformat format of the data: can be 'i' integer or 'f' float (default) */
|
||||
/* \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector */
|
||||
/* \returns OK or FAIL if it could not write the file or data=NULL */
|
||||
/* /\** */
|
||||
/* returns the bad channel list file */
|
||||
/* *\/ */
|
||||
/* virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1)=0; */
|
||||
/* virtual string getBadChannelCorrectionFile()=0; */
|
||||
|
||||
|
||||
|
||||
|
||||
virtual int enableBadChannelCorrection(int i=-1)=0;
|
||||
|
||||
virtual int enableAngularConversion(int i=-1)=0;
|
||||
|
||||
|
||||
/* /\** */
|
||||
/* set angular conversion */
|
||||
/* \param fname file with angular conversion constants ("" disable) */
|
||||
/* \returns 0 if angular conversion disabled, >0 otherwise */
|
||||
/* *\/ */
|
||||
/* virtual int setAngularConversionFile(string fname="")=0; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
/* writes an angular conversion file */
|
||||
/* \param fname file to be written */
|
||||
/* \return OK/FAIL */
|
||||
/* pure virtual function */
|
||||
/* returns the angular conversion file */
|
||||
/* *\/ */
|
||||
/* virtual int writeAngularConversion(string fname)=0; */
|
||||
/* virtual string getAngularConversionFile()=0; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
/* set/get if the data processing and file writing should be done by a separate thread - do not use except for debugging! */
|
||||
/* \param i 0 sequencial data acquisition and file writing, 1 separate thread, -1 get */
|
||||
/* \returns thread flag */
|
||||
/* *\/ */
|
||||
/* virtual int setThreadedProcessing(int i=-1)=0; */
|
||||
|
||||
/**
|
||||
set positions for the acquisition
|
||||
\param nPos number of positions
|
||||
@ -393,122 +231,97 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
*/
|
||||
virtual int getPositions(float *pos=NULL)=0;
|
||||
|
||||
/**
|
||||
set action
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||
\param fname for script ("" disable)
|
||||
\returns 0 if action disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setActionScript(int iaction, string fname="")=0;
|
||||
/* /\** */
|
||||
/* set action */
|
||||
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} */
|
||||
/* \param fname for script ("" disable) */
|
||||
/* \returns 0 if action disabled, >0 otherwise */
|
||||
/* *\/ */
|
||||
/* virtual int setActionScript(int iaction, string fname="")=0; */
|
||||
|
||||
/**
|
||||
set action
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS}
|
||||
\param par for script ("" disable)
|
||||
\returns 0 if action disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setActionParameter(int iaction, string par="")=0;
|
||||
/* /\** */
|
||||
/* set action */
|
||||
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript, MAX_ACTIONS} */
|
||||
/* \param par for script ("" disable) */
|
||||
/* \returns 0 if action disabled, >0 otherwise */
|
||||
/* *\/ */
|
||||
/* virtual int setActionParameter(int iaction, string par="")=0; */
|
||||
|
||||
/**
|
||||
returns action script
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action script
|
||||
*/
|
||||
virtual string getActionScript(int iaction)=0;
|
||||
/* /\** */
|
||||
/* returns action script */
|
||||
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} */
|
||||
/* \returns action script */
|
||||
/* *\/ */
|
||||
/* virtual string getActionScript(int iaction)=0; */
|
||||
|
||||
/**
|
||||
returns action parameter
|
||||
\param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript}
|
||||
\returns action parameter
|
||||
*/
|
||||
virtual string getActionParameter(int iaction)=0;
|
||||
/* /\** */
|
||||
/* returns action parameter */
|
||||
/* \param iaction can be enum {startScript, scriptBefore, headerBefore, headerAfter,scriptAfter, stopScript} */
|
||||
/* \returns action parameter */
|
||||
/* *\/ */
|
||||
/* virtual string getActionParameter(int iaction)=0; */
|
||||
|
||||
/**
|
||||
set scan script
|
||||
\param index is the scan index (0 or 1)
|
||||
\param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan)
|
||||
\returns 0 if scan disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setScanScript(int index, string script="")=0;
|
||||
/* /\** */
|
||||
/* set scan script */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \param script fname for script ("" disable, "none" disables and overwrites current, "threshold" makes threshold scan, "trimbits" make trimbits scan, "energy" makes energy scan) */
|
||||
/* \returns 0 if scan disabled, >0 otherwise */
|
||||
/* *\/ */
|
||||
/* virtual int setScanScript(int index, string script="")=0; */
|
||||
|
||||
/**
|
||||
set scan script parameter
|
||||
\param index is the scan index (0 or 1)
|
||||
\param spar parameter to be passed to the scan script with syntax par=spar
|
||||
\returns 0 if scan disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setScanParameter(int index, string spar="")=0;
|
||||
/* /\** */
|
||||
/* set scan script parameter */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \param spar parameter to be passed to the scan script with syntax par=spar */
|
||||
/* \returns 0 if scan disabled, >0 otherwise */
|
||||
/* *\/ */
|
||||
/* virtual int setScanParameter(int index, string spar="")=0; */
|
||||
|
||||
/**
|
||||
set scan precision
|
||||
\param index is the scan index (0 or 1)
|
||||
\param precision number of decimals to use for the scan variable in the file name
|
||||
\returns 0 if scan disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setScanPrecision(int index, int precision=-1)=0;
|
||||
/* /\** */
|
||||
/* set scan precision */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \param precision number of decimals to use for the scan variable in the file name */
|
||||
/* \returns 0 if scan disabled, >0 otherwise */
|
||||
/* *\/ */
|
||||
/* virtual int setScanPrecision(int index, int precision=-1)=0; */
|
||||
|
||||
/**
|
||||
set scan steps (passed to the scan script as var=step)
|
||||
\param index is the scan index (0 or 1)
|
||||
\param nvalues is the number of steps
|
||||
\param values array of steps
|
||||
\returns 0 if scan disabled, >0 otherwise
|
||||
*/
|
||||
virtual int setScanSteps(int index, int nvalues=-1, float *values=NULL)=0;
|
||||
/* /\** */
|
||||
/* set scan steps (passed to the scan script as var=step) */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \param nvalues is the number of steps */
|
||||
/* \param values array of steps */
|
||||
/* \returns 0 if scan disabled, >0 otherwise */
|
||||
/* *\/ */
|
||||
/* virtual int setScanSteps(int index, int nvalues=-1, float *values=NULL)=0; */
|
||||
|
||||
/**
|
||||
get scan script
|
||||
\param index is the scan index (0 or 1)
|
||||
\returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name
|
||||
*/
|
||||
virtual string getScanScript(int index)=0;
|
||||
/* /\** */
|
||||
/* get scan script */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \returns "none" if disables, "threshold" threshold scan, "trimbits" trimbits scan, "energy" energy scan or scan script name */
|
||||
/* *\/ */
|
||||
/* virtual string getScanScript(int index)=0; */
|
||||
|
||||
/**
|
||||
get scan script
|
||||
\param index is the scan index (0 or 1)
|
||||
\returns scan script parameter
|
||||
*/
|
||||
virtual string getScanParameter(int index)=0;
|
||||
/* /\** */
|
||||
/* get scan script */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \returns scan script parameter */
|
||||
/* *\/ */
|
||||
/* virtual string getScanParameter(int index)=0; */
|
||||
|
||||
/**
|
||||
get scan precision
|
||||
\param index is the scan index (0 or 1)
|
||||
\returns precision i.e. number of decimals to use for the scan variable in the file name
|
||||
*/
|
||||
virtual int getScanPrecision(int index)=0;
|
||||
/* /\** */
|
||||
/* get scan precision */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \returns precision i.e. number of decimals to use for the scan variable in the file name */
|
||||
/* *\/ */
|
||||
/* virtual int getScanPrecision(int index)=0; */
|
||||
|
||||
/**
|
||||
get scan steps
|
||||
\param index is the scan index (0 or 1)
|
||||
\param values pointer to array of values (must be allocated in advance)
|
||||
\returns number of steps
|
||||
*/
|
||||
virtual int getScanSteps(int index, float *values=NULL)=0;
|
||||
|
||||
/**
|
||||
gets the network parameters (implemented for gotthard)
|
||||
\param i network parameter type can be CLIENT_IP, CLIENT_MAC, SERVER_MAC
|
||||
\returns parameter
|
||||
|
||||
*/
|
||||
virtual char *getNetworkParameter(networkParameter i)=0;
|
||||
|
||||
/**
|
||||
sets the network parameters (implemented for gotthard)
|
||||
\param i network parameter type can be CLIENT_IP, CLIENT_MAC, SERVER_MAC
|
||||
\param s value to be set
|
||||
\returns parameter
|
||||
|
||||
*/
|
||||
virtual char *setNetworkParameter(networkParameter i, string s)=0;
|
||||
|
||||
/**
|
||||
changes/gets the port number
|
||||
\param t type port type can be CONTROL_PORT, DATA_PORT, STOP_PORT
|
||||
\param i new port number (<1024 gets)
|
||||
\returns actual port number
|
||||
*/
|
||||
virtual int setPort(portType t, int i=-1)=0;
|
||||
/* /\** */
|
||||
/* get scan steps */
|
||||
/* \param index is the scan index (0 or 1) */
|
||||
/* \param values pointer to array of values (must be allocated in advance) */
|
||||
/* \returns number of steps */
|
||||
/* *\/ */
|
||||
/* virtual int getScanSteps(int index, float *values=NULL)=0; */
|
||||
|
||||
/** Locks/Unlocks the connection to the server
|
||||
/param lock sets (1), usets (0), gets (-1) the lock
|
||||
@ -516,19 +329,6 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
*/
|
||||
virtual int lockServer(int i=-1)=0;
|
||||
|
||||
/**
|
||||
Returns the IP of the last client connecting to the detector
|
||||
*/
|
||||
virtual string getLastClientIP()=0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
configures mac for gotthard readout
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
|
||||
virtual int configureMAC()=0;
|
||||
|
||||
|
||||
/**
|
||||
@ -540,13 +340,6 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
virtual int setNumberOfModules(int i=-1, dimension d=X)=0;
|
||||
|
||||
|
||||
/**
|
||||
get the maximum size of the detector
|
||||
\param d dimension
|
||||
\returns maximum number of modules that can be installed in direction d
|
||||
*/
|
||||
virtual int getMaxNumberOfModules(dimension d=X)=0;
|
||||
|
||||
|
||||
/**
|
||||
set/get dynamic range
|
||||
@ -589,78 +382,7 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
*/
|
||||
virtual int setThresholdEnergy(int e_eV, int imod=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||
|
||||
/**
|
||||
get detector ids/versions for module
|
||||
\param mode which id/version has to be read
|
||||
\param imod module number for module serial number
|
||||
\returns id
|
||||
*/
|
||||
virtual int64_t getId(idMode mode, int imod=0)=0;
|
||||
|
||||
/**
|
||||
Digital test of the modules
|
||||
\param mode test mode
|
||||
\param imod module number for chip test or module firmware test
|
||||
\returns OK or error mask
|
||||
*/
|
||||
virtual int digitalTest(digitalTestMode mode, int imod=0)=0;
|
||||
|
||||
/**
|
||||
ex cute trimming
|
||||
\param mode trim mode
|
||||
\param par1 if noise, beam or fixed setting trimming it is count limit, if improve maximum number of iterations
|
||||
\param par2 if noise or beam nsigma, if improve par2!=means vthreshold will be optimized, if fixed settings par2<0 trimwith median, par2>=0 trim with level
|
||||
\param imod module number (-1 all)
|
||||
\returns OK or FAIl (FAIL also if some channel are 0 or 63
|
||||
*/
|
||||
virtual int executeTrimming(trimMode mode, int par1, int par2, int imod=-1)=0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
returns currently the loaded trimfile/settingsfile name
|
||||
*/
|
||||
virtual const char *getSettingsFile()=0;
|
||||
|
||||
|
||||
|
||||
/** loads the modules settings/trimbits reading from a file
|
||||
\param fname file name . If not specified, extension is automatically generated!
|
||||
\param imod module number, -1 means all modules
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int loadSettingsFile(string fname, int imod=-1)=0;
|
||||
|
||||
|
||||
|
||||
/** saves the modules settings/trimbits writing to a file
|
||||
\param fname file name . Axtension is automatically generated!
|
||||
\param imod module number, -1 means all modules
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int saveSettingsFile(string fname, int imod=-1)=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
set dacs value
|
||||
\param val value (in V)
|
||||
\param index DAC index
|
||||
\param imod module number (if -1 alla modules)
|
||||
\returns current DAC value
|
||||
*/
|
||||
virtual float setDAC(float val, dacIndex index , int imod=-1)=0;
|
||||
|
||||
|
||||
/**
|
||||
gets ADC value
|
||||
\param index ADC index
|
||||
\param imod module number
|
||||
\returns current ADC value
|
||||
*/
|
||||
virtual float getADC(dacIndex index, int imod=0)=0;
|
||||
|
||||
|
||||
/**
|
||||
@ -672,60 +394,6 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0;
|
||||
|
||||
|
||||
/**
|
||||
get current timer value
|
||||
\param index timer index
|
||||
\returns elapsed time value in ns or number of...(e.g. frames, gates, probes)
|
||||
*/
|
||||
virtual int64_t getTimeLeft(timerIndex index)=0;
|
||||
|
||||
|
||||
|
||||
|
||||
/** sets/gets the value of important readout speed parameters
|
||||
\param sp is the parameter to be set/get
|
||||
\param value is the value to be set, if -1 get value
|
||||
\returns current value for the specified parameter
|
||||
\sa speedVariable
|
||||
*/
|
||||
virtual int setSpeed(speedVariable sp, int value=-1)=0;
|
||||
|
||||
|
||||
|
||||
/** sets the number of trim energies and their value \sa sharedSlsDetector
|
||||
\param nen number of energies
|
||||
\param en array of energies
|
||||
\returns number of trim energies
|
||||
|
||||
unused!
|
||||
|
||||
*/
|
||||
virtual int setTrimEn(int nen, int *en=NULL)=0;
|
||||
|
||||
/** returns the number of trim energies and their value \sa sharedSlsDetector
|
||||
\param en pointer to the array that will contain the trim energies (in ev)
|
||||
\returns number of trim energies
|
||||
|
||||
unused!
|
||||
*/
|
||||
virtual int getTrimEn(int *en=NULL)=0;
|
||||
|
||||
|
||||
/**
|
||||
set/get the use of an external signal
|
||||
\param pol meaning of the signal \sa externalSignalFlag
|
||||
\param signalindex index of the signal
|
||||
\returns current meaning of signal signalIndex
|
||||
*/
|
||||
virtual externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0)=0;
|
||||
|
||||
/**
|
||||
set/get readout flags
|
||||
\param flag readout flag to be set
|
||||
\returns current flag
|
||||
*/
|
||||
virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0;
|
||||
|
||||
|
||||
/**
|
||||
set/get the external communication mode
|
||||
@ -736,19 +404,19 @@ class slsDetectorBase : public slsDetectorDefs
|
||||
|
||||
|
||||
/**
|
||||
Reads the configuration file
|
||||
Reads the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.)
|
||||
\param fname file name
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int readConfigurationFile(string const fname)=0;
|
||||
|
||||
|
||||
/**
|
||||
Writes the configuration file
|
||||
\param fname file name
|
||||
\returns OK or FAIL
|
||||
*/
|
||||
virtual int writeConfigurationFile(string const fname)=0;
|
||||
/* /\** */
|
||||
/* Writes the configuration file -- will contain all the informations needed for the configuration (e.g. for a PSI detector caldir, settingsdir, angconv, badchannels etc.) */
|
||||
/* \param fname file name */
|
||||
/* \returns OK or FAIL */
|
||||
/* *\/ */
|
||||
/* virtual int writeConfigurationFile(string const fname)=0; */
|
||||
|
||||
/**
|
||||
Reads the parameters from the detector and writes them to file
|
||||
|
@ -114,6 +114,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv;
|
||||
i++;
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="moveflag" ;//
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAngConv;
|
||||
i++;
|
||||
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="threaded"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdThreaded;
|
||||
i++;
|
||||
@ -1508,9 +1515,9 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){
|
||||
if (sval=="none")
|
||||
sval="";
|
||||
|
||||
myDet->setAngularConversion(sval);
|
||||
myDet->setAngularConversionFile(sval);
|
||||
|
||||
return string(myDet->getAngularConversion());
|
||||
return string(myDet->getAngularConversionFile());
|
||||
} else if (action==GET_ACTION) {
|
||||
if (narg>1)
|
||||
sval=string(args[1]);
|
||||
@ -1522,7 +1529,7 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){
|
||||
myDet->writeAngularConversion(sval.c_str());
|
||||
return sval;
|
||||
}
|
||||
return string(myDet->getAngularConversion());
|
||||
return string(myDet->getAngularConversionFile());
|
||||
} else {
|
||||
return string("none");
|
||||
}
|
||||
@ -1541,6 +1548,8 @@ string slsDetectorCommand::cmdAngConv(int narg, char *args[], int action){
|
||||
} else if (string(args[0])==string("angdir")) {
|
||||
c=ANGULAR_DIRECTION;
|
||||
|
||||
} else if (string(args[0])==string("moveflag")) {
|
||||
c=MOVE_FLAG;
|
||||
} else
|
||||
return string("could not decode angular conversion parameter ")+cmd;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user