mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
Merge branch 'developer' of git.psi.ch:sls_detectors_software/sls_detector_software into developer
This commit is contained in:
commit
f937b8ca5d
@ -69,14 +69,14 @@ gotthardVirtualServer: $(SRC_MYTHEN_SVC)
|
||||
|
||||
|
||||
%.o : %.cpp %.h Makefile
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread -lrt $(LIBZMQ) #$(FLAGS)
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -pthread -lrt $(LIBZMQ) #$(FLAGS)
|
||||
|
||||
|
||||
package: $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a
|
||||
|
||||
|
||||
$(DESTDIR)/libSlsDetector.so: $(OBJS)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -lpthread -lrt $(LIBZMQ)
|
||||
$(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -pthread -lrt $(LIBZMQ)
|
||||
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
|
||||
mv libSlsDetector.so $(DESTDIR)
|
||||
|
||||
|
@ -6181,151 +6181,173 @@ int slsDetector::setUDPConnection(){
|
||||
|
||||
|
||||
int slsDetector::configureMAC(){
|
||||
int i;
|
||||
int ret=FAIL;
|
||||
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
char arg[6][50]={"","","","","",""};
|
||||
char cword[50]="", *pcword;
|
||||
string sword;
|
||||
int retval=-1;
|
||||
int i;
|
||||
int ret=FAIL;
|
||||
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
char arg[6][50]={"","","","","",""};
|
||||
int retval=-1;
|
||||
|
||||
|
||||
//if udpip wasnt initialized in config file
|
||||
if(!(strcmp(thisDetector->receiverUDPIP,"none"))){
|
||||
//hostname is an ip address
|
||||
if(strchr(thisDetector->receiver_hostname,'.')!=NULL)
|
||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||
//if hostname not ip, convert it to ip
|
||||
else{
|
||||
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
||||
if (he != NULL)
|
||||
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
||||
else{
|
||||
std::cout << "configure mac failed. no rx_udpip given and invalid receiver hostname" << endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
strcpy(arg[0],thisDetector->receiverUDPIP);
|
||||
strcpy(arg[1],thisDetector->receiverUDPMAC);
|
||||
sprintf(arg[2],"%x",thisDetector->receiverUDPPort);
|
||||
strcpy(arg[3],thisDetector->detectorMAC);
|
||||
strcpy(arg[4],thisDetector->detectorIP);
|
||||
sprintf(arg[5],"%x",thisDetector->receiverUDPPort2);
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Configuring MAC"<< std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
for(i=0;i<2;i++){
|
||||
if(!strcmp(arg[i],"none")){
|
||||
std::cout<< "Configure MAC Error. IP/MAC Addresses not set"<< std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "IP/MAC Addresses valid "<< std::endl;
|
||||
#endif
|
||||
|
||||
//converting IPaddress to hex.
|
||||
pcword = strtok (arg[0],".");
|
||||
while (pcword != NULL) {
|
||||
sprintf(arg[0],"%02x",atoi(pcword));
|
||||
strcat(cword,arg[0]);
|
||||
pcword = strtok (NULL, ".");
|
||||
}
|
||||
strcpy(arg[0],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp ip:"<<arg[0]<<"."<<std::endl;
|
||||
#endif
|
||||
//converting MACaddress to hex.
|
||||
sword.assign(arg[1]);
|
||||
strcpy(arg[1],"");
|
||||
stringstream sstr(sword);
|
||||
while(getline(sstr,sword,':'))
|
||||
strcat(arg[1],sword.c_str());
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver mac:"<<arg[1]<<"."<<std::endl;
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp port:"<<arg[2]<<"."<<std::endl;
|
||||
#endif
|
||||
//converting server MACaddress to hex.
|
||||
sword.assign(arg[3]);
|
||||
strcpy(arg[3],"");
|
||||
stringstream ssstr(sword);
|
||||
while(getline(ssstr,sword,':'))
|
||||
strcat(arg[3],sword.c_str());
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"detecotor mac:"<<arg[3]<<"."<<std::endl;
|
||||
#endif
|
||||
//converting IPaddress to hex.
|
||||
strcpy(cword,"");
|
||||
pcword = strtok (arg[4],".");
|
||||
while (pcword != NULL) {
|
||||
sprintf(arg[4],"%02x",atoi(pcword));
|
||||
strcat(cword,arg[4]);
|
||||
pcword = strtok (NULL, ".");
|
||||
}
|
||||
strcpy(arg[4],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"detector ip:"<<arg[4]<<"."<<std::endl;
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp port2:"<<arg[5]<<"."<<std::endl;
|
||||
#endif
|
||||
|
||||
//send to server
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(arg,sizeof(arg));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL){
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
else
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
if (ret==FAIL) {
|
||||
ret=FAIL;
|
||||
std::cout<< "Configuring MAC failed " << std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
else if (thisDetector->myDetectorType==GOTTHARD){
|
||||
//set frames per file - only for gotthard
|
||||
pthread_mutex_lock(&ms);
|
||||
if(retval==-1)
|
||||
setFramesPerFile(MAX_FRAMES_PER_FILE);
|
||||
else
|
||||
setFramesPerFile(SHORT_MAX_FRAMES_PER_FILE);
|
||||
pthread_mutex_unlock(&ms);
|
||||
//connect to receiver
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending adc val to receiver " << retval << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum2,retval,retval);
|
||||
disconnectData();
|
||||
//if udpip wasnt initialized in config file
|
||||
if(!(strcmp(thisDetector->receiverUDPIP,"none"))){
|
||||
//hostname is an ip address
|
||||
if(strchr(thisDetector->receiver_hostname,'.')!=NULL)
|
||||
strcpy(thisDetector->receiverUDPIP,thisDetector->receiver_hostname);
|
||||
//if hostname not ip, convert it to ip
|
||||
else{
|
||||
struct hostent *he = gethostbyname(thisDetector->receiver_hostname);
|
||||
if (he != NULL)
|
||||
strcpy(thisDetector->receiverUDPIP,inet_ntoa(*(struct in_addr*)he->h_addr));
|
||||
else{
|
||||
std::cout << "configure mac failed. no rx_udpip given and invalid receiver hostname" << endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
}
|
||||
strcpy(arg[0],thisDetector->receiverUDPIP);
|
||||
strcpy(arg[1],thisDetector->receiverUDPMAC);
|
||||
sprintf(arg[2],"%x",thisDetector->receiverUDPPort);
|
||||
strcpy(arg[3],thisDetector->detectorMAC);
|
||||
strcpy(arg[4],thisDetector->detectorIP);
|
||||
sprintf(arg[5],"%x",thisDetector->receiverUDPPort2);
|
||||
|
||||
return ret;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Configuring MAC"<< std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
for(i=0;i<2;i++){
|
||||
if(!strcmp(arg[i],"none")){
|
||||
std::cout<< "Configure MAC Error. IP/MAC Addresses not set"<< std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "IP/MAC Addresses valid "<< std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
{
|
||||
//converting IPaddress to hex
|
||||
stringstream ss(arg[0]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, '.')) {
|
||||
sprintf(cword,"%s%02x",cword,atoi(s.c_str()));
|
||||
}
|
||||
bzero(arg[0], 50);
|
||||
strcpy(arg[0],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp ip:"<<arg[0]<<"."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
//converting MACaddress to hex
|
||||
stringstream ss(arg[1]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, ':')) {
|
||||
sprintf(cword,"%s%s",cword,s.c_str());
|
||||
}
|
||||
bzero(arg[1], 50);
|
||||
strcpy(arg[1],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver mac:"<<arg[1]<<"."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp port:"<<arg[2]<<"."<<std::endl;
|
||||
#endif
|
||||
|
||||
{
|
||||
stringstream ss(arg[3]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, ':')) {
|
||||
sprintf(cword,"%s%s",cword,s.c_str());
|
||||
}
|
||||
bzero(arg[3], 50);
|
||||
strcpy(arg[3],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"detecotor mac:"<<arg[3]<<"."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
//converting IPaddress to hex
|
||||
stringstream ss(arg[4]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, '.')) {
|
||||
sprintf(cword,"%s%02x",cword,atoi(s.c_str()));
|
||||
}
|
||||
bzero(arg[4], 50);
|
||||
strcpy(arg[4],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"detector ip:"<<arg[4]<<"."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp port2:"<<arg[5]<<"."<<std::endl;
|
||||
#endif
|
||||
|
||||
//send to server
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
controlSocket->SendDataOnly(arg,sizeof(arg));
|
||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
if (ret==FAIL){
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
else
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
updateDetector();
|
||||
}
|
||||
}
|
||||
if (ret==FAIL) {
|
||||
ret=FAIL;
|
||||
std::cout<< "Configuring MAC failed " << std::endl;
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
else if (thisDetector->myDetectorType==GOTTHARD){
|
||||
//set frames per file - only for gotthard
|
||||
pthread_mutex_lock(&ms);
|
||||
if(retval==-1)
|
||||
setFramesPerFile(MAX_FRAMES_PER_FILE);
|
||||
else
|
||||
setFramesPerFile(SHORT_MAX_FRAMES_PER_FILE);
|
||||
pthread_mutex_unlock(&ms);
|
||||
//connect to receiver
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Sending adc val to receiver " << retval << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum2,retval,retval);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@ INCLUDES?= -I../commonFiles -I../slsDetector -I ../MySocketTCP -I../usersFuncti
|
||||
LIBDIR?=../
|
||||
LIBS?= -L$(LIBDIR) -lSlsDetector
|
||||
|
||||
LDFLAG= -L/usr/lib64/ -lpthread
|
||||
LDFLAG= -L/usr/lib64/ -pthread
|
||||
|
||||
|
||||
DESTDIR ?= bin
|
||||
|
@ -2,7 +2,7 @@ CFLAGS= -DC_ONLY
|
||||
FLAGS=-DVERBOSE
|
||||
INCLUDES= -I../slsDetectorSoftware/commonFiles -I../slsDetectorSoftware/slsDetector -I ../slsDetectorSoftware/MySocketTCP -I../slsDetectorSoftware/usersFunctions -I../slsDetectorSoftware/multiSlsDetector -I../slsDetectorSoftware/slsDetectorAnalysis
|
||||
LIBS= -L../slsDetectorSoftware/
|
||||
LDFLAG= -lSlsDetector -lpthread
|
||||
LDFLAG= -lSlsDetector -pthread
|
||||
|
||||
EPICSFLAGS=-DEPICS -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
|
||||
|
||||
|
@ -2,20 +2,20 @@ OBJPATH=bin/obj
|
||||
EXAMPLEPATH=bin/example
|
||||
|
||||
all:
|
||||
g++ CondVar.cpp -lpthread -c -g -o $(OBJPATH)/CondVar.o
|
||||
g++ Mutex.cpp -lpthread -c -g -o $(OBJPATH)/Mutex.o
|
||||
#g++ Task.cpp -lpthread -c -g -o $(OBJPATH)/Task.o
|
||||
g++ ThreadPool.cpp -lpthread -c -g -o $(OBJPATH)/ThreadPool.o
|
||||
g++ Multi.cpp -lpthread -c -g -o $(OBJPATH)/Multi.o
|
||||
#g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/Task.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -lpthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -lpthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ CondVar.cpp -pthread -c -g -o $(OBJPATH)/CondVar.o
|
||||
g++ Mutex.cpp -pthread -c -g -o $(OBJPATH)/Mutex.o
|
||||
#g++ Task.cpp -pthread -c -g -o $(OBJPATH)/Task.o
|
||||
g++ ThreadPool.cpp -pthread -c -g -o $(OBJPATH)/ThreadPool.o
|
||||
g++ Multi.cpp -pthread -c -g -o $(OBJPATH)/Multi.o
|
||||
#g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/Task.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
g++ $(OBJPATH)/CondVar.o $(OBJPATH)/Mutex.o $(OBJPATH)/ThreadPool.o threadpool_test.cpp Single.cpp Multi.cpp -pthread -I . -g -o $(EXAMPLEPATH)threadpool_test
|
||||
|
||||
#all:
|
||||
# g++ threadpool.cpp -lpthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -L./bin bin/obj/threadpool.o -lpthread threadpool_test.cpp -o bin/example/threadpool_test
|
||||
# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -L./bin bin/obj/threadpool.o -pthread threadpool_test.cpp -o bin/example/threadpool_test
|
||||
|
||||
#threadpool:
|
||||
# g++ threadpool.cpp -lpthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ threadpool.cpp -pthread -fpic -c -o bin/obj/threadpool.o
|
||||
# g++ -shared -fPIC bin/obj/threadpool.o -o bin/lib/libthreadpool.so
|
||||
#example:
|
||||
# g++ -L./bin/lib -lthreadpool threadpool_test.cpp -o threadpool_test
|
||||
|
Loading…
x
Reference in New Issue
Block a user