From 7c07ae5a5afee101e9ce9d9be34631bfea12ff71 Mon Sep 17 00:00:00 2001 From: x04sa Date: Fri, 9 Mar 2012 14:40:10 +0000 Subject: [PATCH] after some debugging at the beamline git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@137 951219d9-93cf-4727-9268-0efd64621fa3 --- slsDetectorSoftware/Makefile | 15 ++------ slsDetectorSoftware/Makefile.x04sa | 35 +++++++++++-------- .../multiSlsDetector/multiSlsDetector.cpp | 29 +++++---------- .../multiSlsDetector/multiSlsDetector.h | 14 ++++---- .../slsDetector/slsDetectorCommand.cpp | 25 +++++++++---- .../slsDetector/slsDetectorUtils.cpp | 16 ++++++--- .../usersFunctions/usersFunctions.c | 4 +-- .../usersFunctions/usersFunctions.cpp | 13 ++++--- 8 files changed, 75 insertions(+), 76 deletions(-) diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 67e561087..190e405ad 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -32,29 +32,18 @@ picassoServer: $(SRC_MYTHEN_SVC) -.cpp.o: - echo "short syntax" - $(CXX) -c -Wall $< -o $@ $(INCLUDES) $(FLAGS) $(EPICSFLAGS) +%.o : %.cpp %.h + $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(FLAGS) $(EPICSFLAGS) package: $(OBJS) echo $(OBJS) - - -# $(CXX) -fPIC -g -o objs/slsDetectorCommand.o -c -Wall slsDetector/slsDetectorCommand.cpp $(INCLUDES) $(FLAGS) -# $(CXX) -fPIC -g -o objs/slsDetectorUtils.o -c -Wall slsDetector/slsDetectorUtils.cpp $(INCLUDES) $(FLAGS) -# $(CXX) -fPIC -g -o objs/slsDetector.o -c -Wall slsDetector/slsDetector.cpp $(INCLUDES) $(FLAGS) -# $(CXX) -fPIC -g -o objs/multiSlsDetector.o -c -Wall multiSlsDetector/multiSlsDetector.cpp $(INCLUDES) $(FLAGS) -# $(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) -shared -Wl,-soname,libSlsDetector.so.1 -o libSlsDetector.so.1.0.1 objs/slsDetector.o objs/slsDetectorUtils.o objs/slsDetectorCommand.o objs/multiSlsDetector.o objs/usersFunctions.o objs/MySocketTCP.o -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS) ln -sf libSlsDetector.so libSlsDetector.so.1 ln -sf libSlsDetector.so libSlsDetector.so.1.0.1 ar rcs libSlsDetector.a $(OBJS) -#objs/slsDetector.o objs/usersFunctions.o objs/MySocketTCP.o objs/multiSlsDetector.o objs/slsDetectorUtils.o objs/slsDetectorCommand.o - clean: rm -rf libSlsDetector.so.1 libSlsDetector.so.1.0.1 libSlsDetector.so core docs/* $(OBJS) #objs/* diff --git a/slsDetectorSoftware/Makefile.x04sa b/slsDetectorSoftware/Makefile.x04sa index ca590f35d..0cbd50e6d 100644 --- a/slsDetectorSoftware/Makefile.x04sa +++ b/slsDetectorSoftware/Makefile.x04sa @@ -1,14 +1,18 @@ -CFLAGS= -DC_ONLY -FLAGS=-DVERBOSE +#CFLAGS= -DC_ONLY +#FLAGS=-DVERBOSE INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand 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.cpp usersFunctions/usersFunctions.c multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp +SRC_CLNT= slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp usersFunctions/usersFunctions.cpp MySocketTCP/MySocketTCP.cpp + + +OBJS = $(SRC_CLNT:.cpp=.o) + 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 -all: package mythenServer doc picassoServer +all: package doc doc: $(SRC_H) $(SRC_CLNT) doxygen doxy.config @@ -25,18 +29,19 @@ picassoServer: $(SRC_MYTHEN_SVC) mv a.out picassoServer +%.o : %.cpp %.h + $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(FLAGS) $(EPICSFLAGS) + +package: $(OBJS) + $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS) +# $(CXX) -shared -Wl,-soname,libSlsDetector.so.1 -o libSlsDetector.so.1.0.1 objs/slsDetector.o $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS) +# ln -sf libSlsDetector.so libSlsDetector.so.1 +# ln -sf libSlsDetector.so libSlsDetector.so.1.0.1 + ar rcs libSlsDetector.a $(OBJS) + + + -package: $(SRC_CLNT) - $(CXX) -fPIC -g -o objs/slsDetectorCommand.o -c -Wall slsDetector/slsDetectorCommand.cpp $(INCLUDES) $(FLAGS) - $(CXX) -fPIC -g -o objs/slsDetectorUtils.o -c -Wall slsDetector/slsDetectorUtils.cpp $(INCLUDES) $(FLAGS) - $(CXX) -fPIC -g -o objs/slsDetector.o -c -Wall slsDetector/slsDetector.cpp $(INCLUDES) $(FLAGS) - $(CXX) -fPIC -g -o objs/multiSlsDetector.o -c -Wall multiSlsDetector/multiSlsDetector.cpp $(INCLUDES) $(FLAGS) - $(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) -shared -Wl,-soname,libSlsDetector.so.1 -o libSlsDetector.so.1.0.1 objs/slsDetector.o objs/slsDetectorUtils.o objs/slsDetectorCommand.o objs/multiSlsDetector.o objs/usersFunctions.o objs/MySocketTCP.o -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS) - ln -sf libSlsDetector.so libSlsDetector.so.1 - ln -sf libSlsDetector.so libSlsDetector.so.1.0.1 - ar rcs libSlsDetector.a objs/slsDetector.o objs/usersFunctions.o objs/MySocketTCP.o objs/multiSlsDetector.o objs/slsDetectorUtils.o objs/slsDetectorCommand.o clean: rm -rf libSlsDetector.so.1 libSlsDetector.so.1.0.1 libSlsDetector.so core objs/* docs/* diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index a152c17e8..6daa0d6ed 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -917,7 +917,7 @@ int multiSlsDetector::stopAcquisition(){ } for (i=0; inumberOfDetectors; i++) { if (detectors[i]) { - ret=detectors[i]->startAcquisition(); + ret=detectors[i]->stopAcquisition(); if (ret!=OK) ret1=FAIL; } @@ -1027,7 +1027,6 @@ int* multiSlsDetector::readFrame(){ memcpy(p,retdet,n); delete [] retdet; p+=n/sizeof(int); - } else { #ifdef VERBOSE cout << "Detector " << id << " does not have data left " << endl; @@ -1037,6 +1036,7 @@ int* multiSlsDetector::readFrame(){ } } } + dataQueue.push(retval); return retval; }; @@ -1115,7 +1115,7 @@ int* multiSlsDetector::startAndReadAll(){ } #ifdef VERBOSE - std::cout<< "recieved "<< i<< " frames" << std::endl; + std::cout<< "MMMM recieved "<< i<< " frames" << std::endl; #endif return dataQueue.front(); // check what we return! @@ -1751,12 +1751,12 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { for (int ich=0; ich=detectors[idet]->getTotalNumberOfChannels()) { + if ((badlist[ich]-choff)>=detectors[idet]->getMaxNumberOfChannels()) { #ifdef VERBOSE cout << "setting " << nbaddet << " badchans to detector " << idet << endl; #endif detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0); - choff+=detectors[idet]->getTotalNumberOfChannels(); + choff+=detectors[idet]->getMaxNumberOfChannels(); nbaddet=0; idet++; if (detectors[idet]==NULL) @@ -1774,7 +1774,7 @@ int multiSlsDetector::setBadChannelCorrection(int nbad, int *badlist, int ff) { cout << "setting " << nbaddet << " badchans to detector " << idet << endl; #endif detectors[idet]->setBadChannelCorrection(nbaddet,badlist,0); - choff+=detectors[idet]->getTotalNumberOfChannels(); + choff+=detectors[idet]->getMaxNumberOfChannels(); nbaddet=0; idet++; } @@ -3040,21 +3040,11 @@ int multiSlsDetector::dumpDetectorSetup(string const fname, int level){ #ifdef VERBOSE std::cout<< "wrote " <setThreadedProcessing(-1); + myDet->setThreadedProcessing(0); myDet->setOnline(ONLINE_FLAG); myDet->readAll(); myDet->processData(1); + myDet->setThreadedProcessing(b); return string("ok"); } } @@ -736,7 +740,7 @@ string slsDetectorCommand::helpData(int narg, char *args[], int action){ string slsDetectorCommand::cmdFrame(int narg, char *args[], int action) { - + int b; #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif @@ -745,9 +749,12 @@ string slsDetectorCommand::cmdFrame(int narg, char *args[], int action) { } else if (action==HELP_ACTION) { return helpFrame(narg,args,HELP_ACTION); } else { + b=myDet->setThreadedProcessing(-1); + myDet->setThreadedProcessing(0); myDet->setOnline(ONLINE_FLAG); myDet->readFrame(); myDet->processData(1); + myDet->setThreadedProcessing(b); return string("ok"); } @@ -1772,16 +1779,22 @@ string slsDetectorCommand::cmdScans(int narg, char *args[], int action) { ; else return string("invalid scan minimum")+string(args[1]); - if (sscanf(args[2],"%f",&fmin)) + if (sscanf(args[2],"%f",&fmax)) ; else - return string("invalid scan minimum")+string(args[2]); - if (sscanf(args[2],"%f",&fstep)) + return string("invalid scan maximum")+string(args[2]); + if (sscanf(args[3],"%f",&fstep)) ; else return string("invalid scan step")+string(args[3]); + + if (fstep==0) return string("scan step cannot be 0!"); + +#ifdef VERBOSE + cout << fmin << " " << fmax << " " << fstep << endl; +#endif ns=(fmax-fmin)/fstep; if (ns<0) @@ -2176,7 +2189,7 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) { } return string(myDet->getSettingsFile()); } else if (cmd=="trim") { - if (action==GET_ACTION) { + if (action==GET_ACTION) return string("cannot get!"); trimMode mode=NOISE_TRIMMING; @@ -2212,7 +2225,7 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) { string sval=string(args[1]); myDet->saveSettingsFile(sval, -1); return string("done"); - } + } return string("unknown settings command ")+cmd; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index 6c154efc4..cbf630680 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -1792,16 +1792,22 @@ void* slsDetectorUtils::processData(int delflag) { } pthread_mutex_unlock(&mp); usleep(1000); - } - pthread_mutex_unlock(&mp); - pthread_mutex_lock(&mp); +#ifdef VERBOSE + // cout << "looping on dataque size" << endl; +#endif + } + //pthread_mutex_unlock(&mp); + //pthread_mutex_lock(&mp); if (jointhread) { pthread_mutex_unlock(&mp); if (dataQueue.size()==0) break; - } else + } else { +#ifdef VERBOSE + // cout << "waiting on jointhread "<< jointhread << " " << (*threadedProcessing) << endl; +#endif pthread_mutex_unlock(&mp); - + } dum=0; } // ???????????????????????? return 0; diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.c b/slsDetectorSoftware/usersFunctions/usersFunctions.c index 87de99c2b..eec6ad739 100644 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.c +++ b/slsDetectorSoftware/usersFunctions/usersFunctions.c @@ -152,7 +152,7 @@ float get_position() { pos=value; } else printf(ca_message(status)); -#endif; +#endif @@ -244,7 +244,7 @@ float get_i0() { printf(ca_message(status)); #else i0++; -#endif; +#endif //"ca_get X04SA-ES2-SC:CH6" return i0; diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp index 87de99c2b..13d6f0de1 100644 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp +++ b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp @@ -152,7 +152,7 @@ float get_position() { pos=value; } else printf(ca_message(status)); -#endif; +#endif @@ -171,12 +171,12 @@ int go_to_position(float p) { int status; if (ch_pos<0) return -1; /* /\* caput and wait until done *\/ */ - if ((status = caput(ch_pos, p)) == ECA_NORMAL) + if ((status = caput(ch_pos, p)) == ECA_NORMAL) { ; #ifdef VERBOSE printf("caput: success\n"); #endif - else + } else printf(ca_message(status)); #else pos=p; @@ -199,13 +199,12 @@ int go_to_position_no_wait(float p) { int status; if (ch_pos<0) return -1; /* /\* caput and wait until done *\/ */ - if ((status = caputq(ch_pos, p)) == ECA_NORMAL) + if ((status = caputq(ch_pos, p)) == ECA_NORMAL) { ; #ifdef VERBOSE printf("caputq: success\n"); #endif - - else + } else printf(ca_message(status)); #else pos=p; @@ -244,7 +243,7 @@ float get_i0() { printf(ca_message(status)); #else i0++; -#endif; +#endif //"ca_get X04SA-ES2-SC:CH6" return i0;