diff --git a/Makefile b/Makefile index c78f2b53a..773fa5282 100755 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ MANAPIDIR = $(MANDIR)/manual-api TABSPACE := "\t" -INCLUDES=-I. -I$(WD)/commonFiles -I$(LIBRARYDIR)/slsDetector -I$(LIBRARYDIR)/usersFunctions -I$(LIBRARYDIR)/multiSlsDetector -I$(LIBRARYDIR)/slsDetectorUtils -I$(LIBRARYDIR)/slsDetectorCommand -I$(LIBRARYDIR)/slsDetectorAnalysis -I$(LIBRARYDIR)/slsReceiverInterface -I$(LIBRARYRXRDIR)/include -I$(LIBRARYDIR)/threadFiles -I$(LIBRARYDIR)/sharedMemory -I$(ASM) +INCLUDES=-I. -I$(WD)/commonFiles -I$(LIBRARYDIR)/slsDetector -I$(LIBRARYDIR)/usersFunctions -I$(LIBRARYDIR)/multiSlsDetector -I$(LIBRARYDIR)/slsReceiverInterface -I$(LIBRARYRXRDIR)/include -I$(LIBRARYDIR)/threadFiles -I$(LIBRARYDIR)/sharedMemory -I$(ASM) INCLUDESRXR += -I. -I$(LIBRARYRXRDIR)/include -I$(WD)/commonFiles -I$(CALIBDIR) -I$(ASM) #LIBFLAGRXR += diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 5b7ddbafa..9fb82c08b 100644 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -2,10 +2,8 @@ set(SOURCES multiSlsDetector/multiSlsDetector.cpp sharedMemory/SharedMemory.cpp slsDetector/slsDetectorUsers.cpp - slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp - slsDetectorAnalysis/postProcessing.cpp slsReceiverInterface/receiverInterface.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp @@ -21,9 +19,6 @@ include_directories( multiSlsDetector sharedMemory slsDetector -slsDetectorUtils -slsDetectorCommand -slsDetectorAnalysis slsReceiverInterface threadFiles ) @@ -65,12 +60,10 @@ set(PUBLICHEADERS ../commonFiles/sls_receiver_exceptions.h ../commonFiles/utilties.h sharedMemory/SharedMemory.h - slsDetector/slsDetectorUtils.h slsDetector/slsDetector.h slsDetector/slsDetectorBase.h slsDetector/slsDetectorUsers.h - slsDetectorAnalysis/postProcessing.h - slsDetectorAnalysis/detectorData.h + slsDetector/detectorData.h multiSlsDetector/multiSlsDetector.h slsReceiverInterface/receiverInterface.h ) diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index a9525ceb0..b8ac5ffb7 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -9,15 +9,15 @@ CFLAGS= -g -DC_ONLY -fPIC DFLAGS= -g -DDACS_INT -INCLUDES?= -I../commonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -IsharedMemory -I$(ASM) +INCLUDES?= -I../commonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -ImultiSlsDetector -IslsReceiverInterface -I../slsReceiverSoftware/include -IthreadFiles -IsharedMemory -I$(ASM) #EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -Wl,-R/usr/local/epics/base/lib/$(EPICS_HOST_ARCH) -lca -lCom LIBZMQDIR = ../commonFiles LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq -SRC_CLNT= slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp ../commonFiles/utilities.cpp#../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp -DEPSINCLUDES = ../commonFiles/sls_receiver_defs.h ../commonFiles/sls_receiver_funcs.h ../commonFiles/ansi.h ../commonFiles/sls_detector_defs.h ../commonFiles/sls_detector_funcs.h ../commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetectorAnalysis/detectorData.h threadFiles/Global.h threadFiles/Task.h sharedMemory/SharedMemory.h ../commonFiles/sls_receiver_exceptions.h ../commonFiles/versionAPI.h ../commonFiles/utilities.h +SRC_CLNT= slsDetector/slsDetectorCommand.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsReceiverInterface/receiverInterface.cpp slsDetector/slsDetectorUsers.cpp threadFiles/CondVar.cpp threadFiles/Mutex.cpp threadFiles/ThreadPool.cpp sharedMemory/SharedMemory.cpp ../commonFiles/utilities.cpp#../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp +DEPSINCLUDES = ../commonFiles/sls_receiver_defs.h ../commonFiles/sls_receiver_funcs.h ../commonFiles/ansi.h ../commonFiles/sls_detector_defs.h ../commonFiles/sls_detector_funcs.h ../commonFiles/error_defs.h slsDetector/slsDetectorBase.h slsDetector/detectorData.h threadFiles/Global.h threadFiles/Task.h sharedMemory/SharedMemory.h ../commonFiles/sls_receiver_exceptions.h ../commonFiles/versionAPI.h ../commonFiles/utilities.h @@ -77,6 +77,6 @@ install: package install_inc: $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P slsDetector/slsDetectorUsers.h slsDetectorAnalysis/detectorData.h $(DESTDIR) + cp -P slsDetector/slsDetectorUsers.h slsDetector/detectorData.h $(DESTDIR) diff --git a/slsDetectorSoftware/doxy.config b/slsDetectorSoftware/doxy.config index 259566611..ce0c700f7 100644 --- a/slsDetectorSoftware/doxy.config +++ b/slsDetectorSoftware/doxy.config @@ -99,9 +99,7 @@ INPUT = ../commonfiles/communication_funcs.h \ slsDetector/slsDetectorCommand.h \ slsDetector/slsDetector.h \ slsDetector/slsDetectorUsers.h \ - slsDetector/slsDetectorUtils.h \ - slsDetectorAnalysis/detectorData.h \ - slsDetectorAnalysis/postProcessing.h \ + slsDetector/detectorData.h \ slsReceiverInterface/receiverInterface.h \ threadFiles/CondVar.h \ threadFiles/Global.h \ diff --git a/slsDetectorSoftware/include/detectorData.h b/slsDetectorSoftware/include/detectorData.h deleted file mode 120000 index 44205ed04..000000000 --- a/slsDetectorSoftware/include/detectorData.h +++ /dev/null @@ -1 +0,0 @@ -../slsDetectorAnalysis/detectorData.h \ No newline at end of file diff --git a/slsDetectorSoftware/include/slsDetectorUsers.h b/slsDetectorSoftware/include/slsDetectorUsers.h deleted file mode 120000 index 51e196881..000000000 --- a/slsDetectorSoftware/include/slsDetectorUsers.h +++ /dev/null @@ -1 +0,0 @@ -../slsDetector/slsDetectorUsers.h \ No newline at end of file diff --git a/slsDetectorSoftware/include/slsReceiverUsers.h b/slsDetectorSoftware/include/slsReceiverUsers.h deleted file mode 120000 index c8727f200..000000000 --- a/slsDetectorSoftware/include/slsReceiverUsers.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/slsReceiverUsers.h \ No newline at end of file diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index e034ca869..3b1254a2c 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -7,6 +7,7 @@ #include "multiSlsDetectorClient.h" #include "multiSlsDetectorCommand.h" #include "utilities.h" +#include "detectorData.h" #include #include @@ -27,14 +28,30 @@ multiSlsDetector::multiSlsDetector(int id, bool verify, bool update) threadpool(0), totalProgress(0), progressIndex(0), - acquisition_finished(NULL), - measurement_finished(NULL), - acqFinished_p(NULL), - measFinished_p(NULL), + threadedProcessing(1), + jointhread(0), + acquiringDone(0), + fdata(0), + thisData(0), + acquisition_finished(0), + acqFinished_p(0), + measurement_finished(0), + measFinished_p(0), progress_call(0), - pProgressCallArg(0) + pProgressCallArg(0), + dataReady(0), + pCallbackArg(0) { + pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; + mp=mp1; + pthread_mutex_init(&mp, NULL); + mg=mp1; + pthread_mutex_init(&mg, NULL); + ms=mp1; + pthread_mutex_init(&ms, NULL); + setupMultiDetector(verify, update); + } @@ -60,10 +77,6 @@ multiSlsDetector::~multiSlsDetector() { } -bool multiSlsDetector::isMultiSlsDetectorClass() { - return true; -} - void multiSlsDetector::setupMultiDetector(bool verify, bool update) { if (initSharedMemory(verify)) // shared memory just created, so initialize the structure @@ -4175,6 +4188,17 @@ void multiSlsDetector::registerProgressCallback(int( *func)(double,void*), void } +void multiSlsDetector::registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), + void *pArg) { + dataReady = userCallback; + pCallbackArg = pArg; + if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { + enableDataStreamingToClient(1); + enableDataStreamingFromReceiver(1); + } +} + + int multiSlsDetector::setTotalProgress() { int nf=1, nc=1, ns=1, nm=1; @@ -4227,7 +4251,7 @@ void multiSlsDetector::incrementProgress() { cout << "\r" << flush; #endif -}; +} void multiSlsDetector::setCurrentProgress(int i){ @@ -4282,8 +4306,8 @@ int multiSlsDetector::acquire(){ } // start processing thread - if (*threadedProcessing) - startThread(); + if (threadedProcessing) + startProcessingThread(); //resets frames caught in receiver @@ -4320,7 +4344,7 @@ int multiSlsDetector::acquire(){ // detector start startAndReadAll(); - if (*threadedProcessing==0){ + if (threadedProcessing==0){ processData(); } @@ -4333,7 +4357,7 @@ int multiSlsDetector::acquire(){ pthread_mutex_unlock(&mg); } else { pthread_mutex_unlock(&mg); - if (*threadedProcessing && dataReady) + if (threadedProcessing && dataReady) sem_wait(&sem_endRTAcquisition); // waits for receiver's external process to be done sending data to gui } } @@ -4357,7 +4381,7 @@ int multiSlsDetector::acquire(){ // waiting for the data processing thread to finish! - if (*threadedProcessing) { + if (threadedProcessing) { setJoinThread(1); //let processing thread continue and checkjointhread @@ -4388,3 +4412,144 @@ int multiSlsDetector::acquire(){ } + + +int multiSlsDetector::setThreadedProcessing(int enable=-1) { + if (enable>=0) + threadedProcessing=enable; + return threadedProcessing; +} + + +void multiSlsDetector::startProcessingThread() { + + setTotalProgress(); +#ifdef VERBOSE + std::cout << "start thread stuff" << std::endl; +#endif + + pthread_attr_t tattr; + int ret; + sched_param param, mparam; + int policy= SCHED_OTHER; + + // set the priority; others are unchanged + //newprio = 30; + mparam.sched_priority =1; + param.sched_priority =1; + + /* Initialize and set thread detached attribute */ + pthread_attr_init(&tattr); + pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); + + ret = pthread_setschedparam(pthread_self(), policy, &mparam); + + + ret = pthread_create(&dataProcessingThread, &tattr,startProcessData, (void*)this); + + if (ret) + printf("ret %d\n", ret); + + pthread_attr_destroy(&tattr); + + // scheduling parameters of target thread + ret = pthread_setschedparam(dataProcessingThread, policy, ¶m); +} + + +void* multiSlsDetector::startProcessData(void *n) { + postProcessing *myDet=(postProcessing*)n; + myDet->processData(); + pthread_exit(NULL); +} + + +void* multiSlsDetector::processData() { + if(setReceiverOnline()==OFFLINE_FLAG){ + return 0; + } //receiver + else{ + //cprintf(RED,"In post processing threads\n"); + + if(dataReady) { + readFrameFromReceiver(); + } + //only update progress + else{ + int caught = -1; + char c; + int ifp; + while(true){ + + // set only in startThread + if (*threadedProcessing==0) + setTotalProgress(); + + // to exit acquire by typing q + ifp=kbhit(); + if (ifp!=0){ + c=fgetc(stdin); + if (c=='q') { + std::cout<<"Caught the command to stop acquisition"< #include @@ -23,7 +23,7 @@ class ZmqSocket; #define SHORT_STRING_LENGTH 50 #define DATE_LENGTH 30 -class multiSlsDetector : public postProcessing { +class multiSlsDetector : public slsDetectorBase { private: @@ -142,12 +142,6 @@ public: */ virtual ~multiSlsDetector(); - /** - * returns true. Used when reference is slsDetectorUtils and to determine - * if command can be implemented as slsDetector/multiSlsDetector object/ - */ - bool isMultiSlsDetectorClass(); - /** * Creates/open shared memory, initializes detector structure and members * Called by constructor/ set hostname / read config file @@ -1450,6 +1444,17 @@ public: */ void registerProgressCallback(int( *func)(double,void*), void *pArg); + /** + * register calbback for accessing detector final data, + * also enables data streaming in client and receiver + * @param userCallback function for plotting/analyzing the data. + * Its arguments are + * the data structure d and the frame number f, + * s is for subframe number for eiger for 32 bit mode + * @param pArg argument + */ + void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg); + /** * Performs a complete acquisition * resets frames caught in receiver, starts receiver, starts detector, @@ -1459,6 +1464,12 @@ public: */ int acquire(); + /** + * Set/get if the data processing thread si enabled + * @param enable 0 no data processing thread, 1 separate thread, -1 get + */ + int setThreadedProcessing(int enable=-1); + private: /** * Initialize (open/create) shared memory for the sharedMultiDetector structure @@ -1528,6 +1539,39 @@ private: */ void setCurrentProgress(int i=0); + /** + * Start data processing thread + */ + void startProcessingThread(); + + /** + * Static function to call processing thread + */ + static void* startProcessData(void *n); + + /** + * Combines data from all readouts and gives it to the gui + * or just gives progress of acquisition by polling receivers + */ + void* processData(); + + /** + * Check if processing thread is ready to join main thread + * @returns true if ready, else false + */ + int checkJoinThread(); + + /** + * Main thread sets if the processing thread should join it + * @param v true if it should join, else false + */ + void setJoinThread(int v); + + /** + * Listen to key event to stop acquiring + * when using acquire command + */ + int kbhit(void); /** Multi detector Id */ @@ -1552,20 +1596,54 @@ private: ThreadPool* threadpool; - int totalProgress; - int progressIndex; - - int (*acquisition_finished)(double,int,void*); - int (*measurement_finished)(int,int,void*); - void *acqFinished_p, *measFinished_p; - int (*progress_call)(double,void*); - void *pProgressCallArg; - /** semaphore to let postprocessing thread continue for next scan/measurement */ sem_t sem_newRTAcquisition; /** semaphore to let main thread know it got all the dummy packets (also from ext. process) */ sem_t sem_endRTAcquisition; + + int totalProgress; + int progressIndex; + /** mutex to synchronize main and data processing threads */ + pthread_mutex_t mp; + + /** mutex to synchronizedata processing and plotting threads */ + pthread_mutex_t mg; + + /** mutex to synchronize slsdetector threads */ + pthread_mutex_t ms; + + int threadedProcessing; + + /** sets when the acquisition is finished */ + int jointhread; + + /** set when detector finishes acquiring */ + int acquiringDone; + + /** the data processing thread */ + pthread_t dataProcessingThread; + + double *fdata; + detectorData *thisData; + + int (*acquisition_finished)(double,int,void*); + void *acqFinished_p; + + int (*measurement_finished)(int,int,void*); + void *measFinished_p; + + int (*progress_call)(double,void*); + void *pProgressCallArg; + + int (*dataReady)(detectorData*,int, int, void*); + void *pCallbackArg; + + + + + + }; diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorCommand.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorCommand.h index f30d807f8..7e95d2728 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorCommand.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetectorCommand.h @@ -14,54 +14,43 @@ class multiSlsDetectorCommand : public slsDetectorCommand { - public: +public: - multiSlsDetectorCommand(multiSlsDetector *det) : slsDetectorCommand(det) {myDet=det;}; + multiSlsDetectorCommand(multiSlsDetector *det) : slsDetectorCommand(det) {myDet=det;}; - /* /\** */ -/* executes a set of string arguments according to a given format. It is used to read/write configuration file, dump and retrieve detector settings and for the command line interface command parsing */ -/* \param narg number of arguments */ -/* \param args array of string arguments */ -/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ -/* \returns answer string */ -/* *\/ */ + /* /\** */ + /* executes a set of string arguments according to a given format. It is used to read/write configuration file, dump and retrieve detector settings and for the command line interface command parsing */ + /* \param narg number of arguments */ + /* \param args array of string arguments */ + /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ + /* \returns answer string */ + /* *\/ */ - std::string executeLine(int narg, char *args[], int action, int id=-1) { \ - std::string s; \ - if (id>=0) { - slsDetector *d=myDet->getSlsDetector(id); \ - if (d) { \ - slsDetectorCommand *cmd=new slsDetectorCommand(d); \ - s=cmd->executeLine(narg, args, action); \ - if(d->getErrorMask()) \ - myDet->setErrorMask((myDet->getErrorMask())|(1</dev/null - \ No newline at end of file diff --git a/slsDetectorSoftware/mythenDetectorServer/Makefile.dum b/slsDetectorSoftware/mythenDetectorServer/Makefile.dum deleted file mode 100644 index 4656a39bf..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/Makefile.dum +++ /dev/null @@ -1,40 +0,0 @@ -# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $ -# first compile -# make cris-axis-linux-gnu - -AXIS_USABLE_LIBS = UCLIBC GLIBC -include $(AXIS_TOP_DIR)/tools/build/Rules.axis - -PROGS= dummy - -INSTDIR= $(prefix)/bin -INSTMODE= 0777 - -SRCS= dummy_main.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c -OBJS= $(SRCS:%.c=%.o) - -CFLAGS+= -Wall -DC_ONLY -DVERBOSE -#-Werror - -LDLIBS+= -lm - -all: versioning $(PROGS) - -boot: $(OBJS) - -$(PROGS): $(OBJS) - echo $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - -install: $(PROGS) - $(INSTALL) -d $(INSTDIR) - $(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR) - -clean: - rm -rf $(PROGS) *.o - -depend: - makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null - -versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` \ No newline at end of file diff --git a/slsDetectorSoftware/mythenDetectorServer/Makefile.picasso b/slsDetectorSoftware/mythenDetectorServer/Makefile.picasso deleted file mode 100644 index 48d204135..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/Makefile.picasso +++ /dev/null @@ -1,49 +0,0 @@ -# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $ -# first compile -# make cris-axis-linux-gnu - -AXIS_USABLE_LIBS = UCLIBC GLIBC -include $(AXIS_TOP_DIR)/tools/build/Rules.axis - -PROGS= mythenDetectorServer -PICASSO= picassoDetectorServer -PICASSOFLAGS= -DPICASSOD - -INSTDIR= $(prefix)/bin -INSTMODE= 0777 - -SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c -OBJS= $(SRCS:%.c=%.o) - -CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE -DVERYVERBOSE -DPICASSOD -#-Werror - -LDLIBS+= -lm - -picasso: $(PICASSO) -mythen: versioning $(PROGS) -all: versioning $(PROGS) $(PICASSO) - -boot: $(OBJS) - -$(PROGS): $(OBJS) - echo $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) $(CFLAGS) -o $@ - -$(PICASSO): $(OBJS) - echo $(OBJS) - $(CC) $(LDFLAGS) $^ $(LDLIBS) $(CFLAGS) $(PICASSOFLAGS) -o $@ - - -install: $(PROGS) - $(INSTALL) -d $(INSTDIR) - $(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR) - -clean: - rm -rf $(PROGS) $(PICASSO) *.o - -depend: - makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null - -versioning: - @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;` \ No newline at end of file diff --git a/slsDetectorSoftware/mythenDetectorServer/Makefile.virtual b/slsDetectorSoftware/mythenDetectorServer/Makefile.virtual deleted file mode 100755 index f3cb34b21..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/Makefile.virtual +++ /dev/null @@ -1,18 +0,0 @@ -DESTDIR?= ./ -PROGS= $(DESTDIR)/mythenVirtualServer - -SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c - -OBJS= $(SRCS:%.c=%.o) - -CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DDACS_INT $(VFLAGS) -DVIRTUAL -DVERBOSE - -LDLIBS+= -lm -mythenVirtualServer : clean $(PROGS) - -$(PROGS): $(SRCS) - gcc $(LDFLAGS) $(SRCS) $(LDLIBS) $(CFLAGS) -o $@ - -clean: - rm -f *.o $(PROGS) - diff --git a/slsDetectorSoftware/mythenDetectorServer/ansi.h b/slsDetectorSoftware/mythenDetectorServer/ansi.h deleted file mode 120000 index a122db0ad..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/ansi.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/ansi.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c deleted file mode 100755 index 6e90105cb..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c +++ /dev/null @@ -1,1765 +0,0 @@ -#ifndef PICASSOD -#include "server_defs.h" -#else -#include "picasso_defs.h" -#endif - -#include "firmware_funcs.h" -#include "mcb_funcs.h" -#include "registers.h" - -#ifdef SHAREDMEMORY -#include "sharedmemory.h" -#endif - -#include -#include -#include - -#include -//#define VERBOSE - -//for memory mapping -u_int64_t CSP0BASE; - -FILE *debugfp, *datafp; - -int fr; -int wait_time; -int *fifocntrl; -int *values; -int *statusreg; -const int nModY=1; -int nModBoard; -int nModX=NMAXMOD; -int dynamicRange=32; -int dataBytes=NMAXMOD*NCHIP*NCHAN*4; -int storeInRAM=0; -int *ram_values=NULL; -char *now_ptr=NULL; -int ram_size=0; - -int64_t totalTime=1; -u_int32_t progressMask=0; - - - -int ififostart, ififostop, ififostep, ififo; - -int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING; - -enum externalSignalFlag signals[4]={GATE_IN_ACTIVE_HIGH, TRIGGER_IN_RISING_EDGE, SIGNAL_OFF, SIGNAL_OFF}; - - -#ifdef MCB_FUNCS -extern const int nChans; -extern const int nChips; -extern const int nDacs; -extern const int nAdcs; -#endif -#ifndef MCB_FUNCS - -const int nChans=NCHAN; -const int nChips=NCHIP; -const int nDacs=NDAC; -const int nAdcs=NADC; -#endif - -//int mybyte; -//int mysize=dataBytes/8; - -int mapCSP0(void) { - printf("Mapping memory\n"); -#ifndef VIRTUAL - int fd; - fd = open("/dev/mem", O_RDWR | O_SYNC, 0); - if (fd == -1) { - printf("\nCan't find /dev/mem!\n"); - return FAIL; - } - printf("/dev/mem opened\n"); - CSP0BASE = (u_int32_t)mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0); - if (CSP0BASE == (u_int32_t)MAP_FAILED) { - printf("\nCan't map memmory area!!\n"); - return FAIL; - } - printf("CSP0 mapped\n"); - -#endif -#ifdef VIRTUAL - CSP0BASE = malloc(MEM_SIZE); - printf("memory allocated\n"); -#endif -#ifdef SHAREDMEMORY - if ( (res=inism(SMSV))<0) { - printf("error attaching shared memory! %i",res); - return FAIL; - } -#endif - printf("CSPOBASE=from %08x to %x\n",CSP0BASE,CSP0BASE+MEM_SIZE); - - values=(u_int32_t*)(CSP0BASE+FIFO_DATA_REG_OFF); - printf("values=%08x\n",values); - fifocntrl=(u_int32_t*)(CSP0BASE+FIFO_CNTRL_REG_OFF); - printf("fifcntrl=%08x\n",fifocntrl); - statusreg=(u_int32_t*)(CSP0BASE+STATUS_REG); - printf("statusreg=%08x\n",statusreg); - - return OK; -} - - -u_int32_t bus_w(u_int32_t offset, u_int32_t data) { - u_int32_t *ptr1; - - - ptr1=(u_int32_t*)(CSP0BASE+offset); - *ptr1=data; - - return OK; -} - - -u_int32_t bus_r(u_int32_t offset) { - u_int32_t *ptr1; - - ptr1=(u_int32_t*)(CSP0BASE+offset); - return *ptr1; -} - -// direct pattern output -u_int32_t putout(char *s, int modnum) { - int i; - u_int32_t pat; - int addr; - - if (strlen(s)<16) { - fprintf(stdout," *** putout error: incorrect pattern length ***\n"); - fprintf(stdout," %s \n",s); - return FAIL; - } - - pat=0; - for (i=0;i<16;i++) { - if (s[i]=='1') pat=pat+(1<>CLK_DIVIDER_OFFSET); -} - -u_int32_t getClockDivider() { - u_int32_t clk_div; - clk_div=((bus_r(SPEED_REG)&CLK_DIVIDER_MASK)>>CLK_DIVIDER_OFFSET); - return clk_div; -} - -u_int32_t setSetLength(int d) { - u_int32_t c; - c=bus_r(SPEED_REG); - bus_w(SPEED_REG,(d<>SET_LENGTH_OFFSET); -} - -u_int32_t getSetLength() { - u_int32_t clk_div; - clk_div=((bus_r(SPEED_REG)& SET_LENGTH_MASK)>>SET_LENGTH_OFFSET); - return clk_div; -} - - -u_int32_t setWaitStates(int d1) { - u_int32_t c; - int d=d1-2; - //int d=d1-3; - char cmd[100]; - if (d1<=0xf) { - sprintf(cmd,"bus -a 0xb0000000 -w 0x%x0008",d1); - c=bus_r(SPEED_REG); - bus_w(SPEED_REG,(d<>WAIT_STATES_OFFSET)+2; -} - -u_int32_t getWaitStates() { - u_int32_t clk_div; - clk_div=((bus_r(SPEED_REG)& WAIT_STATES_MASK)>>WAIT_STATES_OFFSET); - return clk_div+2; -} - - -u_int32_t setTotClockDivider(int d) { - u_int32_t c; - c=bus_r(SPEED_REG); - bus_w(SPEED_REG,(d<>TOTCLK_DIVIDER_OFFSET); -} - -u_int32_t getTotClockDivider() { - u_int32_t clk_div; - clk_div=((bus_r(SPEED_REG)&TOTCLK_DIVIDER_MASK)>>TOTCLK_DIVIDER_OFFSET); - return clk_div; -} - - -u_int32_t setTotDutyCycle(int d) { - u_int32_t c; - c=bus_r(SPEED_REG); - bus_w(SPEED_REG,(d<>TOTCLK_DUTYCYCLE_OFFSET); -} - -u_int32_t getTotDutyCycle() { - u_int32_t clk_div; - clk_div=((bus_r(SPEED_REG)&TOTCLK_DUTYCYCLE_MASK)>>TOTCLK_DUTYCYCLE_OFFSET); - return clk_div; -} - - -u_int32_t setExtSignal(int d, enum externalSignalFlag mode) { - - - // int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING}; - - u_int32_t c; - // int off=d*SIGNAL_OFFSET; - c=bus_r(EXT_SIGNAL_REG); - - - - if (d>=0 && d<4) { - signals[d]=mode; -#ifdef VERBOSE - printf("settings signal variable number %d to value %04x\n", d, signals[d]); -#endif - - // if output signal, set it! - - switch (mode) { - case GATE_IN_ACTIVE_HIGH: - case GATE_IN_ACTIVE_LOW: - if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER) - setFPGASignal(d,mode); - else - setFPGASignal(d,SIGNAL_OFF); - break; - case TRIGGER_IN_RISING_EDGE: - case TRIGGER_IN_FALLING_EDGE: - if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER) - setFPGASignal(d,mode); - else - setFPGASignal(d,SIGNAL_OFF); - break; - case RO_TRIGGER_IN_RISING_EDGE: - case RO_TRIGGER_IN_FALLING_EDGE: - if (timingMode==TRIGGER_READOUT) - setFPGASignal(d,mode); - else - setFPGASignal(d,SIGNAL_OFF); - break; - case MASTER_SLAVE_SYNCHRONIZATION: - setSynchronization(syncMode); - break; - default: - setFPGASignal(d,mode); - } - - setTiming(GET_EXTERNAL_COMMUNICATION_MODE); - } - - return getExtSignal(d); -} - -u_int32_t setFPGASignal(int d, enum externalSignalFlag mode) { - - - int modes[]={SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW,TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE,RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE,RO_TRIGGER_OUT_FALLING_EDGE}; - - // int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING}; - - u_int32_t c; - int off=d*SIGNAL_OFFSET; - c=bus_r(EXT_SIGNAL_REG); - - - if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0) { -#ifdef VERBOSE - printf("writing signal register number %d mode %04x\n",d, modes[mode]); -#endif - bus_w(EXT_SIGNAL_REG,((modes[mode])<>off); */ - -/* if (mode=0 && d<4) { -#ifdef VERBOSE - printf("gettings signal variable number %d value %04x\n", d, signals[d]); -#endif - return signals[d]; - } else - return -1; - -} - - -int getFPGASignal(int d) { - - int modes[]={SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW,TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE,RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE,RO_TRIGGER_OUT_FALLING_EDGE}; - - int off=d*SIGNAL_OFFSET; - int mode=((bus_r(EXT_SIGNAL_REG)&(SIGNAL_MASK<>off); - - if (mode<=RO_TRIGGER_OUT_FALLING_EDGE) { - if (modes[mode]!=SIGNAL_OFF && signals[d]!=MASTER_SLAVE_SYNCHRONIZATION) - signals[d]=modes[mode]; -#ifdef VERBOSE - printf("gettings signal register number %d value %04x\n", d, modes[mode]); -#endif - return modes[mode]; - } else - return -1; - -} - - -/* -enum externalCommunicationMode{ - GET_EXTERNAL_COMMUNICATION_MODE, - AUTO, - TRIGGER_EXPOSURE_SERIES, - TRIGGER_EXPOSURE_BURST, - TRIGGER_READOUT, - TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE, - GATE_FIX_NUMBER, - GATE_FIX_DURATION, - GATE_WITH_START_TRIGGER, - GATE_COINCIDENCE_WITH_INTERNAL_ENABLE -}; -*/ - - -int setTiming(int ti) { - - - int ret=GET_EXTERNAL_COMMUNICATION_MODE; - - int g=-1, t=-1, rot=-1; - - int i; - printf("*********************************Setting timing mode %d!\n", ti); - switch (ti) { - case AUTO_TIMING: - timingMode=ti; - // disable all gates/triggers in except if used for master/slave synchronization - for (i=0; i<4; i++) { - if (getFPGASignal(i)>0 && getFPGASignal(i)=0 && t>=0 && rot<0) { - ret=GATE_WITH_START_TRIGGER; - } else if (g<0 && t>=0 && rot<0) { - ret=TRIGGER_EXPOSURE; - } else if (g>=0 && t<0 && rot<0) { - ret=GATE_FIX_NUMBER; - } else if (g<0 && t<0 && rot>0) { - ret=TRIGGER_READOUT; - } else if (g<0 && t<0 && rot<0) { - ret=AUTO_TIMING; - } - - // timingMode=ret; - - return ret; - -} - - - - -int setConfigurationRegister(int d) { -#ifdef VERBOSE - printf("Setting configuration register to %x",d); -#endif - if (d>=0) { - bus_w(CONFIG_REG,d); - } -#ifdef VERBOSE - printf("configuration register is %x", bus_r(CONFIG_REG)); -#endif - return bus_r(CONFIG_REG); -} - -int setToT(int d) { - // int ret=0; - int reg; -#ifdef VERBOSE - printf("Setting ToT to %d\n",d); -#endif - reg=bus_r(CONFIG_REG); -#ifdef VERBOSE - printf("Before: ToT is %x\n", reg); -#endif - if (d>0) { - bus_w(CONFIG_REG,reg|TOT_ENABLE_BIT); - } else if (d==0) { - bus_w(CONFIG_REG,reg&(~TOT_ENABLE_BIT)); - } - reg=bus_r(CONFIG_REG); -#ifdef VERBOSE - printf("ToT is %x\n", reg); -#endif - if (reg&TOT_ENABLE_BIT) - return 1; - else - return 0; -} - -int setContinousReadOut(int d) { - // int ret=0; - int reg; -#ifdef VERBOSE - printf("Setting Continous readout to %d\n",d); -#endif - reg=bus_r(CONFIG_REG); -#ifdef VERBOSE - printf("Before: Continous readout is %x\n", reg); -#endif - if (d>0) { - bus_w(CONFIG_REG,reg|CONT_RO_ENABLE_BIT); - } else if (d==0) { - bus_w(CONFIG_REG,reg&(~CONT_RO_ENABLE_BIT)); - } - reg=bus_r(CONFIG_REG); -#ifdef VERBOSE - printf("Continous readout is %x\n", reg); -#endif - if (reg&CONT_RO_ENABLE_BIT) - return 1; - else - return 0; -} - - -u_int64_t getMcsNumber() { - - FILE *fp=NULL; - u_int64_t res; - char line[150]; - int a[6]; - - int n=0, i; - //u_int64_t a0,a1,a2,a3,a4,a5,n=0; - fp=fopen("/etc/conf.d/mac","r"); - if (fp==NULL) { - printf("could not ope MAC file\n");; - return -1; - } - while (fgets(line,150,fp)) { - //MAC="00:40:8C:CD:00:00" - printf(line); - if (strstr(line,"MAC=")) - n=sscanf(line,"MAC=\"%x:%x:%x:%x:%x:%x\"",a+5,a+4,a+3,a+2,a+1,a); - } - fclose(fp); - if (n!=6){ - printf("could not scan MAC address\n");; - return -1; - } - res=0; - for (i=0; i=(FPGA_VERSION_VAL&0x00ffffff)) { - printf("FPGA version ok!! %06x\n",val); - } else { - printf("FPGA version too old! %06x\n",val); - return FAIL; - } - //dummy register - val=0xF0F0F0F0; - bus_w(DUMMY_REG, val); - val=bus_r(DUMMY_REG); - if (val==0xF0F0F0F0) { - printf("FPGA dummy register ok!! %x\n",val); - } else { - printf("FPGA dummy register wrong!! %x instead of 0xF0F0F0F0 \n",val); - result=FAIL; - // return FAIL; - } - //dummy register - val=0x0F0F0F0F; - bus_w(DUMMY_REG, val); - val=bus_r(DUMMY_REG); - if (val==0x0F0F0F0F) { - printf("FPGA dummy register ok!! %x\n",val); - } else { - printf("FPGA dummy register wrong!! %x instead of 0x0F0F0F0F \n",val); - result=FAIL; - // return FAIL; - } - // } - return result; -} - - -// for fpga test -u_int32_t testRAM(void) { - int result=OK; - int i=0; - allocateRAM(); - // while(i<100000) { - memcpy(ram_values, values, dataBytes); - printf ("%d: copied fifo %x to memory %x size %d\n",i++, values, ram_values, dataBytes); - // } - return result; -} - -int getNModBoard() { - int nmodboard; - u_int32_t val; - val=bus_r(FPGA_VERSION_REG)&0xff000000; - - // printf("version register %08x\n",val); - nmodboard=val >> 24; - #ifdef VERY_VERBOSE - printf("The board hosts %d modules\n",nmodboard); - #endif - nModBoard=nmodboard; - //getNModBoard()=nmodboard; - return nmodboard; -} - -int setNMod(int n) { - - // int fifo; - // int ifsta, ifsto, ifste; - int imod; - int rval; - int reg; - int nf=0; - int shiftfifo=SHIFTFIFO; - int ntot=getNModBoard(); - if (getProbes()==0) { - switch (dynamicRange) { - case 16: - shiftfifo=SHIFTFIFO-1; - break; - case 8: - shiftfifo=SHIFTFIFO-2; - break; - case 4: - shiftfifo=SHIFTFIFO-3; - break; - case 1: - shiftfifo=SHIFTFIFO-5; - break; - default: - shiftfifo=SHIFTFIFO; - } - } else - shiftfifo=SHIFTFIFO; - - - //#ifdef VERBOSE - printf("SetNMod called arg %d -- dr %d shiftfifo %d\n",n,dynamicRange,shiftfifo); - //#endif - if (n>=0 && n<=ntot) { - nModX=n; - - /*d isable the fifos relative to the unused modules */ - for (ififo=0; ififo>FIFO_NM_OFF, (reg&FIFO_NC_MASK)>>FIFO_NC_OFF, FIFO_COUNTR_REG_OFF+(ififo<>FIFO_NM_OFF, (reg&FIFO_NC_MASK)>>FIFO_NC_OFF, FIFO_COUNTR_REG_OFF+(ififo<> 32; - vMSB=v64&(0xffffffff); - bus_w(aMSB,vMSB); - } - return get64BitReg(aLSB, aMSB); - -} - -int64_t get64BitReg(int aLSB, int aMSB){ - int64_t v64; - u_int32_t vLSB,vMSB; - vMSB=bus_r(aMSB); - vLSB=bus_r(aLSB); - v64=vMSB; - v64=(v64<<32) | vLSB; -#ifdef VERBOSE - printf("MSB %08x LSB %08x, %016llx\n", vMSB, vLSB, v64); -#endif - - return v64; -} - -int64_t setFrames(int64_t value){ - return set64BitReg(value, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG); -} - -int64_t getFrames(){ - return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); -} - -int64_t setExposureTime(int64_t value){ - /* time is in ns */ - if (value!=-1) - value*=(1E-9*CLK_FREQ); - - if (masterMode==IS_SLAVE && syncMode==MASTER_GATES) - setGates(1); - - return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ); -} - -int64_t getExposureTime(){ - return get64BitReg(GET_EXPTIME_LSB_REG, GET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ); -} - -int64_t setGates(int64_t value){ - return set64BitReg(value, SET_GATES_LSB_REG, SET_GATES_MSB_REG); -} - -int64_t getGates(){ - return get64BitReg(GET_GATES_LSB_REG, GET_GATES_MSB_REG); -} - -int64_t setPeriod(int64_t value){ - /* time is in ns */ - if (value!=-1) { - value*=(1E-9*CLK_FREQ); - } - - - - return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ); -} - -int64_t getPeriod(){ - return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ); -} - -int64_t setDelay(int64_t value){ - /* time is in ns */ - if (value!=-1) { - value*=(1E-9*CLK_FREQ); - } - return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-9*CLK_FREQ); -} - -int64_t getDelay(){ - return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-9*CLK_FREQ); -} - -int64_t setTrains(int64_t value){ - return set64BitReg(value, SET_TRAINS_LSB_REG, SET_TRAINS_MSB_REG); -} - -int64_t getTrains(){ - return get64BitReg(GET_TRAINS_LSB_REG, GET_TRAINS_MSB_REG); -} - - -int64_t setProbes(int64_t value){ - int ow; - int nm=setNMod(-1); - switch (getDynamicRange()) { - case 32: - ow=1; - break; - case 16: - ow=2; - break; - case 8: - ow=3; - break; - case 4: - ow=4; - break; - case 1: - ow=5; - break; - default: - ow=1; - } - if (value>=0) { - setCSregister(ALLMOD); - initChipWithProbes(0, ow,value, ALLMOD); - putout("0000000000000000",ALLMOD); - setNMod(nm); - getDynamicRange(); // needed to change dataBytes - } - return getProbes(); -} - - -int64_t setProgress() { - - //????? eventually call after setting the registers - return 100; -} - - -int64_t getProgress() { - - - //should be done in firmware!!!! - return 0; - -} - - -int64_t getActualTime(){ - return get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG)/(1E-9*CLK_FREQ); -} - -int64_t getMeasurementTime(){ - int64_t v=get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG); - int64_t mask=0x8000000000000000; - - if (v & mask ) { -#ifdef VERBOSE - printf("no measurement time left\n"); -#endif - return -1E+9; - } else - return v/(1E-9*CLK_FREQ); -} - - - -int64_t getProbes(){ - u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG); - u_int32_t np=(shiftin >>PROBES_OFF) & PROBES_MASK; -#ifdef VERYVERBOSE - printf("%08x ",shiftin); - printf("probes==%01x\n",np); -#endif - - return np; - -} - - -int setDACRegister(int idac, int val, int imod) { - u_int32_t addr, reg, mask; - int off; -#ifdef VERBOSE - printf("Settings dac %d module %d register to %d\n",idac,imod,val); -#endif - if ((idac%2)==0) { - addr=MOD_DACS1_REG; - } else { - addr=MOD_DACS2_REG; - } - off=(idac%3)*10; - mask=~((0x3ff)<=0 && val>off)&0x3ff; -#ifdef VERBOSE - printf("Dac %d module %d register is %d\n",idac,imod,val); -#endif - return val; -} - - - - -u_int32_t runBusy(void) { - return bus_r(STATUS_REG)&RUN_BUSY_BIT; -} - -u_int32_t dataPresent(void) { - return bus_r(LOOK_AT_ME_REG); -} - -u_int32_t runState(void) { - int s=bus_r(STATUS_REG); -#ifdef SHAREDMEMORY - if (s&RUN_BUSY_BIT) - write_status_sm("Running"); - else - write_status_sm("Stopped"); - - write_istatus_sm(s); - -#endif -#ifdef VERBOSE - printf("status %08x\n",s); -#endif - return s; -} - - -// State Machine - -u_int32_t startStateMachine(){ -#ifdef VERBOSE - printf("Starting State Machine\n"); -#endif - fifoReset(); - now_ptr=(char*)ram_values; -#ifdef SHAREDMEMORY - write_stop_sm(0); - write_status_sm("Started"); -#endif -#ifdef MCB_FUNCS - setCSregister(ALLMOD); - clearSSregister(ALLMOD); -#endif - putout("0000000000000000",ALLMOD); - bus_w(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT); - return OK; -} - - - - -u_int32_t stopStateMachine(){ - -#ifdef VERBOSE - printf("Stopping State Machine\n"); -#endif -#ifdef SHAREDMEMORY - write_stop_sm(1); - write_status_sm("Stopped"); -#endif - bus_w(CONTROL_REG, STOP_ACQ_BIT); - usleep(500); - if (!runBusy()) - return OK; - else - return FAIL; -} - - -u_int32_t startReadOut(){ - u_int32_t status; -#ifdef VERBOSE - printf("Starting State Machine Readout\n"); -#endif - status=bus_r(STATUS_REG)&RUN_BUSY_BIT; -#ifdef DEBUG - printf("State machine status is %08x\n",bus_r(STATUS_REG)); -#endif - bus_w(CONTROL_REG, START_ACQ_BIT |START_READOUT_BIT); // start readout - return OK; -} - - -// fifo routines - -u_int32_t fifoReset(void) { -#ifdef DEBUG - printf("resetting fifo\n"); -#endif - bus_w(FIFO_CNTRL_REG_OFF+(ALLFIFO<128) - printf("chip %d ch %d %d\n",ichip/128, ichip%128, (fifoReadCounter(ichip/128)&FIFO_COUNTER_MASK)); -#endif - } - //#endif - */ - - - -#ifdef VERYVERBOSE - printf("Copying to ptr %x %d\n",now_ptr, dataBytes); - printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); - for (ichip=0; ichip0) { - now_ptr+=dataBytes; - } - return ram_values; -} - - - -u_int32_t* decode_data(int *datain) -{ - u_int32_t *dataout; - // const char one=1; - const int bytesize=8; - char *ptr=(char*)datain; - //int nbits=dynamicRange; - int ipos=0, ichan=0;; - //int nch, boff=0; - int ibyte;//, ibit; - char iptr; - -#ifdef VERBOSE - printf("Decoding data for DR %d\n",dynamicRange); -#endif - dataout=malloc(nChans*nChips*nModX*4); - ichan=0; - switch (dynamicRange) { - case 1: - for (ibyte=0; ibyte>(ipos))&0x1; - ichan++; - } - } - break; - case 4: - for (ibyte=0; ibyte>(ipos*4))&0xf; - ichan++; - } - } - break; - case 8: - for (ichan=0; ichan0) { - nm=setNMod(-1); - if (dr==1) { - dynamicRange=1; - ow=5; - } else if (dr<=4) { - dynamicRange=4; - ow=4; - } else if (dr<=8) { - dynamicRange=8; - ow=3; - } else if (dr<=16) { - dynamicRange=16; - ow=2; - } else { - dynamicRange=32; - ow=0; //or 1? - } - setCSregister(ALLMOD); - initChipWithProbes(0, ow,np, ALLMOD); - putout("0000000000000000",ALLMOD); - setNMod(nm); - } - - - return getDynamicRange(); -} - - - - - - -int getDynamicRange() { - int dr; - u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG); - u_int32_t outmux=(shiftin >> OUTMUX_OFF) & OUTMUX_MASK; - u_int32_t probes=(shiftin >> PROBES_OFF) & PROBES_MASK; -#ifdef VERYVERBOSE - printf("%08x ",shiftin); - printf("outmux=%02x probes=%d\n",outmux,probes); -#endif - - switch (outmux) { - case 2: - dr=16; - break; - case 4: - dr=8; - break; - case 8: - dr=4; - break; - case 16: - dr=1; - break; - default: - dr=32; - } - dynamicRange=dr; - if (probes==0) { - dataBytes=nModX*nModY*NCHIP*NCHAN*dynamicRange/8; - } else { - dataBytes=nModX*nModY*NCHIP*NCHAN*4;/// - } -#ifdef VERBOSE - printf("Number of data bytes %d - probes %d dr %d\n", dataBytes, probes, dr); -#endif - if (allocateRAM()==OK) { - ; - } else - printf("ram not allocated\n"); - - return dynamicRange; - -} - -int testBus() { - u_int32_t j; - u_int64_t i, n, nt; - //char cmd[100]; - u_int32_t val=0x0; - int ifail=OK; - // printf("%s\n",cmd); - // system(cmd); - i=0; - - n=1000000; - nt=n/100; - printf("testing bus %d times\n",n); - while (i0) - storeInRAM=1; - else - storeInRAM=0; - return allocateRAM(); -} - - -int allocateRAM() { - size_t size; - u_int32_t nt, nf; - nt=setTrains(-1); - nf=setFrames(-1); - if (nt==0) nt=1; - if (nf==0) nf=1; - // ret=clearRAM(); - if (storeInRAM) { - size=dataBytes*nf*nt; - if (size -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -int mapCSP0(void); -u_int32_t bus_w(u_int32_t offset, u_int32_t data); -u_int32_t bus_r(u_int32_t offset); - - -u_int32_t putout(char *s, int modnum); -u_int32_t readin(int modnum); -u_int32_t setClockDivider(int d); -u_int32_t getClockDivider(); -u_int32_t setSetLength(int d); -u_int32_t getSetLength(); -u_int32_t setWaitStates(int d); -u_int32_t getWaitStates(); -u_int32_t setTotClockDivider(int d); -u_int32_t getTotClockDivider(); -u_int32_t setTotDutyCycle(int d); -u_int32_t getTotDutyCycle(); - -u_int32_t setExtSignal(int d, enum externalSignalFlag mode); -int getExtSignal(int d); - -u_int32_t setFPGASignal(int d, enum externalSignalFlag mode); -int getFPGASignal(int d); - -int setTiming(int t); - - - - - - -int setConfigurationRegister(int d); -int setToT(int d); -int setContinousReadOut(int d); - -int setDACRegister(int idac, int val, int imod); - - -u_int64_t getMcsNumber(); -u_int32_t getMcsVersion(); -u_int32_t testFifos(void); -u_int32_t testFpga(void); -u_int32_t testRAM(void); -int testBus(void); -int64_t set64BitReg(int64_t value, int aLSB, int aMSB); -int64_t get64BitReg(int aLSB, int aMSB); - -int64_t setFrames(int64_t value); -int64_t getFrames(); - -int64_t setExposureTime(int64_t value); -int64_t getExposureTime(); - -int64_t setGates(int64_t value); -int64_t getGates(); - -int64_t setDelay(int64_t value); -int64_t getDelay(); - -int64_t setPeriod(int64_t value); -int64_t getPeriod(); - -int64_t setTrains(int64_t value); -int64_t getTrains(); - -int64_t setProbes(int64_t value); -int64_t getProbes(); - -int64_t getProgress(); -int64_t setProgress(); - -int64_t getActualTime(); -int64_t getMeasurementTime(); - -u_int32_t runBusy(void); -u_int32_t runState(void); -u_int32_t dataPresent(void); - - -u_int32_t startStateMachine(); -u_int32_t stopStateMachine(); -u_int32_t startReadOut(); -u_int32_t fifoReset(void); -u_int32_t fifoReadCounter(int fifonum); -u_int32_t fifoReadStatus(); - - -u_int32_t fifo_full(void); - - - -u_int32_t* fifo_read_event(); -u_int32_t* decode_data(int* datain); -//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout); -int setDynamicRange(int dr); -int getDynamicRange(); -int getNModBoard(); -int setNMod(int n); -int setStoreInRAM(int b); -int allocateRAM(); -int clearRAM(); - - -int setMaster(int f); -int setSynchronization(int s); - - -/* - -u_int32_t setNBits(u_int32_t); -u_int32_t getNBits(); -*/ - -/* -//move to mcb_funcs? - -int readOutChan(int *val); -u_int32_t getModuleNumber(int modnum); -int testShiftIn(int imod); -int testShiftOut(int imod); -int testShiftStSel(int imod); -int testDataInOut(int num, int imod); -int testExtPulse(int imod); -int testExtPulseMux(int imod, int ow); -int testDataInOutMux(int imod, int ow, int num); -int testOutMux(int imod); -int testFpgaMux(int imod); -int calibration_sensor(int num, int *values, int *dacs) ; -int calibration_chip(int num, int *values, int *dacs); -*/ - - -#endif diff --git a/slsDetectorSoftware/mythenDetectorServer/gitInfo.txt b/slsDetectorSoftware/mythenDetectorServer/gitInfo.txt deleted file mode 100644 index ac5d755fc..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/gitInfo.txt +++ /dev/null @@ -1,9 +0,0 @@ -Path: slsDetectorsPackage/slsDetectorSoftware/mythenDetectorServer -URL: -Repository Root: -Repsitory UUID: -Revision: 0 -Branch: -Last Changed Author: _ -Last Changed Rev: 0 -Last Changed Date: 2018-01-30 10:42:45.000000000 +0100 ./Makefile diff --git a/slsDetectorSoftware/mythenDetectorServer/gitInfoMythen.h b/slsDetectorSoftware/mythenDetectorServer/gitInfoMythen.h deleted file mode 100644 index 5fefed3fd..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/gitInfoMythen.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "URL:" -#define GITREPUUID "UUID:" -#define GITAUTH "_" -#define GITREV 0x0 -#define GITDATE 0x20180130 -#define GITBRANCH "Branch:" diff --git a/slsDetectorSoftware/mythenDetectorServer/gitInfoMythenTmp.h b/slsDetectorSoftware/mythenDetectorServer/gitInfoMythenTmp.h deleted file mode 100644 index dfd9bb246..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/gitInfoMythenTmp.h +++ /dev/null @@ -1,6 +0,0 @@ -#define GITURL "" -#define GITREPUUID "" -#define GITAUTH "" -#define GITREV "" -#define GITDATE "" -#define GITBRANCH "" diff --git a/slsDetectorSoftware/mythenDetectorServer/mcb_funcs.c b/slsDetectorSoftware/mythenDetectorServer/mcb_funcs.c deleted file mode 100755 index 70a995cd0..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/mcb_funcs.c +++ /dev/null @@ -1,2716 +0,0 @@ -#ifdef MCB_FUNCS - -#include -#include -#include -#include -#include -#include "registers.h" - -#ifndef PICASSOD -#include "server_defs.h" -#else -#include "picasso_defs.h" -#endif -#include "firmware_funcs.h" -#include "mcb_funcs.h" - -/* global variables */ -#undef DEBUG -#undef DEBUGOUT - -extern int nModX; -extern int nModBoard; -extern int dataBytes; -extern int dynamicRange; -const int nChans=NCHAN; -const int nChips=NCHIP; -const int nDacs=NDAC; -const int nAdcs=NADC; -const enum detectorType myDetectorType=MYTHEN; -enum detectorSettings thisSettings; - -int sChan, sChip, sMod, sDac, sAdc; -const int allSelected=-2; -const int noneSelected=-1; - - -sls_detector_module *detectorModules=NULL; -int *detectorChips=NULL; -int *detectorChans=NULL; -dacs_t *detectorDacs=NULL; -dacs_t *detectorAdcs=NULL; -//int numberOfProbes; - - - - - - - - -int initDetector() { - int imod; - // sls_detector_module *myModule; - int n=getNModBoard(); - nModX=n; - //#ifdef VERBOSE - printf("Board is for %d modules\n",n); - //#endif - detectorModules=malloc(n*sizeof(sls_detector_module)); - detectorChips=malloc(n*NCHIP*sizeof(int)); - - detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); - detectorDacs=malloc(n*NDAC*sizeof(dacs_t)); - detectorAdcs=malloc(n*NADC*sizeof(dacs_t)); - //#ifdef VERBOSE - printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n); - printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP); - printf("chans from 0x%x to 0x%x\n",detectorChans, detectorChans+n*NCHIP*NCHAN); - printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC); - printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC); - //#endif - for (imod=0; imoddacs=detectorDacs+imod*NDAC; - (detectorModules+imod)->adcs=detectorAdcs+imod*NADC; - (detectorModules+imod)->chipregs=detectorChips+imod*NCHIP; - (detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN; - (detectorModules+imod)->ndac=NDAC; - (detectorModules+imod)->nadc=NADC; - (detectorModules+imod)->nchip=NCHIP; - (detectorModules+imod)->nchan=NCHIP*NCHAN; - (detectorModules+imod)->module=imod; - (detectorModules+imod)->gain=0; - (detectorModules+imod)->offset=0; - (detectorModules+imod)->reg=0; - /* initialize registers, dacs, retrieve sn, adc values etc */ - } - printf("modules done\n"); - thisSettings=UNINITIALIZED; - sChan=noneSelected; - sChip=noneSelected; - sMod=noneSelected; - sDac=noneSelected; - sAdc=noneSelected; - setCSregister(ALLMOD); - setSSregister(ALLMOD); - counterClear(ALLMOD); - clearSSregister(ALLMOD); - putout("0000000000000000",ALLMOD); - - printf("dr\n"); - /* initialize dynamic range etc. */ - dynamicRange=getDynamicRange(); - printf("nmod\n"); - nModX=setNMod(-1); - printf("done\n"); - - - - - - //dataBytes=nModX*NCHIP*NCHAN*4; - // dynamicRange=32; - // initChip(0, 0,ALLMOD); - //nModX=n; - // - // allocateRAM(); - - - - - return OK; -} - - - - -int copyChannel(sls_detector_channel *destChan, sls_detector_channel *srcChan) { - destChan->chan=srcChan->chan; - destChan->chip=srcChan->chip; - destChan->module=srcChan->module; - destChan->reg=srcChan->reg; - return OK; -} - - -int copyChip(sls_detector_chip *destChip, sls_detector_chip *srcChip) { - - int ichan; - int ret=OK; - if ((srcChip->nchan)>(destChip->nchan)) { - printf("Number of channels of source is larger than number of channels of destination\n"); - return FAIL; - } - - destChip->nchan=srcChip->nchan; - destChip->reg=srcChip->reg; - destChip->chip=srcChip->chip; - destChip->module=srcChip->module; - for (ichan=0; ichan<(srcChip->nchan); ichan++) { - *((destChip->chanregs)+ichan)=*((srcChip->chanregs)+ichan); - } - return ret; -} - - -int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) { - - int ichip, idac, ichan, iadc; - - int ret=OK; - -#ifdef VERBOSE - printf("Copying module %x to module %x\n",srcMod,destMod); -#endif - - if (srcMod->module>=0) { -#ifdef VERBOSE - printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module); -#endif - destMod->module=srcMod->module; - } - if (srcMod->serialnumber>=0){ -/* #ifdef VERBOSE */ -/* printf("Copying module serial number %x to module serial number %x\n",srcMod->serialnumber,destMod->serialnumber); */ -/* #endif */ - destMod->serialnumber=srcMod->serialnumber; - } - if ((srcMod->nchip)>(destMod->nchip)) { - printf("Number of chip of source is larger than number of chips of destination\n"); - return FAIL; - } - if ((srcMod->nchan)>(destMod->nchan)) { - printf("Number of channels of source is larger than number of channels of destination\n"); - return FAIL; - } - if ((srcMod->ndac)>(destMod->ndac)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); - return FAIL; - } - if ((srcMod->nadc)>(destMod->nadc)) { - printf("Number of dacs of source is larger than number of dacs of destination\n"); - return FAIL; - } - -#ifdef VERBOSE - printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac); - printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc); - printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip); - printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan); - -#endif - - - - destMod->ndac=srcMod->ndac; - destMod->nadc=srcMod->nadc; - destMod->nchip=srcMod->nchip; - destMod->nchan=srcMod->nchan; - if (srcMod->reg>=0) - destMod->reg=srcMod->reg; -#ifdef VERBOSE - printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg ); -#endif - if (srcMod->gain>=0) - destMod->gain=srcMod->gain; - if (srcMod->offset>=0) - destMod->offset=srcMod->offset; - - // printf("copying gain and offset %f %f to %f %f\n",srcMod->gain,srcMod->offset,destMod->gain,destMod->offset); - - for (ichip=0; ichip<(srcMod->nchip); ichip++) { - if (*((srcMod->chipregs)+ichip)>=0) - *((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip); - } - for (ichan=0; ichan<(srcMod->nchan); ichan++) { - if (*((srcMod->chanregs)+ichan)>=0) - *((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan); - } - for (idac=0; idac<(srcMod->ndac); idac++) { - if (*((srcMod->dacs)+idac)>=0) - *((destMod->dacs)+idac)=*((srcMod->dacs)+idac); - } - for (iadc=0; iadc<(srcMod->nadc); iadc++) { - if (*((srcMod->adcs)+iadc)>=0) - *((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc); - } - return ret; -} - - - -/* Register commands */ - - -int clearDACSregister(int imod) { - putout("0000000001000000",imod); - putout("0000000101000000",imod); - putout("0000000101000000",imod); - putout("0000000001000000",imod); -#ifdef DEBUG - fprintf(stdout, "Clearing DAC shiftregister\n"); -#endif - /* - sChan=noneSelected; - sChip=noneSelected; - sMod=noneSelected; - sDac=noneSelected; - sAdc=noneSelected; - */ - sDac=0; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return OK; -} - -int nextDAC(int imod) { - putout("0000000001000000",imod); - putout("0000000001001000",imod); - putout("0000000001000000",imod); -#ifdef DEBUG - fprintf(stdout, "Next DAC\n"); -#endif - sDac++; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return OK; -} - - -int clearCSregister(int imod) { - - putout("0000000001000000",imod); - putout("0000100001000000",imod); - putout("0000100001000000",imod); - putout("0000000001000000",imod); -#ifdef DEBUG - fprintf(stdout, "Clearing CS shiftregister\n"); -#endif - /* - sChan=noneSelected; - sMod=noneSelected; - sDac=noneSelected; - sAdc=noneSelected; - */ - sChip=noneSelected; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - //putout("0000000000000000",imod); - return 0; -} - -int setCSregister(int imod){ - - putout("0000000001000000",imod); - putout("0001000001000000",imod); - putout("0001000001000000",imod); - putout("0000000001000000",imod); -#ifdef DEBUG - fprintf(stdout, "Setting CS shiftregister\n"); -#endif - putout("0000000000000000",imod); - sChip=allSelected; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return 0; -} - -int nextChip(int imod){ - - putout("0000000001000000",imod); - putout("0010000001000000",imod); - putout("0000000001000000",imod); -#ifdef DEBUG - fprintf(stdout, "Next Chip\n"); -#endif - sChip++; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return 0; -} - -int firstChip(int imod){ - - putout("0100000001000000",imod); - putout("0110000001000000",imod); - putout("0100000001000000",imod); -#ifdef DEBUG - fprintf(stdout, "First Chip\n"); -#endif - sChip=0; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return 0; -} - -int clearSSregister(int imod){ - int i; - putout("0000011000000000",imod); - for (i=0; i<10; i++) - putout("0000111000000000",imod); - putout("0000011000000000",imod); -#ifdef DEBUG - fprintf(stdout,"Clearing SS shiftregister\n"); -#endif - putout("0000000000000000",imod); - sChan=noneSelected; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return 0; -} - -int setSSregister(int imod){ - int i; - putout("0000011000000000",imod); - for (i=0; i<10; i++) - putout("0001011000000000",imod); - putout("0000011000000000",imod); -#ifdef DEBUG - fprintf(stdout,"Setting SS shiftregister\n"); -#endif - putout("0000000000000000",imod); - sChan=allSelected; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return 0; -} - -int nextStrip(int imod){ - putout("0000011000000000",imod); - putout("0010011000000000",imod); - putout("0000011000000000",imod); -#ifdef DEBUG - fprintf(stdout,"|-"); -#endif - sChan++; - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - return 0; -} - -int selChannel(const int strip,int imod) { - int istrip; - clearSSregister(imod); - nextStrip(imod); - for (istrip=0; istrip=0 && imoddacs[idac]=v; - detectorDacs[ireg+NDAC*imod]=v; - //#ifdef VERBOSE -#ifdef VERBOSE - printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod); -#endif - - setDACRegister(ireg,v,imod); - - /* - - reg=bus_r(MOD_DACS1_REG+(imod<dacs[idac]=v; - - - - reg=bus_r(MOD_DACS1_REG+(imod<=0) { - initDAC(cs, addr,val, imod); - /*#ifdef VERBOSE - iv=detectorDacs[ind+imod*NDAC]; - printf("module=%d index=%d, cs=%d, addr=%d, dacu=%d, set to %d",imod, ind,cs,addr,val,iv); -#endif - */ - //return val; - } - if (imod>=0 && imodgain,(detectorModules+imod)->offset); -#endif - if ((detectorModules+imod)->gain>0) - myg=(detectorModules+imod)->gain; - else { - if (thisSettings>=0 && thisSettings<3) - myg=g[thisSettings]; - // else - //myg=-1; - } - - if ((detectorModules+imod)->offset>0) - myo=(detectorModules+imod)->offset; - else { - if (thisSettings>=0 && thisSettings<3) - myo=o[thisSettings]; - // else - //myo=-1; - } - - if (myg>0 && myo>0) { - //ethr=(myo-detectorDacs[VTHRESH+imod*NDAC])*1000/myg; - - ethr=(myo-setDACRegister(VTHRESH,-1,imod))*1000/myg; - // else - // ethr=-1; - - } -#ifdef VERBOSE -#ifdef DACS_INT - printf("module=%d gain=%f, offset=%f, dacu=%d\n",imod, myg, myo,setDACRegister(VTHRESH,-1,imod)); -#else - printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo,setDACRegister(VTHRESH,-1,imod)); -#endif - printf("Threshold energy of module %d is %d eV\n", imod, ethr); -#endif - - if (imod==0) - ret=ethr; - else { - if (ethr>(ret+100) || ethr<(ret-100)) - return FAIL; - } - } - } - return ret; -} - -int setThresholdEnergy(int ethr) { - float g[3]=DEFAULTGAIN; - float o[3]=DEFAULTOFFSET; - float myg=-1, myo=-1; - int dacu; - int imod; - int ret=ethr; - - setSettings(GET_SETTINGS); - if (thisSettings>=0 || thisSettings<3){ - myg=g[thisSettings]; - myo=o[thisSettings]; - } - for (imod=0; imodgain>0) - myg=(detectorModules+imod)->gain; - else - if (thisSettings>=0 && thisSettings<3) - myg=g[thisSettings]; - else - myg=-1; - if ((detectorModules+imod)->offset>0) - myo=(detectorModules+imod)->offset; - else - if (thisSettings>=0 && thisSettings<3) - myo=o[thisSettings]; - else - myo=-1; - } else { - if (thisSettings>=0 && thisSettings<3) - myo=o[thisSettings]; - else - myo=-1; - if (thisSettings>=0 && thisSettings<3) - myg=g[thisSettings]; - else - myg=-1; - } - if (myg>0 && myo>0) { - dacu=myo-myg*((float)ethr)/1000.; -#ifdef VERBOSE - printf("module %d (%x): gain %f, off %f, energy %d eV, dac %d\n",imod,(detectorModules+imod),(detectorModules+imod)->gain,(detectorModules+imod)->offset, ethr,dacu); -#endif - } else { - dacu=ethr; -#ifdef VERBOSE - printf("could not set threshold energy for module %d, settings %d (offset is %f; gain is %f)\n",imod,thisSettings,myo,myg); -#endif - } - initDACbyIndexDACU(VTHRESH, dacu, imod); - } - return ret; -} - - - -dacs_t getDACbyIndexDACU(int ind, int imod) { - /* - if (detectorDacs) { - if (imodndac) - return (detectorDacs[ind+imod*NDAC]); - } - return FAIL; - */ - return setDACRegister(ind, -1, imod); -} - - - -int initDAC(int dac_cs, int dac_addr, int value, int imod) { - int i; -#ifdef VERBOSE - printf("Programming dac %d %d with value %d\n", dac_cs, dac_addr, value); -#endif - clearDACSregister(imod); - /*if (dac_cs>0) {*/ - for (i=0; i0) {*/ - for (i=0; i=0) { -#ifdef VERBOSE - fprintf(stdout, "voltage %d\n", *(v+i)); -#endif - program_one_dac(iaddr, *(v+i),imod); - } - nextDAC(imod); - } - } - clearDACSregister(imod); - for (ichip=0; ichip<3; ichip++) { - set_one_dac(imod); - nextDAC(imod); - } - - return 0; -} - - - - -int setSettings(int i) { - int imod, isett, is; - int rgpr[]=RGPRVALS; - int rgsh1[]=RGSH1VALS; - int rgsh2[]=RGSH2VALS; - int irgpr, irgsh1, irgsh2; - - int v[NDAC]; - int ind; - for (ind=0; ind>(NTRIMBITS))&1; - int ae=(reg>>(NTRIMBITS+1))&1; - int coe=(reg>>(NTRIMBITS+2))&1; - int ocoe=(reg>>(NTRIMBITS+3))&1; - int counts=(reg>>(NTRIMBITS+4)); -#ifdef VERBOSE - printf("Initializing channel %d chip %d module %d reg %x\n",myChan.chan,myChan.chip,myChan.module, reg); - printf("trim %d, cae %d, ae %d, coe %d, ocoe %d, counts %d\n",ft, cae, ae, coe, ocoe, counts); -#endif - - if (myChan.chip<0) - setCSregister(myChan.module); - else - selChip(myChan.chip,myChan.module); - - if (myChan.chan<0) - setSSregister(myChan.module); - else - selChannel(myChan.chan,myChan.module); - - initChannel(ft,cae,ae, coe, ocoe, counts,myChan.module); - - setDynamicRange(dynamicRange); - - setCSregister(ALLMOD); - clearSSregister(ALLMOD); - putout("0000000000000000",ALLMOD); - - return myChan.reg; - -} - -int getChannelbyNumber(sls_detector_channel* myChan) { - int imod, ichip, ichan; - imod=myChan->module; - ichip=myChan->chip; - ichan=myChan->chan; - - if (detectorChans) { - if (imod=0) { - if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip) - myChan->reg=detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan]; - return OK; - } - } - return FAIL; - -} - -int getTrimbit(int imod, int ichip, int ichan) { - if (detectorChans) { - if (imod=0) - if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip) - return (detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR); - } //else - return -1; - - -} - -int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod){ - - int ibit, bit, i, im, ichip, ichan; - int chanmi, chanma, chipmi, chipma, modmi, modma; - - - - sMod=imod; - // printf("initializing module %d\n",sMod); - if (imod==ALLMOD) { - sMod=allSelected; - - // printf("initializing all modules\n"); - } - - if (sChan==allSelected) { - // printf("initializing all channels ft=%d coe=%d\n",ft,coe); - chanmi=0; - chanma=NCHAN; - } else if (sChan==noneSelected || sChan>NCHAN || sChan<0) { - // printf("initializing no channels ft=%d coe=%d\n",ft,coe); - chanmi=0; - chanma=-1; - } else { - // printf("initializing channel %d ft=%d coe=%d\n",sChan, ft,coe); - chanmi=sChan; - chanma=sChan+1; - } - - if (sChip==allSelected) { - // printf("initializing all chips\n"); - chipmi=0; - chipma=NCHIP; - } else if (sChip==noneSelected || sChip>NCHIP || sChip<0) { - // printf("initializing no chips\n"); - chipmi=0; - chipma=-1; - } else { - // printf("initializing chip %d\n",sChip); - chipmi=sChip; - chipma=sChip+1; - } - - - if (sMod==allSelected) { - modmi=0; - modma=nModX;//getNModBoard(); - } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) { - modmi=0; - modma=-1; - return 1; - } else { - modmi=sMod; - modma=sMod+1; - } - - if (detectorChans) { - for (im=modmi; im63 || ft<0) { - fprintf(stdout,"Fine Threshold is %d while should be between 0 and 63!",ft); - return 1; - } - /*cal_enable*/ - if (cae) { - putout("0100000000000000",imod); - putout("0110000000000000",imod); - } else { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - } - /*n_an_enable*/ - if (ae) { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - putout("0000000000000000",imod); - } else { - putout("0100000000000000",imod); - putout("0110000000000000",imod); - putout("0100000000000000",imod); - } - /*trb5*/ - ibit=5; - bit=ft & (1<>1; - int nchan, ichan; - int ft, cae, ae, coe, ocoe, counts, chanreg; - - - - nchan=myChip.nchan; - if (ichip<0) - setCSregister(imod); - else - selChip(ichip,imod); - - clearSSregister(imod); - for (ichan=0; ichan>(NTRIMBITS+1))&1; - ae=(chanreg>>(NTRIMBITS+2))&1; - coe=((chanreg)>>(NTRIMBITS+3))&1; - ocoe=((chanreg)>>(NTRIMBITS+4))&1; - counts=((chanreg)>>(NTRIMBITS+5)); - nextStrip(imod); - initChannel(ft,cae,ae, coe, ocoe, counts,imod); - } - initChip(obe,ow,imod); - return myChip.reg; - -} - -int getChipbyNumber(sls_detector_chip* myChip){ - int imod, ichip; - imod=myChip->module; - ichip=myChip->chip; - - if (detectorChips) { - if (imodnchip) { - myChip->reg=detectorChips[ichip+imod*NCHIP]; - myChip->nchan=NCHAN; - myChip->chanregs=detectorChans+imod*NCHAN*NCHIP+ichip*NCHIP; - return OK; - } - } - return FAIL; - -} - - - -int initChip(int obe, int ow,int imod){ - int i; - int im, ichip; - int chipmi, chipma, modmi, modma; - /* switch (ow) { - case 0:; - case 1: - setDynamicRange(32); - break; - case 2: - setDynamicRange(16); - break; - case 3: - setDynamicRange(8); - break; - case 4: - setDynamicRange(4); - break; - case 5: - setDynamicRange(1); - break; - default: - setDynamicRange(32); - break; - } - */ - -#ifdef DEBUGOUT - printf("Initializing chip\n"); -#endif - putout("0000000000000000",imod); -#ifdef DEBUGOUT - printf("Output mode= %d\n", ow); -#endif - - /* clearing shift in register */ - for (i=0; i<10; i++) - putout("0000100000000000",imod); - putout("0000000000000000",imod); - - if (ow>0) { - putout("0100000000000000",imod); - putout("0110000000000000",imod); - putout("0100000000000000",imod); - for (i=0; i<(OUTMUX_OFFSET-1); i++) { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - putout("0000000000000000",imod); - } - if (ow>1) { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - putout("0000000000000000",imod); - } - if (ow>2) { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - putout("0000000000000000",imod); - } - if (ow>3) { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - putout("0000000000000000",imod); - } - if (ow>4) { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - putout("0000000000000000",imod); - } - } -#ifdef DEBUGOUT - printf("Output buffer enable= %d\n", obe); -#endif - if (obe) { - putout("0100000000000000",imod); - putout("0110000000000000",imod); - putout("0100000000000000",imod); - } else { - putout("0000000000000000",imod); - putout("0010000000000000",imod); - putout("0000000000000000",imod); - } - /*}*/ - putout("0000000000000000",imod); - - - - - - sMod=imod; - if (imod==ALLMOD) - sMod=allSelected; - - - if (sChip==allSelected) { - chipmi=0; - chipma=NCHIP; - } else if (sChip==noneSelected || sChip>NCHIP || sChip<0) { - chipmi=0; - chipma=-1; - } else { - chipmi=sChip; - chipma=sChip+1; - } - - - if (sMod==allSelected) { - modmi=0; - modma=nModX;//getNModBoard(); - } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) { - modmi=0; - modma=-1; - } else { - modmi=sMod; - modma=sMod+1; - } - - if (detectorChips) { - for (im=modmi; imNCHIP || sChip<0) { - chipmi=0; - chipma=-1; - } else { - chipmi=sChip; - chipma=sChip+1; - } - - - if (sMod==allSelected) { - modmi=0; - modma=nModX;//getNModBoard(); - } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) { - modmi=0; - modma=-1; - } else { - modmi=sMod; - modma=sMod+1; - } - - if (detectorChips) { - for (im=modmi; imnModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) { - modmi=0; - modma=-1; - } else { - modmi=sMod; - modma=sMod+1; - } - - if (detectorModules) { - for (im=modmi; imreg)=cm; -#ifdef VERBOSE - printf("imod=%d reg=%d (%x)\n",im,(detectorModules+im)->reg,(detectorModules+im)); -#endif - } - } - return 0; -} - -int initModulebyNumber(sls_detector_module myMod) { - - - int ichip, nchip, ichan, nchan; - int im, modmi,modma; - int ft, cae, ae, coe, ocoe, counts, chanreg; - int imod; - int obe; - int ow; - int v[NDAC]; - - - nchip=myMod.nchip; - nchan=(myMod.nchan)/nchip; - - imod=myMod.module; - sMod=imod; - - if (sMod==ALLMOD) - sMod=allSelected; - - if (sMod==allSelected) { - modmi=0; - modma=nModX;//getNModBoard(); - } else if (sMod==noneSelected || sMod>nModX || sMod<0) {// (sMod==noneSelected || sMod>getNModBoard() || sMod<0) { - modmi=0; - modma=-1; - } else { - modmi=sMod; - modma=sMod+1; - } - - - /* - for (idac=0; idac>(NTRIMBITS+1))&1; - ae=(chanreg>>(NTRIMBITS+2))&1; - coe=((chanreg)>>(NTRIMBITS+3))&1; - ocoe=((chanreg)>>(NTRIMBITS+4))&1; - counts=((chanreg)>>(NTRIMBITS+5)); - nextStrip(imod); - initChannel(ft,cae,ae, coe, ocoe, counts,imod); - } - obe=((myMod.chipregs)[ichip])&1; - ow=1;//((myMod.chipregs)[ichip])>>1; - initChip(obe,ow,imod); - nextChip(imod); - } - - - initMCBregisters(myMod.reg,imod); - - if (detectorModules) { - for (im=modmi; immodule; -#ifdef VERBOSE - printf("Getting module %d\n",imod); -#endif - if (detectorModules) { - copyModule(myMod,detectorModules+imod); - ; - } else - return FAIL; - - return OK; -} - -/* To chips */ -int clearCounter(int imod){ - int i; -#ifdef DEBUG - printf("Clearing counter with contclear\n"); -#endif - putout("0000000000000000",imod); - for (i=0; i<10; i++) - putout("0000000000010000",imod); - putout("0000000000000000",imod); - - return 0; -} - -int clearOutReg(int imod){ - int i; -#ifdef DEBUG - printf("Clearing output register\n"); -#endif - putout("0000010000000000",imod); - for (i=0; i<10; i++) - putout("0000110000000000",imod); - putout("0000010000000000",imod); - return 0; -} -int setOutReg(int imod){ - int i; -#ifdef DEBUG - printf("Setting output register\n"); -#endif - putout("0000010000000000",imod); - for (i=0; i<10; i++) - putout("0001010000000000",imod); - putout("0000010000000000",imod); - return 0; -} - - -int extPulse(int ncal, int imod) { - int ical; -#ifdef DEBUG - printf("Giving a clock pulse to the counter\n"); -#endif - for (ical=0; ical0 && i%2==0) { - printf("Shift in: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, i%2); - result++; - } - if (i%2>0 && (val & 1<0 && (dum & (1<0) { - printf("Shift out: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, (dum &1<0 && i%2==0) { - printf("Shift stsel: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, i%2); - result++; - } - if (i%2>0 && (val & 1<> 1; - - - putout("0000000000000000",imod); - putout("0010000000000000",imod); //change mux setting - putout("0000000000000000",imod); - } - - printf("Test FpgaMux module %d : %d errors\n", imod,result); - if (result) - return 1; - else - return 0; -} - - - - - - - - - -int calibration_sensor(int num, int *v, int *dacs) { - int ich, ichip, imod; - int val[10]; - - - printf("calibrating sensor..."); - for (imod=0; imod - - -// Hardware definitions - -#define NCHAN 128 -#define NCHIP 12 //10 modified for PICASSO -#define NMAXMODX 24 -#define NMAXMODY 1 -#define NMAXMOD NMAXMODX*NMAXMODY -#define NDAC 6 -#define NADC 0 - -#define NCHANS NCHAN*NCHIP*NMAXMOD -#define NDACS NDAC*NMAXMOD - -#define NTRIMBITS 6 -#define NCOUNTBITS 24 - -//#define TRIM_DR ((2**NTRIMBITS)-1) -//#define COUNT_DR ((2**NCOUNTBITS)-1) -#define TRIM_DR (((int)pow(2,NTRIMBITS))-1) -#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1) - - -#define ALLMOD 0xffff -#define ALLFIFO 0xffff - -#ifdef VIRTUAL -#define DEBUGOUT -#endif - -#define CLK_FREQ 100E+6 - - -#define THIS_SOFTWARE_VERSION 0x20090205 -#endif diff --git a/slsDetectorSoftware/mythenDetectorServer/registers.h b/slsDetectorSoftware/mythenDetectorServer/registers.h deleted file mode 100755 index 32f479c3a..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/registers.h +++ /dev/null @@ -1,184 +0,0 @@ -#ifndef REGISTERS_H -#define REGISTERS_H - - - -/* Definitions for FPGA*/ -#define CSP0 0x90000000 // Base Addresse CSP0 -#define CSP4 0xa0000000 // Base Addresse CSP4 - -//#define MEM_SIZE 0xFFFFFF // map so much memory -#define MEM_SIZE 0xFFFFFFF // map so much memory - - - -/* registers defined in FPGA */ -#define FIX_PATT_REG 0x000000 -#define FPGA_VERSION_REG 0x001000 -#define DUMMY_REG 0x002000 -#define CONTROL_REG 0x003000 -#define STATUS_REG 0x004000 -#define CONFIG_REG 0x005000 -#define SPEED_REG 0x006000 -#define EXT_SIGNAL_REG 0x007000 -#define SET_NBITS_REG 0x008000 -#define LOOK_AT_ME_REG 0x009000 - -#define SET_FRAMES_LSB_REG 0x00A000 -#define SET_FRAMES_MSB_REG 0x00B000 -#define GET_FRAMES_LSB_REG 0x00C000 -#define GET_FRAMES_MSB_REG 0x00D000 - -#define SET_EXPTIME_LSB_REG 0x00E000 -#define SET_EXPTIME_MSB_REG 0x00F000 -#define GET_EXPTIME_LSB_REG 0x010000 -#define GET_EXPTIME_MSB_REG 0x011000 - -#define SET_GATES_LSB_REG 0x012000 -#define SET_GATES_MSB_REG 0x013000 -#define GET_GATES_LSB_REG 0x014000 -#define GET_GATES_MSB_REG 0x015000 - -#define SET_PERIOD_LSB_REG 0x016000 -#define SET_PERIOD_MSB_REG 0x017000 -#define GET_PERIOD_LSB_REG 0x018000 -#define GET_PERIOD_MSB_REG 0x019000 - -#define SET_DELAY_LSB_REG 0x01A000 -#define SET_DELAY_MSB_REG 0x01B000 -#define GET_DELAY_LSB_REG 0x01C000 -#define GET_DELAY_MSB_REG 0x01D000 - -#define SET_TRAINS_LSB_REG 0x01E000 -#define SET_TRAINS_MSB_REG 0x01F000 -#define GET_TRAINS_LSB_REG 0x020000 -#define GET_TRAINS_MSB_REG 0x021000 - - -#define GET_SHIFT_IN_REG 0x022000 - -#define GET_MEASUREMENT_TIME_LSB_REG 0x023000 -#define GET_MEASUREMENT_TIME_MSB_REG 0x024000 - -#define GET_ACTUAL_TIME_LSB_REG 0x025000 -#define GET_ACTUAL_TIME_MSB_REG 0x026000 - -#define MOD_DACS1_REG 0x030000 -#define MOD_DACS2_REG 0x040000 - -#define MCB_CNTRL_REG_OFF 0x100000 -#define MCB_DOUT_REG_OFF 0x200000 -#define FIFO_CNTRL_REG_OFF 0x300000 -#define FIFO_COUNTR_REG_OFF 0x400000 -#define FIFO_DATA_REG_OFF 0x800000 - -#define SHIFTMOD 2 -#define SHIFTFIFO 9 - - - -/* values defined for FPGA */ -#define MCSNUM 0x0 -#define MCSVERSION 0x101 -#define FIXED_PATT_VAL 0xacdc1980 -#define FPGA_VERSION_VAL 0x00090514 -#define FPGA_INIT_PAT 0x60008 -#define FPGA_INIT_ADDR 0xb0000000 - -/* for control register */ -#define START_ACQ_BIT 0x00000001 -#define STOP_ACQ_BIT 0x00000002 -#define START_FIFOTEST_BIT 0x00000004 // ????? -#define STOP_FIFOTEST_BIT 0x00000008 // ?????? -#define START_READOUT_BIT 0x00000010 -#define STOP_READOUT_BIT 0x00000020 -#define START_EXPOSURE_BIT 0x00000040 -#define STOP_EXPOSURE_BIT 0x00000080 -#define START_TRAIN_BIT 0x00000100 -#define STOP_TRAIN_BIT 0x00000200 -#define SYNC_RESET 0x80000000 - -/* for status register */ -#define RUN_BUSY_BIT 0x00000001 -#define READOUT_BUSY_BIT 0x00000002 -#define FIFOTEST_BUSY_BIT 0x00000004 //???? -#define WAITING_FOR_TRIGGER_BIT 0x00000008 -#define DELAYBEFORE_BIT 0x00000010 -#define DELAYAFTER_BIT 0x00000020 -#define EXPOSING_BIT 0x00000040 -#define COUNT_ENABLE_BIT 0x00000080 -#define SOME_FIFO_FULL_BIT 0x00008000 // error! -#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready - -/* for fifo status register */ -#define FIFO_ENABLED_BIT 0x80000000 -#define FIFO_DISABLED_BIT 0x01000000 -#define FIFO_ERROR_BIT 0x08000000 -#define FIFO_EMPTY_BIT 0x04000000 -#define FIFO_DATA_READY_BIT 0x02000000 -#define FIFO_COUNTER_MASK 0x000001ff -#define FIFO_NM_MASK 0x00e00000 -#define FIFO_NM_OFF 21 -#define FIFO_NC_MASK 0x001ffe00 -#define FIFO_NC_OFF 9 - -/* for config register */ - -#define TOT_ENABLE_BIT 0x00000002 -#define TIMED_GATE_BIT 0x00000004 -#define CONT_RO_ENABLE_BIT 0x00080000 - - - -/* for speed register */ - -#define CLK_DIVIDER_MASK 0x000000ff -#define CLK_DIVIDER_OFFSET 0 -#define SET_LENGTH_MASK 0x00000f00 -#define SET_LENGTH_OFFSET 8 -#define WAIT_STATES_MASK 0x0000f000 -#define WAIT_STATES_OFFSET 12 -#define TOTCLK_DIVIDER_MASK 0xff000000 -#define TOTCLK_DIVIDER_OFFSET 24 -#define TOTCLK_DUTYCYCLE_MASK 0x00ff0000 -#define TOTCLK_DUTYCYCLE_OFFSET 16 - -/* for external signal register */ - -#define SIGNAL_OFFSET 4 -#define SIGNAL_MASK 0xF -#define EXT_SIG_OFF 0x0 -#define EXT_GATE_IN_ACTIVEHIGH 0x1 -#define EXT_GATE_IN_ACTIVELOW 0x2 -#define EXT_TRIG_IN_RISING 0x3 -#define EXT_TRIG_IN_FALLING 0x4 -#define EXT_RO_TRIG_IN_RISING 0x5 -#define EXT_RO_TRIG_IN_FALLING 0x6 -#define EXT_GATE_OUT_ACTIVEHIGH 0x7 -#define EXT_GATE_OUT_ACTIVELOW 0x8 -#define EXT_TRIG_OUT_RISING 0x9 -#define EXT_TRIG_OUT_FALLING 0xA -#define EXT_RO_TRIG_OUT_RISING 0xB -#define EXT_RO_TRIG_OUT_FALLING 0xC -#define EXT_OUT_LOW 0xD // to be implemented in firmware (and corrected in software) -#define EXT_OUT_HIGH 0xE // to be implemented in firmware (and corrected in software) -#define EXT_MASTER_SLAVE_SYNC 0xF // to be implemented in firmware (and corrected in software) - - - -/* fifo control register */ -#define FIFO_RESET_BIT 0x00000001 -#define FIFO_DISABLE_TOGGLE_BIT 0x00000002 - - -//chip shiftin register meaning - -#define OUTMUX_OFF 20 -#define OUTMUX_MASK 0x1f -#define PROBES_OFF 4 -#define PROBES_MASK 0x7f -#define OUTBUF_OFF 0 -#define OUTBUF_MASK 1 - - -#endif diff --git a/slsDetectorSoftware/mythenDetectorServer/server.c b/slsDetectorSoftware/mythenDetectorServer/server.c deleted file mode 100755 index f39b221f5..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/server.c +++ /dev/null @@ -1,91 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ -#include "communication_funcs.h" -#include "server_funcs.h" -#include - - -extern int sockfd; - - -void error(char *msg) -{ - perror(msg); -} - -int main(int argc, char *argv[]) -{ - int portno, b; - char cmd[100]; - int retval=OK; - int sd, fd; - - - if (argc==1) { - portno = DEFAULT_PORTNO; - sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1); - printf("opening control server on port %d\n",portno ); - system(cmd); - b=1; - } else { - portno = DEFAULT_PORTNO+1; - if ( sscanf(argv[1],"%d",&portno) ==0) { - printf("could not open stop server: unknown port\n"); - return 1; - } - b=0; - printf("opening stop server on port %d\n",portno); - } - - - - init_detector(b); //defined in server_funcs - - - sd=bindSocket(portno); //defined in communication_funcs - - sockfd=sd; - - - if (getServerError(sd)) { //defined in communication_funcs - printf("server error!\n"); - return -1; - } - - /* assign function table */ - function_table(); //defined in server_funcs -#ifdef VERBOSE - printf("function table assigned \n"); -#endif - - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Waiting for client call\n"); -#endif - fd=acceptConnection(sockfd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("Conenction accepted\n"); -#endif - if (fd>0) { - retval=decode_function(fd); //defined in server_funcs -#ifdef VERY_VERBOSE - printf("function executed\n"); -#endif - closeConnection(fd); //defined in communication_funcs -#ifdef VERY_VERBOSE - printf("connection closed\n"); -#endif - } - } - - exitServer(sockfd); //defined in communication_funcs - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/mythenDetectorServer/server_defs.h b/slsDetectorSoftware/mythenDetectorServer/server_defs.h deleted file mode 100755 index e91bb5685..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/server_defs.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef SERVER_DEFS_H -#define SERVER_DEFS_H - -#include "sls_detector_defs.h" - -#include - - -// Hardware definitions - -#define NCHAN 128 -#define NCHIP 10 -#define NMAXMODX 24 -#define NMAXMODY 1 -#define NMAXMOD NMAXMODX*NMAXMODY -#define NDAC 6 -#define NADC 0 - -#define NCHANS NCHAN*NCHIP*NMAXMOD -#define NDACS NDAC*NMAXMOD - -#define NTRIMBITS 6 -#define NCOUNTBITS 24 - -//#define TRIM_DR ((2**NTRIMBITS)-1) -//#define COUNT_DR ((2**NCOUNTBITS)-1) -#define TRIM_DR (((int)pow(2,NTRIMBITS))-1) -#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1) - - -#define ALLMOD 0xffff -#define ALLFIFO 0xffff - -#ifdef VIRTUAL -#define DEBUGOUT -#endif - -#define CLK_FREQ 100E+6 - - -#define THIS_SOFTWARE_VERSION 0x20120419 -#define THIS_REVISION "$Rev: 379 $" -#endif diff --git a/slsDetectorSoftware/mythenDetectorServer/server_funcs.c b/slsDetectorSoftware/mythenDetectorServer/server_funcs.c deleted file mode 100755 index ce0b86fef..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/server_funcs.c +++ /dev/null @@ -1,2857 +0,0 @@ -#include "sls_detector_defs.h" -#include "server_funcs.h" -#ifndef PICASSOD -#include "server_defs.h" -#else -#include "picasso_defs.h" -#endif -#include "firmware_funcs.h" -#include "mcb_funcs.h" -#include "trimming_funcs.h" -#include "gitInfoMythen.h" - -// Global variables - -int (*flist[256])(int); - - - -#ifdef MCB_FUNCS -extern const enum detectorType myDetectorType; -#endif -#ifndef MCB_FUNCS -const enum detectorType myDetectorType=MYTHEN; -#endif -extern int nModX; -extern int nModY; -extern int dataBytes; -extern int dynamicRange; -extern int storeInRAM; - -extern int lockStatus; -extern char lastClientIP[INET_ADDRSTRLEN]; -extern char thisClientIP[INET_ADDRSTRLEN]; -extern int differentClients; - -/* global variables for optimized readout */ -extern int *ram_values; -char *dataretval=NULL; -int nframes, iframes, dataret; -char mess[MAX_STR_LENGTH]; - - - - - -int init_detector( int b) { -#ifndef PICASSOD - printf("This is a MYTHEN detector with %d chips per module\n", NCHIP); -#else - printf("This is a PICASSO detector with %d chips per module\n", NCHIP); -#endif - mapCSP0(); -#ifndef VIRTUAL - system("bus -a 0xb0000000 -w 0xd0008"); -#ifdef VERBOSE - printf("setting wait states \n"); - system("bus -a 0xb0000000"); -#endif -#endif - testFpga(); - if (b) { -#ifdef MCB_FUNCS - initDetector(); - printf("init \n"); - setSettings(GET_SETTINGS); - printf("get settings \n"); - testRAM(); - printf("test ram \n"); -#endif - setTiming(GET_EXTERNAL_COMMUNICATION_MODE); - printf("timing \n"); - setMaster(GET_MASTER); - printf("master \n"); - setSynchronization(GET_SYNCHRONIZATION_MODE); - printf("sync \n"); - } - strcpy(mess,"dummy message"); - strcpy(lastClientIP,"none"); - strcpy(thisClientIP,"none1"); - lockStatus=0; - return OK; -} - - -int decode_function(int file_des) { - int fnum,n; - int retval=FAIL; -#ifdef VERBOSE - printf( "receive data\n"); -#endif - n = receiveDataOnly(file_des,&fnum,sizeof(fnum)); - if (n <= 0) { - printf("ERROR reading from socket %d, %d %d\n", n, fnum, file_des); - return FAIL; - } -#ifdef VERBOSE - else - printf("size of data received %d\n",n); -#endif - -#ifdef VERBOSE - printf( "calling function fnum = %d %x\n",fnum,flist[fnum]); -#endif - if (fnum<0 || fnum>255) - fnum=255; - retval=(*flist[fnum])(file_des); - if (retval==FAIL) - printf( "Error executing the function = %d \n",fnum); - return retval; -} - - -int function_table() { - int i; - for (i=0;i<256;i++){ - flist[i]=&M_nofunc; - } - flist[F_EXIT_SERVER]=&exit_server; - flist[F_EXEC_COMMAND]=&exec_command; - flist[F_GET_DETECTOR_TYPE]=&get_detector_type; - flist[F_SET_NUMBER_OF_MODULES]=&set_number_of_modules; - flist[F_GET_MAX_NUMBER_OF_MODULES]=&get_max_number_of_modules; - flist[F_SET_EXTERNAL_SIGNAL_FLAG]=&set_external_signal_flag; - flist[F_SET_EXTERNAL_COMMUNICATION_MODE]=&set_external_communication_mode; - flist[F_GET_ID]=&get_id; - flist[F_DIGITAL_TEST]=&digital_test; - flist[F_WRITE_REGISTER]=&write_register; - flist[F_READ_REGISTER]=&read_register; - flist[F_SET_DAC]=&set_dac; - flist[F_GET_ADC]=&get_adc; - flist[F_SET_CHANNEL]=&set_channel; - flist[F_SET_CHIP]=&set_chip; - flist[F_SET_MODULE]=&set_module; - flist[F_GET_CHANNEL]=&get_channel; - flist[F_GET_CHIP]=&get_chip; - flist[F_GET_MODULE]=&get_module; - flist[F_GET_THRESHOLD_ENERGY]=&get_threshold_energy; - flist[F_SET_THRESHOLD_ENERGY]=&set_threshold_energy; - flist[F_SET_SETTINGS]=&set_settings; - flist[F_START_ACQUISITION]=&start_acquisition; - flist[F_STOP_ACQUISITION]=&stop_acquisition; - flist[F_START_READOUT]=&start_readout; - flist[F_GET_RUN_STATUS]=&get_run_status; - flist[F_READ_FRAME]=&read_frame; - flist[F_READ_ALL]=&read_all; - flist[F_START_AND_READ_ALL]=&start_and_read_all; - flist[F_SET_TIMER]=&set_timer; - flist[F_GET_TIME_LEFT]=&get_time_left; - flist[F_SET_DYNAMIC_RANGE]=&set_dynamic_range; - flist[F_SET_ROI]=&set_roi; - flist[F_SET_SPEED]=&set_speed; - flist[F_SET_READOUT_FLAGS]=&set_readout_flags; - flist[F_EXECUTE_TRIMMING]=&execute_trimming; - flist[F_LOCK_SERVER]=&lock_server; - flist[F_SET_PORT]=&set_port; - flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip; - flist[F_UPDATE_CLIENT]=&update_client; - flist[F_SET_MASTER]=&set_master; - flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization; -#ifdef VERBOSE - /* for (i=0;i<256;i++){ - printf("function %d located at %x\n",i,flist[i]); - }*/ -#endif - return OK; -} - - -int M_nofunc(int file_des){ - - int retval=FAIL; - sprintf(mess,"Unrecognized Function\n"); - printf(mess); - sendDataOnly(file_des,&retval,sizeof(retval)); - sendDataOnly(file_des,mess,sizeof(mess)); - return GOODBYE; -} - - -int exit_server(int file_des) { - int retval=FAIL; - sendDataOnly(file_des,&retval,sizeof(retval)); - printf("closing server."); - sprintf(mess,"closing server"); - sendDataOnly(file_des,mess,sizeof(mess)); - return GOODBYE; -} - -int exec_command(int file_des) { - char cmd[MAX_STR_LENGTH]; - char answer[MAX_STR_LENGTH]; - int retval=OK; - int sysret=0; - int n=0; - - /* receive arguments */ - n = receiveDataOnly(file_des,cmd,MAX_STR_LENGTH); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } - - /* execute action if the arguments correctly arrived*/ - if (retval==OK) { -#ifdef VERBOSE - printf("executing command %s\n", cmd); -#endif - if (lockStatus==0 || differentClients==0) - sysret=system(cmd); - - //should be replaced by popen - if (sysret==0) { - sprintf(answer,"Succeeded\n"); - if (lockStatus==1 && differentClients==1) - sprintf(answer,"Detector locked by %s\n", lastClientIP); - } else { - sprintf(answer,"Failed\n"); - retval=FAIL; - } - } else { - sprintf(answer,"Could not receive the command\n"); - } - - /* send answer */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - n = sendDataOnly(file_des,answer,MAX_STR_LENGTH); - if (n < 0) { - sprintf(mess,"Error writing to socket"); - retval=FAIL; - } - - - /*return ok/fail*/ - return retval; - -} - - - -int get_detector_type(int file_des) { - int n=0; - enum detectorType ret; - int retval=OK; - - sprintf(mess,"Can't return detector type\n"); - - - /* receive arguments */ - /* execute action */ - ret=myDetectorType; - -#ifdef VERBOSE - printf("Returning detector type %d\n",ret); -#endif - - /* send answer */ - /* send OK/failed */ - if (differentClients==1) - retval=FORCE_UPDATE; - - n += sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - /*return ok/fail*/ - return retval; - - -} - - -int set_number_of_modules(int file_des) { - int n; - int arg[2], ret=0; - int retval=OK; - int dim, nm; - - sprintf(mess,"Can't set number of modules\n"); - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket %d", n); - retval=GOODBYE; - } - if (retval==OK) { - dim=arg[0]; - nm=arg[1]; - - /* execute action */ -#ifdef VERBOSE - printf("Setting the number of modules in dimension %d to %d\n",dim,nm ); -#endif - - //if (nm!=GET_FLAG) { - if (dim!=X && nm!=GET_FLAG) { - retval=FAIL; - sprintf(mess,"Can't change module number in dimension %d\n",dim); - } else { - if (lockStatus==1 && differentClients==1 && nm!=GET_FLAG) { - sprintf(mess,"Detector locked by %s\n", lastClientIP); - retval=FAIL; - } else { - ret=setNMod(nm); - if (nModX==nm || nm==GET_FLAG) { - retval=OK; - if (differentClients==1) - retval=FORCE_UPDATE; - } else - retval=FAIL; - } - } - } - /*} else { - if (dim==Y) { - ret=nModY; - } else if (dim==X) { - ret=setNMod(-1); - } - } - */ - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - /*return ok/fail*/ - return retval; - -} - - -int get_max_number_of_modules(int file_des) { - int n; - int ret; - int retval=OK; - enum dimension arg; - - sprintf(mess,"Can't get max number of modules\n"); - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } - /* execute action */ -#ifdef VERBOSE - printf("Getting the max number of modules in dimension %d \n",arg); -#endif - - - switch (arg) { - case X: - ret=getNModBoard(); - break; - case Y: - ret=NMAXMODY; - break; - default: - ret=FAIL; - retval=FAIL; - } -#ifdef VERBOSE - printf("Max number of module in dimension %d is %d\n",arg,ret ); -#endif - - - - if (differentClients==1 && retval==OK) { - retval=FORCE_UPDATE; - } - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - - /*return ok/fail*/ - return retval; -} - - -//index 0 is in gate -//index 1 is in trigger -//index 2 is out gate -//index 3 is out trigger - -int set_external_signal_flag(int file_des) { - int n; - int arg[2]; - int ret=OK; - int signalindex; - enum externalSignalFlag flag, retval; - - sprintf(mess,"Can't set external signal flag\n"); - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - retval=SIGNAL_OFF; - if (ret==OK) { - signalindex=arg[0]; - flag=arg[1]; - /* execute action */ - switch (flag) { - case GET_EXTERNAL_SIGNAL_FLAG: - retval=getExtSignal(signalindex); - break; - - default: - if (differentClients==0 || lockStatus==0) { - retval=setExtSignal(signalindex,flag); - } else { - if (lockStatus!=0) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n", lastClientIP); - } - } - - - } - -#ifdef VERBOSE - printf("Setting external signal %d to flag %d\n",signalindex,flag ); - printf("Set to flag %d\n",retval); -#endif - - } else { - ret=FAIL; - } - - if (ret==OK && differentClients!=0) - ret=FORCE_UPDATE; - - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - /*return ok/fail*/ - return ret; - -} - - -int set_external_communication_mode(int file_des) { - int n; - enum externalCommunicationMode arg, ret=GET_EXTERNAL_COMMUNICATION_MODE; - int retval=OK; - - sprintf(mess,"Can't set external communication mode\n"); - - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } - /* -enum externalCommunicationMode{ - GET_EXTERNAL_COMMUNICATION_MODE, - AUTO, - TRIGGER_EXPOSURE_SERIES, - TRIGGER_EXPOSURE_BURST, - TRIGGER_READOUT, - TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE, - GATE_FIX_NUMBER, - GATE_FIX_DURATION, - GATE_WITH_START_TRIGGER, - GATE_COINCIDENCE_WITH_INTERNAL_ENABLE -}; - */ - if (retval==OK) { - /* execute action */ - - ret=setTiming(arg); - -/* switch(arg) { */ -/* default: */ -/* sprintf(mess,"The meaning of single signals should be set\n"); */ -/* retval=FAIL; */ -/* } */ - - -#ifdef VERBOSE - printf("Setting external communication mode to %d\n", arg); -#endif - } else - ret=FAIL; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&retval,sizeof(retval)); - if (retval!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&ret,sizeof(ret)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return retval; - - -} - - - -int get_id(int file_des) { - // sends back 64 bits! - int64_t retval, rev, dat; - int ret=OK; - int imod=-1; - int n=0; - int rev1; - enum idMode arg; - - sprintf(mess,"Can't return id\n"); - - /* receive arguments */ - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - -#ifdef VERBOSE - printf("Getting id %d\n", arg); -#endif - - switch (arg) { - case MODULE_SERIAL_NUMBER: - n = receiveDataOnly(file_des,&imod,sizeof(imod)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } else { -#ifdef VERBOSE - printf("of module %d\n", imod); -#endif - if (imod>=0 && imod<=getNModBoard()) { -#ifdef MCB_FUNCS - retval=getModuleNumber(imod); -#endif - ; - } - else { - sprintf(mess,"Module number %d out of range\n",imod); - ret=FAIL; - } - } - break; - case MODULE_FIRMWARE_VERSION: - retval=0x1; - break; - case DETECTOR_SERIAL_NUMBER: - retval=getMcsNumber(); - break; - case DETECTOR_FIRMWARE_VERSION: - retval=getMcsVersion(); - break; - case DETECTOR_SOFTWARE_VERSION: - retval= GITREV; - retval= (retval <<32) | GITDATE; -/* sscanf(THIS_REVISION,"$Rev : %x",&rev1); - rev=((int64_t)rev1); - dat=THIS_SOFTWARE_VERSION; - retval=(dat<<32) | rev; - */ - break; - default: - printf("Required unknown id %d \n", arg); - ret=FAIL; - retval=FAIL; - } - -#ifdef VERBOSE - printf("Id is %llx\n", retval); -#endif - - if (differentClients==1) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - -int digital_test(int file_des) { - - int retval; - int ret=OK; - int imod=-1; - int n=0; - int ibit=0; - int ow; - enum digitalTestMode arg; - - sprintf(mess,"Can't send digital test\n"); - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - -#ifdef VERBOSE - printf("Digital test mode %d\n",arg ); -#endif - - switch (arg) { - case CHIP_TEST: - n = receiveDataOnly(file_des,&imod,sizeof(imod)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - retval=FAIL; - } -#ifdef VERBOSE - printf("of module %d\n", imod); -#endif - retval=0; -#ifdef MCB_FUNCS - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - break; - } - if (imod >= nModX) { - ret=FAIL; - sprintf(mess,"Module %d disabled\n",imod); - break; - } - if (testShiftIn(imod)) retval|=(1<<(ibit)); - ibit++; - if (testShiftOut(imod)) retval|=(1<<(ibit)); - ibit++; - if (testShiftStSel(imod)) retval|=(1<<(ibit)); - ibit++; - //if ( testDataInOut(0x123456, imod)) retval|=(1<<(ibit++)); - //if ( testExtPulse(imod)) retval|=(1<<(ibit++)); - // for (ow=0; ow<6; ow++) - // ow=1; - //#ifndef PICASSOD - for (ow=0; ow<5; ow++) { - //#endif - if (testDataInOutMux(imod, ow, 0x789abc)) retval|=(1<=getNModBoard()) - ret=FAIL; - if (imod<0) - imod=ALLMOD; - -#ifdef MCB_FUNCS - switch (ind) { - case TRIMBIT_SIZE: - idac=VTRIM; - break; - case THRESHOLD: - idac=VTHRESH; - break; - case SHAPER1: - idac=RGSH1; - break; - case SHAPER2: - idac=RGSH2; - break; - case CALIBRATION_PULSE: - idac=VCAL; - break; - case PREAMP: - idac=RGPR; - break; - /*************************************************************** -add possible potentiometers like in chiptest board!!!!!!!!!!!!!!! - - ****************************************************************/ - - - - - default: - printf("Unknown DAC index %d\n",ind); - sprintf(mess,"Unknown DAC index %d\n",ind); - ret=FAIL; - } - - if (ret==OK) { - if (differentClients==1 && lockStatus==1 && val!=-1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else - retval=initDACbyIndexDACU(idac,val,imod); - } -#endif - -#ifdef VERBOSE - printf("DAC set to %f V\n", retval); -#endif - if (retval==val || val==-1) { - ret=OK; - if (differentClients) - ret=FORCE_UPDATE; - } else { - ret=FAIL; - printf("Setting dac %d of module %d: wrote %f but read %f\n", ind, imod, val, retval); - } - - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /* Maybe this is done inside the initialization funcs */ - //detectorDacs[imod][ind]=val; - /*return ok/fail*/ - return ret; - -} - - - -int get_adc(int file_des) { - - dacs_t retval; - int ret=OK; - int arg[2]; - enum dacIndex ind; - int imod; - int n; - int idac=0; - - sprintf(mess,"Can't read ADC\n"); - - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - ind=arg[0]; - imod=arg[1]; - - - if (imod>=getNModBoard() || imod<0) - ret=FAIL; - -#ifdef MCB_FUNCS - switch (ind) { - case TRIMBIT_SIZE: - idac=VTRIM; - break; - case THRESHOLD: - idac=VTHRESH; - break; - case SHAPER1: - idac=RGSH1; - break; - case SHAPER2: - idac=RGSH2; - break; - case CALIBRATION_PULSE: - idac=VCAL; - break; - case PREAMP: - idac=RGPR; - break; - default: - printf("Unknown DAC index %d\n",ind); - ret=FAIL; - sprintf(mess,"Unknown DAC index %d\n",ind); - } - - if (ret==OK) { - retval=getDACbyIndexDACU(idac,imod); - } - #endif -#ifdef VERBOSE - printf("Getting ADC %d of module %d\n", ind, imod); -#endif - -#ifdef VERBOSE - printf("ADC is %f V\n", retval); -#endif - if (ret==FAIL) { - printf("Getting adc %d of module %d failed\n", ind, imod); - } - - - if (differentClients) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - /*return ok/fail*/ - return ret; - -} - -int set_channel(int file_des) { - int ret=OK; - sls_detector_channel myChan; - int retval; - int n; - - - sprintf(mess,"Can't set channel\n"); - -#ifdef VERBOSE - printf("Setting channel\n"); -#endif - ret=receiveChannel(file_des, &myChan); - if (ret>=0) - ret=OK; - else - ret=FAIL; -#ifdef VERBOSE - printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg); -#endif - - if (ret==OK) { - if (myChan.module>=getNModBoard()) - ret=FAIL; - if (myChan.chip>=NCHIP) - ret=FAIL; - if (myChan.chan>=NCHAN) - ret=FAIL; - if (myChan.module<0) - myChan.module=ALLMOD; - } - - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { -#ifdef MCB_FUNCS - retval=initChannelbyNumber(myChan); -#endif - } - } - /* Maybe this is done inside the initialization funcs */ - //copyChannel(detectorChans[myChan.module][myChan.chip]+(myChan.chan), &myChan); - - - - if (differentClients==1 && ret==OK) - ret=FORCE_UPDATE; - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - /*return ok/fail*/ - return ret; - -} - - - - -int get_channel(int file_des) { - - int ret=OK; - sls_detector_channel retval; - - int arg[3]; - int ichan, ichip, imod; - int n; - - sprintf(mess,"Can't get channel\n"); - - - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - ichan=arg[0]; - ichip=arg[1]; - imod=arg[2]; - - if (ret==OK) { - ret=FAIL; - if (imod>=0 && imod=0 && ichip=0 && ichan=0) - ret=OK; - else - ret=FAIL; -#ifdef VERBOSE - printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan); -#endif - - if (ret==OK) { - if (myChip.module>=getNModBoard()) - ret=FAIL; - if (myChip.module<0) - myChip.module=ALLMOD; - if (myChip.chip>=NCHIP) - ret=FAIL; - } - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { -#ifdef MCB_FUNCS - retval=initChipbyNumber(myChip); -#endif - } - /* Maybe this is done inside the initialization funcs */ - //copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip); - - if (differentClients && ret==OK) - ret=FORCE_UPDATE; - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - - - return ret; -} - -int get_chip(int file_des) { - - - int ret=OK; - sls_detector_chip retval; - int arg[2]; - int ichip, imod; - int n; - - - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - ichip=arg[0]; - imod=arg[1]; - if (ret==OK) { - ret=FAIL; - if (imod>=0 && imod=0 && ichip=0) - ret=OK; - else - ret=FAIL; - - -#ifdef VERBOSE - printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n",myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset); -#endif - - if (ret==OK) { - if (myModule.module>=getNModBoard()) { - ret=FAIL; - printf("Module number is too large %d\n",myModule.module); - } - if (myModule.module<0) - myModule.module=ALLMOD; - } - - if (ret==OK) { - if (differentClients==1 && lockStatus==1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { -#ifdef MCB_FUNCS - retval=initModulebyNumber(myModule); -#endif - } - } - - if (differentClients==1 && ret==OK) - ret=FORCE_UPDATE; - - /* Maybe this is done inside the initialization funcs */ - //copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip); - - /* send answer */ - /* send OK/failed */ - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret!=FAIL) { - /* send return argument */ - n += sendDataOnly(file_des,&retval,sizeof(retval)); - } else { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } - free(myChip); - free(myChan); - free(myDac); - free(myAdc); - - setDynamicRange(dr); - - - return ret; -} - - - - -int get_module(int file_des) { - - - int ret=OK; - - - int arg; - int imod; - int n; - - - - sls_detector_module myModule; - int *myChip=malloc(NCHIP*sizeof(int)); - int *myChan=malloc(NCHIP*NCHAN*sizeof(int)); - dacs_t *myDac=malloc(NDAC*sizeof(dacs_t)); - dacs_t *myAdc=malloc(NADC*sizeof(dacs_t)); - - - if (myDac) - myModule.dacs=myDac; - else { - sprintf(mess,"could not allocate dacs\n"); - ret=FAIL; - } - if (myAdc) - myModule.adcs=myAdc; - else { - sprintf(mess,"could not allocate adcs\n"); - ret=FAIL; - } - if (myChip) - myModule.chipregs=myChip; - else { - sprintf(mess,"could not allocate chips\n"); - ret=FAIL; - } - if (myChan) - myModule.chanregs=myChan; - else { - sprintf(mess,"could not allocate chans\n"); - ret=FAIL; - } - - myModule.ndac=NDAC; - myModule.nchip=NCHIP; - myModule.nchan=NCHAN*NCHIP; - myModule.nadc=NADC; - - - - - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - imod=arg; - - if (ret==OK) { - ret=FAIL; - if (imod>=0 && imod-2) { - dataret=FAIL; - sprintf(mess,"no data and run stopped: %d frames left\n",getFrames()+2); - printf("%s\n",mess); - } else { - dataret=FINISHED; - sprintf(mess,"acquisition successfully finished\n"); - printf("%s\n",mess); - } -#ifdef VERYVERBOSE - printf("%d %d %x %s\n",sizeof(mess),strlen(mess), mess,mess); -#endif - sendDataOnly(file_des,&dataret,sizeof(dataret)); - sendDataOnly(file_des,mess,sizeof(mess));//sizeof(mess));//sizeof(mess)); -#ifdef VERYVERBOSE - printf("message sent\n",mess); -#endif - printf("dataret %d\n",dataret); - return dataret; - } - } else { - nframes=0; - while(fifo_read_event()) { - nframes++; - } - dataretval=(char*)ram_values; - dataret=OK; -#ifdef VERBOSE - printf("sending data of %d frames\n",nframes); -#endif - for (iframes=0; iframes-2) { - dataret=FAIL; - sprintf(mess,"no data and run stopped: %d frames left\n",getFrames()+2); - printf("%s\n",mess); - } else { - dataret=FINISHED; - sprintf(mess,"acquisition successfully finished\n"); - printf("%s\n",mess); - if (differentClients) - dataret=FORCE_UPDATE; - } -#ifdef VERBOSE - printf("Frames left %d\n",getFrames()); -#endif - sendDataOnly(file_des,&dataret,sizeof(dataret)); - sendDataOnly(file_des,mess,sizeof(mess)); - printf("dataret %d\n",dataret); - return dataret; - } - printf("dataret %d\n",dataret); - return dataret; -} - - - - - - - - -int read_all(int file_des) { - - - while(read_frame(file_des)==OK) { -#ifdef VERBOSE - printf("frame read\n"); -#endif - ; - } - -#ifdef VERBOSE - printf("Frames finished\n"); -#endif - return OK; - - -} - -int start_and_read_all(int file_des) { - //int dataret=OK; -#ifdef VERBOSE - printf("Starting and reading all frames\n"); -#endif - - if (differentClients==1 && lockStatus==1) { - dataret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - sendDataOnly(file_des,&dataret,sizeof(dataret)); - sendDataOnly(file_des,mess,sizeof(mess)); - return dataret; - - } - - - startStateMachine(); - /* ret=startStateMachine(); - if (ret!=OK) { - sprintf(mess,"could not start state machine\n"); - sendDataOnly(file_des,&ret,sizeof(ret)); - sendDataOnly(file_des,mess,sizeof(mess)); - - #ifdef VERBOSE - printf("could not start state machine\n"); -#endif -} else {*/ - read_all(file_des); -#ifdef VERBOSE - printf("Frames finished\n"); -#endif - //} - - - return OK; - - -} - -int set_timer(int file_des) { - enum timerIndex ind; - int64_t tns; - int n; - int64_t retval; - int ret=OK; - - - sprintf(mess,"can't set timer\n"); - - n = receiveDataOnly(file_des,&ind,sizeof(ind)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - n = receiveDataOnly(file_des,&tns,sizeof(tns)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - if (ret!=OK) { - printf(mess); - } - -#ifdef VERBOSE - printf("setting timer %d to %lld ns\n",ind,tns); -#endif - if (ret==OK) { - - if (differentClients==1 && lockStatus==1 && tns!=-1) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - switch(ind) { - case FRAME_NUMBER: - retval=setFrames(tns); - break; - case ACQUISITION_TIME: - retval=setExposureTime(tns); - break; - case FRAME_PERIOD: - retval=setPeriod(tns); - break; - case DELAY_AFTER_TRIGGER: - retval=setDelay(tns); - break; - case GATES_NUMBER: - retval=setGates(tns); - break; - case PROBES_NUMBER: - retval=setProbes(tns); - break; - case CYCLES_NUMBER: - retval=setTrains(tns); - break; - default: - ret=FAIL; - sprintf(mess,"timer index unknown %d\n",ind); - } - } - } - if (ret!=OK) { - printf(mess); - if (differentClients) - ret=FORCE_UPDATE; - } - - if (ret!=OK) { - printf(mess); - printf("set timer failed\n"); - sprintf(mess, "set timer %d failed\n", ind); - } else if (ind==FRAME_NUMBER) { - ret=allocateRAM(); - if (ret!=OK) - sprintf(mess, "could not allocate RAM for %lld frames\n", tns); - } - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { -#ifdef VERBOSE - printf("returning ok %d\n",sizeof(retval)); -#endif - - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - - return ret; - -} - - - - - - - - -int get_time_left(int file_des) { - - enum timerIndex ind; - int n; - int64_t retval; - int ret=OK; - - sprintf(mess,"can't get timer\n"); - n = receiveDataOnly(file_des,&ind,sizeof(ind)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - -#ifdef VERBOSE - - printf("getting time left on timer %d \n",ind); -#endif - - if (ret==OK) { - switch(ind) { - case FRAME_NUMBER: - retval=getFrames(); - break; - case ACQUISITION_TIME: - retval=getExposureTime(); - break; - case FRAME_PERIOD: - retval=getPeriod(); - break; - case DELAY_AFTER_TRIGGER: - retval=getDelay(); - break; - case GATES_NUMBER: - retval=getGates(); - break; - case PROBES_NUMBER: - retval=getProbes(); - break; - case CYCLES_NUMBER: - retval=getTrains(); - break; - case PROGRESS: - retval=getProgress(); - break; - case ACTUAL_TIME: - retval=getActualTime(); - break; - case MEASUREMENT_TIME: - retval=getMeasurementTime(); - break; - default: - ret=FAIL; - sprintf(mess,"timer index unknown %d\n",ind); - } - } - - - if (ret!=OK) { - printf("get time left failed\n"); - } else if (differentClients) - ret=FORCE_UPDATE; - -#ifdef VERBOSE - - printf("time left on timer %d is %lld\n",ind, retval); -#endif - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n += sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } -#ifdef VERBOSE - - printf("data sent\n"); -#endif - - return ret; - - -} - -int set_dynamic_range(int file_des) { - - - - int dr; - int n; - int retval; - int ret=OK; - - - sprintf(mess,"can't set dynamic range\n"); - - - n = receiveDataOnly(file_des,&dr,sizeof(dr)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - - if (differentClients==1 && lockStatus==1 && dr>=0) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - retval=setDynamicRange(dr); - } - - if (dr>=0 && retval!=dr) - ret=FAIL; - if (ret!=OK) { - sprintf(mess,"set dynamic range failed\n"); - } else { - ret=allocateRAM(); - if (ret!=OK) - sprintf(mess,"Could not allocate RAM for the dynamic range selected\n"); - else if (differentClients) - ret=FORCE_UPDATE; - } - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - -int set_roi(int file_des) { - - - int arg=-1; - int n; - ROI roiLimits[MAX_ROIS]; - int ret=OK; - ROI retval; - - int nm=setNMod(-1), nmax=getNModBoard(), nroi; - - - sprintf(mess,"can't set ROI\n"); - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if(arg>0){ - n+=receiveDataOnly(file_des,roiLimits,arg*sizeof(ROI)); - } - - if (arg>1) { - ret=FAIL; - sprintf(mess,"can't set more than 1 ROI per detector\n"); - - } else - ret=OK; - - if (arg>0) { - - nm=(roiLimits[0].xmax-1)/1280+1; - - if (roiLimits[0].xmin>0) { - roiLimits[0].xmin=0; - ret=FAIL; - sprintf(mess,"ROI starts at 0\n"); - } - - if (nm>nmax) { - retval.xmax=setNMod(-1)*1280; - ret=FAIL; - sprintf(mess,"ROI max larger than detector size\n"); - } - - } else if (arg==0) { - setNMod(nmax); - } - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - retval.xmin=0; - retval.xmax=setNMod(-1)*1280; - retval.ymin=0; - retval.ymax=0; - if (setNMod(-1)=0) { - if (differentClients==1 && lockStatus==1 && val>=0) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - switch (arg) { - case CLOCK_DIVIDER: - retval=setClockDivider(val); - break; - case WAIT_STATES: - retval=setWaitStates(val); - break; - case SET_SIGNAL_LENGTH: - retval=setSetLength(val); - break; - case TOT_CLOCK_DIVIDER: - retval=setTotClockDivider(val); - break; - case TOT_DUTY_CYCLE: - retval=setTotDutyCycle(val); - break; - default: - ret=FAIL; - } - } - } else { - - switch (arg) { - case CLOCK_DIVIDER: - retval=getClockDivider(); - break; - case WAIT_STATES: - retval=getWaitStates(); - break; - case SET_SIGNAL_LENGTH: - retval=getSetLength(); - break; - case TOT_CLOCK_DIVIDER: - retval=getTotClockDivider(); - break; - case TOT_DUTY_CYCLE: - retval=getTotDutyCycle(); - break; - default: - ret=FAIL; - } - } - } - - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - - - -int set_readout_flags(int file_des) { - - enum readOutFlags retval; - enum readOutFlags arg; - int n; - int ret=OK; - int regret=OK; - - - sprintf(mess,"can't set readout flags\n"); - - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - -#ifdef VERBOSE - printf("setting readout flags to %d\n",arg); -#endif - - if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - //ret=setStoreInRAM(0); - // initChipWithProbes(0,0,0, ALLMOD); - switch(arg) { - case GET_READOUT_FLAGS: - break; - case STORE_IN_RAM: - if (setStoreInRAM(1)==OK) - ret=OK; - else - ret=FAIL; - break; - case TOT_MODE: - if(setToT(1)) - ret=OK; - else - ret=FAIL; - break; - case CONTINOUS_RO: - if (setContinousReadOut(1)) - ret=OK; - else - ret=FAIL; - break; - // case PUMP_PROBE_MODE: - //set number of probes - //initChipWithProbes(0,0,2, ALLMOD); - //break; - default: - ret=setStoreInRAM(0); - regret=setConfigurationRegister(0); - ret=OK; - } - } - retval=NORMAL_READOUT; - - if (storeInRAM) - retval=STORE_IN_RAM; - //else if (getProbes()) - // retval=PUMP_PROBE_MODE; - //else - if (setToT(-1)) - retval|=TOT_MODE; - if (setContinousReadOut(-1)) - retval|=CONTINOUS_RO; - if (ret!=OK) { - printf("set readout flags failed\n"); - sprintf(mess,"Could not allocate RAM\n"); - } else if (differentClients) - ret=FORCE_UPDATE; - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - - - - - -int execute_trimming(int file_des) { - - int arg[3]; - int n; - int ret=OK; - int imod, par1,par2; - enum trimMode mode; - - printf("called function execute trimming\n"); - - sprintf(mess,"can't set execute trimming\n"); - - n = receiveDataOnly(file_des,&mode,sizeof(mode)); - printf("mode received\n"); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (mode)\n"); - ret=FAIL; - } - - n = receiveDataOnly(file_des,arg,sizeof(arg)); - printf("arg received\n"); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (args)\n"); - ret=FAIL; - } - - imod=arg[0]; - - if (imod>=getNModBoard()) - ret=FAIL; - - if (imod<0) - imod=ALLMOD; - - par1=arg[1]; - par2=arg[2]; - -#ifdef VERBOSE - printf("trimming module %d mode %d, parameters %d %d \n",imod,mode, par1, par2); -#endif - - if (differentClients==1 && lockStatus==1 ) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - - if (ret==OK) { - switch(mode) { - case NOISE_TRIMMING: - // par1 is countlim; par2 is nsigma - ret=trim_with_noise(par1, par2, imod); - break; - case BEAM_TRIMMING: - // par1 is countlim; par2 is nsigma - ret=trim_with_beam(par1,par2,imod); - break; - case IMPROVE_TRIMMING: - // par1 is maxit; if par2!=0 vthresh will be optimized - ret=trim_improve(par1, par2,imod); - break; - case FIXEDSETTINGS_TRIMMING: - // par1 is countlim; if par2<0 then trimwithlevel else trim with median - ret=trim_fixed_settings(par1,par2,imod); - break; - // case OFFLINE_TRIMMING: - - //break; - default: - printf("Unknown trimming mode\n"); - sprintf(mess,"Unknown trimming mode\n"); - ret=FAIL; - } - } - } - - - 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) - ret=FORCE_UPDATE; - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } - - return ret; -} - - -int lock_server(int file_des) { - - - int n; - int ret=OK; - - int lock; - n = receiveDataOnly(file_des,&lock,sizeof(lock)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (lock)\n"); - ret=FAIL; - } - if (lock>=0) { - if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0) { - lockStatus=lock; - - } else { - ret=FAIL; - sprintf(mess,"Server already locked by %s\n", lastClientIP); - } - } - if (differentClients && ret==OK) - ret=FORCE_UPDATE; - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else - n = sendDataOnly(file_des,&lockStatus,sizeof(lockStatus)); - - return ret; - -} - -int set_port(int file_des) { - int n; - int ret=OK; - int sd=-1; - - enum portType p_type; /** data? control? stop? Unused! */ - int p_number; /** new port number */ - - n = receiveDataOnly(file_des,&p_type,sizeof(p_type)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (ptype)\n"); - ret=FAIL; - } - - n = receiveDataOnly(file_des,&p_number,sizeof(p_number)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - printf("Error reading from socket (pnum)\n"); - ret=FAIL; - } - if (differentClients==1 && lockStatus==1 ) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - if (p_number<1024) { - sprintf(mess,"Too low port number %d\n", p_number); - printf("\n"); - ret=FAIL; - } - - printf("set port %d to %d\n",p_type, p_number); - - sd=bindSocket(p_number); - } - if (sd>=0 || sd==-10) { - ret=OK; - if (differentClients ) - ret=FORCE_UPDATE; - } else { - ret=FAIL; - sprintf(mess,"Could not bind port %d\n", p_number); - printf("Could not bind port %d\n", p_number); - - } - - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&p_number,sizeof(p_number)); - if (sd>=0) { - closeConnection(file_des); - exitServer(sockfd); - sockfd=sd; - } - - } - - return ret; - -} - -int get_last_client_ip(int file_des) { - int ret=OK; - int n; - if (differentClients ) - ret=FORCE_UPDATE; - n = sendDataOnly(file_des,&ret,sizeof(ret)); - n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP)); - - return ret; - -} - - -int send_update(int file_des) { - - int ret=OK; - enum detectorSettings t; - int thr, n; - // int it; - int64_t retval, tns=-1; - - - n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP)); - n = sendDataOnly(file_des,&nModX,sizeof(nModX)); - // n = sendDataOnly(file_des,&nModY,sizeof(nModY)); - //sends back max modules instead of nmodulesY! - - thr = getNModBoard(); - sendDataOnly(file_des,&thr,sizeof(thr)); - - n = sendDataOnly(file_des,&dynamicRange,sizeof(dynamicRange)); - n = sendDataOnly(file_des,&dataBytes,sizeof(dataBytes)); - t=setSettings(GET_SETTINGS); - n = sendDataOnly(file_des,&t,sizeof(t)); - thr=getThresholdEnergy(); - n = sendDataOnly(file_des,&thr,sizeof(thr)); - retval=setFrames(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setExposureTime(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setPeriod(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setDelay(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setGates(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setProbes(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - retval=setTrains(tns); - n = sendDataOnly(file_des,&retval,sizeof(int64_t)); - - if (lockStatus==0) { - strcpy(lastClientIP,thisClientIP); - } - - return ret; - - -} -int update_client(int file_des) { - - int ret=OK; - - sendDataOnly(file_des,&ret,sizeof(ret)); - return send_update(file_des); - - - -} - - -int set_master(int file_des) { - - enum masterFlags retval=GET_MASTER; - enum masterFlags arg; - int n; - int ret=OK; - // int regret=OK; - - - sprintf(mess,"can't set master flags\n"); - - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - - if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - retval=setMaster(arg); - - } - if (retval==GET_MASTER) { - ret=FAIL; - } - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} - - - - - - -int set_synchronization(int file_des) { - - enum synchronizationMode retval=GET_MASTER; - enum synchronizationMode arg; - int n; - int ret=OK; - //int regret=OK; - - - sprintf(mess,"can't set synchronization mode\n"); - - - n = receiveDataOnly(file_des,&arg,sizeof(arg)); - if (n < 0) { - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } -#ifdef VERBOSE - printf("setting master flags to %d\n",arg); -#endif - - if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); - } else { - //ret=setStoreInRAM(0); - // initChipWithProbes(0,0,0, ALLMOD); - retval=setSynchronization(arg); - } - if (retval==GET_SYNCHRONIZATION_MODE) { - ret=FAIL; - } - n = sendDataOnly(file_des,&ret,sizeof(ret)); - if (ret==FAIL) { - n = sendDataOnly(file_des,mess,sizeof(mess)); - } else { - n = sendDataOnly(file_des,&retval,sizeof(retval)); - } - return ret; -} diff --git a/slsDetectorSoftware/mythenDetectorServer/server_funcs.h b/slsDetectorSoftware/mythenDetectorServer/server_funcs.h deleted file mode 100755 index 7a458e9cd..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/server_funcs.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef SERVER_FUNCS_H -#define SERVER_FUNCS_H -#include -/* -#include -#include -#include -*/ -#include "communication_funcs.h" - - - - -#define GOODBYE -200 - -int sockfd; - -int function_table(); - -int decode_function(int); - -int init_detector(int); - -int M_nofunc(int); -int exit_server(int); - - - - - // General purpose functions -int get_detector_type(int); -int set_number_of_modules(int); -int get_max_number_of_modules(int); - - -int exec_command(int); -int set_external_signal_flag(int); -int set_external_communication_mode(int); -int get_id(int); -int digital_test(int); -int write_register(int); -int read_register(int); -int set_dac(int); -int get_adc(int); -int set_channel(int); -int set_chip(int); -int set_module(int); -int get_channel(int); -int get_chip(int); -int get_module(int); - -int get_threshold_energy(int); -int set_threshold_energy(int); -int set_settings(int); -int start_acquisition(int); -int stop_acquisition(int); -int start_readout(int); -int get_run_status(int); -int read_frame(int); -int read_all(int); -int start_and_read_all(int); -int set_timer(int); -int get_time_left(int); -int set_dynamic_range(int); -int set_roi(int); -int get_roi(int); -int set_speed(int); -int set_readout_flags(int); -int execute_trimming(int); -int lock_server(int); -int set_port(int); -int get_last_client_ip(int); -int set_master(int); -int set_synchronization(int); - -int update_client(int); -int send_update(int); - -#endif diff --git a/slsDetectorSoftware/mythenDetectorServer/sharedmemory.c b/slsDetectorSoftware/mythenDetectorServer/sharedmemory.c deleted file mode 100755 index 302a0308c..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/sharedmemory.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "sharedmemory.h" - -struct statusdata *stdata; - -int inism(int clsv) { - -static int scansmid; - - if (clsv==SMSV) { - if ( (scansmid=shmget(SMKEY,1024,IPC_CREAT | 0666 ))==-1 ) { - return -1; - } - if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) { - return -2; - } - } - - if (clsv==SMCL) { - if ( (scansmid=shmget(SMKEY,0,0) )==-1 ) { - return -3; - } - if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) { - return -4; - } - } - return 1; -} - -void write_status_sm(char *status) { - strcpy(stdata->status,status); -} - -void write_istatus_sm(int i) { - stdata->istatus=i; -} -int read_istatus_sm() { - return stdata->istatus; -} - -void write_stop_sm(int v) { - stdata->stop=v; -} - -void write_runnumber_sm(int v) { - stdata->runnumber=v; -} diff --git a/slsDetectorSoftware/mythenDetectorServer/sharedmemory.h b/slsDetectorSoftware/mythenDetectorServer/sharedmemory.h deleted file mode 100755 index d50eb5047..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/sharedmemory.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef SM -#define SM - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include - -#include -#include - -/* key for shared memory */ -#define SMKEY 10001 - -#define SMSV 1 -#define SMCL 2 - - -struct statusdata { - int runnumber; - int stop; - int istatus; - char status[20]; -} ; - - -/* for shared memory */ - -int inism(int clsv); -void write_status_sm(char *status); -void write_stop_sm(int v); -void write_runnumber_sm(int v); - -void write_istatus_sm(int v); - -int read_istatus_sm(); - -#endif diff --git a/slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h deleted file mode 120000 index 1de31caf5..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/sls_receiver_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythenDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/mythenDetectorServer/sls_receiver_funcs.h deleted file mode 120000 index c2ea4ded9..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/sls_receiver_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../../slsReceiverSoftware/include/sls_receiver_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythenDetectorServer/stop_server.c b/slsDetectorSoftware/mythenDetectorServer/stop_server.c deleted file mode 100755 index 571c9a978..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/stop_server.c +++ /dev/null @@ -1,41 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ -#include "communication_funcs.h" -#include "firmware_funcs.h" - - -int sockfd; - -int main(int argc, char *argv[]) -{ - int portno; - int retval=0; - - portno = DEFAULT_PORTNO; - - - bindSocket(portno); - if (getServerError()) - return -1; - - - - /* waits for connection */ - while(retval!=GOODBYE) { -#ifdef VERBOSE - printf("\n"); -#endif -#ifdef VERY_VERBOSE - printf("Stop server: waiting for client call\n"); -#endif - acceptConnection(); - retval=stopStateMachine(); - closeConnection(); - } - - exitServer(); - printf("Goodbye!\n"); - - return 0; -} - diff --git a/slsDetectorSoftware/mythenDetectorServer/trimming_funcs.c b/slsDetectorSoftware/mythenDetectorServer/trimming_funcs.c deleted file mode 100755 index b86e9f3f4..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/trimming_funcs.c +++ /dev/null @@ -1,789 +0,0 @@ -#ifndef PICASSOD -#include "server_defs.h" -#else -#include "picasso_defs.h" -#endif -#include "trimming_funcs.h" -#include "mcb_funcs.h" -#include "firmware_funcs.h" -#include - - - -extern int nModX; -//extern int *values; - -extern const int nChans; -extern const int nChips; -extern const int nDacs; -extern const int nAdcs; - - -int trim_fixed_settings(int countlim, int par2, int im) -{ - - int retval=OK; -#ifdef VERBOSE - printf("Trimming with fixed settings\n"); -#endif -#ifdef VIRTUAL - return OK; -#endif - - if (par2<=0) - retval=trim_with_level(countlim, im); - else - retval=trim_with_median(countlim,im); - - - return retval; -} - - -int trim_with_noise(int countlim, int nsigma, int im) -{ - - - int retval1=OK, retval2=OK; -#ifdef VERBOSE - printf("Trimming using noise\n"); -#endif -#ifdef VIRTUAL - return OK; -#endif - - /* threshold scan */ - -#ifdef VERBOSE - printf("chosing vthresh and vtrim....."); -#endif - retval1=choose_vthresh_and_vtrim(countlim,nsigma, im); - -#ifdef VERBOSE - printf("trimming with noise.....\n"); -#endif - if (retval1==OK) - retval2=trim_with_level(countlim, im); - else - retval2=-1; - -#ifdef DEBUGOUT - printf("done\n"); -#endif - //if (retval1==OK && retval2==OK) - // retval=OK; - //else - // retval=FAIL; - - return retval2; - -} - -int trim_with_beam(int countlim, int nsigma, int im) //rpc -{ - - - int retval1=OK, retval2=OK; - - printf("Trimming using beam\n"); - //return OK; -#ifdef VIRTUAL - printf("Trimming using beam\n"); - return OK; -#endif - /* threshold scan */ -#ifdef DEBUGOUT - printf("chosing vthresh and vtrim....."); -#endif - - retval1=choose_vthresh_and_vtrim(countlim,nsigma,im); - if (retval1==OK) - retval2=trim_with_median(TRIM_DR, im); - else return -1; - -#ifdef DEBUGOUT - printf("done\n"); -#endif - - // if (retval1==OK && retval2==OK) - // retval=OK; - //else - // retval=FAIL; - - return retval2; - -} - - -int trim_improve(int maxit, int par2, int im) //rpc -{ - - int retval1=OK, retval2=OK; - - -#ifdef VERBOSE - printf("Improve the trimming\n"); -#endif -#ifdef VIRTUAL - return OK; -#endif - - - if (par2!=0 && im==ALLMOD) - retval1=choose_vthresh(); - if (retval1==OK) - retval2=trim_with_median(2*maxit+1, im); - else - return -1; -#ifdef DEBUGOUT - printf("done\n"); -#endif - // if (retval1==OK && retval2==OK) - // retval=OK; - //else - //retval=FAIL; - - return retval2; - -} - -int calcthr_from_vcal(int vcal) { - int thrmin; - //thrmin=140+3*vcal/5; - thrmin=180+3*vcal/5; - return thrmin; -} - -int calccal_from_vthr(int vthr) { - int vcal; - vcal=5*(vthr-140)/3; - return vcal; -} - -int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) { - int retval=OK; -#ifdef MCB_FUNCS - int modma, modmi, nm; - int thr, thrstep=5, nthr=31; - - int *fifodata; - - float vthreshmean, vthreshSTDev; - int *thrmi, *thrma; - float c; - float b=BVTRIM; - float a=AVTRIM; - int *trim; - int ich, imod, ichan; - int nvalid=0; - u_int32_t *scan; - int ithr; - sls_detector_channel myChan; - - - - setFrames(1); - // setNMod(getNModBoard()); - - if (im==ALLMOD){ - modmi=0; - modma=nModX; - } else { - modmi=im; - modma=im+1; - } - nm=modma-modmi; - - trim=malloc(sizeof(int)*nChans*nChips*nModX); - thrmi=malloc(sizeof(int)*nModX); - thrma=malloc(sizeof(int)*nModX); - - - for (ich=0; ichcountlim && trim[ich]==-1) { - trim[ich]=getDACbyIndexDACU(VTHRESH,imod); -#ifdef VERBOSE - // printf("yes: %d %d %d\n",ich,ithr,scan[ich]); -#endif - } -#ifdef VERBOSE - /* else { - printf("no: %d %d %d\n",ich,ithr,scan[ich]); - }*/ -#endif - } - } - free(scan); - } - - for (imod=modmi; imodthrmi[imod] && trim[ich]0) { - vthreshmean=vthreshmean/nvalid; - vthreshSTDev=sqrt((vthreshSTDev/nvalid)-vthreshmean*vthreshmean); - } else { - vthreshmean=thrmi[imod]; - vthreshSTDev=nthr*thrstep; - printf("No valid channel for module %d\n",imod); - retval=FAIL; - } - -#ifdef DEBUGOUT - printf("module= %d nvalid = %d mean=%f RMS=%f\n",imod, nvalid, vthreshmean,vthreshSTDev); -#endif - // *vthresh=round(vthreshmean-nsigma*vthreshSTDev); - thr=(int)(vthreshmean-nsigma*vthreshSTDev); - if (thr<0 || thr>(DAC_DR-1)) { - thr=thrmi[imod]/2; - printf("Can't find correct threshold for module %d\n",imod); - retval=FAIL; - } - initDACbyIndexDACU(VTHRESH,thr,imod); -#ifdef VERBOSE - printf("vthresh=%d \n",thr); -#endif - c=CVTRIM-2.*nsigma*vthreshSTDev/63.; - thr=(int)((-b-sqrt(b*b-4*a*c))/(2*a)); - if (thr<500 || thr>(DAC_DR-1)) { - thr=750; - printf("Can't find correct trimbit size for module %d\n",imod); - retval=FAIL; - } - - initDACbyIndexDACU(VTRIM,thr,imod); - -#ifdef VERBOSE - printf("vtrim=%d \n",thr); -#endif - - } - free(trim); - free(thrmi); - free(thrma); - -#endif - return retval; -} - - - - - -int trim_with_level(int countlim, int im) { - int ich, itrim, ichan, ichip, imod; - u_int32_t *scan; - int *inttrim; - int modma, modmi, nm; - int retval=0; - int *fifodata; - sls_detector_channel myChan; - printf("trimming module number %d", im); - - -#ifdef MCB_FUNCS - setFrames(1); - // setNMod(getNModBoard()); - - if (im==ALLMOD){ - modmi=0; - modma=nModX; - } else { - modmi=im; - modma=im+1; - } - nm=modma-modmi; - - inttrim=malloc(sizeof(int)*nChips*nChans*nModX); - printf("countlim=%d\n",countlim); - for (ich=0; ichcountlim){ - inttrim[ich]=itrim; - if (scan[ich]>2*countlim && itrim>0) { - //if (scan[ich]>2*countlim || itrim==0) { - inttrim[ich]=itrim-1; - } -#ifdef VERBOSE - printf("Channel %d trimbit %d counted %d (%08x) countlim %d\n",ich,itrim,scan[ich],fifodata[ich],countlim); -#endif - } - } -#ifdef VERBOSE - /* else - printf("Channel %d trimbit %d counted %d countlim %d\n",ich,itrim,scan[ich],countlim);*/ -#endif - } - } - free(scan); - } - - for (imod=modmi; imod0) - direction[ichan]=1; - else - direction[ichan]=-1; - } - vthresh=getDACbyIndexDACU(VTHRESH,imod); - if ( direction[ichan]!=-3) { - if (abs(diff)>abs(olddiff[ichan])) { - vthresh=vthresh-direction[ichan]; - if (vthresh>(DAC_DR-1)) { - vthresh=(DAC_DR-1); - printf("can't equalize threshold for module %d\n", ichan); - retval=FAIL; - } - if (vthresh<0) { - vthresh=0; - printf("can't equalize threshold for module %d\n", ichan); - retval=FAIL; - } - direction[ichan]=-3; - } else { - vthresh=vthresh+direction[ichan]; - olddiff[ichan]=diff; - change_flag=1; - } - initDACbyIndex(VTHRESH,vthresh, ichan); - } - } - iteration++; - free(scan); - free(scan1); - } -#endif - return retval; -} - - - - - -int trim_with_median(int stop, int im) { - - - int retval=0; - -#ifdef MCB_FUNCS - int ichan, imod, ichip, ich; - u_int32_t *scan, *scan1; - int *olddiff, *direction; - int med, diff; - int change_flag=1; - int iteration=0; - int me[nModX], me1[nModX]; - int modma, modmi, nm; - int trim; - int *fifodata; - - setFrames(1); - // setNMod(getNModBoard()); - - if (im==ALLMOD){ - modmi=0; - modma=nModX; - } else { - modmi=im; - modma=im+1; - } - nm=modma-modmi; - - olddiff=malloc(4*nModX*nChips*nChans); - direction=malloc(4*nModX*nChips*nChans); - for (imod=modmi; imod0) { - direction[ichan]=1; - } else { - direction[ichan]=-1; - } - } - if ( direction[ichan]!=-3) { - if (abs(diff)>abs(olddiff[ichan])) { - trim=getTrimbit(imod,ichip,ich)+direction[ichan]; - printf("%d old diff %d < new diff %d %d - trimbit %d\n",ichan, olddiff[ichan], diff, direction[ichan], trim); - direction[ichan]=-3; - } else { - trim=getTrimbit(imod,ichip,ich)-direction[ichan]; - olddiff[ichan]=diff; - change_flag=1; - } - if (trim>TRIM_DR) { - trim=63; - printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim); - retval++; - } - if (trim<0) { - printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim); - trim=0; - retval++; - } - initChannel(trim,0,0,1,0,0,imod); - } - } - } - } - iteration++; - free(scan); - free(scan1); - } - free(olddiff); - free(direction); -#endif - return retval; -} diff --git a/slsDetectorSoftware/mythenDetectorServer/trimming_funcs.h b/slsDetectorSoftware/mythenDetectorServer/trimming_funcs.h deleted file mode 100755 index ac73dcaa1..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/trimming_funcs.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef TRIMMING_FUNCS_H -#define TRIMMING_FUNCS_H -int trim_fixed_settings(int countlim, int par2, int imod); -int trim_with_noise(int countlim, int nsigma, int imod); -int trim_with_beam(int countlim, int nsigma, int imod); -int trim_improve(int maxit, int par2, int imod); -int calcthr_from_vcal(int vcal); -int calccal_from_vthr(int vthr); -int choose_vthresh_and_vtrim(int countlim, int nsigma, int imod); - -int choose_vthresh(); -int trim_with_level(int countlim, int imod); -int trim_with_median(int stop, int imod); -int calcthr_from_vcal(int vcal); -int calccal_from_vthr(int vthr); -int median(int *a,int n); -#endif diff --git a/slsDetectorSoftware/mythenDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/mythenDetectorServer/updateGitVersion.sh deleted file mode 100755 index 74dcf8dc4..000000000 --- a/slsDetectorSoftware/mythenDetectorServer/updateGitVersion.sh +++ /dev/null @@ -1,31 +0,0 @@ -SERVER=mythenDetectorServer -MAINDIR=slsDetectorsPackage -SPECDIR=slsDetectorSoftware/$SERVER -TMPFILE=gitInfoMythenTmp.h -INCLFILE=gitInfoMythen.h - - -#evaluate the variables -EVALFILE=../../evalVersionVariables.sh -source $EVALFILE - - -#get modified date -#RDATE1='git log --pretty=format:"%ci" -1' -RDATE1="find ../slsDetectorServer . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|bin|.git|updateGitVersion|.o' | head -n 1" -RDATE=`eval $RDATE1` -NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}') -NEWDATE=${NEWDATE/#/0x} - - -#get old date from INCLFILE -OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') - - -#update INCLFILE if changes -if [ "$OLDDATE" != "$NEWDATE" ]; then - echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt - cd ../../ - ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE - cd $WD -fi \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorAnalysis/detectorData.h b/slsDetectorSoftware/slsDetector/detectorData.h similarity index 100% rename from slsDetectorSoftware/slsDetectorAnalysis/detectorData.h rename to slsDetectorSoftware/slsDetector/detectorData.h diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index e326e52e4..69a5a3ee2 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -108,10 +108,6 @@ slsDetector::~slsDetector() { } -bool slsDetector::isMultiSlsDetectorClass() { - return false; -} - int64_t slsDetector::clearAllErrorMask() { clearErrorMask(); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 026dc7480..8d684257c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -9,7 +9,7 @@ * @author Anna Bergamaschi */ -#include "slsDetectorUtils.h" +#include "slsDetectorBase.h" #include "MySocketTCP.h" class multiSlsDetector; @@ -38,7 +38,7 @@ typedef struct detParameterList { } detParameterList; -class slsDetector : public postProcessing { +class slsDetector : public slsDetectorBase { private: /** @@ -316,12 +316,6 @@ public: */ virtual ~slsDetector(); - /** - * returns false. Used when reference is slsDetectorUtils and to determine - * if command can be implemented as slsDetector/multiSlsDetector object/ - */ - bool isMultiSlsDetectorClass(); - /** * Clears error mask and also the bit in parent det multi error mask * @returns error mask diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index 853706b55..033fa1683 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -541,11 +541,6 @@ virtual int enableDataStreamingFromReceiver(int enable=-1)=0; return atoi(sret.c_str()); } - /** - * Used when reference is slsDetectorUtils and to determine - * if command can be implemented as slsDetector/multiSlsDetector object/ - */ - virtual bool isMultiSlsDetectorClass() = 0; /** * Set acquiring flag in shared memory diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 012f53dca..50c5d9ab0 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -1,4 +1,5 @@ #include "slsDetectorCommand.h" +#include "multiSlsDetector.h" #include #include @@ -66,7 +67,7 @@ The commands are sudivided into different pages depending on their functionaliti */ -slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { +slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { myDet=det; @@ -2006,12 +2007,12 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { //----------------------------------------------------------- -string slsDetectorCommand::executeLine(int narg, char *args[], int action) { +string slsDetectorCommand::executeLine(int narg, char *args[], int action, int detPos) { if (action==READOUT_ACTION) - return cmdAcquire(narg, args, action); + return cmdAcquire(narg, args, action, detPos); size_t s=string(args[0]).find(':'); @@ -2027,9 +2028,6 @@ string slsDetectorCommand::executeLine(int narg, char *args[], int action) { /* otherwise one could try if truncated key is unique */ - // size_t p=(descrToFuncMap[i].m_pFuncName).find(); - // if (p==0) { - if(key==descrToFuncMap[i].m_pFuncName){ #ifdef VERBOSE std::cout<getNumberOfDetectors()) { cprintf(RED, "Error: This shared memory has no detectors added. Aborting.\n"); return string("acquire unsuccessful"); } + if (detPos >= 0) { + cprintf(RED, "Error: Individual detectors not allowed for readout. Aborting.\n"); + return string("acquire unsuccessful"); + } + myDet->setOnline(ONLINE_FLAG); int r_online = myDet->setReceiverOnline(ONLINE_FLAG); @@ -2124,7 +2127,7 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) { -string slsDetectorCommand::helpAcquire(int narg, char *args[], int action){ +string slsDetectorCommand::helpAcquire(int action){ if (action==PUT_ACTION) @@ -2138,7 +2141,7 @@ string slsDetectorCommand::helpAcquire(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdData(int narg, char *args[], int action) { +string slsDetectorCommand::cmdData(int narg, char *args[], int action, int detPos) { #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); @@ -2147,16 +2150,19 @@ string slsDetectorCommand::cmdData(int narg, char *args[], int action) { if (action==PUT_ACTION) { return string("cannot set"); } else if (action==HELP_ACTION) { - return helpData(narg,args,HELP_ACTION); + return helpData(HELP_ACTION); + } else if (detPos >= 0) { + cprintf(RED, "Error: Individual detectors not allowed for readout. Aborting.\n"); + return string("unsuccessful"); } else { b=myDet->setThreadedProcessing(-1); myDet->setThreadedProcessing(0); - myDet->setOnline(ONLINE_FLAG); - myDet->setReceiverOnline(ONLINE_FLAG); - myDet->readAll(); + myDet->setOnline(detPos, ONLINE_FLAG); + myDet->setReceiverOnline(detPos, ONLINE_FLAG); + myDet->readAll(detPos); //processdata in receiver is useful only for gui purposes - if(myDet->setReceiverOnline()==OFFLINE_FLAG) - myDet->processData(1); + if(myDet->setReceiverOnline(detPos)==OFFLINE_FLAG) + myDet->processData(detPos); myDet->setThreadedProcessing(b); return string(""); } @@ -2164,7 +2170,7 @@ string slsDetectorCommand::cmdData(int narg, char *args[], int action) { -string slsDetectorCommand::helpData(int narg, char *args[], int action){ +string slsDetectorCommand::helpData(int action){ if (action==PUT_ACTION) return string(""); @@ -2174,14 +2180,14 @@ string slsDetectorCommand::helpData(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdStatus(int narg, char *args[], int action) { +string slsDetectorCommand::cmdStatus(int narg, char *args[], int action, int detPos) { #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) - return helpStatus(narg,args,action); + return helpStatus(action); if (cmd=="status") { myDet->setOnline(ONLINE_FLAG); @@ -2219,7 +2225,7 @@ string slsDetectorCommand::cmdStatus(int narg, char *args[], int action) { -string slsDetectorCommand::helpStatus(int narg, char *args[], int action) { +string slsDetectorCommand::helpStatus(int action) { ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) { @@ -2235,7 +2241,7 @@ string slsDetectorCommand::helpStatus(int narg, char *args[], int action) { -string slsDetectorCommand::cmdDataStream(int narg, char *args[], int action) { +string slsDetectorCommand::cmdDataStream(int narg, char *args[], int action, int detPos) { #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); @@ -2247,7 +2253,7 @@ string slsDetectorCommand::cmdDataStream(int narg, char *args[], int action) { myDet->setReceiverOnline(ONLINE_FLAG); if (action==HELP_ACTION) - return helpDataStream(narg,args,HELP_ACTION); + return helpDataStream(HELP_ACTION); if (action==PUT_ACTION) { if (!sscanf(args[1],"%d",&ival)) @@ -2260,7 +2266,7 @@ string slsDetectorCommand::cmdDataStream(int narg, char *args[], int action) { } -string slsDetectorCommand::helpDataStream(int narg, char *args[], int action) { +string slsDetectorCommand::helpDataStream(int action) { ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) @@ -2272,31 +2278,31 @@ string slsDetectorCommand::helpDataStream(int narg, char *args[], int action) { -string slsDetectorCommand::cmdFree(int narg, char *args[], int action) { +string slsDetectorCommand::cmdFree(int narg, char *args[], int action, int detPos) { #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) { - return helpFree(narg,args,HELP_ACTION); + return helpFree(HELP_ACTION); } return("Error: Should have been freed before creating constructor\n"); } -string slsDetectorCommand::helpFree(int narg, char *args[], int action) { +string slsDetectorCommand::helpFree(int action) { return string("free \t frees the shared memory\n"); } -string slsDetectorCommand::cmdHostname(int narg, char *args[], int action){ +string slsDetectorCommand::cmdHostname(int narg, char *args[], int action, int detPos){ #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) { - return helpHostname(narg,args,HELP_ACTION); + return helpHostname(HELP_ACTION); } if (action==GET_ACTION) { if ((cmd == "add") || (cmd == "replace")) @@ -2333,7 +2339,7 @@ string slsDetectorCommand::cmdHostname(int narg, char *args[], int action){ -string slsDetectorCommand::helpHostname(int narg, char *args[], int action){ +string slsDetectorCommand::helpHostname(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) { os << string("hostname \t returns the hostname(s) of the multi detector structure.\n"); @@ -2354,13 +2360,13 @@ string slsDetectorCommand::helpHostname(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdUser(int narg, char *args[], int action){ +string slsDetectorCommand::cmdUser(int narg, char *args[], int action, int detPos){ #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) { - return helpHostname(narg,args,HELP_ACTION); + return helpHostname(HELP_ACTION); } if (action==PUT_ACTION) { return string("cannot put"); @@ -2374,7 +2380,7 @@ string slsDetectorCommand::cmdUser(int narg, char *args[], int action){ -string slsDetectorCommand::helpUser(int narg, char *args[], int action){ +string slsDetectorCommand::helpUser(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) { os << string("user \t returns user details from shared memory without updating shared memory. " @@ -2388,7 +2394,7 @@ string slsDetectorCommand::helpUser(int narg, char *args[], int action){ -string slsDetectorCommand::cmdHelp(int narg, char *args[], int action){ +string slsDetectorCommand::cmdHelp(int narg, char *args[], int action, int detPos){ #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif @@ -2396,20 +2402,20 @@ string slsDetectorCommand::cmdHelp(int narg, char *args[], int action){ cout << narg << endl; if (narg>=1) - return helpLine(narg-1, args+1, action); + return helpLine(narg-1, action); else - return helpLine(0, args, action); + return helpLine(0, action); } -string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action){ +string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action, int detPos){ #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) { - return helpExitServer(narg, args, action); + return helpExitServer(action); } if (action==PUT_ACTION) { @@ -2433,7 +2439,7 @@ string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action){ } -string slsDetectorCommand::helpExitServer(int narg, char *args[], int action){ +string slsDetectorCommand::helpExitServer(int action){ ostringstream os; os << string("exitserver \t shuts down all the detector servers. Don't use it!!!!\n"); os << string("exitreceiver \t shuts down all the receiver servers.\n"); @@ -2441,12 +2447,12 @@ string slsDetectorCommand::helpExitServer(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdSettingsDir(int narg, char *args[], int action){ +string slsDetectorCommand::cmdSettingsDir(int narg, char *args[], int action, int detPos){ #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) { - return helpSettingsDir(narg, args, action); + return helpSettingsDir(action); } if (action==PUT_ACTION) { myDet->setSettingsDir(string(args[1])); @@ -2458,7 +2464,7 @@ string slsDetectorCommand::cmdSettingsDir(int narg, char *args[], int action){ -string slsDetectorCommand::helpSettingsDir(int narg, char *args[], int action){ +string slsDetectorCommand::helpSettingsDir(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("settingsdir \t gets the directory where the settings files are located\n"); @@ -2473,10 +2479,10 @@ string slsDetectorCommand::helpSettingsDir(int narg, char *args[], int action){ -string slsDetectorCommand::cmdCalDir(int narg, char *args[], int action){ +string slsDetectorCommand::cmdCalDir(int narg, char *args[], int action, int detPos){ if (action==HELP_ACTION) { - return helpCalDir(narg, args, action); + return helpCalDir(action); } if (action==PUT_ACTION) { myDet->setCalDir(string(args[1])); @@ -2488,7 +2494,7 @@ string slsDetectorCommand::cmdCalDir(int narg, char *args[], int action){ -string slsDetectorCommand::helpCalDir(int narg, char *args[], int action){ +string slsDetectorCommand::helpCalDir(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("caldir \t gets the directory where the calibration files are located\n"); @@ -2499,13 +2505,13 @@ string slsDetectorCommand::helpCalDir(int narg, char *args[], int action){ -string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action){ +string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action, int detPos){ int ival; int ip; char answer[1000]; - if (action==HELP_ACTION) return helpTrimEn(narg,args,action); + if (action==HELP_ACTION) return helpTrimEn(action); if (action==PUT_ACTION) { if (sscanf(args[1],"%d",&ival)) { @@ -2537,7 +2543,7 @@ string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action){ } -string slsDetectorCommand::helpTrimEn(int narg, char *args[], int action) { +string slsDetectorCommand::helpTrimEn(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) @@ -2548,10 +2554,10 @@ string slsDetectorCommand::helpTrimEn(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action){ +string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action, int detPos){ myDet->setReceiverOnline(ONLINE_FLAG); if (action==HELP_ACTION) - return helpOutDir(narg, args, action); + return helpOutDir(action); else if(action==PUT_ACTION) myDet->setFilePath(string(args[1])); @@ -2561,7 +2567,7 @@ string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action){ -string slsDetectorCommand::helpOutDir(int narg, char *args[], int action){ +string slsDetectorCommand::helpOutDir(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("outdir \t gets the directory where the output files will be written\n"); @@ -2573,10 +2579,10 @@ string slsDetectorCommand::helpOutDir(int narg, char *args[], int action){ -string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){ +string slsDetectorCommand::cmdFileName(int narg, char *args[], int action, int detPos){ myDet->setReceiverOnline(ONLINE_FLAG); if (action==HELP_ACTION) - return helpFileName(narg, args, action); + return helpFileName(action); if (cmd=="fname") { if (action==PUT_ACTION) myDet->setFileName(string(args[1])); @@ -2600,7 +2606,7 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){ -string slsDetectorCommand::helpFileName(int narg, char *args[], int action){ +string slsDetectorCommand::helpFileName(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION){ os << string("fname \t gets the filename for the data without index and extension\n"); @@ -2615,13 +2621,13 @@ string slsDetectorCommand::helpFileName(int narg, char *args[], int action){ -string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){ +string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action, int detPos){ int i; char ans[100]; myDet->setReceiverOnline(ONLINE_FLAG); if (action==HELP_ACTION) { - return helpEnablefwrite(narg, args, action); + return helpEnablefwrite(action); } if (action==PUT_ACTION) { if (sscanf(args[1],"%d",&i)) @@ -2637,7 +2643,7 @@ string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action){ -string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){ +string slsDetectorCommand::helpEnablefwrite(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("enablefwrite \t When Enabled writes the data into the file\n"); @@ -2647,13 +2653,13 @@ string slsDetectorCommand::helpEnablefwrite(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action){ +string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action, int detPos){ int i; char ans[100]; myDet->setReceiverOnline(ONLINE_FLAG); if (action==HELP_ACTION) { - return helpOverwrite(narg, args, action); + return helpOverwrite(action); } if (action==PUT_ACTION) { if (sscanf(args[1],"%d",&i)) @@ -2669,7 +2675,7 @@ string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action){ -string slsDetectorCommand::helpOverwrite(int narg, char *args[], int action){ +string slsDetectorCommand::helpOverwrite(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("overwrite \t When Enabled overwrites files\n"); @@ -2680,12 +2686,12 @@ string slsDetectorCommand::helpOverwrite(int narg, char *args[], int action){ -string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){ +string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action, int detPos){ char ans[100]; int i; myDet->setReceiverOnline(ONLINE_FLAG); if (action==HELP_ACTION) { - return helpFileName(narg, args, action); + return helpFileName(action); } else if (action==PUT_ACTION){ if(!sscanf(args[1],"%d",&i)) @@ -2699,7 +2705,7 @@ string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){ -string slsDetectorCommand::helpFileIndex(int narg, char *args[], int action){ +string slsDetectorCommand::helpFileIndex(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("index \t gets the file index for the next the data file\n"); @@ -2711,10 +2717,10 @@ string slsDetectorCommand::helpFileIndex(int narg, char *args[], int action){ -string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action){ +string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action, int detPos){ if (action==HELP_ACTION) { - return helpRateCorr(narg, args, action); + return helpRateCorr(action); } double fval; char answer[1000]; @@ -2735,7 +2741,7 @@ string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action){ } -string slsDetectorCommand::helpRateCorr(int narg, char *args[], int action){ +string slsDetectorCommand::helpRateCorr(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("ratecorr \t returns the dead time used for rate correections in ns \n"); @@ -2747,12 +2753,12 @@ string slsDetectorCommand::helpRateCorr(int narg, char *args[], int action){ -string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action){ +string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){ int ival; char answer[1000]; if (action==HELP_ACTION) - return helpThreaded(narg,args,action); + return helpThreaded(action); if (action==PUT_ACTION) { if (sscanf(args[1],"%d",&ival)) @@ -2764,7 +2770,7 @@ string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action){ } -string slsDetectorCommand::helpThreaded(int narg, char *args[], int action){ +string slsDetectorCommand::helpThreaded(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) os << string("threaded \t returns wether the data processing is threaded. \n"); @@ -2776,11 +2782,11 @@ string slsDetectorCommand::helpThreaded(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdImage(int narg, char *args[], int action){ +string slsDetectorCommand::cmdImage(int narg, char *args[], int action, int detPos){ string sval; int retval; if (action==HELP_ACTION) - return helpImage(narg,args,HELP_ACTION); + return helpImage(HELP_ACTION); else if (action==GET_ACTION) return string("Cannot get"); @@ -2801,7 +2807,7 @@ string slsDetectorCommand::cmdImage(int narg, char *args[], int action){ } -string slsDetectorCommand::helpImage(int narg, char *args[], int action){ +string slsDetectorCommand::helpImage(int action){ ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION){ os << "darkimage f \t loads the image to detector from file f"<< std::endl; @@ -2815,13 +2821,13 @@ string slsDetectorCommand::helpImage(int narg, char *args[], int action){ } -string slsDetectorCommand::cmdCounter(int narg, char *args[], int action){ +string slsDetectorCommand::cmdCounter(int narg, char *args[], int action, int detPos){ int ival; char answer[100]; string sval; int retval; if (action==HELP_ACTION) - return helpCounter(narg,args,HELP_ACTION); + return helpCounter(HELP_ACTION); else if (action==PUT_ACTION) ival=atoi(args[1]); @@ -2862,7 +2868,7 @@ string slsDetectorCommand::cmdCounter(int narg, char *args[], int action){ } -string slsDetectorCommand::helpCounter(int narg, char *args[], int action){ +string slsDetectorCommand::helpCounter(int action){ ostringstream os; os << std::endl; if (action==PUT_ACTION || action==HELP_ACTION){ @@ -2884,13 +2890,13 @@ string slsDetectorCommand::helpCounter(int narg, char *args[], int action){ -string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int action) { +string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int action, int detPos) { networkParameter t; int i; int prev_streaming = 0; if (action==HELP_ACTION) - return helpNetworkParameter(narg,args,action); + return helpNetworkParameter(action); myDet->setOnline(ONLINE_FLAG); myDet->setReceiverOnline(ONLINE_FLAG); @@ -2990,7 +2996,7 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio return myDet->getNetworkParameter(t); } -string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int action) { +string slsDetectorCommand::helpNetworkParameter(int action) { @@ -3053,10 +3059,10 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti } -string slsDetectorCommand::cmdPort(int narg, char *args[], int action) { +string slsDetectorCommand::cmdPort(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpPort(narg,args,action); + return helpPort(action); int val; //ret, char ans[1000]; portType index; @@ -3088,7 +3094,7 @@ string slsDetectorCommand::cmdPort(int narg, char *args[], int action) { -string slsDetectorCommand::helpPort(int narg, char *args[], int action) { +string slsDetectorCommand::helpPort(int action) { ostringstream os; @@ -3109,10 +3115,10 @@ string slsDetectorCommand::helpPort(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdLock(int narg, char *args[], int action) { +string slsDetectorCommand::cmdLock(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpLock(narg,args,action); + return helpLock(action); int val;//, ret; char ans[1000]; @@ -3150,7 +3156,7 @@ string slsDetectorCommand::cmdLock(int narg, char *args[], int action) { -string slsDetectorCommand::helpLock(int narg, char *args[], int action) { +string slsDetectorCommand::helpLock(int action) { ostringstream os; @@ -3168,10 +3174,10 @@ string slsDetectorCommand::helpLock(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action) { +string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpLastClient(narg,args,action); + return helpLastClient(action); if (action==PUT_ACTION) return string("cannot set"); @@ -3190,7 +3196,7 @@ string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action) { return string("cannot decode command"); } -string slsDetectorCommand::helpLastClient(int narg, char *args[], int action) { +string slsDetectorCommand::helpLastClient(int action) { ostringstream os; @@ -3203,10 +3209,10 @@ string slsDetectorCommand::helpLastClient(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) { +string slsDetectorCommand::cmdOnline(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) { - return helpOnline(narg,args,action); + return helpOnline(action); } int ival; char ans[1000]; @@ -3273,7 +3279,7 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) { return ans; } -string slsDetectorCommand::helpOnline(int narg, char *args[], int action) { +string slsDetectorCommand::helpOnline(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -3296,10 +3302,10 @@ string slsDetectorCommand::helpOnline(int narg, char *args[], int action) { -string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action) { +string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) { - return helpConfigureMac(narg,args,action); + return helpConfigureMac(action); } int ret; char ans[1000]; @@ -3316,7 +3322,7 @@ string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action) { return ans; } -string slsDetectorCommand::helpConfigureMac(int narg, char *args[], int action) { +string slsDetectorCommand::helpConfigureMac(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) @@ -3328,10 +3334,10 @@ string slsDetectorCommand::helpConfigureMac(int narg, char *args[], int action) } -string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { +string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpDetectorSize(narg,args,action); + return helpDetectorSize(action); int ret, val=-1, pos=-1,i; char ans[1000]; @@ -3347,7 +3353,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { if (cmd=="roi"){ //debug number of arguments if ((val<0) || (narg!=((val*4)+2)) ) - return helpDetectorSize(narg,args,action); + return helpDetectorSize(action); ROI allroi[val]; pos=2; for(i=0;isetOnline(ONLINE_FLAG); @@ -3737,7 +3743,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) { } -string slsDetectorCommand::helpDigiTest(int narg, char *args[], int action) { +string slsDetectorCommand::helpDigiTest(int action) { ostringstream os; @@ -3750,11 +3756,11 @@ string slsDetectorCommand::helpDigiTest(int narg, char *args[], int action) { return os.str(); } -string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) { +string slsDetectorCommand::cmdRegister(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpRegister(narg, args, action); + return helpRegister(action); int addr, val,n; char answer[1000]; @@ -3869,7 +3875,7 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) { } -string slsDetectorCommand::helpRegister(int narg, char *args[], int action) { +string slsDetectorCommand::helpRegister(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -3885,10 +3891,10 @@ string slsDetectorCommand::helpRegister(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) { +string slsDetectorCommand::cmdDAC(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpDAC(narg, args, action); + return helpDAC(action); dacIndex dac; dacs_t val=-1; @@ -4059,7 +4065,7 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) { } -string slsDetectorCommand::helpDAC(int narg, char *args[], int action) { +string slsDetectorCommand::helpDAC(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -4179,7 +4185,7 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) { -string slsDetectorCommand::cmdADC(int narg, char *args[], int action) { +string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int detPos) { dacIndex adc; int idac; @@ -4187,7 +4193,7 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) { char answer[1000]; if (action==HELP_ACTION) - return helpADC(narg, args, action); + return helpADC(action); else if (action==PUT_ACTION) return string("cannot set ")+cmd; @@ -4258,7 +4264,7 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) { } -string slsDetectorCommand::helpADC(int narg, char *args[], int action) { +string slsDetectorCommand::helpADC(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -4289,12 +4295,12 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) { -string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action) { +string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action, int detPos) { char answer[1000]=""; int val = -1; if (action==HELP_ACTION) - return helpTempControl(narg, args, action); + return helpTempControl(action); myDet->setOnline(ONLINE_FLAG); @@ -4343,7 +4349,7 @@ string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action) { -string slsDetectorCommand::helpTempControl(int narg, char *args[], int action) { +string slsDetectorCommand::helpTempControl(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { os << "temp_threshold t \t sets the threshold temperature. Jungfrau only" << std::endl; @@ -4360,13 +4366,13 @@ string slsDetectorCommand::helpTempControl(int narg, char *args[], int action) { -string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){ +string slsDetectorCommand::cmdTiming(int narg, char *args[], int action, int detPos){ #ifdef VERBOSE cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n"); #endif if (action==HELP_ACTION) { - return helpTiming(narg,args,HELP_ACTION); + return helpTiming(HELP_ACTION); } myDet->setOnline(ONLINE_FLAG); if (action==PUT_ACTION) { @@ -4376,7 +4382,7 @@ string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){ return myDet->externalCommunicationType(myDet->setExternalCommunicationMode()); } -string slsDetectorCommand::helpTiming(int narg, char *args[], int action){ +string slsDetectorCommand::helpTiming(int action){ ostringstream os; if (action==GET_ACTION || action==HELP_ACTION) @@ -4388,7 +4394,7 @@ string slsDetectorCommand::helpTiming(int narg, char *args[], int action){ -string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) { +string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int detPos) { timerIndex index; int64_t t=-1, ret; double val, rval; @@ -4397,7 +4403,7 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) { if (action==HELP_ACTION) - return helpTimer(narg, args, action); + return helpTimer(action); if (cmd=="exptime") index=ACQUISITION_TIME; @@ -4472,7 +4478,7 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) { } -string slsDetectorCommand::helpTimer(int narg, char *args[], int action) { +string slsDetectorCommand::helpTimer(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -4517,7 +4523,7 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) { +string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action, int detPos) { timerIndex index; int64_t ret; double rval; @@ -4526,7 +4532,7 @@ string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) { if (action==HELP_ACTION) - return helpTimeLeft(narg, args, action); + return helpTimeLeft(action); if (cmd=="exptimel") index=ACQUISITION_TIME; @@ -4580,7 +4586,7 @@ string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) { } -string slsDetectorCommand::helpTimeLeft(int narg, char *args[], int action) { +string slsDetectorCommand::helpTimeLeft(int action) { @@ -4610,7 +4616,7 @@ string slsDetectorCommand::helpTimeLeft(int narg, char *args[], int action) { -string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) { +string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action, int detPos) { speedVariable index; int t=-1, ret; @@ -4619,7 +4625,7 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) { if (action==HELP_ACTION) - return helpSpeed(narg, args, action); + return helpSpeed(action); if (cmd=="clkdivider") index=CLOCK_DIVIDER; @@ -4667,7 +4673,7 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) { } -string slsDetectorCommand::helpSpeed(int narg, char *args[], int action) { +string slsDetectorCommand::helpSpeed(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -4698,13 +4704,13 @@ string slsDetectorCommand::helpSpeed(int narg, char *args[], int action) { -string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) { +string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action, int detPos) { int retval; char answer[1000]=""; if (action==HELP_ACTION) - return helpAdvanced(narg, args, action); + return helpAdvanced(action); if (cmd=="flags") { @@ -4865,7 +4871,7 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) { } -string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) { +string slsDetectorCommand::helpAdvanced(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -4904,12 +4910,12 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) { -string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action) { +string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpConfiguration(narg, args, action); + return helpConfiguration(action); string sval; @@ -4959,7 +4965,7 @@ string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action) } -string slsDetectorCommand::helpConfiguration(int narg, char *args[], int action) { +string slsDetectorCommand::helpConfiguration(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -4989,12 +4995,12 @@ string slsDetectorCommand::helpConfiguration(int narg, char *args[], int action) } -string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) { +string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action, int detPos) { char answer[100]; int ival = -1; if (action==HELP_ACTION) - return helpReceiver(narg, args, action); + return helpReceiver(action); myDet->setOnline(ONLINE_FLAG); @@ -5007,7 +5013,7 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) { else if(!strcasecmp(args[1],"stop")) myDet->stopReceiver(); else - return helpReceiver(narg, args, action); + return helpReceiver(action); } return myDet->runStatusType(myDet->getReceiverStatus()); } @@ -5133,7 +5139,7 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) { -string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) { +string slsDetectorCommand::helpReceiver(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -5162,7 +5168,7 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) { return os.str(); } -string slsDetectorCommand::helpPattern(int narg, char *args[], int action) { +string slsDetectorCommand::helpPattern(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -5215,11 +5221,11 @@ string slsDetectorCommand::helpPattern(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { +string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, int detPos) { if (action==HELP_ACTION) - return helpPattern(narg, args, action); + return helpPattern(action); /******** Must implement set ctb functions in slsDetector and multiSlsDetector @@ -5716,7 +5722,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { - else return helpPattern(narg, args, action); + else return helpPattern(action); @@ -5728,7 +5734,7 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) { -string slsDetectorCommand::helpPulse(int narg, char *args[], int action) { +string slsDetectorCommand::helpPulse(int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { @@ -5746,11 +5752,11 @@ string slsDetectorCommand::helpPulse(int narg, char *args[], int action) { } -string slsDetectorCommand::cmdPulse(int narg, char *args[], int action) { +string slsDetectorCommand::cmdPulse(int narg, char *args[], int action, int detPos) { int retval = FAIL; if (action==HELP_ACTION) - return helpPulse(narg, args, action); + return helpPulse(action); else if (action==GET_ACTION) return string("cannot get ")+cmd; @@ -5769,7 +5775,7 @@ string slsDetectorCommand::cmdPulse(int narg, char *args[], int action) { //next commands requires 3 addnl. arguments int ival2=-1,ival3=-1; if(narg<4) - return string("insufficient arguments:\n" + helpPulse(narg, args, action)); + return string("insufficient arguments:\n" + helpPulse(action)); if (!sscanf(args[2],"%d",&ival2)) return string("Could not scan 2nd argument ")+string(args[2]); if (!sscanf(args[3],"%d",&ival3)) diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h index b02dcbe32..39b8fe3fd 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.h @@ -4,7 +4,8 @@ #include "sls_detector_defs.h" -#include "slsDetectorUtils.h" + +class multiSlsDetector; @@ -16,67 +17,69 @@ class slsDetectorCommand : public virtual slsDetectorDefs { public: - slsDetectorCommand(slsDetectorUtils *det); + slsDetectorCommand(multiSlsDetector *det); virtual ~slsDetectorCommand(){}; - /* /\** */ - /* executes a set of string arguments according to a given format. It is used to read/write configuration file, dump and retrieve detector settings and for the command line interface command parsing */ - /* \param narg number of arguments */ - /* \param args array of string arguments */ - /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ - /* \returns answer string */ - /* *\/ */ - virtual std::string executeLine(int narg, char *args[], int action); + /* + * Executes a set of string arguments according to a given format. + * It is used to read/write configuration file, dump and retrieve detector + * settings and for the command line interface command parsing + * @param narg number of arguments + * @param args array of string arguments + * @param action can be PUT_ACTION or GET_ACTION(from text client even READOUT_ACTION for acquisition) + * @param detPos -1 for all detectors in multi detector list or position of a specific detector in list + */ + virtual std::string executeLine(int narg, char *args[], int action, int detPos = -1); /* /\** */ /* returns the help for the executeLine command */ /* \param os output stream to return the help to */ /* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */ /* *\/ */ - std::string helpLine(int narg, char *args[], int action=HELP_ACTION); - static std::string helpAcquire(int narg, char *args[], int action); - static std::string helpData(int narg, char *args[], int action); - static std::string helpStatus(int narg, char *args[], int action); - static std::string helpDataStream(int narg, char *args[], int action); - static std::string helpFree(int narg, char *args[], int action); - static std::string helpHostname(int narg, char *args[], int action); - static std::string helpUser(int narg, char *args[], int action); - static std::string helpExitServer(int narg, char *args[], int action); - static std::string helpSettingsDir(int narg, char *args[], int action); - static std::string helpCalDir(int narg, char *args[], int action); - static std::string helpTrimEn(int narg, char *args[], int action); - static std::string helpOutDir(int narg, char *args[], int action); - static std::string helpFileName(int narg, char *args[], int action); - static std::string helpFileIndex(int narg, char *args[], int action); - static std::string helpRateCorr(int narg, char *args[], int action); - static std::string helpThreaded(int narg, char *args[], int action); - static std::string helpNetworkParameter(int narg, char *args[], int action); - static std::string helpPort(int narg, char *args[], int action); - static std::string helpLock(int narg, char *args[], int action); - static std::string helpLastClient(int narg, char *args[], int action); - static std::string helpOnline(int narg, char *args[], int action); - static std::string helpConfigureMac(int narg, char *args[], int action); - static std::string helpDetectorSize(int narg, char *args[], int action); - static std::string helpSettings(int narg, char *args[], int action); - static std::string helpSN(int narg, char *args[], int action); - static std::string helpDigiTest(int narg, char *args[], int action); - static std::string helpRegister(int narg, char *args[], int action); - static std::string helpDAC(int narg, char *args[], int action); - static std::string helpTimer(int narg, char *args[], int action); - static std::string helpTiming(int narg, char *args[], int action); - static std::string helpTimeLeft(int narg, char *args[], int action); - static std::string helpSpeed(int narg, char *args[], int action); - static std::string helpAdvanced(int narg, char *args[], int action); - static std::string helpConfiguration(int narg, char *args[], int action); - static std::string helpImage(int narg, char *args[], int action); - static std::string helpCounter(int narg, char *args[], int action); - static std::string helpADC(int narg, char *args[], int action); - static std::string helpTempControl(int narg, char *args[], int action); - static std::string helpEnablefwrite(int narg, char *args[], int action); - static std::string helpOverwrite(int narg, char *args[], int action); - static std::string helpReceiver(int narg, char *args[], int action); - static std::string helpPattern(int narg, char *args[], int action); - static std::string helpPulse(int narg, char *args[], int action); + std::string helpLine(int narg, int action=HELP_ACTION); + static std::string helpAcquire(int action); + static std::string helpData(int action); + static std::string helpStatus(int action); + static std::string helpDataStream(int action); + static std::string helpFree(int action); + static std::string helpHostname(int action); + static std::string helpUser(int action); + static std::string helpExitServer(int action); + static std::string helpSettingsDir(int action); + static std::string helpCalDir(int action); + static std::string helpTrimEn(int action); + static std::string helpOutDir(int action); + static std::string helpFileName(int action); + static std::string helpFileIndex(int action); + static std::string helpRateCorr(int action); + static std::string helpThreaded(int action); + static std::string helpNetworkParameter(int action); + static std::string helpPort(int action); + static std::string helpLock(int action); + static std::string helpLastClient(int action); + static std::string helpOnline(int action); + static std::string helpConfigureMac(int action); + static std::string helpDetectorSize(int action); + static std::string helpSettings(int action); + static std::string helpSN(int action); + static std::string helpDigiTest(int action); + static std::string helpRegister(int action); + static std::string helpDAC(int action); + static std::string helpTimer(int action); + static std::string helpTiming(int action); + static std::string helpTimeLeft(int action); + static std::string helpSpeed(int action); + static std::string helpAdvanced(int action); + static std::string helpConfiguration(int action); + static std::string helpImage(int action); + static std::string helpCounter(int action); + static std::string helpADC(int action); + static std::string helpTempControl(int action); + static std::string helpEnablefwrite(int action); + static std::string helpOverwrite(int action); + static std::string helpReceiver(int action); + static std::string helpPattern(int action); + static std::string helpPulse(int action); @@ -92,60 +95,60 @@ class slsDetectorCommand : public virtual slsDetectorDefs { private: - slsDetectorUtils *myDet; + multiSlsDetector *myDet; - std::string cmdUnderDevelopment(int narg, char *args[], int action); - std::string cmdUnknown(int narg, char *args[], int action); - std::string cmdAcquire(int narg, char *args[], int action); - std::string cmdData(int narg, char *args[], int action); - std::string cmdStatus(int narg, char *args[], int action); - std::string cmdDataStream(int narg, char *args[], int action); - std::string cmdFree(int narg, char *args[], int action); - std::string cmdHostname(int narg, char *args[], int action); - std::string cmdUser(int narg, char *args[], int action); - std::string cmdHelp(int narg, char *args[], int action); - std::string cmdExitServer(int narg, char *args[], int action); - std::string cmdSettingsDir(int narg, char *args[], int action); - std::string cmdCalDir(int narg, char *args[], int action); - std::string cmdTrimEn(int narg, char *args[], int action); - std::string cmdOutDir(int narg, char *args[], int action); - std::string cmdFileName(int narg, char *args[], int action); - std::string cmdFileIndex(int narg, char *args[], int action); - std::string cmdRateCorr(int narg, char *args[], int action); - std::string cmdThreaded(int narg, char *args[], int action); - std::string cmdNetworkParameter(int narg, char *args[], int action); - std::string cmdPort(int narg, char *args[], int action); - std::string cmdLock(int narg, char *args[], int action); - std::string cmdLastClient(int narg, char *args[], int action); - std::string cmdOnline(int narg, char *args[], int action); - std::string cmdConfigureMac(int narg, char *args[], int action); - std::string cmdDetectorSize(int narg, char *args[], int action); - std::string cmdSettings(int narg, char *args[], int action); - std::string cmdSN(int narg, char *args[], int action); - std::string cmdDigiTest(int narg, char *args[], int action); - std::string cmdRegister(int narg, char *args[], int action); - std::string cmdDAC(int narg, char *args[], int action); - std::string cmdTiming(int narg, char *args[], int action); - std::string cmdTimer(int narg, char *args[], int action); - std::string cmdTimeLeft(int narg, char *args[], int action); - std::string cmdSpeed(int narg, char *args[], int action); - std::string cmdAdvanced(int narg, char *args[], int action); - std::string cmdConfiguration(int narg, char *args[], int action); - std::string cmdImage(int narg, char *args[], int action); - std::string cmdCounter(int narg, char *args[], int action); - std::string cmdADC(int narg, char *args[], int action); - std::string cmdTempControl(int narg, char *args[], int action); - std::string cmdEnablefwrite(int narg, char *args[], int action); - std::string cmdOverwrite(int narg, char *args[], int action); - std::string cmdReceiver(int narg, char *args[], int action); - std::string cmdPattern(int narg, char *args[], int action); - std::string cmdPulse(int narg, char *args[], int action); + std::string cmdUnderDevelopment(int narg, char *args[], int action, int detPos = -1); + std::string cmdUnknown(int narg, char *args[], int action, int detPos = -1); + std::string cmdAcquire(int narg, char *args[], int action, int detPos = -1); + std::string cmdData(int narg, char *args[], int action, int detPos = -1); + std::string cmdStatus(int narg, char *args[], int action, int detPos = -1); + std::string cmdDataStream(int narg, char *args[], int action, int detPos = -1); + std::string cmdFree(int narg, char *args[], int action, int detPos = -1); + std::string cmdHostname(int narg, char *args[], int action, int detPos = -1); + std::string cmdUser(int narg, char *args[], int action, int detPos = -1); + std::string cmdHelp(int narg, char *args[], int action, int detPos = -1); + std::string cmdExitServer(int narg, char *args[], int action, int detPos = -1); + std::string cmdSettingsDir(int narg, char *args[], int action, int detPos = -1); + std::string cmdCalDir(int narg, char *args[], int action, int detPos = -1); + std::string cmdTrimEn(int narg, char *args[], int action, int detPos = -1); + std::string cmdOutDir(int narg, char *args[], int action, int detPos = -1); + std::string cmdFileName(int narg, char *args[], int action, int detPos = -1); + std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1); + std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1); + std::string cmdThreaded(int narg, char *args[], int action, int detPos = -1); + std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1); + std::string cmdPort(int narg, char *args[], int action, int detPos = -1); + std::string cmdLock(int narg, char *args[], int action, int detPos = -1); + std::string cmdLastClient(int narg, char *args[], int action, int detPos = -1); + std::string cmdOnline(int narg, char *args[], int action, int detPos = -1); + std::string cmdConfigureMac(int narg, char *args[], int action, int detPos = -1); + std::string cmdDetectorSize(int narg, char *args[], int action, int detPos = -1); + std::string cmdSettings(int narg, char *args[], int action, int detPos = -1); + std::string cmdSN(int narg, char *args[], int action, int detPos = -1); + std::string cmdDigiTest(int narg, char *args[], int action, int detPos = -1); + std::string cmdRegister(int narg, char *args[], int action, int detPos = -1); + std::string cmdDAC(int narg, char *args[], int action, int detPos = -1); + std::string cmdTiming(int narg, char *args[], int action, int detPos = -1); + std::string cmdTimer(int narg, char *args[], int action, int detPos = -1); + std::string cmdTimeLeft(int narg, char *args[], int action, int detPos = -1); + std::string cmdSpeed(int narg, char *args[], int action, int detPos = -1); + std::string cmdAdvanced(int narg, char *args[], int action, int detPos = -1); + std::string cmdConfiguration(int narg, char *args[], int action, int detPos = -1); + std::string cmdImage(int narg, char *args[], int action, int detPos = -1); + std::string cmdCounter(int narg, char *args[], int action, int detPos = -1); + std::string cmdADC(int narg, char *args[], int action, int detPos = -1); + std::string cmdTempControl(int narg, char *args[], int action, int detPos = -1); + std::string cmdEnablefwrite(int narg, char *args[], int action, int detPos = -1); + std::string cmdOverwrite(int narg, char *args[], int action, int detPos = -1); + std::string cmdReceiver(int narg, char *args[], int action, int detPos = -1); + std::string cmdPattern(int narg, char *args[], int action, int detPos = -1); + std::string cmdPulse(int narg, char *args[], int action, int detPos = -1); int numberOfCommands; std::string cmd; - typedef std::string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action); + typedef std::string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action, int detPos = -1); struct FuncTable diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp deleted file mode 100644 index 4b0057ba2..000000000 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "slsDetectorUtils.h" -#include "slsDetectorCommand.h" -#include "postProcessing.h" - - -#include -#include -#include -#include //clock() -#include -using namespace std; - -slsDetectorUtils::slsDetectorUtils(): - - { - -} - - - - - - - - - - - - diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h deleted file mode 100644 index 52f36343b..000000000 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ /dev/null @@ -1,85 +0,0 @@ - - -#ifndef SLS_DETECTOR_UTILS_H -#define SLS_DETECTOR_UTILS_H - - -#ifdef __CINT__ -class pthread_mutex_t; -class pthread_t; -#endif - - -extern "C" { -#include -} - -#include -#include -#include -#include -#include - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#include "postProcessing.h" - - - - - -/** - @short class containing all the possible detector functionalities - - (used in the PSi command line interface) - */ - - -class slsDetectorUtils : public postProcessing { - - -public: - - slsDetectorUtils(); - - virtual ~slsDetectorUtils(){}; - - - - - - - - - - - - - - - - - - -protected: - - - - -}; - - - -#endif diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp deleted file mode 100644 index 393207b7a..000000000 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include "postProcessing.h" - -#include - - -static void* startProcessData(void *n){ - postProcessing *myDet=(postProcessing*)n; - myDet->processData(); - pthread_exit(NULL); - -}; - - - -int postProcessing::kbhit(){ - struct timeval tv; - fd_set fds; - tv.tv_sec = 0; - tv.tv_usec = 0; - FD_ZERO(&fds); - FD_SET(STDIN_FILENO, &fds); //STDIN_FILENO is 0 - select(STDIN_FILENO+1, &fds, NULL, NULL, &tv); - return FD_ISSET(STDIN_FILENO, &fds); -} - - -postProcessing::postProcessing(): - threadedProcessing(0), - jointhread(0), - acquiringDone(0), - fdata(0), - thisData(0), - dataReady(0), - pCallbackArg(0) - { - pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; - mp=mp1; - pthread_mutex_init(&mp, NULL); - mg=mp1; - pthread_mutex_init(&mg, NULL); - ms=mp1; - pthread_mutex_init(&ms, NULL); - -} - - - - - -postProcessing::~postProcessing(){ -} - - -void* postProcessing::processData() { - if(setReceiverOnline()==OFFLINE_FLAG){ - return 0; - } //receiver - else{ - //cprintf(RED,"In post processing threads\n"); - - if(dataReady) { - readFrameFromReceiver(); - } - //only update progress - else{ - int caught = -1; - char c; - int ifp; - while(true){ - - // set only in startThread - if (*threadedProcessing==0) - setTotalProgress(); - - // to exit acquire by typing q - ifp=kbhit(); - if (ifp!=0){ - c=fgetc(stdin); - if (c=='q') { - std::cout<<"Caught the command to stop acquisition"< -#include -#include -#include -#include -#include -#include -#include -#include - - - -/** - @short methods for data postprocessing - (including thread for writing data files and plotting in parallel with the acquisition) -*/ - -class postProcessing: public virtual slsDetectorBase { - -public: - postProcessing(); - virtual ~postProcessing(); - - - /** - set/get if the data processing and file writing should be done by a separate threads - \param b 0 sequencial data acquisition and file writing, 1 separate thread, -1 get - \returns thread flag - */ - - int setThreadedProcessing(int b=-1) {if (b>=0) *threadedProcessing=b; return *threadedProcessing;}; - - /** processes the data - \returns nothing - */ - void *processData(); - - int checkJoinThread(); - void setJoinThread(int v); - - - void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) { \ - dataReady = userCallback; \ - pCallbackArg = pArg; \ - if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { \ - enableDataStreamingToClient(1); \ - enableDataStreamingFromReceiver(1);}}; \ - - - - -protected: - - /** - start data processing thread - */ - void startThread(); - - /** mutex to synchronize main and data processing threads */ - pthread_mutex_t mp; - - /** mutex to synchronizedata processing and plotting threads */ - pthread_mutex_t mg; - - /** mutex to synchronize slsdetector threads */ - pthread_mutex_t ms; - - int *threadedProcessing; - - /** sets when the acquisition is finished */ - int jointhread; - - /** set when detector finishes acquiring */ - int acquiringDone; - - - /** the data processing thread */ - - pthread_t dataProcessingThread; - - double *fdata; - detectorData *thisData; - - int (*dataReady)(detectorData*,int, int, void*); - void *pCallbackArg; - - -private: - int kbhit(void); - - -}; - - -#endif diff --git a/slsDetectorSoftware/slsDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServer/communication_funcs.c deleted file mode 120000 index 87a4f95d1..000000000 --- a/slsDetectorSoftware/slsDetectorServer/communication_funcs.c +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.c \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServer/communication_funcs.h deleted file mode 120000 index f220903b2..000000000 --- a/slsDetectorSoftware/slsDetectorServer/communication_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/communication_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h deleted file mode 120000 index c5062e03f..000000000 --- a/slsDetectorSoftware/slsDetectorServer/sls_detector_defs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h deleted file mode 120000 index 844b67129..000000000 --- a/slsDetectorSoftware/slsDetectorServer/sls_detector_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/9mhvserial_bf.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/9mhvserial_bf.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/9mhvserial_bf.c diff --git a/slsDetectorSoftware/eigerDetectorServer/Beb.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Beb.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/Beb.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Beb.c diff --git a/slsDetectorSoftware/eigerDetectorServer/Beb.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Beb.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/Beb.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Beb.h diff --git a/slsDetectorSoftware/eigerDetectorServer/Feb.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Feb.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/Feb.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Feb.c diff --git a/slsDetectorSoftware/eigerDetectorServer/Feb.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Feb.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/Feb.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Feb.h diff --git a/slsDetectorSoftware/eigerDetectorServer/FebControl.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebControl.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/FebControl.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebControl.c diff --git a/slsDetectorSoftware/eigerDetectorServer/FebControl.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebControl.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/FebControl.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebControl.h diff --git a/slsDetectorSoftware/eigerDetectorServer/FebInterface.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebInterface.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/FebInterface.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebInterface.c diff --git a/slsDetectorSoftware/eigerDetectorServer/FebInterface.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebInterface.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/FebInterface.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebInterface.h diff --git a/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/HardwareIO.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/HardwareIO.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/HardwareIO.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/HardwareIO.c diff --git a/slsDetectorSoftware/eigerDetectorServer/HardwareIO.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/HardwareIO.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/HardwareIO.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/HardwareIO.h diff --git a/slsDetectorSoftware/eigerDetectorServer/HardwareMMappingDefs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/HardwareMMappingDefs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/HardwareMMappingDefs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/LocalLinkInterface.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/LocalLinkInterface.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.c diff --git a/slsDetectorSoftware/eigerDetectorServer/LocalLinkInterface.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/LocalLinkInterface.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/LocalLinkInterface.h diff --git a/slsDetectorSoftware/eigerDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/Makefile rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile diff --git a/slsDetectorSoftware/eigerDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile.virtual similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/Makefile.virtual rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile.virtual diff --git a/slsDetectorSoftware/eigerDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/ansi.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/ansi.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/ansi.h diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_developer rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_virtualMaster diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_virtualSlave diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/hv9m_blackfin_serverv3.0.0.1 b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/hv9m_blackfin_serverv3.0.0.1 similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/bin/hv9m_blackfin_serverv3.0.0.1 rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/hv9m_blackfin_serverv3.0.0.1 diff --git a/slsDetectorSoftware/eigerDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/communication_funcs.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.c diff --git a/slsDetectorSoftware/eigerDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/communication_funcs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfo.txt similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/gitInfo.txt rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfo.txt diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/gitInfoEiger.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h diff --git a/slsDetectorSoftware/eigerDetectorServer/gitInfoEigerTmp.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEigerTmp.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/gitInfoEigerTmp.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEigerTmp.h diff --git a/slsDetectorSoftware/eigerDetectorServer/renameServer.sh b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/renameServer.sh similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/renameServer.sh rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/renameServer.sh diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.h diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorServer.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/slsDetectorServer.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer.c diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_defs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_funcs.c similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_funcs.c rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_funcs.c diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_funcs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/slsDetectorServer_funcs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_funcs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_defs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/sls_detector_defs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_defs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_funcs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/sls_detector_funcs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_funcs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_defs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/sls_receiver_defs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_defs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_funcs.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/sls_receiver_funcs.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_funcs.h diff --git a/slsDetectorSoftware/eigerDetectorServer/updateAPIVersion.sh b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateAPIVersion.sh similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/updateAPIVersion.sh rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateAPIVersion.sh diff --git a/slsDetectorSoftware/eigerDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/updateGitVersion.sh rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh diff --git a/slsDetectorSoftware/eigerDetectorServer/versionAPI.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/versionAPI.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/versionAPI.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/versionAPI.h diff --git a/slsDetectorSoftware/eigerDetectorServer/xfs_types.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/xfs_types.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/xfs_types.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/xfs_types.h diff --git a/slsDetectorSoftware/eigerDetectorServer/xparameters.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/xparameters.h similarity index 100% rename from slsDetectorSoftware/eigerDetectorServer/xparameters.h rename to slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/xparameters.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/.target-makefrag b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/.target-makefrag similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/.target-makefrag rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/.target-makefrag diff --git a/slsDetectorSoftware/gotthardDetectorServer/AD9257.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/AD9257.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/AD9257.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/AD9257.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/Makefile rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile diff --git a/slsDetectorSoftware/gotthardDetectorServer/Makefile.propix b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.propix similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/Makefile.propix rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.propix diff --git a/slsDetectorSoftware/gotthardDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.virtual similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/Makefile.virtual rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.virtual diff --git a/slsDetectorSoftware/gotthardDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/ansi.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/ansi.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/ansi.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/commonServerFunctions.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/commonServerFunctions.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/commonServerFunctions.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.c similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/communication_funcs.c rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.c diff --git a/slsDetectorSoftware/gotthardDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/communication_funcs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/config.txt b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/config.txt similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/config.txt rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/config.txt diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/firmware_funcs.c similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/firmware_funcs.c diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/firmware_funcs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/firmware_funcs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gitInfo.txt similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/gitInfo.txt rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gitInfo.txt diff --git a/slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthard.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthard.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthardTmp.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gitInfoGotthardTmp.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/gitInfoGotthardTmp.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gitInfoGotthardTmp.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServer_developer similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_developer rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServer_developer diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServer_virtual similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer_virtual rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServer_virtual diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3 b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3 similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3 rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3 diff --git a/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/mcb_funcs.c similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/mcb_funcs.c diff --git a/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/mcb_funcs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/mcb_funcs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/registers_g.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/registers_g.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/registers_g.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/registers_g.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/server.c b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server.c similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/server.c rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server.c diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_defs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server_defs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/server_defs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server_defs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server_funcs.c similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/server_funcs.c rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server_funcs.c diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server_funcs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/server_funcs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/server_funcs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_defs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/sls_detector_defs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_defs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_funcs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/sls_detector_funcs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_funcs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_defs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/sls_receiver_defs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_defs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_funcs.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/sls_receiver_funcs.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_funcs.h diff --git a/slsDetectorSoftware/gotthardDetectorServer/stop_server.c b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/stop_server.c similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/stop_server.c rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/stop_server.c diff --git a/slsDetectorSoftware/gotthardDetectorServer/updateAPIVersion.sh b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateAPIVersion.sh similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/updateAPIVersion.sh rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateAPIVersion.sh diff --git a/slsDetectorSoftware/gotthardDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/updateGitVersion.sh rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh diff --git a/slsDetectorSoftware/gotthardDetectorServer/versionAPI.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/versionAPI.h similarity index 100% rename from slsDetectorSoftware/gotthardDetectorServer/versionAPI.h rename to slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/versionAPI.h diff --git a/slsDetectorSoftware/jctbDetectorServer/AD9257.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/AD9257.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/AD9257.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/AD9257.h diff --git a/slsDetectorSoftware/jctbDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/Makefile similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/Makefile rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/Makefile diff --git a/slsDetectorSoftware/jctbDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/ansi.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/ansi.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/ansi.h diff --git a/slsDetectorSoftware/jctbDetectorServer/bf_init.sh b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/bf_init.sh similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/bf_init.sh rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/bf_init.sh diff --git a/slsDetectorSoftware/jctbDetectorServer/blackfin.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/blackfin.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/blackfin.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/blackfin.c diff --git a/slsDetectorSoftware/jctbDetectorServer/blackfin.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/blackfin.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/blackfin.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/blackfin.h diff --git a/slsDetectorSoftware/jctbDetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/commonServerFunctions.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/commonServerFunctions.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/commonServerFunctions.h diff --git a/slsDetectorSoftware/jctbDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/communication_funcs.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/communication_funcs.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/communication_funcs.c diff --git a/slsDetectorSoftware/jctbDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/communication_funcs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/communication_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/communication_funcs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/convert_pof_to_raw.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/convert_pof_to_raw.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/convert_pof_to_raw.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/convert_pof_to_raw.c diff --git a/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/firmware_funcs.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/firmware_funcs.c diff --git a/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/firmware_funcs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/firmware_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/firmware_funcs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/get_server.sh b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/get_server.sh similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/get_server.sh rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/get_server.sh diff --git a/slsDetectorSoftware/jctbDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/gitInfo.txt similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/gitInfo.txt rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/gitInfo.txt diff --git a/slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/gitInfoMoench.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/gitInfoMoench.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/gitInfoMoench.h diff --git a/slsDetectorSoftware/jctbDetectorServer/gitInfoMoenchTmp.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/gitInfoMoenchTmp.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/gitInfoMoenchTmp.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/gitInfoMoenchTmp.h diff --git a/slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer_developer b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/jctbDetectorServer_developer similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/jctbDetectorServer_developer rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/jctbDetectorServer_developer diff --git a/slsDetectorSoftware/jctbDetectorServer/mcb_funcs.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/mcb_funcs.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/mcb_funcs.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/mcb_funcs.c diff --git a/slsDetectorSoftware/jctbDetectorServer/mcb_funcs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/mcb_funcs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/mcb_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/mcb_funcs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/program_fpga.sh b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/program_fpga.sh similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/program_fpga.sh rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/program_fpga.sh diff --git a/slsDetectorSoftware/jctbDetectorServer/registers_m.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/registers_m.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/registers_m.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/registers_m.h diff --git a/slsDetectorSoftware/jctbDetectorServer/server.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/server.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server.c diff --git a/slsDetectorSoftware/jctbDetectorServer/server_defs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_defs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/server_defs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_defs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/server_funcs.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/server_funcs.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.c diff --git a/slsDetectorSoftware/jctbDetectorServer/server_funcs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/server_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/server_funcs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/sharedmemory.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sharedmemory.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/sharedmemory.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sharedmemory.c diff --git a/slsDetectorSoftware/jctbDetectorServer/sharedmemory.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sharedmemory.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/sharedmemory.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sharedmemory.h diff --git a/slsDetectorSoftware/jctbDetectorServer/slow_adc.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/slow_adc.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/slow_adc.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/slow_adc.c diff --git a/slsDetectorSoftware/jctbDetectorServer/slow_adc.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/slow_adc.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/slow_adc.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/slow_adc.h diff --git a/slsDetectorSoftware/jctbDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_detector_defs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/sls_detector_defs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_detector_defs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_detector_funcs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/sls_detector_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_detector_funcs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_receiver_defs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/sls_receiver_defs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_receiver_defs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_receiver_funcs.h similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/sls_receiver_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/sls_receiver_funcs.h diff --git a/slsDetectorSoftware/jctbDetectorServer/stop_server.c b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/stop_server.c similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/stop_server.c rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/stop_server.c diff --git a/slsDetectorSoftware/jctbDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/updateGitVersion.sh similarity index 100% rename from slsDetectorSoftware/jctbDetectorServer/updateGitVersion.sh rename to slsDetectorSoftware/slsDetectorServers/jctbDetectorServer/updateGitVersion.sh diff --git a/slsDetectorSoftware/jungfrauDetectorServer/AD9257.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/AD9257.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/AD9257.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/AD9257.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/Makefile rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile diff --git a/slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/Makefile.virtual rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual diff --git a/slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/RegisterDefs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/RegisterDefs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/ansi.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/ansi.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/ansi.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer diff --git a/slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_virtual diff --git a/slsDetectorSoftware/jungfrauDetectorServer/blackfin.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/blackfin.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/blackfin.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/blackfin.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/commonServerFunctions.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/commonServerFunctions.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/commonServerFunctions.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.c similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/communication_funcs.c rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.c diff --git a/slsDetectorSoftware/jungfrauDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/communication_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/gitInfo.txt rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt diff --git a/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrau.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrauTmp.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrauTmp.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/gitInfoJungfrauTmp.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrauTmp.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/programfpga.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/programfpga.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/programfpga.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/programfpga.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.c rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/slsDetectorFunctionList.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer.c b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer.c similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer.c rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer.c diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_defs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_funcs.c similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.c rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_funcs.c diff --git a/slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_funcs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/slsDetectorServer_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_funcs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_defs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/sls_detector_defs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_defs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_funcs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/sls_detector_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_funcs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_defs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/sls_receiver_defs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_defs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_funcs.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/sls_receiver_funcs.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_funcs.h diff --git a/slsDetectorSoftware/jungfrauDetectorServer/updateAPIVersion.sh b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateAPIVersion.sh similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/updateAPIVersion.sh rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateAPIVersion.sh diff --git a/slsDetectorSoftware/jungfrauDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/updateGitVersion.sh rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh diff --git a/slsDetectorSoftware/jungfrauDetectorServer/versionAPI.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/versionAPI.h similarity index 100% rename from slsDetectorSoftware/jungfrauDetectorServer/versionAPI.h rename to slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/versionAPI.h diff --git a/slsDetectorSoftware/moenchDetectorServer/.target-makefrag b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/.target-makefrag similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/.target-makefrag rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/.target-makefrag diff --git a/slsDetectorSoftware/moenchDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/Makefile rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile diff --git a/slsDetectorSoftware/moenchDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile.virtual similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/Makefile.virtual rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile.virtual diff --git a/slsDetectorSoftware/moenchDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/ansi.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/ansi.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/ansi.h diff --git a/slsDetectorSoftware/moenchDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/communication_funcs.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.c diff --git a/slsDetectorSoftware/moenchDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/communication_funcs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.c diff --git a/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/firmware_funcs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfo.txt similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/gitInfo.txt rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfo.txt diff --git a/slsDetectorSoftware/moenchDetectorServer/gitInfoMoench.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/gitInfoMoench.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h diff --git a/slsDetectorSoftware/moenchDetectorServer/gitInfoMoenchTmp.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/gitInfoMoenchTmp.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h diff --git a/slsDetectorSoftware/moenchDetectorServer/mcb_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/mcb_funcs.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/mcb_funcs.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/mcb_funcs.c diff --git a/slsDetectorSoftware/moenchDetectorServer/mcb_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/mcb_funcs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/mcb_funcs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/mcb_funcs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/moenchVirtualServer b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/moenchVirtualServer similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/moenchVirtualServer rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/moenchVirtualServer diff --git a/slsDetectorSoftware/moenchDetectorServer/registers_m.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/registers_m.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/registers_m.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/registers_m.h diff --git a/slsDetectorSoftware/moenchDetectorServer/server.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/server.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server.c diff --git a/slsDetectorSoftware/moenchDetectorServer/server_defs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_defs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/server_defs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_defs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/server_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/server_funcs.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.c diff --git a/slsDetectorSoftware/moenchDetectorServer/server_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/server_funcs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/sharedmemory.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/sharedmemory.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.c diff --git a/slsDetectorSoftware/moenchDetectorServer/sharedmemory.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/sharedmemory.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.h diff --git a/slsDetectorSoftware/moenchDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_defs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/sls_detector_defs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_defs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_funcs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/sls_detector_funcs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_funcs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_defs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/sls_receiver_defs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_defs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_funcs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/sls_receiver_funcs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_funcs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/stop_server.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/stop_server.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/stop_server.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/stop_server.c diff --git a/slsDetectorSoftware/moenchDetectorServer/trimming_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.c similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/trimming_funcs.c rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.c diff --git a/slsDetectorSoftware/moenchDetectorServer/trimming_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.h similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/trimming_funcs.h rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.h diff --git a/slsDetectorSoftware/moenchDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh similarity index 100% rename from slsDetectorSoftware/moenchDetectorServer/updateGitVersion.sh rename to slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh diff --git a/slsDetectorSoftware/mythen3DetectorServer/AD9257.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/AD9257.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/AD9257.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/AD9257.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/Makefile similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/Makefile rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/Makefile diff --git a/slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/Makefile.virtual similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/Makefile.virtual rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/Makefile.virtual diff --git a/slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/RegisterDefs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/ansi.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/ansi.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/ansi.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/blackfin.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/blackfin.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/blackfin.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/blackfin.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/commonServerFunctions.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/commonServerFunctions.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/commonServerFunctions.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/communication_funcs.c similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/communication_funcs.c rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/communication_funcs.c diff --git a/slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/communication_funcs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/communication_funcs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/communication_funcs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/gitInfo.txt similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/gitInfo.txt rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/gitInfo.txt diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3Tmp.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/gitInfoMythen3Tmp.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/gitInfoMythen3Tmp.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/mythen3Server similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/mythen3Server rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/mythen3Server diff --git a/slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/mythen3Server.gdb similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/mythen3Server.gdb rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/mythen3Server.gdb diff --git a/slsDetectorSoftware/mythen3DetectorServer/programfpga.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/programfpga.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/programfpga.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/programfpga.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.c rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/slsDetectorFunctionList.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer.c similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer.c rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer.c diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_defs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.c similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.c rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.c diff --git a/slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/slsDetectorServer_funcs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_funcs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_detector_defs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/sls_detector_defs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_detector_defs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_detector_funcs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/sls_detector_funcs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_detector_funcs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_receiver_defs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/sls_receiver_defs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_receiver_defs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_receiver_funcs.h similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/sls_receiver_funcs.h rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/sls_receiver_funcs.h diff --git a/slsDetectorSoftware/mythen3DetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/updateGitVersion.sh similarity index 100% rename from slsDetectorSoftware/mythen3DetectorServer/updateGitVersion.sh rename to slsDetectorSoftware/slsDetectorServers/mythen3DetectorServer/updateGitVersion.sh diff --git a/slsDetectorSoftware/slsDetectorServer/AD9257.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/AD9257.h similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/AD9257.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/AD9257.h diff --git a/slsDetectorSoftware/slsDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/Makefile similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/Makefile rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/Makefile diff --git a/slsDetectorSoftware/slsDetectorServer/blackfin.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/blackfin.h similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/blackfin.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/blackfin.h diff --git a/slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/commonServerFunctions.h similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/commonServerFunctions.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/commonServerFunctions.h diff --git a/slsDetectorSoftware/mythenDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/communication_funcs.c similarity index 100% rename from slsDetectorSoftware/mythenDetectorServer/communication_funcs.c rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/communication_funcs.c diff --git a/slsDetectorSoftware/mythenDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/communication_funcs.h similarity index 100% rename from slsDetectorSoftware/mythenDetectorServer/communication_funcs.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/communication_funcs.h diff --git a/slsDetectorSoftware/slsDetectorServer/programfpga.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/programfpga.h similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/programfpga.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/programfpga.h diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.c similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.c rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.c diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer.c similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/slsDetectorServer.c rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer.c diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_defs.h similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/slsDetectorServer_defs.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_defs.h diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetector_stopServer.c b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetector_stopServer.c similarity index 100% rename from slsDetectorSoftware/slsDetectorServer/slsDetector_stopServer.c rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetector_stopServer.c diff --git a/slsDetectorSoftware/mythenDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/sls_detector_defs.h similarity index 100% rename from slsDetectorSoftware/mythenDetectorServer/sls_detector_defs.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/sls_detector_defs.h diff --git a/slsDetectorSoftware/mythenDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/sls_detector_funcs.h similarity index 100% rename from slsDetectorSoftware/mythenDetectorServer/sls_detector_funcs.h rename to slsDetectorSoftware/slsDetectorServers/slsDetectorServer/sls_detector_funcs.h diff --git a/slsDetectorSoftware/threadFiles/CondVar.cpp b/slsDetectorSoftware/threadFiles/CondVar.cpp deleted file mode 100644 index 2feff962f..000000000 --- a/slsDetectorSoftware/threadFiles/CondVar.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "CondVar.h" - -CondVar::CondVar() { - pthread_cond_init(&m_cond_var, NULL); -} -CondVar::~CondVar() { - pthread_cond_destroy(&m_cond_var); -} -void CondVar::wait(pthread_mutex_t* mutex) { - pthread_cond_wait(&m_cond_var, mutex); -} -void CondVar::signal() { - pthread_cond_signal(&m_cond_var); -} -void CondVar::broadcast() { - pthread_cond_broadcast(&m_cond_var); -} diff --git a/slsDetectorSoftware/threadFiles/CondVar.h b/slsDetectorSoftware/threadFiles/CondVar.h deleted file mode 100644 index 3bf69d146..000000000 --- a/slsDetectorSoftware/threadFiles/CondVar.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "Global.h" - - -class CondVar { -public: - - CondVar(); - ~CondVar(); - void wait(pthread_mutex_t* mutex); - void signal(); - void broadcast(); - -private: - pthread_cond_t m_cond_var; -}; diff --git a/slsDetectorSoftware/threadFiles/Global.h b/slsDetectorSoftware/threadFiles/Global.h deleted file mode 100644 index 2596df0c0..000000000 --- a/slsDetectorSoftware/threadFiles/Global.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -const int DEFAULT_POOL_SIZE = 10; -const int MAX_SINGLES = 5; -const int STARTED = 0; -const int STOPPED = 1; diff --git a/slsDetectorSoftware/threadFiles/Makefile b/slsDetectorSoftware/threadFiles/Makefile deleted file mode 100644 index a1eb27d29..000000000 --- a/slsDetectorSoftware/threadFiles/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -OBJPATH=bin/obj -EXAMPLEPATH=bin/example - -all: - 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 -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 -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 diff --git a/slsDetectorSoftware/threadFiles/Multi.cpp b/slsDetectorSoftware/threadFiles/Multi.cpp deleted file mode 100644 index 02e34438e..000000000 --- a/slsDetectorSoftware/threadFiles/Multi.cpp +++ /dev/null @@ -1,197 +0,0 @@ -#include "Multi.h" -#include "Single.h" -#include "ThreadPool.h" - - - -#include -#include -#include -#include -using namespace std; - -char ans[1000]; -int threadflag = 1; - -Multi::Multi() { - numSingles = 1; - threadpool = 0; - for(int i=0;idestroy_threadpool(); - threadpool=0; - } - if(numSingles > 0) - threadpool = new ThreadPool(numSingles); - switch(threadpool->initialize_threadpool()){ - case -1: - cerr << "Failed to initialize thread pool!" << endl; - return 0; - case 0: - cout << "Not initializing threads, only one detector" << endl; - break; - default: - cout << "Initialized Threadpool" << endl; - break; - } - return 1; -} - -int Multi::destroyThreadPool(){ - if(threadpool){ - threadpool->destroy_threadpool(); - threadpool=0; - cout<<"Destroyed Threadpool"<* binder = - // new func_t(&Single::printNumber,singles[i],inum,iret[i]); - Task* task = new Task(new func1_t(&Single::printNumber,singles[i],inum,iret[i])); - threadpool->add_task(task); - } - threadpool->wait_for_tasks_to_complete(); - - - for(int i=0;i1){ - string* sret[numSingles]; - - - for(int i=0;i* binder = - new func1_t(&Single::printString,singles[i],s,sret[i]); - Task* task = new Task(binder); - threadpool->add_task(task); - } - threadpool->wait_for_tasks_to_complete(); - for(int i=0;iprintString(s); - if(ret=="error") - ret = ret1; - else if (ret != ret1) - ret = "sss"; - } - } - return ret; -} - -char* Multi::printCharArray(char a[]){ - string ret="error", ret1="sss"; - - if(numSingles>1){ - string* sret[numSingles]; - - for(int i=0;i* binder = - new func1_t (&Single::printCharArray,singles[i],a,sret[i]); - Task* task = new Task(binder); - threadpool->add_task(task); - } - threadpool->wait_for_tasks_to_complete(); - - for(int i=0;iprintCharArray(a); - if(ret=="error") - ret = ret1; - else if (ret != ret1) - ret = "sss"; - } - } - strcpy(ans,ret.c_str()); - return ans; -} diff --git a/slsDetectorSoftware/threadFiles/Multi.h b/slsDetectorSoftware/threadFiles/Multi.h deleted file mode 100644 index cf34396a8..000000000 --- a/slsDetectorSoftware/threadFiles/Multi.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - - -#include "Global.h" - -#include - -class Single; -class ThreadPool; - -class Multi { -public: - - Multi(); - ~Multi(); - - std::string executeCommand(int argc,char* argv[]); - - int printNumber(int inum); - std::string printString(std::string s); - char* printCharArray(char a[]); - - int createThreadPool(); - int destroyThreadPool(); - -protected: - Single* singles[MAX_SINGLES]; - int numSingles; - ThreadPool* threadpool; - - - -}; - - diff --git a/slsDetectorSoftware/threadFiles/Mutex.cpp b/slsDetectorSoftware/threadFiles/Mutex.cpp deleted file mode 100644 index 4aefec723..000000000 --- a/slsDetectorSoftware/threadFiles/Mutex.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Mutex.h" - -Mutex::Mutex() { - pthread_mutex_init(&m_lock, NULL); - is_locked = false; -} - -Mutex::~Mutex() { - while(is_locked); - //unlock(); // Unlock Mutex after shared resource is safe - pthread_mutex_destroy(&m_lock); -} - -void Mutex::lock() { - pthread_mutex_lock(&m_lock); - is_locked = true; -} - -void Mutex::unlock() { - is_locked = false; // do it BEFORE unlocking to avoid race condition - pthread_mutex_unlock(&m_lock); -} - -pthread_mutex_t* Mutex::get_mutex_ptr(){ - return &m_lock; -} diff --git a/slsDetectorSoftware/threadFiles/Mutex.h b/slsDetectorSoftware/threadFiles/Mutex.h deleted file mode 100644 index 33e108777..000000000 --- a/slsDetectorSoftware/threadFiles/Mutex.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include "Global.h" - -// - -class Mutex -{ -public: - Mutex(); - ~Mutex(); - void lock(); - void unlock(); - pthread_mutex_t* get_mutex_ptr(); - -private: - pthread_mutex_t m_lock; - volatile bool is_locked; -}; diff --git a/slsDetectorSoftware/threadFiles/Single.cpp b/slsDetectorSoftware/threadFiles/Single.cpp deleted file mode 100644 index 43b0ca14b..000000000 --- a/slsDetectorSoftware/threadFiles/Single.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "Single.h" - -#include -#include -using namespace std; - -char local_ans[1000]; - -Single::Single(int id) { - detID = id; - // cout<<"detID:"< -// - -class Single { -public: - Single(int id); - ~Single(); - int getID(); - - int printNumber(int i); - string printString(string s); - char* printCharArray(char a[]); - -private: - int detID; - - int* someValue; - -}; - diff --git a/slsDetectorSoftware/threadFiles/Task.h b/slsDetectorSoftware/threadFiles/Task.h deleted file mode 100644 index 9b926aadf..000000000 --- a/slsDetectorSoftware/threadFiles/Task.h +++ /dev/null @@ -1,221 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Global.h" -#include "sls_detector_defs.h" - -class slsDetector; - -template -class func00_t{ -public: - func00_t(_Ret (slsDetector::*fn)(),slsDetector* ptr): - m_fn(fn),m_ptr(ptr){} - ~func00_t() {} - void operator()() const {((m_ptr->*m_fn)());} -private: - _Ret (slsDetector::*m_fn)(); - slsDetector* m_ptr; -}; - -template -class func0_t{ -public: - func0_t(_Ret (slsDetector::*fn)(),slsDetector* ptr, _Ret* sto): - m_fn(fn),m_ptr(ptr),m_store(sto){} - ~func0_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)());} -private: - _Ret (slsDetector::*m_fn)(); - slsDetector* m_ptr; - _Ret* m_store; -}; - -template -class func1_t{ -public: - func1_t(_Ret (slsDetector::*fn)(_Arg1),slsDetector* ptr,_Arg1 arg1, _Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_store(sto){} - ~func1_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));} -private: - _Ret (slsDetector::*m_fn)(_Arg1); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Ret* m_store; -}; - -template -class func2_t{ -public: - func2_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_store(sto){} - ~func2_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));} -private: - _Ret (slsDetector::*m_fn)(_Arg1,_Arg2); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Arg2 m_arg2; - _Ret* m_store; -}; - -template -class func3_t{ -public: - func3_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_store(sto){} - ~func3_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3));} -private: - _Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Arg2 m_arg2; - _Arg3 m_arg3; - _Ret* m_store; -}; - -template -class func4_t{ -public: - func4_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3,_Arg4),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Arg4 arg4,_Ret* sto): - m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_arg4(arg4),m_store(sto){} - ~func4_t() {} - void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));} -private: - _Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4); - slsDetector* m_ptr; - _Arg1 m_arg1; - _Arg2 m_arg2; - _Arg3 m_arg3; - _Arg4 m_arg4; - _Ret* m_store; -}; - - -class SuperTask: public virtual slsDetectorDefs { -public: - SuperTask(): - m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0),m19(0){}; - virtual ~SuperTask(){}; -protected: - /** Function signature defined - * First argument is Return type, the remaining are arguments - */ - func00_t * m1; - func0_t * m2; - func0_t * m3; - func0_t * m4; - func1_t * m5; - func1_t * m6; - func1_t * m7; - func1_t * m8; - func2_t * m9; - func2_t * m10; - func2_t * m11; - func2_t * m12; - func3_t * m13; - func2_t * m14; - func3_t * m15; - func4_t * m16; - func4_t * m17; - func1_t * m18; - func1_t * m19; -}; - -class Task: public virtual SuperTask { -public: - /** Task Constructors using appropriate function signature - * First argument is Return type, the remaining are arguments - */ - Task(func00_t * t): SuperTask(),fnum(1){m1 = t;}; - Task(func0_t * t): SuperTask(),fnum(2){m2 = t;}; - Task(func0_t * t): SuperTask(),fnum(3){m3 = t;}; - Task(func0_t * t): SuperTask(),fnum(4){m4 = t;}; - Task(func1_t * t): SuperTask(),fnum(5){m5 = t;}; - Task(func1_t * t): SuperTask(),fnum(6){m6 = t;}; - Task(func1_t * t): SuperTask(),fnum(7){m7 = t;}; - Task(func1_t * t): SuperTask(),fnum(8){m8 = t;}; - Task(func2_t * t): SuperTask(),fnum(9){m9 = t;}; - Task(func2_t * t): SuperTask(),fnum(10){m10 = t;}; - Task(func2_t * t): SuperTask(),fnum(11){m11 = t;}; - Task(func2_t * t): SuperTask(),fnum(12){m12 = t;}; - Task(func3_t * t): SuperTask(),fnum(13){m13 = t;}; - Task(func2_t * t): SuperTask(),fnum(14){m14 = t;}; - Task(func3_t * t): SuperTask(),fnum(15){m15 = t;}; - Task(func4_t * t): SuperTask(),fnum(16){m16 = t;}; - Task(func4_t * t): SuperTask(),fnum(17){m17 = t;}; - Task(func1_t * t): SuperTask(),fnum(18){m18 = t;}; - Task(func1_t * t): SuperTask(),fnum(19){m19 = t;}; - - virtual ~Task(){ - switch(fnum) { - case 1: delete m1; break; - case 2: delete m2; break; - case 3: delete m3; break; - case 4: delete m4; break; - case 5: delete m5; break; - case 6: delete m6; break; - case 7: delete m7; break; - case 8: delete m8; break; - case 9: delete m9; break; - case 10: delete m10; break; - case 11: delete m11; break; - case 12: delete m12; break; - case 13: delete m13; break; - case 14: delete m14; break; - case 15: delete m15; break; - case 16: delete m16; break; - case 17: delete m17; break; - case 18: delete m18; break; - case 19: delete m19; break; - default: - cprintf(RED, "Error: Task not defined. Abort!\n"); - break; - } - - }; - - void operator()(){ - switch(fnum) { - case 1: (*m1)(); break; - case 2: (*m2)(); break; - case 3: (*m3)(); break; - case 4: (*m4)(); break; - case 5: (*m5)(); break; - case 6: (*m6)(); break; - case 7: (*m7)(); break; - case 8: (*m8)(); break; - case 9: (*m9)(); break; - case 10: (*m10)(); break; - case 11: (*m11)(); break; - case 12: (*m12)(); break; - case 13: (*m13)(); break; - case 14: (*m14)(); break; - case 15: (*m15)(); break; - case 16: (*m16)(); break; - case 17: (*m17)(); break; - case 18: (*m18)(); break; - case 19: (*m19)(); break; - default: - cprintf(RED, "Error: Task not defined. Abort!\n"); - break; - } - } - -private: - /** function number */ - int fnum; - -}; - - diff --git a/slsDetectorSoftware/threadFiles/ThreadPool.cpp b/slsDetectorSoftware/threadFiles/ThreadPool.cpp deleted file mode 100644 index 224038f5c..000000000 --- a/slsDetectorSoftware/threadFiles/ThreadPool.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include "ThreadPool.h" -#include -using namespace std; -ThreadPool::ThreadPool(int pool_size) : m_pool_size(pool_size){ -#ifdef VERBOSE - cout << "Constructed ThreadPool of size " << m_pool_size << endl; -#endif - m_tasks_loaded = false; - thread_started = false; - current_thread_number = -1; - number_of_ongoing_tasks = 0; - number_of_total_tasks = 0; -} - -ThreadPool::~ThreadPool(){ - // Release resources - if (m_pool_state != STOPPED) { - destroy_threadpool(); - } -} - - -extern "C" -void* start_thread(void* arg) -{ - ThreadPool* tp = (ThreadPool*) arg; - tp->execute_thread(); - return NULL; -} - -int ThreadPool::initialize_threadpool(){ - if(m_pool_size == 1) - return m_pool_size; - - m_pool_state = STARTED; - int ret = -1; - sem_init(&semStart,1,0); - sem_init(&semDone,1,0); - for (int i = 0; i < m_pool_size; i++) { - pthread_t tid; - thread_started = false; - current_thread_number = i; - ret = pthread_create(&tid, NULL, start_thread, (void*) this); - if (ret != 0) { - cerr << "pthread_create() failed: " << ret << endl; - return 0; - } - m_threads.push_back(tid); - while(!thread_started); - } -#ifdef VERBOSE - cout << m_pool_size << " threads created by the thread pool" << endl; -#endif - return m_pool_size; -} - -int ThreadPool::destroy_threadpool(){ - if(m_pool_size == 1) - return 0; - /*cout << "in destroying threadpool" << endl;*/ - // thread communication- modified m_pool_state may not show up - //to other threads until its modified in a lock! - m_task_mutex.lock(); - m_pool_state = STOPPED; - /*cout << "Broadcasting STOP signal to all threads..." << endl;*/ - m_task_cond_var.broadcast(); // notify all threads we are shttung down - m_task_mutex.unlock(); - -// int ret = -1; - for (int i = 0; i < m_pool_size; i++) { - sem_post(&semStart); - sem_post(&semDone); - - void* result; - pthread_join(m_threads[i], &result); - /*cout << "pthread_join() returned " << ret << ": " << strerror(errno) << endl;*/ - m_task_mutex.lock(); - m_task_cond_var.broadcast(); // try waking up a bunch of threads that are still waiting - m_task_mutex.unlock(); - } - - - sem_destroy(&semStart); - sem_destroy(&semDone); - number_of_ongoing_tasks = 0; - number_of_total_tasks = 0; - - /* cout << m_pool_size << " threads exited from the thread pool" << endl;*/ - return 0; -} - -void* ThreadPool::execute_thread(){ -//for debugging seting ithread value -// int ithread = current_thread_number; - thread_started = true; - Task* task = NULL; - m_tasks_loaded = false; - /*cout << "Starting thread " << pthread_self() << endl;*/ - while(true) { - // Try to pick a task - /*cout << "Locking: " << pthread_self() << endl;*/ - m_task_mutex.lock(); - - while ((m_pool_state != STOPPED) && (m_tasks.empty())) { - // Wait until there is a task in the queue - // Unlock mutex while wait, then lock it back when signaled - /* cout << "Unlocking and waiting: " << pthread_self() << endl;*/ - m_task_cond_var.wait(m_task_mutex.get_mutex_ptr()); - /* cout << "Signaled and locking: " << pthread_self() << endl;*/ - } - - // If the thread was woken up to notify process shutdown, return from here - if (m_pool_state == STOPPED) { - /* cout << "Unlocking and exiting: " << pthread_self() << endl;*/ - m_task_mutex.unlock(); - pthread_exit(NULL); - } - - task = m_tasks.front(); - m_tasks.pop_front(); - /*cout << "Unlocking: " << pthread_self() << endl;*/ - m_task_mutex.unlock(); - - sem_wait(&semStart); - - //cout<<"***"<run(arg); - /*cout << ithread <<" Done executing thread " << pthread_self() << endl;*/ - - delete task; - /*cout << ithread << " task deleted" << endl;*/ - - m_task_mutex.lock(); - number_of_ongoing_tasks--; - m_task_mutex.unlock(); - - //last task and check m_tasks_loaded to ensure done only once - if((!number_of_ongoing_tasks) && m_tasks_loaded){ - m_tasks_loaded = false; - } - - sem_post(&semDone); - //removed deleteing task to earlier - } - return NULL; -} - -int ThreadPool::add_task(Task* task){ - if(m_pool_size == 1){ - (*task)(); - return 0; - } - m_task_mutex.lock(); - - // TODO: put a limit on how many tasks can be added at most - m_tasks.push_back(task); - number_of_ongoing_tasks++; - number_of_total_tasks++; - m_task_cond_var.signal(); // wake up one thread that is waiting for a task to be available - m_task_mutex.unlock(); - return 0; -} - -void ThreadPool::startExecuting(){ - if(m_pool_size == 1) - return; - - /*cout << "waiting for tasks: locked. gonna wait" << endl;*/ - m_tasks_loaded = true; - - //giving all threads permission to start as all tasks have been added - for(int i=0;i -#include -#include -#include -#include -#include -#include -#include - -#include "Mutex.h" -#include "Task.h" -#include "CondVar.h" -#include "Global.h" -#include -// - - -class ThreadPool -{ -public: - ThreadPool(int pool_size); - ~ThreadPool(); - int initialize_threadpool(); - int destroy_threadpool(); - void* execute_thread(); - int add_task(Task* task); - void startExecuting(); - void wait_for_tasks_to_complete(); - -private: - int m_pool_size; - Mutex m_task_mutex; - CondVar m_task_cond_var; - std::vector m_threads; // storage for threads - std::deque m_tasks; - volatile int m_pool_state; - - volatile bool m_tasks_loaded; - volatile bool thread_started; - int current_thread_number; - - //volatile uint64_t tasks_done_mask; - volatile int number_of_ongoing_tasks; - volatile int number_of_total_tasks; - - sem_t semStart; - sem_t semDone; -}; - diff --git a/slsDetectorSoftware/threadFiles/bin/examplethreadpool_test b/slsDetectorSoftware/threadFiles/bin/examplethreadpool_test deleted file mode 100755 index 621d57a47..000000000 Binary files a/slsDetectorSoftware/threadFiles/bin/examplethreadpool_test and /dev/null differ diff --git a/slsDetectorSoftware/threadFiles/threadpool_test.cpp b/slsDetectorSoftware/threadFiles/threadpool_test.cpp deleted file mode 100644 index 2dbd2c416..000000000 --- a/slsDetectorSoftware/threadFiles/threadpool_test.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//#include "ThreadPool.h" - -//#include "threadpool.h" - -#include -#include - -#include "Multi.h" -using namespace std; - -//const int MAX_TASKS = 4; - -/* -void hello(void* arg) -{ - string* x = (string*) arg; - cout << "Hello: " << *x << endl; -// cout << "\n"; -} -*/ -int main(int argc, char* argv[]) -{ - - Multi* m = new Multi(); - cout<<"Answer:"<< m->executeCommand(argc,argv) << endl; - delete m; - /* - ThreadPool tp(2); - int ret = tp.initialize_threadpool(); - if (ret == -1) { - cerr << "Failed to initialize thread pool!" << endl; - return 0; - } -*/ - - -/* - for (int i = 0; i < MAX_TASKS; i++) { - cout<<"adding task:" <