mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Gotthard class implemented
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@34 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -5,10 +5,6 @@
|
||||
#include <sys/shm.h>
|
||||
|
||||
|
||||
|
||||
//using namespace std;
|
||||
|
||||
|
||||
int slsDetector::initSharedMemory(detectorType type, int id) {
|
||||
|
||||
|
||||
@ -34,6 +30,12 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
||||
nc=12;
|
||||
nd=6; // dacs+adcs
|
||||
break;
|
||||
case GOTTHARD:
|
||||
nch=128;
|
||||
nm=1;
|
||||
nc=10;
|
||||
nd=13; // dacs+adcs
|
||||
break;
|
||||
default:
|
||||
nch=65535; // one EIGER module
|
||||
nm=1; //modules/detector
|
||||
@ -115,22 +117,25 @@ slsDetector::slsDetector(detectorType type, int id):
|
||||
chanregs(NULL),
|
||||
badChannelMask(NULL)
|
||||
{
|
||||
while (shmId<0) {
|
||||
/**Initlializes shared memory \sa initSharedMemory
|
||||
while (shmId<0) {
|
||||
/**Initlializes shared memory \sa initSharedMemory
|
||||
|
||||
if it fails the detector id is incremented until it succeeds
|
||||
*/
|
||||
shmId=initSharedMemory(type,id);
|
||||
id++;
|
||||
}
|
||||
id--;
|
||||
if it fails the detector id is incremented until it succeeds
|
||||
*/
|
||||
shmId=initSharedMemory(type,id);
|
||||
id++;
|
||||
}
|
||||
id--;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Detector id is " << id << std::endl;
|
||||
std::cout<< "Detector id is " << id << std::endl;
|
||||
#endif
|
||||
detId=id;
|
||||
/**Initializes the detector stucture \sa initializeDetectorSize
|
||||
*/
|
||||
initializeDetectorSize(type);
|
||||
detId=id;
|
||||
|
||||
|
||||
/**Initializes the detector stucture \sa initializeDetectorSize
|
||||
*/
|
||||
initializeDetectorSize(type);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -146,10 +151,17 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
/** sets onlineFlag to OFFLINE_FLAG */
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
/** set ports to defaults */
|
||||
switch(type){
|
||||
case GOTTHARD:
|
||||
thisDetector->controlPort=DEFAULT_PORTNO_GOTTHARD;
|
||||
thisDetector->stopPort=DEFAULT_PORTNO_GOTTHARD+1;
|
||||
thisDetector->dataPort=DEFAULT_PORTNO_GOTTHARD+2;
|
||||
break;
|
||||
default:
|
||||
thisDetector->controlPort=DEFAULT_PORTNO;
|
||||
thisDetector->stopPort=DEFAULT_PORTNO+1;
|
||||
thisDetector->dataPort=DEFAULT_PORTNO+2;
|
||||
|
||||
}
|
||||
/** set thisDetector->myDetectorType to type and according to this set nChans, nChips, nDacs, nAdcs, nModMax, dynamicRange, nMod*/
|
||||
thisDetector->myDetectorType=type;
|
||||
switch(thisDetector->myDetectorType) {
|
||||
@ -171,6 +183,15 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
thisDetector->nModMax[Y]=1;
|
||||
thisDetector->dynamicRange=24;
|
||||
break;
|
||||
case GOTTHARD:
|
||||
thisDetector->nChans=128;
|
||||
thisDetector->nChips=10;
|
||||
thisDetector->nDacs=8;
|
||||
thisDetector->nAdcs=5;
|
||||
thisDetector->nModMax[X]=1;
|
||||
thisDetector->nModMax[Y]=1;
|
||||
thisDetector->dynamicRange=1;
|
||||
break;
|
||||
default:
|
||||
thisDetector->nChans=65536;
|
||||
thisDetector->nChips=8;
|
||||
@ -196,11 +217,11 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
||||
else
|
||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
|
||||
/** set trimDsdir, calDir and filePath to default to home directory*/
|
||||
strcpy(thisDetector->trimDir,getenv("HOME"));
|
||||
strcpy(thisDetector->settingsDir,getenv("HOME"));
|
||||
strcpy(thisDetector->calDir,getenv("HOME"));
|
||||
strcpy(thisDetector->filePath,getenv("HOME"));
|
||||
/** sets trimbit file */
|
||||
strcpy(thisDetector->trimFile,"none");
|
||||
strcpy(thisDetector->settingsFile,"none");
|
||||
/** set fileName to default to run*/
|
||||
strcpy(thisDetector->fileName,"run");
|
||||
/** set fileIndex to default to 0*/
|
||||
@ -2324,7 +2345,7 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
||||
*/
|
||||
detectorSettings slsDetector::getSettings(int imod){
|
||||
|
||||
|
||||
|
||||
int fnum=F_SET_SETTINGS;
|
||||
int ret=FAIL;
|
||||
char mess[100];
|
||||
@ -2359,16 +2380,29 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
detectorSettings slsDetector::setSettings( detectorSettings isettings, int imod){
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
std::cout<< "slsDetector setSettings "<< std::endl;
|
||||
#endif
|
||||
//#endif
|
||||
sls_detector_module *myMod=createModule();
|
||||
int modmi=imod, modma=imod+1, im=imod;
|
||||
string trimfname, calfname;
|
||||
string settingsfname, calfname;
|
||||
string ssettings;
|
||||
detectorSettings minsettings, maxsettings;
|
||||
|
||||
if (isettings>=STANDARD && isettings<=HIGHGAIN) {
|
||||
switch(thisDetector->myDetectorType){
|
||||
case GOTTHARD:
|
||||
minsettings = HIGHGAIN;
|
||||
maxsettings = GAIN3;
|
||||
break;
|
||||
default:
|
||||
minsettings = STANDARD;
|
||||
maxsettings = HIGHGAIN;
|
||||
}
|
||||
|
||||
if (isettings>=minsettings && isettings<=maxsettings) {
|
||||
switch (isettings) {
|
||||
case STANDARD:
|
||||
ssettings="/standard";
|
||||
@ -2382,10 +2416,26 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
||||
ssettings="/highgain";
|
||||
thisDetector->currentSettings=HIGHGAIN;
|
||||
break;
|
||||
case DYNAMICGAIN:
|
||||
ssettings="/dynamicgain";
|
||||
thisDetector->currentSettings=DYNAMICGAIN;
|
||||
break;
|
||||
case GAIN1:
|
||||
ssettings="/gain1";
|
||||
thisDetector->currentSettings=GAIN1;
|
||||
break;
|
||||
case GAIN2:
|
||||
ssettings="/gain2";
|
||||
thisDetector->currentSettings=GAIN2;
|
||||
break;
|
||||
case GAIN3:
|
||||
ssettings="/gain3";
|
||||
thisDetector->currentSettings=GAIN3;
|
||||
break;
|
||||
default:
|
||||
std::cout<< "Unknown settings!" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
if (imod<0) {
|
||||
modmi=0;
|
||||
// modma=thisDetector->nModMax[X]*thisDetector->nModMax[Y];
|
||||
@ -2396,31 +2446,46 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
||||
ostringstream ostfn, oscfn;
|
||||
myMod->module=im;
|
||||
//create file names
|
||||
ostfn << thisDetector->trimDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||
oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||
//
|
||||
trimfname=ostfn.str();
|
||||
#ifdef VERBOSE
|
||||
cout << trimfname << endl;
|
||||
#endif
|
||||
if (readTrimFile(trimfname,myMod)) {
|
||||
switch(thisDetector->myDetectorType){
|
||||
case GOTTHARD:
|
||||
ostfn << thisDetector->settingsDir << ssettings <<"/settings.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||
oscfn << thisDetector->calDir << ssettings << "/calibration.sn";// << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||
std::cout<< thisDetector->settingsDir<<endl<< thisDetector->calDir <<endl;
|
||||
break;
|
||||
default:
|
||||
ostfn << thisDetector->settingsDir << ssettings <<"/noise.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||
oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||
}
|
||||
//oscfn << thisDetector->calDir << ssettings << "/calibration.sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im) << setbase(10);
|
||||
|
||||
settingsfname=ostfn.str();
|
||||
//#ifdef VERBOSE
|
||||
cout << "the settings name is "<<settingsfname << endl;
|
||||
//#endif
|
||||
if (readSettingsFile(settingsfname,myMod)) {
|
||||
calfname=oscfn.str();
|
||||
#ifdef VERBOSE
|
||||
cout << calfname << endl;
|
||||
cout << calfname << endl;
|
||||
#endif
|
||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||
setModule(*myMod);
|
||||
} else {
|
||||
ostringstream ostfn,oscfn;
|
||||
ostfn << thisDetector->trimDir << ssettings << ssettings << ".trim";
|
||||
switch(thisDetector->myDetectorType){
|
||||
case GOTTHARD:
|
||||
ostfn << thisDetector->settingsDir << ssettings << ssettings << ".settings";
|
||||
break;
|
||||
default:
|
||||
ostfn << thisDetector->settingsDir << ssettings << ssettings << ".trim";
|
||||
}
|
||||
oscfn << thisDetector->calDir << ssettings << ssettings << ".cal";
|
||||
calfname=oscfn.str();
|
||||
trimfname=ostfn.str();
|
||||
settingsfname=ostfn.str();
|
||||
#ifdef VERBOSE
|
||||
cout << trimfname << endl;
|
||||
cout << calfname << endl;
|
||||
cout << settingsfname << endl;
|
||||
cout << calfname << endl;
|
||||
#endif
|
||||
if (readTrimFile(trimfname,myMod)) {
|
||||
if (readSettingsFile(settingsfname,myMod)) {
|
||||
calfname=oscfn.str();
|
||||
readCalibrationFile(calfname,myMod->gain, myMod->offset);
|
||||
setModule(*myMod);
|
||||
@ -2429,18 +2494,23 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
|
||||
}
|
||||
}
|
||||
deleteModule(myMod);
|
||||
/*
|
||||
if (thisDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||
int isett=getSettings(imod);
|
||||
float t[]=defaultTDead;
|
||||
if (isett>-1 && isett<3) {
|
||||
thisDetector->tDead=t[isett];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
return getSettings(imod);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Acquisition functions
|
||||
/* change these funcs accepting also ok/fail */
|
||||
|
||||
@ -3698,8 +3768,7 @@ int slsDetector::exitServer(){
|
||||
|
||||
int retval;
|
||||
int fnum=F_EXIT_SERVER;
|
||||
|
||||
|
||||
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (controlSocket) {
|
||||
controlSocket->Connect();
|
||||
@ -3708,12 +3777,13 @@ int slsDetector::exitServer(){
|
||||
controlSocket->Disconnect();
|
||||
}
|
||||
}
|
||||
if (retval==OK) {
|
||||
if (retval!=OK) {
|
||||
std::cout<< std::endl;
|
||||
std::cout<< "Shutting down the server" << std::endl;
|
||||
std::cout<< std::endl;
|
||||
}
|
||||
return retval;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user