mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 18:31:31 +01:00
all detectors merged into slsDetector
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@83 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
CFLAGS= -DC_ONLY
|
CFLAGS= -DC_ONLY
|
||||||
FLAGS=
|
FLAGS=-DVERBOSE
|
||||||
#-DVERBOSE
|
INCLUDES= -I commonFiles -I slsDetector -I MySocketTCP -I usersFunctions -I multiSlsDetector
|
||||||
INCLUDES= -I commonFiles -I slsDetector -I MySocketTCP -I eigerDetector -ImythenDetector -IgotthardDetector -I usersFunctions -I multiSlsDetector
|
#-I eigerDetector -ImythenDetector -IgotthardDetector
|
||||||
|
|
||||||
#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
#EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom
|
||||||
|
|
||||||
|
|
||||||
SRC_CLNT= slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cxx usersFunctions/usersFunctions.c mythenDetector/mythenDetector.cpp eigerDetector/eigerDetector.cpp gotthardDetector/gotthardDetector.cpp multiSlsDetector/multiSlsDetector.cpp
|
SRC_CLNT= slsDetector/slsDetector.cpp MySocketTCP/MySocketTCP.cxx usersFunctions/usersFunctions.c multiSlsDetector/multiSlsDetector.cpp
|
||||||
|
#mythenDetector/mythenDetector.cpp eigerDetector/eigerDetector.cpp gotthardDetector/gotthardDetector.cpp
|
||||||
SRC_MYTHEN_SVC = mythenDetectorServer/server.c mythenDetectorServer/server_funcs.c mythenDetectorServer/communication_funcs.c mythenDetectorServer/firmware_funcs.c mythenDetectorServer/mcb_funcs.c mythenDetectorServer/trimming_funcs.c
|
SRC_MYTHEN_SVC = mythenDetectorServer/server.c mythenDetectorServer/server_funcs.c mythenDetectorServer/communication_funcs.c mythenDetectorServer/firmware_funcs.c mythenDetectorServer/mcb_funcs.c mythenDetectorServer/trimming_funcs.c
|
||||||
#mythenDetectorServer/sharedmemory.c
|
#mythenDetectorServer/sharedmemory.c
|
||||||
|
|
||||||
@@ -30,18 +29,20 @@ picassoServer: $(SRC_MYTHEN_SVC)
|
|||||||
|
|
||||||
|
|
||||||
package: $(SRC_CLNT)
|
package: $(SRC_CLNT)
|
||||||
# $(CXX) -fPIC -g -o objs/multiSlsDetector.o -c -Wall multiSlsDetector/multiSlsDetector.cpp $(INCLUDES) $(FLAGS)
|
$(CXX) -fPIC -g -o objs/multiSlsDetector.o -c -Wall multiSlsDetector/multiSlsDetector.cpp $(INCLUDES) $(FLAGS)
|
||||||
$(CXX) -fPIC -g -o objs/slsDetector.o -c -Wall slsDetector/slsDetector.cpp $(INCLUDES) $(FLAGS)
|
$(CXX) -fPIC -g -o objs/slsDetector.o -c -Wall slsDetector/slsDetector.cpp $(INCLUDES) $(FLAGS)
|
||||||
# $(CXX) -fPIC -g -o objs/eigerDetector.o -c -Wall eigerDetector/eigerDetector.cpp $(INCLUDES) $(FLAGS)
|
# $(CXX) -fPIC -g -o objs/eigerDetector.o -c -Wall eigerDetector/eigerDetector.cpp $(INCLUDES) $(FLAGS)
|
||||||
$(CXX) -fPIC -g -o objs/mythenDetector.o -c -Wall mythenDetector/mythenDetector.cpp $(INCLUDES) $(FLAGS)
|
# $(CXX) -fPIC -g -o objs/mythenDetector.o -c -Wall mythenDetector/mythenDetector.cpp $(INCLUDES) $(FLAGS)
|
||||||
$(CXX) -fPIC -g -o objs/gotthardDetector.o -c -Wall gotthardDetector/gotthardDetector.cpp $(INCLUDES) $(FLAGS)
|
# $(CXX) -fPIC -g -o objs/gotthardDetector.o -c -Wall gotthardDetector/gotthardDetector.cpp $(INCLUDES) $(FLAGS)
|
||||||
$(CXX) -fPIC -g -o objs/usersFunctions.o -c -Wall usersFunctions/usersFunctions.c $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
$(CXX) -fPIC -g -o objs/usersFunctions.o -c -Wall usersFunctions/usersFunctions.c $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
||||||
$(CXX) -fPIC -g -o objs/MySocketTCP.o -c -Wall MySocketTCP/MySocketTCP.cpp $(INCLUDES) $(FLAGS)
|
$(CXX) -fPIC -g -o objs/MySocketTCP.o -c -Wall MySocketTCP/MySocketTCP.cpp $(INCLUDES) $(FLAGS)
|
||||||
$(CXX) -fPIC -g -o objs/multiSDetector.o -c -Wall multiSlsDetector/multiSlsDetector.cpp $(INCLUDES) $(FLAGS)
|
$(CXX) -fPIC -g -o objs/multiSDetector.o -c -Wall multiSlsDetector/multiSlsDetector.cpp $(INCLUDES) $(FLAGS)
|
||||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so.1 -o libSlsDetector.so.1.0.1 objs/slsDetector.o objs/mythenDetector.o objs/gotthardDetector.o objs/usersFunctions.o objs/MySocketTCP.o objs/multiSDetector.o -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
$(CXX) -shared -Wl,-soname,libSlsDetector.so.1 -o libSlsDetector.so.1.0.1 objs/slsDetector.o objs/usersFunctions.o objs/MySocketTCP.o objs/multiSDetector.o -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS)
|
||||||
ln -sf libSlsDetector.so.1.0.1 libSlsDetector.so
|
#objs/mythenDetector.o objs/gotthardDetector.o
|
||||||
ln -sf libSlsDetector.so.1 libSlsDetector.so
|
ln -sf libSlsDetector.so.1.0.1 libSlsDetector.so
|
||||||
ar rcs libSlsDetector.a objs/slsDetector.o objs/mythenDetector.o objs/gotthardDetector.o objs/usersFunctions.o objs/MySocketTCP.o
|
ln -sf libSlsDetector.so.1 libSlsDetector.so
|
||||||
|
ar rcs libSlsDetector.a objs/slsDetector.o objs/usersFunctions.o objs/MySocketTCP.o objs/multiSlsDetector.o
|
||||||
|
#objs/mythenDetector.o objs/gotthardDetector.o
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf libSlsDetector.so.1.0.1 libSlsDetector.so core objs/* docs/*
|
rm -rf libSlsDetector.so.1.0.1 libSlsDetector.so core objs/* docs/*
|
||||||
|
|||||||
@@ -192,9 +192,6 @@ void closeConnection(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
if(file_des>=0)
|
if(file_des>=0)
|
||||||
close(file_des);
|
close(file_des);
|
||||||
if (lockStatus==0) {
|
|
||||||
strcpy(lastClientIP,thisClientIP);
|
|
||||||
}
|
|
||||||
file_des=-1;
|
file_des=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ ID: $Id$
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ int multiSlsDetector::initSharedMemory(int id=0) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<<"multiSlsDetector: Size of shared memory is "<< sz << std::endl;
|
std::cout<<"multiSlsDetector: Size of shared memory is "<< sz << " - id " << mem_key << std::endl;
|
||||||
#endif
|
#endif
|
||||||
shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory
|
shm_id = shmget(mem_key,sz,IPC_CREAT | 0666); // allocate shared memory
|
||||||
|
|
||||||
@@ -106,6 +108,7 @@ multiSlsDetector::multiSlsDetector(int id) : shmId(-1)
|
|||||||
|
|
||||||
|
|
||||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
|
cout << thisMultiDetector->detectorIds[i] << endl;
|
||||||
detectors[i]=new slsDetector(thisMultiDetector->detectorIds[i]);
|
detectors[i]=new slsDetector(thisMultiDetector->detectorIds[i]);
|
||||||
}
|
}
|
||||||
for (int i=thisMultiDetector->numberOfDetectors; i<MAXDET; i++)
|
for (int i=thisMultiDetector->numberOfDetectors; i<MAXDET; i++)
|
||||||
@@ -126,25 +129,50 @@ multiSlsDetector::~multiSlsDetector() {
|
|||||||
int multiSlsDetector::addSlsDetector(int id, int pos, int ox, int oy) {
|
int multiSlsDetector::addSlsDetector(int id, int pos, int ox, int oy) {
|
||||||
int j=thisMultiDetector->numberOfDetectors;
|
int j=thisMultiDetector->numberOfDetectors;
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Adding detector " << id << " in position " << pos << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pos<0)
|
if (pos<0)
|
||||||
pos=j;
|
pos=j;
|
||||||
|
|
||||||
if (pos>j)
|
if (pos>j)
|
||||||
return thisMultiDetector->numberOfDetectors;
|
pos=thisMultiDetector->numberOfDetectors;
|
||||||
|
|
||||||
|
|
||||||
for (int ip=thisMultiDetector->numberOfDetectors-1; ip>pos; ip--) {
|
if (pos!=thisMultiDetector->numberOfDetectors) {
|
||||||
thisMultiDetector->detectorIds[ip+1]=thisMultiDetector->detectorIds[ip];
|
for (int ip=thisMultiDetector->numberOfDetectors-1; ip>=pos; ip--) {
|
||||||
detectors[ip+1]=detectors[ip];
|
#ifdef VERBOSE
|
||||||
|
cout << "Moving detector " << thisMultiDetector->detectorIds[ip] << " from position " << ip << " to " << ip+1 << endl;
|
||||||
|
#endif
|
||||||
|
thisMultiDetector->detectorIds[ip+1]=thisMultiDetector->detectorIds[ip];
|
||||||
|
detectors[ip+1]=detectors[ip];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Creating new detector " << pos << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
detectorType t=slsDetector::getDetectorType(id);
|
|
||||||
detectors[pos]=new slsDetector(t,id);
|
|
||||||
|
|
||||||
|
// detectorType t=slsDetector::getDetectorType(id);
|
||||||
|
detectors[pos]=new slsDetector(id);
|
||||||
|
thisMultiDetector->detectorIds[pos]=detectors[pos]->getDetectorId();
|
||||||
thisMultiDetector->numberOfDetectors++;
|
thisMultiDetector->numberOfDetectors++;
|
||||||
thisMultiDetector->dataBytes+=detectors[pos]->getDataBytes();
|
|
||||||
thisMultiDetector->numberOfChannels+=detectors[pos]->getNChans()*detectors[pos]->getNChips()*detectors[pos]->getNMods();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
thisMultiDetector->dataBytes+=detectors[pos]->getDataBytes();
|
||||||
|
|
||||||
|
thisMultiDetector->numberOfChannels+=detectors[pos]->getNChans()*detectors[pos]->getNChips()*detectors[pos]->getNMods();
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Detector added " << thisMultiDetector->numberOfDetectors<< endl;
|
||||||
|
|
||||||
|
for (int ip=0; ip<thisMultiDetector->numberOfDetectors; ip++) {
|
||||||
|
cout << "Detector " << thisMultiDetector->detectorIds[ip] << " position " << ip << " " << detectors[ip]->getHostname() << endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return thisMultiDetector->numberOfDetectors;
|
return thisMultiDetector->numberOfDetectors;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -188,6 +216,10 @@ int multiSlsDetector::setDetectorOffset(int pos, int ox, int oy) {
|
|||||||
int multiSlsDetector::removeSlsDetector(int pos) {
|
int multiSlsDetector::removeSlsDetector(int pos) {
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Removing detector in position " << pos << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pos<0 )
|
if (pos<0 )
|
||||||
pos=thisMultiDetector->numberOfDetectors-1;
|
pos=thisMultiDetector->numberOfDetectors-1;
|
||||||
|
|
||||||
@@ -1128,7 +1160,11 @@ int multiSlsDetector::setFlatFieldCorrection(string fname){
|
|||||||
#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>0) {
|
|
||||||
|
if (nch>thisMultiDetector->numberOfChannels)
|
||||||
|
nch=thisMultiDetector->numberOfChannels;
|
||||||
|
|
||||||
|
if (nch>0) {
|
||||||
strcpy(thisMultiDetector->flatFieldFile,fname.c_str());
|
strcpy(thisMultiDetector->flatFieldFile,fname.c_str());
|
||||||
|
|
||||||
|
|
||||||
@@ -1292,7 +1328,7 @@ int multiSlsDetector::setRateCorrection(float t){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Setting rate correction with dead time "<< thisDetector->tDead << std::endl;
|
std::cout<< "Setting rate correction with dead time "<< thisMultiDetector->tDead << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return thisMultiDetector->correctionMask&(1<<RATE_CORRECTION);
|
return thisMultiDetector->correctionMask&(1<<RATE_CORRECTION);
|
||||||
@@ -1303,7 +1339,7 @@ int multiSlsDetector::getRateCorrection(float &t){
|
|||||||
|
|
||||||
if (thisMultiDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
if (thisMultiDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Rate correction is enabled with dead time "<< thisDetector->tDead << std::endl;
|
std::cout<< "Rate correction is enabled with dead time "<< thisMultiDetector->tDead << std::endl;
|
||||||
#endif
|
#endif
|
||||||
//which t should we return if they are all different?
|
//which t should we return if they are all different?
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1319,7 +1355,7 @@ float multiSlsDetector::getRateCorrectionTau(){
|
|||||||
|
|
||||||
if (thisMultiDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
if (thisMultiDetector->correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "Rate correction is enabled with dead time "<< thisDetector->tDead << std::endl;
|
std::cout<< "Rate correction is enabled with dead time "<< thisMultiDetector->tDead << std::endl;
|
||||||
#endif
|
#endif
|
||||||
//which t should we return if they are all different?
|
//which t should we return if they are all different?
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1915,6 +1951,197 @@ float multiSlsDetector::getCurrentProgress() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string multiSlsDetector::executeLine(int narg, char *args[], int action) {
|
||||||
|
|
||||||
|
ostringstream os;
|
||||||
|
|
||||||
|
string var=string(args[0]), sval;
|
||||||
|
int ival, ivar;
|
||||||
|
int id;
|
||||||
|
int myId=-1;
|
||||||
|
|
||||||
|
os << "Executing " ;
|
||||||
|
for (int ia=0; ia<narg; ia++)
|
||||||
|
os << args[ia] << " " ;
|
||||||
|
os << " action " << action << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (action==slsDetector::READOUT_ACTION) {
|
||||||
|
os << "Executing readout" << endl;
|
||||||
|
return string("ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (var.find("add")==0) {
|
||||||
|
if (var.size()<=4)
|
||||||
|
ivar=-1;
|
||||||
|
else {
|
||||||
|
//return string("syntax is add:i where i is the detector position");
|
||||||
|
istringstream vvstr(var.substr(9));
|
||||||
|
vvstr >> ivar;
|
||||||
|
if (vvstr.fail())
|
||||||
|
ivar=-1; //append at the end
|
||||||
|
//return string("syntax is add:i where i is the detector position");
|
||||||
|
}
|
||||||
|
if (action==slsDetector::PUT_ACTION) {
|
||||||
|
// if (ivar>thisMultiDetector->numberOfDetectors || ivar<0) {
|
||||||
|
// ivar=thisMultiDetector->numberOfDetectors;
|
||||||
|
// cout << "Appending detector " << endl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (sscanf(args[1],"%d",&ival)) {
|
||||||
|
// add by detector id
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Add detector by id " << thisMultiDetector->numberOfDetectors << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
|
//check that it is not already in the list, in that case move to new position
|
||||||
|
if (detectors[id]) {
|
||||||
|
if (detectors[id]->getDetectorId()==ival) {
|
||||||
|
cout << "Detector " << id << "exists!" << endl;
|
||||||
|
if (id==ivar)
|
||||||
|
break;
|
||||||
|
if (id==(thisMultiDetector->numberOfDetectors-1) && ivar==-1)
|
||||||
|
break;
|
||||||
|
removeSlsDetector(id);
|
||||||
|
addSlsDetector(ival, ivar);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (id==thisMultiDetector->numberOfDetectors) {
|
||||||
|
if (slsDetector::exists(ivar)==0) {
|
||||||
|
return string("Detector does not exist - You should first create it to determine type etc.");
|
||||||
|
}
|
||||||
|
addSlsDetector(ival, ivar);
|
||||||
|
}
|
||||||
|
// if it does not already exist create it
|
||||||
|
} else {
|
||||||
|
//add by hostname
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Adding " << args[1] << " in position " << ivar << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
|
//check that it is not already in the list, in that case move to new position
|
||||||
|
if (detectors[id]) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Detector " << id << " is " << detectors[id]->getHostname() << endl;
|
||||||
|
#endif
|
||||||
|
if (detectors[id]->getHostname()==string(args[1])) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Detector " << id << " exists!" << endl;
|
||||||
|
#endif
|
||||||
|
if (id==ivar)
|
||||||
|
break;
|
||||||
|
if (id==(thisMultiDetector->numberOfDetectors-1) && ivar==-1)
|
||||||
|
break;
|
||||||
|
myId=detectors[id]->getDetectorId();
|
||||||
|
removeSlsDetector(id);
|
||||||
|
addSlsDetector(myId, ivar);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (id==thisMultiDetector->numberOfDetectors) {
|
||||||
|
detectorType t=slsDetector::getDetectorType(args[1], DEFAULT_PORTNO);
|
||||||
|
if (t==GENERIC)
|
||||||
|
return string("could not connect to detector to determine type");
|
||||||
|
#ifdef VERBOSE
|
||||||
|
else
|
||||||
|
cout << "Detector type is " << t << endl;
|
||||||
|
#endif
|
||||||
|
myId=10;
|
||||||
|
slsDetector *s=NULL;
|
||||||
|
while (slsDetector::exists(myId)>0) {
|
||||||
|
cout << myId << endl;
|
||||||
|
s=new slsDetector(myId);
|
||||||
|
if (s->getHostname()==string(args[1]))
|
||||||
|
break;
|
||||||
|
delete s;
|
||||||
|
s=NULL;
|
||||||
|
myId++;
|
||||||
|
}
|
||||||
|
// if it does not already exist create it
|
||||||
|
if (s==NULL) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Creating new detector with id " << myId << endl;
|
||||||
|
#endif
|
||||||
|
s=new slsDetector(t, myId);
|
||||||
|
s->setTCPSocket(args[1]);
|
||||||
|
delete s;
|
||||||
|
}
|
||||||
|
addSlsDetector(myId, ivar);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if (var.find("hostname")==0) {
|
||||||
|
|
||||||
|
if (var.size()<=9)
|
||||||
|
return string("syntax is hostname:i where i is the detector id");
|
||||||
|
istringstream vvstr(var.substr(9));
|
||||||
|
vvstr >> ival;
|
||||||
|
if (vvstr.fail())
|
||||||
|
return string("syntax is hostname:i where i is the detector id");
|
||||||
|
if (action==slsDetector::PUT_ACTION) {
|
||||||
|
sval=string(args[1]);
|
||||||
|
os << "setting hostname of detector " << ival << " to " << sval << endl;
|
||||||
|
//cout << slsDetector::getDetectorType(args[1], DEFAULT_PORTNO) << endl;
|
||||||
|
|
||||||
|
//controlla che non esista gia'
|
||||||
|
// se esiste modifica l'hostname, altrimenti aggiungilo in coda
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
os << "getting hostname of detector " << ival << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string multiSlsDetector::helpLine(int action) {
|
||||||
|
ostringstream os;
|
||||||
|
|
||||||
|
os << "This is the help line of action " << action << endl;
|
||||||
|
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -431,7 +431,6 @@ class multiSlsDetector {
|
|||||||
int writeDataFile(string fname, int *data);
|
int writeDataFile(string fname, int *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
reads a data file
|
reads a data file
|
||||||
\param name of the file to be read
|
\param name of the file to be read
|
||||||
\param data array of data values to be filled
|
\param data array of data values to be filled
|
||||||
@@ -444,7 +443,7 @@ class multiSlsDetector {
|
|||||||
|
|
||||||
\sa mythenDetector::readDataFile
|
\sa mythenDetector::readDataFile
|
||||||
*/
|
*/
|
||||||
int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0);
|
int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0) {return slsDetector::readDataFile(nch, fname, data, err, ang, dataformat);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@@ -454,7 +453,7 @@ class multiSlsDetector {
|
|||||||
\returns OK or FAIL if it could not read the file or data=NULL
|
\returns OK or FAIL if it could not read the file or data=NULL
|
||||||
\sa mythenDetector::readDataFile
|
\sa mythenDetector::readDataFile
|
||||||
*/
|
*/
|
||||||
int readDataFile(string fname, int *data);
|
int readDataFile(string fname, int *data){slsDetector::readDataFile(fname,data,thisMultiDetector->numberOfChannels);};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -463,7 +462,7 @@ class multiSlsDetector {
|
|||||||
\param fname file to be read
|
\param fname file to be read
|
||||||
\sa angleConversionConstant mythenDetector::readAngularConversion
|
\sa angleConversionConstant mythenDetector::readAngularConversion
|
||||||
*/
|
*/
|
||||||
virtual int readAngularConversion(string fname="", int id=-1);
|
/////////////////////////////// virtual int readAngularConversion(string fname="", int id=-1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -473,7 +472,7 @@ class multiSlsDetector {
|
|||||||
\param fname file to be written
|
\param fname file to be written
|
||||||
\sa angleConversionConstant mythenDetector::writeAngularConversion
|
\sa angleConversionConstant mythenDetector::writeAngularConversion
|
||||||
*/
|
*/
|
||||||
virtual int writeAngularConversion(string fname="", int id=-1);
|
/////////////////////////////////////////virtual int writeAngularConversion(string fname="", int id=-1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -807,7 +806,7 @@ s
|
|||||||
\returns 0 if angular conversion disabled, >0 otherwise
|
\returns 0 if angular conversion disabled, >0 otherwise
|
||||||
\sa mythenDetector::setAngularConversion
|
\sa mythenDetector::setAngularConversion
|
||||||
*/
|
*/
|
||||||
virtual int setAngularConversion(string fname="")=0;
|
/////////////////////////////////////////////////// virtual int setAngularConversion(string fname="");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
@@ -817,41 +816,41 @@ s
|
|||||||
\returns 0 if angular conversion disabled, >0 otherwise
|
\returns 0 if angular conversion disabled, >0 otherwise
|
||||||
\sa mythenDetector::getAngularConversion
|
\sa mythenDetector::getAngularConversion
|
||||||
*/
|
*/
|
||||||
virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL)=0;
|
/////////////////////////////////////////////////// virtual int getAngularConversion(int &direction, angleConversionConstant *angconv=NULL);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
returns the angular conversion file
|
returns the angular conversion file
|
||||||
\sa mythenDetector::getAngularConversion */
|
\sa mythenDetector::getAngularConversion */
|
||||||
virtual string getAngularConversion()=0;
|
/////////////////////////////////////////////////// virtual string getAngularConversion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
set detector global offset
|
set detector global offset
|
||||||
\sa mythenDetector::setGlobalOffset
|
\sa mythenDetector::setGlobalOffset
|
||||||
*/
|
*/
|
||||||
virtual float setGlobalOffset(float f)=0;
|
/////////////////////////////////////////////////// virtual float setGlobalOffset(float f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
set detector fine offset
|
set detector fine offset
|
||||||
\sa mythenDetector::setFineOffset
|
\sa mythenDetector::setFineOffset
|
||||||
*/
|
*/
|
||||||
virtual float setFineOffset(float f)=0;
|
/////////////////////////////////////////////////// virtual float setFineOffset(float f);
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
get detector fine offset
|
get detector fine offset
|
||||||
\sa mythenDetector::getFineOffset
|
\sa mythenDetector::getFineOffset
|
||||||
*/
|
*/
|
||||||
virtual float getFineOffset()=0;
|
/////////////////////////////////////////////////// virtual float getFineOffset();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
get detector global offset
|
get detector global offset
|
||||||
\sa mythenDetector::getGlobalOffset
|
\sa mythenDetector::getGlobalOffset
|
||||||
*/
|
*/
|
||||||
virtual float getGlobalOffset()=0;
|
/////////////////////////////////////////////////// virtual float getGlobalOffset();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
@@ -861,7 +860,7 @@ s
|
|||||||
\returns number of positions
|
\returns number of positions
|
||||||
\sa mythenDetector::setPositions
|
\sa mythenDetector::setPositions
|
||||||
*/
|
*/
|
||||||
virtual int setPositions(int nPos, float *pos)=0;
|
/////////////////////////////////////////////////// virtual int setPositions(int nPos, float *pos);
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
get positions for the acquisition
|
get positions for the acquisition
|
||||||
@@ -869,7 +868,7 @@ s
|
|||||||
\returns number of positions
|
\returns number of positions
|
||||||
\sa mythenDetector::getPositions
|
\sa mythenDetector::getPositions
|
||||||
*/
|
*/
|
||||||
virtual int getPositions(float *pos=NULL)=0;
|
/////////////////////////////////////////////////// virtual int getPositions(float *pos=NULL);
|
||||||
|
|
||||||
|
|
||||||
/** pure virtual function
|
/** pure virtual function
|
||||||
@@ -878,13 +877,13 @@ s
|
|||||||
\returns current bin size
|
\returns current bin size
|
||||||
\sa mythenDetector::setBinSize
|
\sa mythenDetector::setBinSize
|
||||||
*/
|
*/
|
||||||
virtual float setBinSize(float bs)=0;
|
/////////////////////////////////////////////////// virtual float setBinSize(float bs);
|
||||||
|
|
||||||
/** pure virtual function
|
/** pure virtual function
|
||||||
return detector bin size used for merging (approx angular resolution)
|
return detector bin size used for merging (approx angular resolution)
|
||||||
\sa mythenDetector::getBinSize
|
\sa mythenDetector::getBinSize
|
||||||
*/
|
*/
|
||||||
virtual float getBinSize()=0;
|
/////////////////////////////////////////////////// virtual float getBinSize();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1058,7 +1057,7 @@ s
|
|||||||
\returns OK or FAIL
|
\returns OK or FAIL
|
||||||
\sa mythenDetector::resetMerging
|
\sa mythenDetector::resetMerging
|
||||||
*/
|
*/
|
||||||
virtual int resetMerging(float *mp, float *mv,float *me, int *mm)=0;
|
/////////////////////////////////////////////////// virtual int resetMerging(float *mp, float *mv,float *me, int *mm);
|
||||||
/**
|
/**
|
||||||
pure virtual function
|
pure virtual function
|
||||||
merge dataset
|
merge dataset
|
||||||
@@ -1071,7 +1070,7 @@ s
|
|||||||
\param mm multiplicity of merged arrays
|
\param mm multiplicity of merged arrays
|
||||||
\sa mythenDetector::addToMerging
|
\sa mythenDetector::addToMerging
|
||||||
*/
|
*/
|
||||||
virtual int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm)=0;
|
/////////////////////////////////////////////////// virtual int addToMerging(float *p1, float *v1, float *e1, float *mp, float *mv,float *me, int *mm);
|
||||||
|
|
||||||
/** pure virtual function
|
/** pure virtual function
|
||||||
calculates the "final" positions, data value and errors for the emrged data
|
calculates the "final" positions, data value and errors for the emrged data
|
||||||
@@ -1089,15 +1088,15 @@ s
|
|||||||
*/
|
*/
|
||||||
int exitServer();
|
int exitServer();
|
||||||
|
|
||||||
/** pure virtual function
|
/** pure /////////////////////////////////////////////////// virtual function
|
||||||
function for processing data
|
function for processing data
|
||||||
/param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue
|
/param delflag if 1 the data are processed, written to file and then deleted. If 0 they are added to the finalDataQueue
|
||||||
\sa mythenDetector::processData
|
\sa mythenDetector::processData
|
||||||
*/
|
*/
|
||||||
virtual void* processData(int delflag=1)=0; // thread function
|
/////////////////////////////////////////////////// virtual void* processData(int delflag=1); // thread function
|
||||||
|
|
||||||
|
|
||||||
virtual void acquire(int delflag=1)=0;
|
/////////////////////////////////////////////////// virtual void acquire(int delflag=1);
|
||||||
|
|
||||||
/** calcualtes the total number of steps of the acquisition.
|
/** calcualtes the total number of steps of the acquisition.
|
||||||
called when number of frames, number of cycles, number of positions and scan steps change
|
called when number of frames, number of cycles, number of positions and scan steps change
|
||||||
@@ -1108,6 +1107,28 @@ s
|
|||||||
float getCurrentProgress();
|
float getCurrentProgress();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string executeLine(int narg, char *args[], int action=slsDetector::GET_ACTION);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static string helpLine(int action=slsDetector::GET_ACTION);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ INSTMODE= 0777
|
|||||||
SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||||
OBJS= $(SRCS:%.c=%.o)
|
OBJS= $(SRCS:%.c=%.o)
|
||||||
|
|
||||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE
|
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS
|
||||||
|
#-DVERBOSE
|
||||||
#-DVERYVERBOSE
|
#-DVERYVERBOSE
|
||||||
#-Werror
|
#-Werror
|
||||||
|
|
||||||
|
|||||||
@@ -434,11 +434,11 @@ int getNModBoard() {
|
|||||||
u_int32_t val;
|
u_int32_t val;
|
||||||
val=bus_r(FPGA_VERSION_REG)&0xff000000;
|
val=bus_r(FPGA_VERSION_REG)&0xff000000;
|
||||||
|
|
||||||
printf("version register %08x\n",val);
|
// printf("version register %08x\n",val);
|
||||||
nmodboard=val >> 24;
|
nmodboard=val >> 24;
|
||||||
//#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("The board hosts %d modules\n",nmodboard);
|
printf("The board hosts %d modules\n",nmodboard);
|
||||||
//#endif
|
#endif
|
||||||
nModBoard=nmodboard;
|
nModBoard=nmodboard;
|
||||||
//getNModBoard()=nmodboard;
|
//getNModBoard()=nmodboard;
|
||||||
return nmodboard;
|
return nmodboard;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#undef DEBUGOUT
|
#undef DEBUGOUT
|
||||||
|
|
||||||
extern int nModX;
|
extern int nModX;
|
||||||
|
extern int nModBoard;
|
||||||
extern int dataBytes;
|
extern int dataBytes;
|
||||||
extern int dynamicRange;
|
extern int dynamicRange;
|
||||||
const int nChans=NCHAN;
|
const int nChans=NCHAN;
|
||||||
@@ -1024,11 +1025,13 @@ int getChannelbyNumber(sls_detector_channel* myChan) {
|
|||||||
|
|
||||||
int getTrimbit(int imod, int ichip, int ichan) {
|
int getTrimbit(int imod, int ichip, int ichan) {
|
||||||
if (detectorChans) {
|
if (detectorChans) {
|
||||||
if (imod<getNModBoard() && imod>=0)
|
if (imod<nModBoard && imod>=0)
|
||||||
if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip)
|
if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip)
|
||||||
return (detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR);
|
return (detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR);
|
||||||
} else
|
} //else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod){
|
int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod){
|
||||||
|
|||||||
@@ -2484,11 +2484,16 @@ int execute_trimming(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret!=OK) {
|
|
||||||
printf("trimming failed\n");
|
if (ret<0) {
|
||||||
|
sprintf(mess,"can't set execute trimming\n");
|
||||||
|
ret=FAIL;
|
||||||
|
} else if (ret>0) {
|
||||||
|
sprintf(mess,"Could not trim %d channels\n", ret);
|
||||||
|
ret=FAIL;
|
||||||
} else if (differentClients)
|
} else if (differentClients)
|
||||||
ret=FORCE_UPDATE;
|
ret=FORCE_UPDATE;
|
||||||
|
|
||||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
if (ret==FAIL) {
|
if (ret==FAIL) {
|
||||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
@@ -2638,6 +2643,10 @@ int send_update(int file_des) {
|
|||||||
retval=setTrains(tns);
|
retval=setTrains(tns);
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
|
|
||||||
|
if (lockStatus==0) {
|
||||||
|
strcpy(lastClientIP,thisClientIP);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,17 +62,20 @@ int trim_with_noise(int countlim, int nsigma, int im)
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("trimming with noise.....\n");
|
printf("trimming with noise.....\n");
|
||||||
#endif
|
#endif
|
||||||
retval2=trim_with_level(countlim, im);
|
if (retval1==OK)
|
||||||
|
retval2=trim_with_level(countlim, im);
|
||||||
|
else
|
||||||
|
retval2=-1;
|
||||||
|
|
||||||
#ifdef DEBUGOUT
|
#ifdef DEBUGOUT
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
#endif
|
#endif
|
||||||
if (retval1==OK && retval2==OK)
|
//if (retval1==OK && retval2==OK)
|
||||||
retval=OK;
|
// retval=OK;
|
||||||
else
|
//else
|
||||||
retval=FAIL;
|
// retval=FAIL;
|
||||||
|
|
||||||
return retval;
|
return retval2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,18 +97,20 @@ int trim_with_beam(int countlim, int nsigma, int im) //rpc
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
retval1=choose_vthresh_and_vtrim(countlim,nsigma,im);
|
retval1=choose_vthresh_and_vtrim(countlim,nsigma,im);
|
||||||
retval2=trim_with_median(TRIM_DR, im);
|
if (retval1==OK)
|
||||||
|
retval2=trim_with_median(TRIM_DR, im);
|
||||||
|
else return -1;
|
||||||
|
|
||||||
#ifdef DEBUGOUT
|
#ifdef DEBUGOUT
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (retval1==OK && retval2==OK)
|
// if (retval1==OK && retval2==OK)
|
||||||
retval=OK;
|
// retval=OK;
|
||||||
else
|
//else
|
||||||
retval=FAIL;
|
// retval=FAIL;
|
||||||
|
|
||||||
return retval;
|
return retval2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,17 +131,19 @@ int trim_improve(int maxit, int par2, int im) //rpc
|
|||||||
|
|
||||||
if (par2!=0 && im==ALLMOD)
|
if (par2!=0 && im==ALLMOD)
|
||||||
retval1=choose_vthresh();
|
retval1=choose_vthresh();
|
||||||
|
if (retval1==OK)
|
||||||
retval2=trim_with_median(2*maxit+1, im);
|
retval2=trim_with_median(2*maxit+1, im);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
#ifdef DEBUGOUT
|
#ifdef DEBUGOUT
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
#endif
|
#endif
|
||||||
if (retval1==OK && retval2==OK)
|
// if (retval1==OK && retval2==OK)
|
||||||
retval=OK;
|
// retval=OK;
|
||||||
else
|
//else
|
||||||
retval=FAIL;
|
//retval=FAIL;
|
||||||
|
|
||||||
return retval;
|
return retval2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +335,7 @@ int trim_with_level(int countlim, int im) {
|
|||||||
u_int32_t *scan;
|
u_int32_t *scan;
|
||||||
int *inttrim;
|
int *inttrim;
|
||||||
int modma, modmi, nm;
|
int modma, modmi, nm;
|
||||||
int retval=OK;
|
int retval=0;
|
||||||
int *fifodata;
|
int *fifodata;
|
||||||
sls_detector_channel myChan;
|
sls_detector_channel myChan;
|
||||||
printf("trimming module number %d", im);
|
printf("trimming module number %d", im);
|
||||||
@@ -411,10 +418,13 @@ int trim_with_level(int countlim, int im) {
|
|||||||
for (ichan=0; ichan<nChans; ichan++) {
|
for (ichan=0; ichan<nChans; ichan++) {
|
||||||
nextStrip(imod);
|
nextStrip(imod);
|
||||||
ich=ichan+imod*nChans*nChips+ichip*nChans;
|
ich=ichan+imod*nChans*nChips+ichip*nChans;
|
||||||
if (*(inttrim+ich)==-1) {
|
//if (*(inttrim+ich)==-1) {
|
||||||
*(inttrim+ich)=TRIM_DR;
|
if (*(inttrim+ich)<1) {
|
||||||
|
if (*(inttrim+ich)==-1) {
|
||||||
|
*(inttrim+ich)=TRIM_DR;
|
||||||
|
}
|
||||||
// printf("could not trim channel %d chip %d module %d - set to %d\n", ichan, ichip, imod, *(inttrim+ich) );
|
// printf("could not trim channel %d chip %d module %d - set to %d\n", ichan, ichip, imod, *(inttrim+ich) );
|
||||||
retval=FAIL;
|
retval++;
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
// else
|
// else
|
||||||
@@ -433,35 +443,65 @@ int trim_with_level(int countlim, int im) {
|
|||||||
|
|
||||||
|
|
||||||
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
|
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
|
||||||
#define median(a,n) kth_smallest(a,n,(((n)&1)?((n)/2):(((n)/2)-1)))
|
|
||||||
|
|
||||||
|
|
||||||
int kth_smallest(int *a, int n, int k)
|
int kth_smallest(int *a, int n, int k)
|
||||||
{
|
{
|
||||||
register int i,j,l,m ;
|
register int i,j,l,m ;
|
||||||
register float x ;
|
register float x ;
|
||||||
|
|
||||||
|
l=0 ; m=n-1 ;
|
||||||
|
while (l<m) {
|
||||||
|
x=a[k] ;
|
||||||
|
i=l ;
|
||||||
|
j=m ;
|
||||||
|
do {
|
||||||
|
while (a[i]<x) i++ ;
|
||||||
|
while (x<a[j]) j-- ;
|
||||||
|
if (i<=j) {
|
||||||
|
ELEM_SWAP(a[i],a[j]) ;
|
||||||
|
i++ ; j-- ;
|
||||||
|
}
|
||||||
|
} while (i<=j) ;
|
||||||
|
if (j<k) l=i ;
|
||||||
|
if (k<i) m=j ;
|
||||||
|
}
|
||||||
|
return a[k] ;
|
||||||
|
|
||||||
l=0 ; m=n-1 ;
|
|
||||||
while (l<m) {
|
|
||||||
x=a[k] ;
|
|
||||||
i=l ;
|
|
||||||
j=m ;
|
|
||||||
do {
|
|
||||||
while (a[i]<x) i++ ;
|
|
||||||
while (x<a[j]) j-- ;
|
|
||||||
if (i<=j) {
|
|
||||||
ELEM_SWAP(a[i],a[j]) ;
|
|
||||||
i++ ; j-- ;
|
|
||||||
}
|
|
||||||
} while (i<=j) ;
|
|
||||||
if (j<k) l=i ;
|
|
||||||
if (k<i) m=j ;
|
|
||||||
}
|
|
||||||
return a[k] ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int median(int *a,int n) {
|
||||||
|
|
||||||
|
int i=0, k=n/2;
|
||||||
|
float k1=0.5*n;
|
||||||
|
|
||||||
|
//discard zeroes and 0xffffff
|
||||||
|
for (i=0; i<n; i++) {
|
||||||
|
if (a[i]==0)
|
||||||
|
k1+=0.5;
|
||||||
|
else if (a[i]==0xffffff)
|
||||||
|
k1-=0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
kth_smallest(a, n, k1);
|
||||||
|
|
||||||
|
|
||||||
|
/* for (k=0; k<n; k++) { */
|
||||||
|
/* printf("%d ",a[k]); */
|
||||||
|
/* } */
|
||||||
|
/* printf("\n"); */
|
||||||
|
|
||||||
|
k=k1;
|
||||||
|
|
||||||
|
return a[k] ;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int ave(int *a, int n)
|
int ave(int *a, int n)
|
||||||
{
|
{
|
||||||
int av=0,i;
|
int av=0,i;
|
||||||
@@ -610,7 +650,7 @@ int choose_vthresh() {
|
|||||||
int trim_with_median(int stop, int im) {
|
int trim_with_median(int stop, int im) {
|
||||||
|
|
||||||
|
|
||||||
int retval=OK;
|
int retval=0;
|
||||||
|
|
||||||
#ifdef MCB_FUNCS
|
#ifdef MCB_FUNCS
|
||||||
int ichan, imod, ichip, ich;
|
int ichan, imod, ichip, ich;
|
||||||
@@ -726,12 +766,12 @@ int trim_with_median(int stop, int im) {
|
|||||||
if (trim>TRIM_DR) {
|
if (trim>TRIM_DR) {
|
||||||
trim=63;
|
trim=63;
|
||||||
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
|
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
|
||||||
retval=FAIL;
|
retval++;
|
||||||
}
|
}
|
||||||
if (trim<0) {
|
if (trim<0) {
|
||||||
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
|
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
|
||||||
trim=0;
|
trim=0;
|
||||||
retval=FAIL;
|
retval++;
|
||||||
}
|
}
|
||||||
initChannel(trim,0,0,1,0,0,imod);
|
initChannel(trim,0,0,1,0,0,imod);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ int trim_with_level(int countlim, int imod);
|
|||||||
int trim_with_median(int stop, int imod);
|
int trim_with_median(int stop, int imod);
|
||||||
int calcthr_from_vcal(int vcal);
|
int calcthr_from_vcal(int vcal);
|
||||||
int calccal_from_vthr(int vthr);
|
int calccal_from_vthr(int vthr);
|
||||||
|
int median(int *a,int n);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -334,7 +334,7 @@ typedef struct sharedSlsDetector {
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
slsDetector(int id){slsDetector(getDetectorType(id),id);};
|
slsDetector(int id);
|
||||||
|
|
||||||
|
|
||||||
slsDetector(char *name, int id=0, int cport=DEFAULT_PORTNO);
|
slsDetector(char *name, int id=0, int cport=DEFAULT_PORTNO);
|
||||||
@@ -351,6 +351,14 @@ typedef struct sharedSlsDetector {
|
|||||||
\returns 1 if the detector structure has already be initlialized, 0 otherwise */
|
\returns 1 if the detector structure has already be initlialized, 0 otherwise */
|
||||||
int exists() {return thisDetector->alreadyExisting;};
|
int exists() {return thisDetector->alreadyExisting;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
checks if detector id exists
|
||||||
|
\param i detector id
|
||||||
|
\returns 1 if the detector already exists, 0 otherwise
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
static int exists(int i);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Purely virtual function
|
Purely virtual function
|
||||||
@@ -358,13 +366,13 @@ typedef struct sharedSlsDetector {
|
|||||||
/sa mythenDetector::readConfigurationFile
|
/sa mythenDetector::readConfigurationFile
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual int readConfigurationFile(string const fname){};
|
virtual int readConfigurationFile(string const fname);
|
||||||
/**
|
/**
|
||||||
Purely virtual function
|
Purely virtual function
|
||||||
Should be implemented in the specific detector class
|
Should be implemented in the specific detector class
|
||||||
/sa mythenDetector::writeConfigurationFile
|
/sa mythenDetector::writeConfigurationFile
|
||||||
*/
|
*/
|
||||||
virtual int writeConfigurationFile(string const fname){};
|
virtual int writeConfigurationFile(string const fname);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -377,13 +385,13 @@ typedef struct sharedSlsDetector {
|
|||||||
Should be implemented in the specific detector class
|
Should be implemented in the specific detector class
|
||||||
/sa mythenDetector::dumpDetectorSetup
|
/sa mythenDetector::dumpDetectorSetup
|
||||||
*/
|
*/
|
||||||
virtual int dumpDetectorSetup(string const fname, int level=0){};
|
virtual int dumpDetectorSetup(string const fname, int level=0);
|
||||||
/**
|
/**
|
||||||
Purely virtual function
|
Purely virtual function
|
||||||
Should be implemented in the specific detector class
|
Should be implemented in the specific detector class
|
||||||
/sa mythenDetector::retrieveDetectorSetup
|
/sa mythenDetector::retrieveDetectorSetup
|
||||||
*/
|
*/
|
||||||
virtual int retrieveDetectorSetup(string const fname, int level=0){};
|
virtual int retrieveDetectorSetup(string const fname, int level=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
configure the socket communication and initializes the socket instances
|
configure the socket communication and initializes the socket instances
|
||||||
@@ -418,7 +426,7 @@ typedef struct sharedSlsDetector {
|
|||||||
string getLastClientIP();
|
string getLastClientIP();
|
||||||
|
|
||||||
/** returns the detector hostname \sa sharedSlsDetector */
|
/** returns the detector hostname \sa sharedSlsDetector */
|
||||||
char* getHostname() {return thisDetector->hostname;};
|
string getHostname() {return string(thisDetector->hostname);};
|
||||||
/** returns the detector control port \sa sharedSlsDetector */
|
/** returns the detector control port \sa sharedSlsDetector */
|
||||||
int getControlPort() {return thisDetector->controlPort;};
|
int getControlPort() {return thisDetector->controlPort;};
|
||||||
/** returns the detector stop port \sa sharedSlsDetector */
|
/** returns the detector stop port \sa sharedSlsDetector */
|
||||||
@@ -486,7 +494,7 @@ typedef struct sharedSlsDetector {
|
|||||||
\sa mythenDetector::readSettingsFile
|
\sa mythenDetector::readSettingsFile
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual 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
|
Pure virtual function
|
||||||
@@ -497,7 +505,7 @@ typedef struct sharedSlsDetector {
|
|||||||
|
|
||||||
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
|
\sa ::sls_detector_module mythenDetector::writeSettingsFile(string, sls_detector_module)
|
||||||
*/
|
*/
|
||||||
virtual int writeSettingsFile(string fname, sls_detector_module mod){};
|
virtual int writeSettingsFile(string fname, sls_detector_module mod);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Pure virtual function
|
Pure virtual function
|
||||||
@@ -507,7 +515,7 @@ typedef struct sharedSlsDetector {
|
|||||||
\returns OK or FAIL if the file could not be written
|
\returns OK or FAIL if the file could not be written
|
||||||
\sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
\sa ::sls_detector_module sharedSlsDetector mythenDetector::writeSettingsFile(string, int)
|
||||||
*/
|
*/
|
||||||
virtual int writeSettingsFile(string fname, int imod){};
|
virtual int writeSettingsFile(string fname, int imod);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -624,7 +632,7 @@ typedef struct sharedSlsDetector {
|
|||||||
\sa mythenDetector::writeDataFile
|
\sa mythenDetector::writeDataFile
|
||||||
|
|
||||||
*/
|
*/
|
||||||
virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1){};
|
virtual int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@@ -634,7 +642,7 @@ typedef struct sharedSlsDetector {
|
|||||||
\returns OK or FAIL if it could not write the file or data=NULL
|
\returns OK or FAIL if it could not write the file or data=NULL
|
||||||
\sa mythenDetector::writeDataFile
|
\sa mythenDetector::writeDataFile
|
||||||
*/
|
*/
|
||||||
virtual int writeDataFile(string fname, int *data){};
|
virtual int writeDataFile(string fname, int *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@@ -650,7 +658,7 @@ typedef struct sharedSlsDetector {
|
|||||||
|
|
||||||
\sa mythenDetector::readDataFile
|
\sa mythenDetector::readDataFile
|
||||||
*/
|
*/
|
||||||
virtual int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0){};
|
int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@@ -660,7 +668,32 @@ typedef struct sharedSlsDetector {
|
|||||||
\returns OK or FAIL if it could not read the file or data=NULL
|
\returns OK or FAIL if it could not read the file or data=NULL
|
||||||
\sa mythenDetector::readDataFile
|
\sa mythenDetector::readDataFile
|
||||||
*/
|
*/
|
||||||
virtual int readDataFile(string fname, int *data){};
|
int readDataFile(string fname, int *data);
|
||||||
|
/**
|
||||||
|
|
||||||
|
reads a data file
|
||||||
|
\param name of the file to be read
|
||||||
|
\param data array of data values to be filled
|
||||||
|
\param err array of arrors on the data. If NULL no errors are expected on the file
|
||||||
|
|
||||||
|
\param ang array of angular values. If NULL data are expected 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 <=0 defaults to the number of installed channels of the detector
|
||||||
|
\returns number of channels read or -1 if it could not read the file or data=NULL
|
||||||
|
|
||||||
|
\sa mythenDetector::readDataFile
|
||||||
|
*/
|
||||||
|
static int readDataFile(int nch, string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f');
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
reads a data file
|
||||||
|
\param name of the file to be read
|
||||||
|
\param data array of data values
|
||||||
|
\returns OK or FAIL if it could not read the file or data=NULL
|
||||||
|
\sa mythenDetector::readDataFile
|
||||||
|
*/
|
||||||
|
static int readDataFile(string fname, int *data, int nch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
returns the location of the calibration files
|
returns the location of the calibration files
|
||||||
@@ -682,7 +715,7 @@ typedef struct sharedSlsDetector {
|
|||||||
\offset reference to the offset variable
|
\offset reference to the offset variable
|
||||||
\sa sharedSlsDetector mythenDetector::readCalibrationFile
|
\sa sharedSlsDetector mythenDetector::readCalibrationFile
|
||||||
*/
|
*/
|
||||||
virtual int readCalibrationFile(string fname, float &gain, float &offset){};
|
virtual int readCalibrationFile(string fname, float &gain, float &offset);
|
||||||
/**
|
/**
|
||||||
|
|
||||||
writes a calibration file
|
writes a calibration file
|
||||||
@@ -691,7 +724,7 @@ typedef struct sharedSlsDetector {
|
|||||||
\param offset
|
\param offset
|
||||||
\sa sharedSlsDetector mythenDetector::writeCalibrationFile
|
\sa sharedSlsDetector mythenDetector::writeCalibrationFile
|
||||||
*/
|
*/
|
||||||
virtual int writeCalibrationFile(string fname, float gain, float offset){};
|
virtual int writeCalibrationFile(string fname, float gain, float offset);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1712,7 +1745,7 @@ enum {GET_ACTION, PUT_ACTION, READOUT_ACTION};
|
|||||||
\return pointer to the data (or NULL if failed)
|
\return pointer to the data (or NULL if failed)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int getDetectorId() { return detId;};
|
int getDetectorId() {return detId;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Receives a data frame from the detector socket
|
Receives a data frame from the detector socket
|
||||||
|
|||||||
Reference in New Issue
Block a user