removed unused variable in slsDetector

This commit is contained in:
Erik Frojdh
2018-03-16 10:41:30 +01:00
parent 40210ae26f
commit 50111bcea7

View File

@ -57,7 +57,7 @@ int multiSlsDetector::freeSharedMemory() {
int multiSlsDetector::initSharedMemory(int id=0) { int multiSlsDetector::initSharedMemory(int id=0) {
key_t mem_key=DEFAULT_SHM_KEY+MAXDET+id; key_t mem_key=DEFAULT_SHM_KEY+MAXDET+id;
int shm_id; int shm_id;
int sz; int sz;
@ -76,20 +76,20 @@ int multiSlsDetector::initSharedMemory(int id=0) {
std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl;
return shm_id; return shm_id;
} }
/** /**
thisMultiDetector pointer is set to the memory address of the shared memory thisMultiDetector pointer is set to the memory address of the shared memory
*/ */
thisMultiDetector = (sharedMultiSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ thisMultiDetector = (sharedMultiSlsDetector*) shmat(shm_id, NULL, 0); /* attach */
if (thisMultiDetector == (void*)-1) { if (thisMultiDetector == (void*)-1) {
std::cout<<"*** shmat error (server) ***" << std::endl; std::cout<<"*** shmat error (server) ***" << std::endl;
return shm_id; return shm_id;
} }
/** /**
shm_id returns -1 is shared memory initialization fails shm_id returns -1 is shared memory initialization fails
*/ */
return shm_id; return shm_id;
@ -191,7 +191,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
/** set binsize*/ /** set binsize*/
thisMultiDetector->binSize=0.001; thisMultiDetector->binSize=0.001;
thisMultiDetector->stoppedFlag=0; thisMultiDetector->stoppedFlag=0;
thisMultiDetector->threadedProcessing=1; thisMultiDetector->threadedProcessing=1;
thisMultiDetector->actionMask=0; thisMultiDetector->actionMask=0;
@ -205,7 +205,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
for (int iscan=0; iscan<MAX_SCAN_LEVELS; ++iscan) { for (int iscan=0; iscan<MAX_SCAN_LEVELS; ++iscan) {
thisMultiDetector->scanMode[iscan]=0; thisMultiDetector->scanMode[iscan]=0;
strcpy(thisMultiDetector->scanScript[iscan],"none"); strcpy(thisMultiDetector->scanScript[iscan],"none");
strcpy(thisMultiDetector->scanParameter[iscan],"none"); strcpy(thisMultiDetector->scanParameter[iscan],"none");
@ -223,8 +223,8 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
stoppedFlag=&thisMultiDetector->stoppedFlag; stoppedFlag=&thisMultiDetector->stoppedFlag;
threadedProcessing=&thisMultiDetector->threadedProcessing; threadedProcessing=&thisMultiDetector->threadedProcessing;
actionMask=&thisMultiDetector->actionMask; actionMask=&thisMultiDetector->actionMask;
actionScript=thisMultiDetector->actionScript; actionScript=thisMultiDetector->actionScript;
actionParameter=thisMultiDetector->actionParameter; actionParameter=thisMultiDetector->actionParameter;
nScanSteps=thisMultiDetector->nScanSteps; nScanSteps=thisMultiDetector->nScanSteps;
scanMode=thisMultiDetector->scanMode; scanMode=thisMultiDetector->scanMode;
scanScript=thisMultiDetector->scanScript; scanScript=thisMultiDetector->scanScript;
@ -343,7 +343,7 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
if (slsDetector::exists(id)==0) { if (slsDetector::exists(id)==0) {
cout << "Detector " << id << " does not exist - You should first create it to determine type etc." << endl; cout << "Detector " << id << " does not exist - You should first create it to determine type etc." << endl;
} }
#ifdef VERBOSE #ifdef VERBOSE
cout << "Adding detector " << id << " in position " << pos << endl; cout << "Adding detector " << id << " in position " << pos << endl;
#endif #endif
@ -353,21 +353,21 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
if (pos>j) if (pos>j)
pos=thisMultiDetector->numberOfDetectors; pos=thisMultiDetector->numberOfDetectors;
//check that it is not already in the list //check that it is not already in the list
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) { for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
//check that it is not already in the list, in that case move to new position //check that it is not already in the list, in that case move to new position
if (detectors[i]) { if (detectors[i]) {
if (detectors[i]->getDetectorId()==id) { if (detectors[i]->getDetectorId()==id) {
cout << "Detector " << id << "already part of the multiDetector in position " << i << "!" << endl << "Remove it before adding it back in a new position!"<< endl; cout << "Detector " << id << "already part of the multiDetector in position " << i << "!" << endl << "Remove it before adding it back in a new position!"<< endl;
return -1; return -1;
} }
} }
} }
if (pos!=thisMultiDetector->numberOfDetectors) { if (pos!=thisMultiDetector->numberOfDetectors) {
@ -386,10 +386,10 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
detectors[pos]=new slsDetector(pos, id, this); detectors[pos]=new slsDetector(pos, id, this);
thisMultiDetector->detectorIds[pos]=detectors[pos]->getDetectorId(); thisMultiDetector->detectorIds[pos]=detectors[pos]->getDetectorId();
++thisMultiDetector->numberOfDetectors; ++thisMultiDetector->numberOfDetectors;
thisMultiDetector->dataBytes+=detectors[pos]->getDataBytes(); thisMultiDetector->dataBytes+=detectors[pos]->getDataBytes();
thisMultiDetector->dataBytesInclGapPixels+=detectors[pos]->getDataBytesInclGapPixels(); thisMultiDetector->dataBytesInclGapPixels+=detectors[pos]->getDataBytesInclGapPixels();
thisMultiDetector->numberOfChannels+=detectors[pos]->getTotalNumberOfChannels(); thisMultiDetector->numberOfChannels+=detectors[pos]->getTotalNumberOfChannels();
thisMultiDetector->maxNumberOfChannels+=detectors[pos]->getMaxNumberOfChannels(); thisMultiDetector->maxNumberOfChannels+=detectors[pos]->getMaxNumberOfChannels();
@ -646,7 +646,7 @@ string multiSlsDetector::getHostname(int pos) {
} }
} }
return s; return s;
} }
@ -667,7 +667,7 @@ slsDetectorDefs::detectorType multiSlsDetector::getDetectorsType(int pos) {
string multiSlsDetector::sgetDetectorsType(int pos) { string multiSlsDetector::sgetDetectorsType(int pos) {
string s=string(""); string s=string("");
#ifdef VERBOSE #ifdef VERBOSE
cout << "returning type" << pos << endl; cout << "returning type" << pos << endl;
@ -690,14 +690,14 @@ string multiSlsDetector::sgetDetectorsType(int pos) {
} }
} }
return s; return s;
} }
int multiSlsDetector::getDetectorId(int pos) { int multiSlsDetector::getDetectorId(int pos) {
#ifdef VERBOSE #ifdef VERBOSE
cout << "Getting detector ID " << pos << endl; cout << "Getting detector ID " << pos << endl;
#endif #endif
@ -705,7 +705,7 @@ int multiSlsDetector::getDetectorId(int pos) {
if (pos>=0) { if (pos>=0) {
if (detectors[pos]) if (detectors[pos])
return detectors[pos]->getDetectorId(); return detectors[pos]->getDetectorId();
} }
return -1; return -1;
} }
@ -721,12 +721,12 @@ int multiSlsDetector::setDetectorId(int ival, int pos){
return -1; return -1;
} }
return -1; return -1;
} }
int multiSlsDetector::addSlsDetector(const char *name, int pos) { int multiSlsDetector::addSlsDetector(const char *name, int pos) {
detectorType t=getDetectorType(string(name)); detectorType t=getDetectorType(string(name));
int online=0; int online=0;
slsDetector *s=NULL; slsDetector *s=NULL;
@ -741,13 +741,13 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) {
if (detectors[i]) { if (detectors[i]) {
if (detectors[i]->getHostname()==string(name)) { if (detectors[i]->getHostname()==string(name)) {
cout << "Detector " << name << "already part of the multiDetector in position " << i << "!" << endl<< "Remove it before adding it back in a new position!"<< endl; cout << "Detector " << name << "already part of the multiDetector in position " << i << "!" << endl<< "Remove it before adding it back in a new position!"<< endl;
return -1; return -1;
} }
} }
} }
//checking that the detector doesn't already exists //checking that the detector doesn't already exists
for (id=0; id<MAXDET; ++id) { for (id=0; id<MAXDET; ++id) {
if (slsDetector::exists(id)>0) { if (slsDetector::exists(id)>0) {
#ifdef VERBOSE #ifdef VERBOSE
@ -776,7 +776,7 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) {
#endif #endif
online=1; online=1;
} }
} }
#ifdef VERBOSE #ifdef VERBOSE
else else
cout << "Adding detector by type " << getDetectorType(t) << endl; cout << "Adding detector by type " << getDetectorType(t) << endl;
@ -790,7 +790,7 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) {
break; break;
} }
} }
#ifdef VERBOSE #ifdef VERBOSE
cout << "Creating detector " << id << " of type " << getDetectorType(t) << endl; cout << "Creating detector " << id << " of type " << getDetectorType(t) << endl;
#endif #endif
@ -823,12 +823,12 @@ int multiSlsDetector::addSlsDetector(detectorType t, int pos) {
break; break;
} }
} }
#ifdef VERBOSE #ifdef VERBOSE
cout << "Creating detector " << id << " of type " << getDetectorType(t) << endl; cout << "Creating detector " << id << " of type " << getDetectorType(t) << endl;
#endif #endif
slsDetector *s=new slsDetector(pos, t, id, this); new slsDetector(pos, t, id, this);
s=NULL;
#ifdef VERBOSE #ifdef VERBOSE
cout << "Adding it to the multi detector structure" << endl; cout << "Adding it to the multi detector structure" << endl;
#endif #endif
@ -855,15 +855,15 @@ int multiSlsDetector::getDetectorOffset(int pos, int &ox, int &oy) {
} }
int multiSlsDetector::setDetectorOffset(int pos, int ox, int oy) { int multiSlsDetector::setDetectorOffset(int pos, int ox, int oy) {
int ret=FAIL; int ret=FAIL;
if (pos>=0 && pos<thisMultiDetector->numberOfDetectors) { if (pos>=0 && pos<thisMultiDetector->numberOfDetectors) {
if (detectors[pos]) { if (detectors[pos]) {
if (ox!=-1) if (ox!=-1)
thisMultiDetector->offsetX[pos]=ox; thisMultiDetector->offsetX[pos]=ox;
if (oy!=-1) if (oy!=-1)
thisMultiDetector->offsetY[pos]=oy; thisMultiDetector->offsetY[pos]=oy;
ret=OK; ret=OK;
} }
@ -875,12 +875,12 @@ int multiSlsDetector::setDetectorOffset(int pos, int ox, int oy) {
int multiSlsDetector::removeSlsDetector(char *name){ int multiSlsDetector::removeSlsDetector(char *name){
for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) { for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) {
if (detectors[id]) { if (detectors[id]) {
if (detectors[id]->getHostname()==string(name)) { if (detectors[id]->getHostname()==string(name)) {
removeSlsDetector(id); removeSlsDetector(id);
} }
} }
} }
return thisMultiDetector->numberOfDetectors; return thisMultiDetector->numberOfDetectors;
}; };
@ -889,7 +889,7 @@ int multiSlsDetector::removeSlsDetector(char *name){
int multiSlsDetector::removeSlsDetector(int pos) { int multiSlsDetector::removeSlsDetector(int pos) {
int j; int j;
#ifdef VERBOSE #ifdef VERBOSE
cout << "Removing detector in position " << pos << endl; cout << "Removing detector in position " << pos << endl;
#endif #endif
@ -910,7 +910,7 @@ int multiSlsDetector::removeSlsDetector(int pos) {
//j=pos; //j=pos;
for (j=mi; j<ma; ++j) { for (j=mi; j<ma; ++j) {
if (detectors[j]) { if (detectors[j]) {
thisMultiDetector->dataBytes-=detectors[j]->getDataBytes(); thisMultiDetector->dataBytes-=detectors[j]->getDataBytes();
@ -947,7 +947,7 @@ int multiSlsDetector::removeSlsDetector(int pos) {
int multiSlsDetector::setMaster(int i) { int multiSlsDetector::setMaster(int i) {
int ret=-1, slave=0; int ret=-1, slave=0;
@ -991,7 +991,7 @@ int multiSlsDetector::setMaster(int i) {
} }
} }
} }
// check return value // check return value
@ -1026,10 +1026,10 @@ int multiSlsDetector::setMaster(int i) {
} }
if (slave>0 && ret<0) if (slave>0 && ret<0)
ret=-2; ret=-2;
if (ret<0) if (ret<0)
ret=-1; ret=-1;
thisMultiDetector->masterPosition=ret; thisMultiDetector->masterPosition=ret;
return thisMultiDetector->masterPosition; return thisMultiDetector->masterPosition;
@ -1042,17 +1042,17 @@ int multiSlsDetector::setMaster(int i) {
// MASTER_TRIGGERS, /**< the master triggers the other detectors */ // MASTER_TRIGGERS, /**< the master triggers the other detectors */
// SLAVE_STARTS_WHEN_MASTER_STOPS /**< the slave acquires when the master finishes, to avoid deadtime */ // SLAVE_STARTS_WHEN_MASTER_STOPS /**< the slave acquires when the master finishes, to avoid deadtime */
// } // }
/** /**
Sets/gets the synchronization mode of the various detectors Sets/gets the synchronization mode of the various detectors
\param sync syncronization mode \param sync syncronization mode
\returns current syncronization mode \returns current syncronization mode
*/ */
slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) { slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) {
synchronizationMode ret=GET_SYNCHRONIZATION_MODE, ret1=GET_SYNCHRONIZATION_MODE; synchronizationMode ret=GET_SYNCHRONIZATION_MODE, ret1=GET_SYNCHRONIZATION_MODE;
for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) { for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) {
if (detectors[id]) { if (detectors[id]) {
ret1=detectors[id]->setSynchronization(sync); ret1=detectors[id]->setSynchronization(sync);
@ -1066,11 +1066,11 @@ slsDetectorDefs::synchronizationMode multiSlsDetector::setSynchronization(synchr
} }
} }
thisMultiDetector->syncMode=ret; thisMultiDetector->syncMode=ret;
return thisMultiDetector->syncMode; return thisMultiDetector->syncMode;
} }
@ -1191,10 +1191,10 @@ int multiSlsDetector::exists() {
int multiSlsDetector::getThresholdEnergy(int pos) { int multiSlsDetector::getThresholdEnergy(int pos) {
int i, posmin, posmax; int i, posmin, posmax;
int ret1=-100, ret; int ret1=-100, ret;
@ -1216,15 +1216,15 @@ int multiSlsDetector::getThresholdEnergy(int pos) {
ret1=ret; ret1=ret;
else if (ret<(ret1-200) || ret>(ret1+200)) else if (ret<(ret1-200) || ret>(ret1+200))
ret1=-1; ret1=-1;
} }
} }
thisMultiDetector->currentThresholdEV=ret1; thisMultiDetector->currentThresholdEV=ret1;
return ret1; return ret1;
} }
int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings, int tb) { int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings isettings, int tb) {
@ -1273,7 +1273,7 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise
thisMultiDetector->currentThresholdEV=ret; thisMultiDetector->currentThresholdEV=ret;
return ret; return ret;
} }
@ -1656,7 +1656,7 @@ int multiSlsDetector::startReadOut(){
} }
return ret1; return ret1;
}; };
@ -1747,7 +1747,7 @@ int* multiSlsDetector::readFrame(){
int n; int n;
int* retval=new int[nel]; int* retval=new int[nel];
int *retdet, *p=retval; int *retdet, *p=retval;
/** probably it's always better to have one integer per channel in any case! */ /** probably it's always better to have one integer per channel in any case! */
for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) { for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) {
@ -1779,7 +1779,7 @@ int* multiSlsDetector::readFrame(){
int* multiSlsDetector::readAll(){ int* multiSlsDetector::readAll(){
/** Thread for each detector?!?!?! */ /** Thread for each detector?!?!?! */
// int fnum=F_READ_ALL; // int fnum=F_READ_ALL;
@ -1791,7 +1791,7 @@ int* multiSlsDetector::readAll(){
std::cout<< "Reading all frames "<< std::endl; std::cout<< "Reading all frames "<< std::endl;
#endif #endif
if (thisMultiDetector->onlineFlag==ONLINE_FLAG) { if (thisMultiDetector->onlineFlag==ONLINE_FLAG) {
for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) { for (int id=0; id<thisMultiDetector->numberOfDetectors; ++id) {
if (detectors[id]) { if (detectors[id]) {
detectors[id]->readAllNoWait(); detectors[id]->readAllNoWait();
@ -1812,14 +1812,14 @@ int* multiSlsDetector::readAll(){
if (detectors[id]) { if (detectors[id]) {
detectors[id]->disconnectControl(); detectors[id]->disconnectControl();
} }
} }
} }
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "received "<< i<< " frames" << std::endl; std::cout<< "received "<< i<< " frames" << std::endl;
//#else //#else
// std::cout << std::endl; // std::cout << std::endl;
#endif #endif
return dataQueueFront(); // check what we return! return dataQueueFront(); // check what we return!
@ -1842,7 +1842,7 @@ int* multiSlsDetector::startAndReadAll(){
return NULL; return NULL;
} }
startAndReadAllNoWait(); startAndReadAllNoWait();
while ((retval=getDataFromDetector())){ while ((retval=getDataFromDetector())){
++i; ++i;
#ifdef VERBOSE #ifdef VERBOSE
@ -1858,17 +1858,17 @@ int* multiSlsDetector::startAndReadAll(){
detectors[id]->disconnectControl(); detectors[id]->disconnectControl();
} }
} }
} }
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "MMMM recieved "<< i<< " frames" << std::endl; std::cout<< "MMMM recieved "<< i<< " frames" << std::endl;
//#else //#else
// std::cout << std::endl; // std::cout << std::endl;
#endif #endif
return dataQueueFront(); // check what we return! return dataQueueFront(); // check what we return!
}; };
@ -1940,7 +1940,7 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() {
} }
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) { for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
s1=detectors[i]->getRunStatus(); s1=detectors[i]->getRunStatus();
if(detectors[i]->getErrorMask()) if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i)); setErrorMask(getErrorMask()|(1<<i));
if (s1==ERROR) { if (s1==ERROR) {
@ -1950,7 +1950,7 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() {
s = s1; s = s1;
// if (s1==IDLE && s!=IDLE) // if (s1==IDLE && s!=IDLE)
// s=ERROR; // s=ERROR;
} }
return s; return s;
} }
@ -1995,8 +1995,8 @@ void multiSlsDetector::resetFinalDataQueue() {
/* /*
set or read the acquisition timers set or read the acquisition timers
enum timerIndex { enum timerIndex {
FRAME_NUMBER, FRAME_NUMBER,
ACQUISITION_TIME, ACQUISITION_TIME,
@ -2052,20 +2052,20 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){
int64_t multiSlsDetector::getTimeLeft(timerIndex index){ int64_t multiSlsDetector::getTimeLeft(timerIndex index){
int i; int i;
int64_t ret1=-100, ret; int64_t ret1=-100, ret;
if (thisMultiDetector->masterPosition>=0) if (thisMultiDetector->masterPosition>=0)
if (detectors[thisMultiDetector->masterPosition]){ if (detectors[thisMultiDetector->masterPosition]){
ret1 = detectors[thisMultiDetector->masterPosition]->getTimeLeft(index); ret1 = detectors[thisMultiDetector->masterPosition]->getTimeLeft(index);
if(detectors[thisMultiDetector->masterPosition]->getErrorMask()) if(detectors[thisMultiDetector->masterPosition]->getErrorMask())
setErrorMask(getErrorMask()|(1<<thisMultiDetector->masterPosition)); setErrorMask(getErrorMask()|(1<<thisMultiDetector->masterPosition));
return ret1; return ret1;
} }
for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) { for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
if (detectors[i]) { if (detectors[i]) {
ret=detectors[i]->getTimeLeft(index); ret=detectors[i]->getTimeLeft(index);
@ -2077,9 +2077,9 @@ int64_t multiSlsDetector::getTimeLeft(timerIndex index){
ret1=-1; ret1=-1;
} }
} }
return ret1; return ret1;
} }
@ -2087,9 +2087,9 @@ int64_t multiSlsDetector::getTimeLeft(timerIndex index){
int multiSlsDetector::setSpeed(speedVariable index, int value){ int multiSlsDetector::setSpeed(speedVariable index, int value){
int i; int i;
int ret1=-100, ret; int ret1=-100, ret;
for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) { for (i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
if (detectors[i]) { if (detectors[i]) {
ret=detectors[i]->setSpeed(index,value); ret=detectors[i]->setSpeed(index,value);
@ -2101,9 +2101,9 @@ int multiSlsDetector::setSpeed(speedVariable index, int value){
ret1=FAIL; ret1=FAIL;
} }
} }
return ret1; return ret1;
} }
@ -2119,9 +2119,9 @@ int multiSlsDetector::setSpeed(speedVariable index, int value){
int multiSlsDetector::getDataBytes(){ int multiSlsDetector::getDataBytes(){
int ret=0; int ret=0;
for (int ip=0; ip<thisMultiDetector->numberOfDetectors; ++ip) { for (int ip=0; ip<thisMultiDetector->numberOfDetectors; ++ip) {
if (detectors[ip]) if (detectors[ip])
ret+=detectors[ip]->getDataBytes(); ret+=detectors[ip]->getDataBytes();
} }
return ret; return ret;
@ -2146,7 +2146,7 @@ int multiSlsDetector::setDynamicRange(int n, int pos){
imi=pos; imi=pos;
ima=pos+1; ima=pos+1;
} }
for (i=imi; i<ima; ++i) { for (i=imi; i<ima; ++i) {
// cout << "multi ************ detector " << i << endl; // cout << "multi ************ detector " << i << endl;
@ -2539,7 +2539,7 @@ double* multiSlsDetector::decodeData(int *datain, int &nn, double *fdata) {
setErrorMask(getErrorMask()|(1<<i)); setErrorMask(getErrorMask()|(1<<i));
#ifdef VERBOSE #ifdef VERBOSE
cout << "increment pointers " << endl; cout << "increment pointers " << endl;
#endif #endif
datap+=detectors[i]->getDataBytes()/sizeof(int); datap+=detectors[i]->getDataBytes()/sizeof(int);
detp+=n; detp+=n;
// if (detectors[0]->getDetectorsType()==JUNGFRAUCTB) { // if (detectors[0]->getDetectorsType()==JUNGFRAUCTB) {
@ -2561,7 +2561,7 @@ double* multiSlsDetector::decodeData(int *datain, int &nn, double *fdata) {
return dataout; return dataout;
} }
//Correction //Correction
/* /*
enum correctionFlags { enum correctionFlags {
@ -2605,13 +2605,13 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
if (fname=="default") { if (fname=="default") {
fname=string(thisMultiDetector->flatFieldFile); fname=string(thisMultiDetector->flatFieldFile);
} }
thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION); thisMultiDetector->correctionMask&=~(1<<FLAT_FIELD_CORRECTION);
if (fname=="") { if (fname=="") {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "disabling flat field correction" << std::endl; std::cout<< "disabling flat field correction" << std::endl;
@ -2625,18 +2625,18 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
setErrorMask(getErrorMask()|(1<<i)); setErrorMask(getErrorMask()|(1<<i));
} }
} }
} else { } else {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "Setting flat field correction from file " << fname << std::endl; std::cout<< "Setting flat field correction from file " << fname << std::endl;
#endif #endif
sprintf(ffffname,"%s/%s",thisMultiDetector->flatFieldDir,fname.c_str()); sprintf(ffffname,"%s/%s",thisMultiDetector->flatFieldDir,fname.c_str());
nch=readDataFile(string(ffffname),data); nch=readDataFile(string(ffffname),data);
if (nch>thisMultiDetector->numberOfChannels) if (nch>thisMultiDetector->numberOfChannels)
nch=thisMultiDetector->numberOfChannels; nch=thisMultiDetector->numberOfChannels;
if (nch>0) { if (nch>0) {
//???? bad ff chans? //???? bad ff chans?
int nm=getNMods(); int nm=getNMods();
int chpm[nm]; int chpm[nm];
@ -2651,18 +2651,18 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
fillBadChannelMask(); fillBadChannelMask();
if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) { if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) {
strcpy(thisMultiDetector->flatFieldFile,fname.c_str()); strcpy(thisMultiDetector->flatFieldFile,fname.c_str());
thisMultiDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION); thisMultiDetector->correctionMask|=(1<<FLAT_FIELD_CORRECTION);
setFlatFieldCorrection(ffcoefficients, fferrors); setFlatFieldCorrection(ffcoefficients, fferrors);
} else } else
std::cout<< "Calculated flat field from file " << fname << " is not valid " << nch << std::endl; std::cout<< "Calculated flat field from file " << fname << " is not valid " << nch << std::endl;
} else { } else {
std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl; std::cout<< "Flat field from file " << fname << " is not valid " << nch << std::endl;
} }
} }
return thisMultiDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION); return thisMultiDetector->correctionMask&(1<<FLAT_FIELD_CORRECTION);
} }
@ -2678,8 +2678,8 @@ int multiSlsDetector::fillModuleMask(int *mM) {
} }
off+=detectors[i]->getMaxMods(); off+=detectors[i]->getMaxMods();
} }
} }
} }
return getNMods(); return getNMods();
@ -3059,14 +3059,14 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
if (fname=="default") if (fname=="default")
fname=string(thisMultiDetector->badChanFile); fname=string(thisMultiDetector->badChanFile);
ret=setBadChannelCorrection(fname, nbad, badlist); ret=setBadChannelCorrection(fname, nbad, badlist);
//#ifdef VERBOSE //#ifdef VERBOSE
cout << "multi: file contained " << ret << " badchans" << endl; cout << "multi: file contained " << ret << " badchans" << endl;
//#endif //#endif
if (ret==0) { if (ret==0) {
thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS); thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
@ -3085,7 +3085,7 @@ int multiSlsDetector::setBadChannelCorrection(string fname){
int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
//#define VERBOSE //#define VERBOSE
int badlistdet[MAX_BADCHANS]; int badlistdet[MAX_BADCHANS];
int nbaddet=0, choff=0, idet=0; int nbaddet=0, choff=0, idet=0;
if (nbad<1) if (nbad<1)
@ -3095,7 +3095,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
if (nbad>0) { if (nbad>0) {
thisMultiDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS); thisMultiDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
for (int ich=0; ich<nbad; ++ich) { for (int ich=0; ich<nbad; ++ich) {
if (detectors[idet]) { if (detectors[idet]) {
if ((badlist[ich]-choff)>=detectors[idet]->getMaxNumberOfChannels()) { if ((badlist[ich]-choff)>=detectors[idet]->getMaxNumberOfChannels()) {
@ -3119,7 +3119,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
} }
} }
if (nbaddet>0) { if (nbaddet>0) {
if (detectors[idet]) { if (detectors[idet]) {
#ifdef VERBOSE #ifdef VERBOSE
cout << "setting " << nbaddet << " badchans to detector " << idet << endl; cout << "setting " << nbaddet << " badchans to detector " << idet << endl;
@ -3143,7 +3143,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
setErrorMask(getErrorMask()|(1<<i)); setErrorMask(getErrorMask()|(1<<i));
} }
} }
} else { } else {
nbaddet=0; nbaddet=0;
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) { for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
@ -3157,8 +3157,8 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
} }
} }
thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS); thisMultiDetector->correctionMask&=~(1<<DISCARD_BAD_CHANNELS);
} }
#ifdef VERBOSE #ifdef VERBOSE
cout << (thisMultiDetector->correctionMask&(1<<DISCARD_BAD_CHANNELS)) << endl; cout << (thisMultiDetector->correctionMask&(1<<DISCARD_BAD_CHANNELS)) << endl;
#endif #endif
return thisMultiDetector->correctionMask&(1<<DISCARD_BAD_CHANNELS); return thisMultiDetector->correctionMask&(1<<DISCARD_BAD_CHANNELS);
@ -3172,7 +3172,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) {
int multiSlsDetector::readAngularConversionFile(string fname) { int multiSlsDetector::readAngularConversionFile(string fname) {
ifstream infile; ifstream infile;
//int nm=0; //int nm=0;
infile.open(fname.c_str(), ios_base::in); infile.open(fname.c_str(), ios_base::in);
@ -3200,7 +3200,7 @@ int multiSlsDetector::readAngularConversionFile(string fname) {
int multiSlsDetector::writeAngularConversion(string fname) { int multiSlsDetector::writeAngularConversion(string fname) {
ofstream outfile; ofstream outfile;
// int nm=0; // int nm=0;
outfile.open(fname.c_str(), ios_base::out); outfile.open(fname.c_str(), ios_base::out);
@ -3242,12 +3242,12 @@ int multiSlsDetector::getAngularConversion(int &direction, angleConversionCons
} }
} }
direction=dir; direction=dir;
if (thisMultiDetector->correctionMask&(1<< ANGULAR_CONVERSION)) { if (thisMultiDetector->correctionMask&(1<< ANGULAR_CONVERSION)) {
return 1; return 1;
} }
return 0; return 0;
} }
@ -3540,7 +3540,7 @@ int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
int ret, ret1=-100; int ret, ret1=-100;
int id=-1, im=-1; int id=-1, im=-1;
int dmi=0, dma=thisMultiDetector->numberOfDetectors; int dmi=0, dma=thisMultiDetector->numberOfDetectors;
if (decodeNMod(imod, id, im)>=0) { if (decodeNMod(imod, id, im)>=0) {
dmi=id; dmi=id;
dma=id+1; dma=id+1;
@ -3557,7 +3557,7 @@ int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
} }
} }
return ret1; return ret1;
} }
@ -3572,9 +3572,9 @@ int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
double multiSlsDetector::setAngularConversionParameter(angleConversionParameter c, double v) { double multiSlsDetector::setAngularConversionParameter(angleConversionParameter c, double v) {
double ret=slsDetectorUtils::setAngularConversionParameter(c,v); double ret=slsDetectorUtils::setAngularConversionParameter(c,v);
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) { if (detectors[idet]) {
detectors[idet]->setAngularConversionParameter(c,v); detectors[idet]->setAngularConversionParameter(c,v);
if(detectors[idet]->getErrorMask()) if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet)); setErrorMask(getErrorMask()|(1<<idet));
@ -3593,7 +3593,7 @@ double multiSlsDetector::setAngularConversionParameter(angleConversionParameter
// int choff=0; // int choff=0;
// for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) { // for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
// if (detectors[idet]) { // if (detectors[idet]) {
// #ifdef EPICS // #ifdef EPICS
// // cout << "convert angle det " << idet << endl; // // cout << "convert angle det " << idet << endl;
@ -3618,7 +3618,7 @@ double multiSlsDetector::setAngularConversionParameter(angleConversionParameter
int multiSlsDetector::getBadChannelCorrection(int *bad) { int multiSlsDetector::getBadChannelCorrection(int *bad) {
//int ichan; //int ichan;
int *bd, nd, ntot=0, choff=0;; int *bd, nd, ntot=0, choff=0;;
if (((thisMultiDetector->correctionMask)&(1<< DISCARD_BAD_CHANNELS))==0) if (((thisMultiDetector->correctionMask)&(1<< DISCARD_BAD_CHANNELS))==0)
return 0; return 0;
//else //else
@ -3644,7 +3644,7 @@ int multiSlsDetector::getBadChannelCorrection(int *bad) {
delete [] bd; delete [] bd;
} else } else
ntot+=nd; ntot+=nd;
} }
} }
return ntot; return ntot;
@ -3669,7 +3669,7 @@ int multiSlsDetector::exitServer() {
/** returns the detector trimbit/settings directory */ /** returns the detector trimbit/settings directory */
char* multiSlsDetector::getSettingsDir() { char* multiSlsDetector::getSettingsDir() {
string s0="", s1="", s; string s0="", s1="", s;
//char ans[1000]; //char ans[1000];
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
@ -3849,7 +3849,7 @@ char* multiSlsDetector::setCalDir(string s){
} }
return getCalDir(); return getCalDir();
} }
/** /**
returns the location of the calibration files returns the location of the calibration files
@ -3947,7 +3947,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){
return getNetworkParameter(p); return getNetworkParameter(p);
} }
int multiSlsDetector::setPort(portType t, int p) { int multiSlsDetector::setPort(portType t, int p) {
@ -3990,7 +3990,7 @@ int multiSlsDetector::lockServer(int p) {
string multiSlsDetector::getLastClientIP() { string multiSlsDetector::getLastClientIP() {
string s0="", s1="",s ; string s0="", s1="",s ;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) { if (detectors[idet]) {
s=detectors[idet]->getLastClientIP(); s=detectors[idet]->getLastClientIP();
@ -4049,7 +4049,7 @@ slsDetectorDefs::externalCommunicationMode multiSlsDetector::setExternalCommunic
if(detectors[0]->getErrorMask()) if(detectors[0]->getErrorMask())
setErrorMask(getErrorMask()|(1<<0)); setErrorMask(getErrorMask()|(1<<0));
for (int idet=1; idet<thisMultiDetector->numberOfDetectors; ++idet) { for (int idet=1; idet<thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) { if (detectors[idet]) {
ret1=detectors[idet]->setExternalCommunicationMode(pol); ret1=detectors[idet]->setExternalCommunicationMode(pol);
@ -4108,7 +4108,7 @@ slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags(ext
string multiSlsDetector::getSettingsFile() { string multiSlsDetector::getSettingsFile() {
string s0="", s1="",s ; string s0="", s1="",s ;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) { if (detectors[idet]) {
s=detectors[idet]->getSettingsFile(); s=detectors[idet]->getSettingsFile();
@ -4327,7 +4327,7 @@ int multiSlsDetector::getMaxMods() {
int ret=0, ret1; int ret=0, ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) { if (detectors[idet]) {
ret1=detectors[idet]->getMaxMods(); ret1=detectors[idet]->getMaxMods();
@ -4390,7 +4390,7 @@ int multiSlsDetector::getMaxMod(dimension d){
int multiSlsDetector::getMaxNumberOfModules(dimension d) { int multiSlsDetector::getMaxNumberOfModules(dimension d) {
int ret=0, ret1; int ret=0, ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) { if (detectors[idet]) {
ret1=detectors[idet]->getMaxNumberOfModules(d); ret1=detectors[idet]->getMaxNumberOfModules(d);
@ -4543,12 +4543,12 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
cout <<" C---------" << id << " position " << im << endl; cout <<" C---------" << id << " position " << im << endl;
#endif #endif
return -1; return -1;
} }
int64_t multiSlsDetector::getId(idMode mode, int imod) { int64_t multiSlsDetector::getId(idMode mode, int imod) {
int id, im; int id, im;
@ -4799,7 +4799,7 @@ int multiSlsDetector::setAllTrimbits(int val, int imod){
return -1; return -1;
} }
} }
// multi // multi
if(!threadpool){ if(!threadpool){
cout << "Error in creating threadpool. Exiting" << endl; cout << "Error in creating threadpool. Exiting" << endl;
@ -5113,14 +5113,14 @@ int multiSlsDetector::readConfigurationFile(string const fname){
while (ssstr.good()) { while (ssstr.good()) {
ssstr >> sargname; ssstr >> sargname;
//if (ssstr.good()) { //if (ssstr.good()) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< iargval << " " << sargname << std::endl; std::cout<< iargval << " " << sargname << std::endl;
#endif #endif
strcpy(myargs[iargval], sargname.c_str()); strcpy(myargs[iargval], sargname.c_str());
args[iargval]=myargs[iargval]; args[iargval]=myargs[iargval];
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "--" << iargval << " " << args[iargval] << std::endl; std::cout<< "--" << iargval << " " << args[iargval] << std::endl;
#endif #endif
@ -5168,7 +5168,7 @@ int multiSlsDetector::readConfigurationFile(string const fname){
return OK; return OK;
}; };
@ -5286,7 +5286,7 @@ int multiSlsDetector::writeDataFile(string fname, double *data, double *err, dou
ofstream outfile; ofstream outfile;
int choff=0, off=0; //idata, int choff=0, off=0; //idata,
double *pe=err, *pa=ang; double *pe=err, *pa=ang;
int nch_left=nch, n;//, nd; int nch_left=nch, n;//, nd;
@ -5300,9 +5300,9 @@ int multiSlsDetector::writeDataFile(string fname, double *data, double *err, dou
outfile.open (fname.c_str(),ios_base::out); outfile.open (fname.c_str(),ios_base::out);
if (outfile.is_open()) if (outfile.is_open())
{ {
for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) { for (int i=0; i<thisMultiDetector->numberOfDetectors; ++i) {
if (detectors[i]) { if (detectors[i]) {
n=detectors[i]->getTotalNumberOfChannels(); n=detectors[i]->getTotalNumberOfChannels();
if (nch_left<n) if (nch_left<n)
@ -5319,17 +5319,17 @@ int multiSlsDetector::writeDataFile(string fname, double *data, double *err, dou
nch_left-=n; nch_left-=n;
choff+=detectors[i]->getMaxNumberOfChannels(); choff+=detectors[i]->getMaxNumberOfChannels();
off+=n; off+=n;
if (pe) if (pe)
pe=err+off; pe=err+off;
if (pa) if (pa)
pa=ang+off; pa=ang+off;
} }
} }
outfile.close(); outfile.close();
return OK; return OK;
@ -5384,7 +5384,7 @@ int multiSlsDetector::readDataFile(string fname, double *data, double *err, doub
#endif #endif
ifstream infile; ifstream infile;
int iline=0;//ichan, int iline=0;//ichan,
//int interrupt=0; //int interrupt=0;
string str; string str;
int choff=0, off=0; int choff=0, off=0;
@ -6416,7 +6416,7 @@ string multiSlsDetector::getReceiverLastClientIP() {
s=detectors[idet]->getReceiverLastClientIP(); s=detectors[idet]->getReceiverLastClientIP();
if(detectors[idet]->getErrorMask()) if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet)); setErrorMask(getErrorMask()|(1<<idet));
if (s0=="") if (s0=="")
s0=s; s0=s;
else else
@ -6734,14 +6734,14 @@ int multiSlsDetector::setReceiverSilentMode(int i){
/** opens pattern file and sends pattern to CTB /** opens pattern file and sends pattern to CTB
@param fname pattern file to open @param fname pattern file to open
@returns OK/FAIL @returns OK/FAIL
*/ */
int multiSlsDetector::setCTBPattern(string fname) { int multiSlsDetector::setCTBPattern(string fname) {
uint64_t word; uint64_t word;
int addr=0; int addr=0;
FILE *fd=fopen(fname.c_str(),"r"); FILE *fd=fopen(fname.c_str(),"r");
@ -6754,11 +6754,11 @@ int multiSlsDetector::setCTBPattern(string fname) {
// cout << hex << addr << " " << word << dec << endl; // cout << hex << addr << " " << word << dec << endl;
++addr; ++addr;
} }
fclose(fd); fclose(fd);
} else } else
return -1; return -1;
@ -6767,7 +6767,7 @@ int multiSlsDetector::setCTBPattern(string fname) {
} }
/** Writes a pattern word to the CTB /** Writes a pattern word to the CTB
@param addr address of the word, -1 is I/O control register, -2 is clk control register @param addr address of the word, -1 is I/O control register, -2 is clk control register
@param word 64bit word to be written, -1 gets @param word 64bit word to be written, -1 gets
@ -6787,7 +6787,7 @@ uint64_t multiSlsDetector::setCTBWord(int addr,uint64_t word) {
} }
return ret; return ret;
} }
@ -6825,7 +6825,7 @@ int multiSlsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) {
*/ */
int multiSlsDetector::setCTBPatWaitAddr(int level, int addr) { int multiSlsDetector::setCTBPatWaitAddr(int level, int addr) {
int ret=-100,ret1; int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet)
@ -6998,4 +6998,3 @@ bool multiSlsDetector::isAcquireReady() {
thisMultiDetector->acquiringFlag = true; thisMultiDetector->acquiringFlag = true;
return OK; return OK;
} }