slsDetectorUsers inherited by all classes i.e. API ready for EPICS driver

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@187 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi 2012-06-05 13:57:00 +00:00
parent ed84d21da0
commit fe86145881
8 changed files with 173 additions and 22 deletions

View File

@ -1608,13 +1608,15 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
int badlist[MAX_BADCHANS];
int im=0;
if (fname=="default") {
fname=string(thisMultiDetector->flatFieldFile);
}
if (fname=="") {
#ifdef VERBOSE
std::cout<< "disabling flat field correction" << std::endl;
#endif
thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
strcpy(thisMultiDetector->flatFieldFile,"none");
// strcpy(thisMultiDetector->flatFieldFile,"none");
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i])
detectors[i]->setFlatFieldCorrection(NULL, NULL);

View File

@ -265,7 +265,9 @@ class multiSlsDetector : public slsDetectorUtils {
string getHostname(int pos=-1);
using slsDetectorBase::getDetectorType;
string getDetectorType(){return sgetDetectorsType();};
detectorType getDetectorsType(int pos=-1);
detectorType setDetectorsType(detectorType type=GET_DETECTOR_TYPE, int pos=-1){addSlsDetector(type, pos); return getDetectorsType(pos);};

View File

@ -3985,14 +3985,17 @@ int slsDetector::setFlatFieldCorrection(string fname){
thisDetector->nBadFF=0;
char ffffname[MAX_STR_LENGTH*2];
if (fname=="default") {
fname=string("thisDetector->flatFieldFile");
}
if (fname=="") {
if (fname=="") {
#ifdef VERBOSE
std::cout<< "disabling flat field correction" << std::endl;
std::cout<< "disabling flat field correction" << std::endl;
#endif
thisDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
strcpy(thisDetector->flatFieldFile,"none");
} else {
thisDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
//strcpy(thisDetector->flatFieldFile,"none");
} else {
#ifdef VERBOSE
std::cout<< "Setting flat field correction from file " << fname << std::endl;
#endif

View File

@ -258,7 +258,7 @@ typedef struct sharedSlsDetector {
using slsDetectorUtils::getAngularConversion;
string getDetectorType(){return sgetDetectorsType();};

View File

@ -47,7 +47,7 @@ Most methods of interest for the user are implemented in the ::slsDetectorBase i
*/
//#include "slsDetectorUsers.h"
#include "slsDetectorUsers.h"
#include "sls_detector_defs.h"
#include <string>
@ -64,8 +64,7 @@ using namespace std;
*/
//public virtual slsDetectorUsers,
class slsDetectorBase : public virtual slsDetectorDefs
{
class slsDetectorBase : public virtual slsDetectorDefs, public slsDetectorUsers {
public:
@ -76,7 +75,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
/** virtual destructor */
virtual ~slsDetectorBase(){};
string getDetectorDeveloper(){return string("PSI");};
// protected:
/**
@ -275,15 +274,15 @@ class slsDetectorBase : public virtual slsDetectorDefs
virtual int setFlatFieldCorrection(string fname="")=0;
int setFlatFieldCorrectionFile(string fname=""){return setFlatFieldCorrection(fname);};
/**
set/get dynamic range
\param i dynamic range (-1 get)
\returns current dynamic range
*/
virtual int setDynamicRange(int i=-1)=0;
int setBitDepth(int i=-1){return setDynamicRange(i);};
/**
set/get the size of the detector
@ -293,6 +292,12 @@ class slsDetectorBase : public virtual slsDetectorDefs
*/
virtual int setNumberOfModules(int i=-1, dimension d=X)=0;
int setDetectorSize(int x0=-1, int y0=-1, int nx=-1, int ny=-1){return setNumberOfModules(nx,X);};
int getDetectorSize(int &x0, int &y0, int &nx, int &ny){x0=0; nx=setNumberOfModules(-1,X); return nx;};
virtual int getMaxNumberOfModules(dimension d=X)=0; //
int getMaximumDetectorSize(int &nx, int &ny){nx=getMaxNumberOfModules(X); ny=1; return nx;};
/** Locks/Unlocks the connection to the server
@ -314,6 +319,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
*/
virtual void acquire(int delflag=1)=0;
int startMeasurement(){acquire(0); return OK;};
/**
asks and receives a data frame from the detector, writes it to disk and processes the data
@ -332,7 +338,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
\returns OK/FAIL
*/
virtual int stopAcquisition()=0;
int stopMeasurement(){return stopAcquisition();};
/**
@ -342,6 +348,12 @@ class slsDetectorBase : public virtual slsDetectorDefs
\returns timer set value in ns or number of...(e.g. frames, gates, probes)
*/
virtual int64_t setTimer(timerIndex index, int64_t t=-1)=0;
int64_t setExposureTime(int64_t t=-1){return setTimer(ACQUISITION_TIME,t);};
int64_t setExposurePeriod(int64_t t=-1){return setTimer(FRAME_PERIOD,t);};
int64_t setDelayAfterTrigger(int64_t t=-1){return setTimer(DELAY_AFTER_TRIGGER,t);};
int64_t setNumberOfGates(int64_t t=-1){return setTimer(GATES_NUMBER,t);};
int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);};
int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
///////////////////////////////////////////////////////////////////////////////////////////
/**
@ -349,7 +361,7 @@ class slsDetectorBase : public virtual slsDetectorDefs
\returns status mask
*/
virtual runStatus getRunStatus()=0;
int getDetectorStatus() {return (int)getRunStatus();};
/** @short sets the onlineFlag
@ -363,15 +375,15 @@ class slsDetectorBase : public virtual slsDetectorDefs
\returns current settings
*/
virtual detectorSettings setSettings(detectorSettings isettings, int imod=-1)=0;
int setSettings(int isettings){return (int)setSettings((detectorSettings)isettings,-1);};
virtual detectorSettings getSettings(int imod=-1)=0;
/**
get threshold energy
\param imod module number (-1 all)
\returns current threshold value for imod in ev (-1 failed)
*/
virtual int getThresholdEnergy(int imod=-1)=0;
virtual int getThresholdEnergy(int imod)=0;
int getThresholdEnergy(){return getThresholdEnergy(-1);};
/**
set/get the external communication mode
@ -381,6 +393,16 @@ class slsDetectorBase : public virtual slsDetectorDefs
\returns current external communication mode
*/
virtual externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE)=0;
int setTimingMode(int i=-1){return (int)setExternalCommunicationMode((externalCommunicationMode)i);};
virtual int setThresholdEnergy(int e_eV, int imod, detectorSettings isettings=GET_SETTINGS)=0;
int setThresholdEnergy(int e_eV){return setThresholdEnergy(e_eV,-1);};
int getBeamEnergy(){return 2*getThresholdEnergy();};
int setBeamEnergy(int e){return 2*setThresholdEnergy(e/2);};
/**
@ -389,8 +411,10 @@ class slsDetectorBase : public virtual slsDetectorDefs
\returns OK or FAIL
*/
virtual int readConfigurationFile(string const fname)=0;
virtual int dumpDetectorSetup(string const fname, int level=0)=0;
virtual int retrieveDetectorSetup(string const fname, int level=0)=0;
virtual int dumpDetectorSetup(string const fname, int level)=0;
int dumpDetectorSetup(string const fname){return dumpDetectorSetup(fname,0);};
virtual int retrieveDetectorSetup(string const fname, int level)=0;
int retrieveDetectorSetup(string const fname){return retrieveDetectorSetup(fname,0);};
/**
@short
\returns the default output file index

View File

@ -735,3 +735,116 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
}
// int slsDetectorUtils::setFlatFieldCorrectionFile(string fname){
// int tch=getTotalNumberOfChannels();
// float data[tch], xmed[tch];
// float ffcoefficients[tch], fferrors[tch];
// int nmed=0;
// int idet=0, ichdet=-1;
// char ffffname[MAX_STR_LENGTH*2];
// int nbad=0, nch;
// int badlist[MAX_BADCHANS];
// int im=0;
// if (fname=="default") {
// fname=string(flatFieldFile);
// }
// if (fname=="") {
// #ifdef VERBOSE
// std::cout<< "disabling flat field correction" << std::endl;
// #endif
// (*correctionMask)&=~(1<<FLAT_FIELD_CORRECTION);
// // strcpy(thisMultiDetector->flatFieldFile,"none");
// setFlatFieldCorrection(NULL, NULL);
// } else {
// #ifdef VERBOSE
// std::cout<< "Setting flat field correction from file " << fname << std::endl;
// #endif
// sprintf(ffffname,"%s/%s",flatFieldDir,fname.c_str());
// nch=readDataFile(string(ffffname),data);
// if (nch>tch)
// nch=tch;
// if (nch>0) {
// strcpy(flatFieldFile,fname.c_str());
// nbad=0;
// for (int ichan=0; ichan<nch; ichan++) {
// if (data[ichan]>0) {
// /* add to median */
// im=0;
// while ((im<nmed) && (xmed[im]<data[ichan]))
// im++;
// for (int i=nmed; i>im; i--)
// xmed[i]=xmed[i-1];
// xmed[im]=data[ichan];
// nmed++;
// } else {
// if (nbad<MAX_BADCHANS) {
// badlist[nbad]=ichan;
// nbad++;
// }
// }
// }
// if (nmed>1 && xmed[nmed/2]>0) {
// #ifdef VERBOSE
// std::cout<< "Flat field median is " << xmed[nmed/2] << " calculated using "<< nmed << " points" << std::endl;
// #endif
// thisMultiDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
// // add to ff coefficients and errors of single detectors
// for (int ichan=0; ichan<nch; ichan++) {
// setFlatFieldCorrection(ffcoefficients, fferrors);
// if (data[ichan]>0) {
// ffcoefficients[ichan]=xmed[nmed/2]/data[ichan];
// fferrors[ichan]=ffcoefficients[ichan]*sqrt(data[ichan])/data[ichan];
// } else {
// ffcoefficients[ichan]=0.;
// fferrors[ichan]=1.;
// }
// }
// setFlatFieldCorrection(ffcoefficients, fferrors);
// } else {
// std::cout<< "Flat field data from file " << fname << " are not valid (" << nmed << "///" << xmed[nmed/2] << std::endl;
// thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
// for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
// if (detectors[i])
// detectors[i]->setFlatFieldCorrection(NULL, NULL);
// }
// return -1;
// }
// } else {
// std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl;
// thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
// for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
// if (detectors[i])
// detectors[i]->setFlatFieldCorrection(NULL, NULL);
// }
// return -1;
// }
// }
// return thisMultiDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION);
// }

View File

@ -71,6 +71,9 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
using slsDetectorBase::setFlatFieldCorrection;
using postProcessing::setBadChannelCorrection;
int enableFlatFieldCorrection(int i=-1) {if (i>0) setFlatFieldCorrectionFile("default"); else if (i==0) setFlatFieldCorrectionFile(""); return getFlatFieldCorrection();}
int enablePixelMaskCorrection(int i=-1) {if (i>0) setBadChannelCorrection("default"); else if (i==0) setBadChannelCorrection(""); return getBadChannelCorrection();}
int enableCountRateCorrection(int i=-1){if (i>0) setRateCorrection(-1); else if (i==0) setRateCorrection(0); return getRateCorrection();}
// string getFilePath(){return fileIO::getFilePath();};
// string setFilePath(string s){return fileIO::setFilePath(s);};

View File

@ -15,6 +15,10 @@ postProcessing::postProcessing(){
}
int postProcessing::flatFieldCorrect(float datain, float errin, float &dataout, float &errout, float ffcoefficient, float fferr){
float e;