diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index aee251d9c..e37edef0e 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -8,25 +8,19 @@ DOCDIR ?= docs CFLAGS= -g -DC_ONLY -fPIC #FLAGS+= #-DVERBOSE -DVERYVERBOSE -DFLAGS= -g -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' -DSLS_RECEIVER_FUNCTION_LIST #$(shell root-config --cflags --glibs) -DMYROOT1 #-DALLFILE_DEBUG #-DMYROOT1 -DALLFILE #-DMYROOT1 `root-config --cflags --glibs` +DFLAGS= -g -DDACS_INT -INCLUDES?= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -IslsReceiver -I../slsDetectorCalibration -I$(ASM) +INCLUDES?= -IcommonFiles -IslsDetector -I../slsReceiverSoftware/MySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -I../slsReceiverSoftware/includes -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 -SRC_CLNT=slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsReceiver/slsReceiverFunctionList.cpp slsReceiver/slsReceiver_funcs.cpp slsReceiver/slsReceiverUsers.cpp -# slsReceiver/eigerReceiver.cpp +SRC_CLNT=slsDetectorAnalysis/fileIO.cpp ../slsReceiverSoftware/MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp OBJS = $(SRC_CLNT:.cpp=.o) -OBJS += slsReceiver/eigerReceiver.o -### LEO: unused -#HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h usersFunctions/angleFunction.h slsReceiverInterface/receiverInterface.h slsDetector/svnInfoLib.h slsReceiver/circularFifo.h slsReceiver/slsReceiver_funcs.h slsReceiver/svnInfoReceiverTmp.h slsReceiver/receiver_defs.h slsReceiver/slsReceiverFunctionList.h slsReceiver/slsReceiverUsers.h slsReceiver/svnInfoReceiver.h #../slsDetectorCalibration/singlePhotonDetector.h ../slsDetectorCalibration/moenchCommonMode.h ../slsDetectorCalibration/moench02ModuleData.h ../slsDetectorCalibration/slsReceiverData.h - - -.PHONY: all intdoc doc htmldoc package eigerReceiver clean +.PHONY: all intdoc doc htmldoc package clean all: package $(SRC_CLNT) @@ -63,21 +57,12 @@ gotthardVirtualServer: $(SRC_MYTHEN_SVC) %.o : %.cpp %.h Makefile -ifeq ($(EIGERSLS),yes) - $(CXX) -DEIGERSLS -o $@ -c $< $(INCLUDES) $(DFLAGS) $(EIGERFLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/ #$(FLAGS) -else ifeq ($(ROOTSLS),yes) - echo "with root" - $(CXX) -DROOTSLS -o $@ -c $< $(INCLUDES) $(DFLAGS) $(ROOTFLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/ #$(FLAGS) -else - echo "without root" $(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS) -endif + -# LEO: not satisfied by eigerReceiver -package: eigerReceiver $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a -eigerReceiver: - cd slsReceiver && make eigerReceiver +package: $(OBJS) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a + $(DESTDIR)/libSlsDetector.so: $(OBJS) $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) -L/usr/lib64 -lpthread @@ -89,7 +74,6 @@ $(DESTDIR)/libSlsDetector.a: $(OBJS) mv libSlsDetector.a $(DESTDIR) clean: - cd slsReceiver && make clean rm -rf $(DESTDIR)/libSlsDetector.a $(DESTDIR)/libSlsDetector.so core docs/* slsDetectorUsersDocs $(OBJS) cd @@ -99,6 +83,6 @@ install: package install_inc: $(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR)) - cp -P slsDetector/slsDetectorUsers.h slsDetectorAnalysis/detectorData.h $(DESTDIR) slsReceiver/slsReceiverUsers.h $(DESTDIR) + cp -P slsDetector/slsDetectorUsers.h slsDetectorAnalysis/detectorData.h $(DESTDIR) diff --git a/slsDetectorSoftware/MySocketTCP/._.DS_Store b/slsDetectorSoftware/MySocketTCP/._.DS_Store deleted file mode 100644 index c9474ea62..000000000 Binary files a/slsDetectorSoftware/MySocketTCP/._.DS_Store and /dev/null differ diff --git a/slsDetectorSoftware/MySocketTCP/Makefile b/slsDetectorSoftware/MySocketTCP/Makefile deleted file mode 100644 index 69634f361..000000000 --- a/slsDetectorSoftware/MySocketTCP/Makefile +++ /dev/null @@ -1,23 +0,0 @@ - -TOBECLEANED = MySocketTCP.o - -PROGRAMS = rec send - -all: $(PROGRAMS) - -clean: - @rm -f $(TOBECLEANED) $(PROGRAMS) - -rec: MySocketTCP.o rec.cxx - g++ -o $@ $^ - @echo "$@ done" - -send: MySocketTCP.o send.cxx - g++ -o $@ $^ - @echo "$@ done" - -MySocketTCP.o: MySocketTCP.cxx MySocketTCP.h - g++ -c $< - @echo "$@ done" - - diff --git a/slsDetectorSoftware/MySocketTCP/MySocketTCP.c b/slsDetectorSoftware/MySocketTCP/MySocketTCP.c deleted file mode 120000 index a995312db..000000000 --- a/slsDetectorSoftware/MySocketTCP/MySocketTCP.c +++ /dev/null @@ -1 +0,0 @@ -MySocketTCP.cxx \ No newline at end of file diff --git a/slsDetectorSoftware/MySocketTCP/MySocketTCP.cpp b/slsDetectorSoftware/MySocketTCP/MySocketTCP.cpp deleted file mode 120000 index a995312db..000000000 --- a/slsDetectorSoftware/MySocketTCP/MySocketTCP.cpp +++ /dev/null @@ -1 +0,0 @@ -MySocketTCP.cxx \ No newline at end of file diff --git a/slsDetectorSoftware/MySocketTCP/MySocketTCP.cxx b/slsDetectorSoftware/MySocketTCP/MySocketTCP.cxx deleted file mode 100644 index ba9583c1c..000000000 --- a/slsDetectorSoftware/MySocketTCP/MySocketTCP.cxx +++ /dev/null @@ -1,53 +0,0 @@ - -//version 1.0, base development, Ian 19/01/09 - - -#include "MySocketTCP.h" -#include -#include -#include - -using namespace std; - - - - - - - - - -int MySocketTCP::SendData(void* buf,int length){//length in characters - int ndata = SendDataAndKeepConnection(buf,length); - Disconnect(); - return ndata; -} - -int MySocketTCP::SendDataAndKeepConnection(void* buf,int length){//length in characters - if(last_keep_connection_open_action_was_a_send) Disconnect(); //to keep a structured data flow; - - Connect(); - int total_sent=SendDataOnly(buf,length); - last_keep_connection_open_action_was_a_send=1; - return total_sent; -} - - - - -int MySocketTCP::ReceiveData(void* buf,int length){//length in characters - int ndata = ReceiveDataAndKeepConnection(buf,length); - Disconnect(); - return ndata; -} - -int MySocketTCP::ReceiveDataAndKeepConnection(void* buf,int length){//length in characters - if(!last_keep_connection_open_action_was_a_send) Disconnect(); //to a keep structured data flow; - - Connect(); - // should preform two reads one to receive incomming char count - int total_received=ReceiveDataOnly(buf,length); - last_keep_connection_open_action_was_a_send=0; - return total_received; -} - diff --git a/slsDetectorSoftware/MySocketTCP/MySocketTCP.h b/slsDetectorSoftware/MySocketTCP/MySocketTCP.h deleted file mode 100644 index 31f56d453..000000000 --- a/slsDetectorSoftware/MySocketTCP/MySocketTCP.h +++ /dev/null @@ -1,79 +0,0 @@ - -#ifndef MY_SOCKET_TCP_H -#define MY_SOCKET_TCP_H - - - - -/** - * - * @libdoc The MySocketTCP class provides a simple interface for creating and sending/receiving data over a TCP socket. - * - * @short This class provides a simple interface for creating and sending/receiving data over a TCP socket. - * @author Ian Johnson - * @version 1.0 - */ - - - -//version 1.0, base development, Ian 19/01/09 - -/* Modified by anna on 19.01.2009 */ -/* - canceled SetupParameters() and varaibles intialized in the constructors' headers; - defined SEND_REC_MAX_SIZE (for compatibilty with mythen (and possibly other) pure C servers (i would move it to the common header file) - - added #ifndef C_ONLY... to cutout class definition when including in pure C servers (can be removed if SEND_REC_MAX_SIZE is moved to the common header file) - - defined private variables char hostname[1000] and int portno to store connection informations; - - defined public functions int getHostname(char *name) and int getPortNumber() to retrieve connection informations - - added public function int getErrorStatus() returning 1 if socketDescriptor<0 - - remove exits in the constructors and replace them with socketDescriptor=-1 - - replaced the argument of send/receive data with void (to avoid too much casting or compiler errors/warnings) - - added a function which really does not close the socket between send/receive (senddataonly, receivedataonly) - -*/ - - -/* Modified by Anna on 31.10.2012 - -developed and - -*/ - - -#include "genericSocket.h" -#define TCP_PACKET_SIZE 4096 - -class MySocketTCP: public genericSocket { - - public: - MySocketTCP(const char* const host_ip_or_name, unsigned short int const port_number): genericSocket(host_ip_or_name, port_number,TCP), last_keep_connection_open_action_was_a_send(0){setPacketSize(TCP_PACKET_SIZE);}; // sender (client): where to? ip - MySocketTCP(unsigned short int const port_number):genericSocket(port_number,TCP), last_keep_connection_open_action_was_a_send(0) {setPacketSize(TCP_PACKET_SIZE);}; // receiver (server) local no need for ip - - - //The following two functions will connectioned->send/receive->disconnect - int SendData(void* buf,int length);//length in characters - int ReceiveData(void* buf,int length); - - - //The following two functions stay connected, blocking other connections, and must be manually disconnected, - // when the last call is a SendData() or ReceiveData() the disconnection will be done automatically - //These function will also automatically disconnect->reconnect if - // two reads (or two writes) are called in a row to preserve the data send/receive structure - int SendDataAndKeepConnection(void* buf,int length); - int ReceiveDataAndKeepConnection(void* buf,int length); - - private: - - - bool last_keep_connection_open_action_was_a_send; - - -}; -#endif diff --git a/slsDetectorSoftware/MySocketTCP/genericSocket.h b/slsDetectorSoftware/MySocketTCP/genericSocket.h deleted file mode 100644 index 1fa136939..000000000 --- a/slsDetectorSoftware/MySocketTCP/genericSocket.h +++ /dev/null @@ -1,686 +0,0 @@ - -#ifndef GENERIC_SOCKET_H -#define GENERIC_SOCKET_H - - - - - -/** - * - * @libdoc genericSocket provides some functions to open/close sockets both TCP and UDP - * - * @short some functions to open/close sockets both TCP and UDP - * @author Anna Bergamaschi - * @version 0.0 - */ - - - -//version 1.0, base development, Ian 19/01/09 - -/* Modified by anna on 19.01.2009 */ -/* - canceled SetupParameters() and varaibles intialized in the constructors' headers; - defined SEND_REC_MAX_SIZE (for compatibilty with mythen (and possibly other) pure C servers (i would move it to the common header file) - - added #ifndef C_ONLY... to cutout class definition when including in pure C servers (can be removed if SEND_REC_MAX_SIZE is moved to the common header file) - - defined private variables char hostname[1000] and int portno to store connection informations; - - defined public functions int getHostname(char *name) and int getPortNumber() to retrieve connection informations - - added public function int getErrorStatus() returning 1 if socketDescriptor<0 - - remove exits in the constructors and replace them with socketDescriptor=-1 - - replaced the argument of send/receive data with void (to avoid too much casting or compiler errors/warnings) - - added a function which really does not close the socket between send/receive (senddataonly, receivedataonly) -*/ - -#ifdef __CINT__ -//class sockaddr_in; -class socklen_t; -class uint32_t; -class uint32_t_ss; -// CINT view of types: -class sockaddr_in; -// { -// unsigned short int sa_family; -// unsigned char sa_data[14]; -// }; -#else - -#include -#include -#include -#include -#include -#include - -#endif - -#include -#include -#include - -#include -#include -#include - -using namespace std; - -#define DEFAULT_PACKET_SIZE 1286 -#define DEFAULT_PACKETS_PER_FRAME 2 -#define SOCKET_BUFFER_SIZE (100*1024*1024) //100MB -#define DEFAULT_PORTNO 1952 -#define DEFAULT_BACKLOG 5 -#define DEFAULT_UDP_PORTNO 50001 -#define DEFAULT_GUI_PORTNO 65000 - -class genericSocket{ - - public: - - /** - Communication protocol -*/ -enum communicationProtocol{ - TCP, /**< TCP/IP */ - UDP /**< UDP */ -}; - - - genericSocket(const char* const host_ip_or_name, unsigned short int const port_number, communicationProtocol p, int ps = DEFAULT_PACKET_SIZE, int t = DEFAULT_PACKETS_PER_FRAME) : - // portno(port_number), - protocol(p), - is_a_server(0), - socketDescriptor(-1), - file_des(-1), - packet_size(ps), - nsending(0), - nsent(0), - total_sent(0), - packets_per_frame(t)// sender (client): where to? ip - { - - // strcpy(hostname,host_ip_or_name); - struct hostent *hostInfo = gethostbyname(host_ip_or_name); - if (hostInfo == NULL){ - cerr << "Exiting: Problem interpreting host: " << host_ip_or_name << "\n"; - } else { - // Set some fields in the serverAddress structure. - serverAddress.sin_family = hostInfo->h_addrtype; - memcpy((char *) &serverAddress.sin_addr.s_addr, - hostInfo->h_addr_list[0], hostInfo->h_length); - serverAddress.sin_port = htons(port_number); - socketDescriptor=0; //You can use send and recv, //would it work????? - } - clientAddress_length=sizeof(clientAddress); - } - - - int getProtocol(communicationProtocol p) { - switch (p) { - case TCP: - return SOCK_STREAM; - break; - case UDP: - return SOCK_DGRAM; - - default: - cerr << "unknow protocol " << p << endl; - return -1; - } - } - - int getProtocol() {return getProtocol(protocol);}; - - - - - /** - The constructor for a server - @short the contructor for a server - \param port_number port number to listen to - \param p TCP or UDP - \param eth interface name or IP address to listen to (if NULL, listen to all interfaces) - - */ - - genericSocket(unsigned short int const port_number, communicationProtocol p, int ps = DEFAULT_PACKET_SIZE, int t = DEFAULT_PACKETS_PER_FRAME, const char *eth=NULL): - //portno(port_number), - protocol(p), - is_a_server(1), - socketDescriptor(-1), - file_des(-1), - packet_size(ps), - nsending(0), - nsent(0), - total_sent(0), - packets_per_frame(t) - { - -/* // you can specify an IP address: */ -/* */ - -/* // or you can let it automatically select one: */ -/* myaddr.sin_addr.s_addr = INADDR_ANY; */ - - - if(serverAddress.sin_port == htons(port_number)){ - socketDescriptor = -10; - return; - } - - char ip[20]; - - strcpy(ip,"0.0.0.0"); - clientAddress_length=sizeof(clientAddress); - if (eth) { - strcpy(ip,nameToIp(string(eth)).c_str()); - if (string(ip)==string("0.0.0.0")) - strcpy(ip,eth); - } - - // strcpy(hostname,"localhost"); //needed?!?!?!? - - - socketDescriptor = socket(AF_INET, getProtocol(),0); //tcp - - if (socketDescriptor < 0) { - cerr << "Can not create socket "<= 0){ \ - close(socketDescriptor); \ - } \ - file_des=-1; \ - }; - - -/* /\** @short if client returns hostname for connection */ -/* \param name string to write the hostname to */ -/* \returns 0 if client, 1 if server (in this case ignore name return value) */ - -/* *\/ */ -/* int getHostname(char *name){ */ -/* if (is_a_server==0) { */ -/* strcpy(name,getHostname().c_str()); */ -/* } */ -/* return is_a_server; */ -/* }; */ -/* /\** @short if client returns hostname for connection */ -/* \returns hostname */ - -/* *\/ */ -/* string getHostname(){return string(hostname);}; */ - -/* /\** @short returns port number for connection */ -/* \returns port number */ -/* *\/ */ -/* int getPortNumber(){return portno;}; */ - - /** @short returns communication protocol - \returns TCP or UDP - */ - int getCommunicationProtocol(){return protocol;}; - - - /** @short returns error status - \returns 1 if error - */ - int getErrorStatus(){if (socketDescriptor==-10) return -10; else if (socketDescriptor<0) return 1; else return 0;}; - - - /** @short etablishes connection; disconnect should always follow - \returns 1 if error - */ - int Connect(){//cout<<"connect"<0) return file_des; - if (protocol==UDP) return -1; - - if(is_a_server && protocol==TCP){ //server tcp; the server will wait for the clients connection - if (socketDescriptor>0) { - if ((file_des = accept(socketDescriptor,(struct sockaddr *) &clientAddress, &clientAddress_length)) < 0) { - cerr << "Error: with server accept, connection refused"<=0){ //then was open - if(is_a_server){ - close(file_des); - } - else { - close(socketDescriptor); - socketDescriptor=-1; - } - file_des=-1; - } - } - }; - - - void ShutDownSocket(){ - while(!shutdown(socketDescriptor, SHUT_RDWR)); - }; - - - - /** Set the socket timeout ts is in seconds */ - int SetTimeOut(int ts){ - - - if (ts<=0) - return -1; - - //cout << "socketdescriptor "<< socketDescriptor << endl; - struct timeval tout; - tout.tv_sec = 0; - tout.tv_usec = 0; - if(::setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVTIMEO, &tout, sizeof(struct timeval)) <0) - { - cerr << "Error in setsockopt SO_RCVTIMEO "<< 0 << endl; - } - tout.tv_sec = ts; - tout.tv_usec = 0; - if(::setsockopt(socketDescriptor, SOL_SOCKET, SO_SNDTIMEO, &tout, sizeof(struct timeval)) < 0) - { - cerr << "Error in setsockopt SO_SNDTIMEO " << ts << endl; - } - return 0; - - - }; - - - int setPacketSize(int i=-1) { if (i>=0) packet_size=i; return packet_size;}; - - - - static string ipToName(string ip) { - struct ifaddrs *addrs, *iap; - struct sockaddr_in *sa; - char buf[32]; - - strcpy(buf,"none"); - - getifaddrs(&addrs); - for (iap = addrs; iap != NULL; iap = iap->ifa_next) { - if (iap->ifa_addr && (iap->ifa_flags & IFF_UP) && iap->ifa_addr->sa_family == AF_INET) { - sa = (struct sockaddr_in *)(iap->ifa_addr); - inet_ntop(iap->ifa_addr->sa_family, (void *)&(sa->sin_addr), buf, sizeof(buf)); - if (ip==string(buf)) { - //printf("%s\n", iap->ifa_name); - strcpy(buf,iap->ifa_name); - break; - } - } - } - freeifaddrs(addrs); - return string(buf); - }; - - static string nameToMac(string inf) { - struct ifreq ifr; - int sock, j, k; - char mac[32]; - - sock=getSock(inf,&ifr); - - if (-1==ioctl(sock, SIOCGIFHWADDR, &ifr)) { - perror("ioctl(SIOCGIFHWADDR) "); - return string("00:00:00:00:00:00"); - } - for (j=0, k=0; j<6; j++) { - k+=snprintf(mac+k, sizeof(mac)-k-1, j ? ":%02X" : "%02X", - (int)(unsigned int)(unsigned char)ifr.ifr_hwaddr.sa_data[j]); - } - mac[sizeof(mac)-1]='\0'; - - return string(mac); - - }; - - - - static string nameToIp(string inf){ - struct ifreq ifr; - int sock; - char *p, addr[32]; - - sock=getSock(inf,&ifr); - - if (-1==ioctl(sock, SIOCGIFADDR, &ifr)) { - perror("ioctl(SIOCGIFADDR) "); - return string("0.0.0.0"); - } - p=inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr); - strncpy(addr,p,sizeof(addr)-1); - addr[sizeof(addr)-1]='\0'; - - return string(addr); - - }; - - static int getSock(string inf, struct ifreq *ifr) { - - int sock; - sock=socket(PF_INET, SOCK_STREAM, 0); - if (-1==sock) { - perror("socket() "); - return 1; - } - strncpy(ifr->ifr_name,inf.c_str(),sizeof(ifr->ifr_name)-1); - ifr->ifr_name[sizeof(ifr->ifr_name)-1]='\0'; - - return sock; - - }; - - - int ReceiveDataOnly(void* buf,int length=0){ - - - if (buf==NULL) return -1; - - - total_sent=0; - - switch(protocol) { - case TCP: - if (file_des<0) return -1; - while(length>0){ - nsending = (length>packet_size) ? packet_size:length; - nsent = read(file_des,(char*)buf+total_sent,nsending); - if(!nsent) break; - length-=nsent; - total_sent+=nsent; - } - break; - case UDP: - if (socketDescriptor<0) return -1; - //if length given - if(length){ - while(length>0){ - nsending=packet_size; - nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length); - if(!nsent) break; - length-=nsent; - total_sent+=nsent; - } - } - //depends on packets per frame - else{ - for(int i=0;i0) - strcpy(thisClientIP,dummyClientIP); - - if (strcmp(lastClientIP,thisClientIP)) - differentClients=1; - else - differentClients=0; - - return total_sent; - - - - } - - - int SendDataOnly(void *buf, int length) { -#ifdef VERY_VERBOSE - cout << "want to send "<< length << " Bytes" << endl; -#endif - if (buf==NULL) return -1; - - total_sent=0; - - - switch(protocol) { - case TCP: - if (file_des<0) return -1; - while(length>0){ - nsending = (length>packet_size) ? packet_size:length; - nsent = write(file_des,(char*)buf+total_sent,nsending); - if(!nsent) break; - length-=nsent; - total_sent+=nsent; - } - break; - case UDP: - if (socketDescriptor<0) return -1; - while(length>0){ - nsending = (length>packet_size) ? packet_size:length; - nsent = sendto(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, clientAddress_length); - if(!nsent) break; - length-=nsent; - total_sent+=nsent; - } - - break; - default: - ; - } -#ifdef VERY_VERBOSE - cout << "sent "<< total_sent << " Bytes" << endl; -#endif - return total_sent; - - - } - - char lastClientIP[INET_ADDRSTRLEN]; - char thisClientIP[INET_ADDRSTRLEN]; - int differentClients; - - - protected: - - communicationProtocol protocol; - - - - int is_a_server; - - - int socketDescriptor; - int file_des; - - int packet_size; - - struct sockaddr_in clientAddress, serverAddress; - socklen_t clientAddress_length; - - - char dummyClientIP[INET_ADDRSTRLEN]; - - - private: - - int nsending; - int nsent; - int total_sent; - int packets_per_frame; - - - - // pthread_mutex_t mp; -}; -#endif diff --git a/slsDetectorSoftware/MySocketTCP/rec b/slsDetectorSoftware/MySocketTCP/rec deleted file mode 100755 index b652bb8f4..000000000 Binary files a/slsDetectorSoftware/MySocketTCP/rec and /dev/null differ diff --git a/slsDetectorSoftware/MySocketTCP/rec.cxx b/slsDetectorSoftware/MySocketTCP/rec.cxx deleted file mode 100644 index fe937cb14..000000000 --- a/slsDetectorSoftware/MySocketTCP/rec.cxx +++ /dev/null @@ -1,31 +0,0 @@ - -//version 1.0, base development ij 19/01/09 - -#include -#include "MySocketTCP.h" - -using namespace std; - -int main(){ - - char data[50000]; - int length=50000; - - unsigned short int portnum = 1952; - MySocketTCP* sock = new MySocketTCP(portnum); - - cout<<"\tReceived :"<ReceiveDataAndKeepConnection(data,23000)<ReceiveData(data,32200)<ReceiveData(data,33300)<ReceiveData(data,30000)<ReceiveData(data,3222)< -#include "MySocketTCP.h" - -using namespace std; - -int main(int argc, char *argv[]){ - - if(argc!=2){ - cout<<"Usage: send ip_addess/hostName"<SendDataAndKeepConnection(data,2000)<SendData(data,2200)<SendData(data,1200)<SendData(data,25000)<SendData(data,222)< +//#include +#include "sls_receiver_defs.h" -/** default maximum string length */ -#define MAX_STR_LENGTH 1000 /** default maximum string length */ #define MAX_SCAN_STEPS 2000 /** maxmimum number of modules per controller*/ @@ -23,9 +22,7 @@ /** maximum rois */ #define MAX_ROIS 100 -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; + typedef char mystring[MAX_STR_LENGTH]; typedef double mysteps[MAX_SCAN_STEPS]; @@ -39,10 +36,6 @@ typedef float dacs_t; #define DEFAULT_DET_MAC "00:aa:bb:cc:dd:ee" #define DEFAULT_DET_IP "129.129.202.46" -#define MAX_FRAMES_PER_FILE 20000 -#define SHORT_MAX_FRAMES_PER_FILE 100000 -#define MOENCH_MAX_FRAMES_PER_FILE 1000 - /** \file sls_detector_defs.h @@ -54,7 +47,7 @@ and to the server programs running on the detector * @version 0.1alpha (any string) * @see slsDetector -$Revision$ +$Revision: 824 $ */ @@ -62,11 +55,11 @@ $Revision$ /** get flag form most functions */ #define GET_FLAG -1 -//#if defined(__cplusplus) && !defined(EIGERD) + #ifdef __cplusplus /** @short class containing all the structures, constants and enum definitions */ -class slsDetectorDefs { +class slsDetectorDefs: public virtual slsReceiverDefs{ public: slsDetectorDefs(){}; @@ -78,7 +71,7 @@ class slsDetectorDefs { -/** +/** @short structure for a detector channel should not be used by unexperienced users @@ -91,8 +84,8 @@ class slsDetectorDefs { int module; /**< is the module number */ int64_t reg; /**< is the is the channel register (e.g. trimbits, calibration enable, comparator enable...) */ } sls_detector_channel; - - /** + + /** @short structure for a detector chip should not be used by unexperienced users @@ -102,17 +95,17 @@ class slsDetectorDefs { int chip; /**< is the chip number */ int module; /**< is the module number */ int nchan; /**< is the number of channels in the chip */ - int reg; /** #include +#include //for memory mapping -u_int32_t CSP0BASE; +u_int64_t CSP0BASE; FILE *debugfp, *datafp; @@ -161,7 +162,7 @@ int mapCSP0(void) { #endif #ifdef VIRTUAL - CSP0BASE = (u_int32_t)malloc(MEM_SIZE); + CSP0BASE = malloc(MEM_SIZE); printf("memory allocated\n"); #endif #ifdef SHAREDMEMORY diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer b/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer index a81dd959f..c6f9d9403 100755 Binary files a/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer and b/slsDetectorSoftware/gotthardDetectorServer/gotthardDetectorServer differ diff --git a/slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer b/slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer new file mode 100755 index 000000000..00f509290 Binary files /dev/null and b/slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer differ diff --git a/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_defs.h new file mode 120000 index 000000000..a07bf98e7 --- /dev/null +++ b/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_defs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/includes/sls_receiver_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_funcs.h new file mode 120000 index 000000000..67df52bf4 --- /dev/null +++ b/slsDetectorSoftware/gotthardDetectorServer/sls_receiver_funcs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/includes/sls_receiver_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/moenchDetectorServer/Makefile.virtual b/slsDetectorSoftware/moenchDetectorServer/Makefile.virtual index 289901ae0..38dd2537c 100755 --- a/slsDetectorSoftware/moenchDetectorServer/Makefile.virtual +++ b/slsDetectorSoftware/moenchDetectorServer/Makefile.virtual @@ -2,16 +2,16 @@ DESTDIR ?= ./ CC = gcc -CFLAGS += -Wall -DMOENCH -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL +CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL -PROGS= $(DESTDIR)/gotthardVirtualServer +PROGS= $(DESTDIR)/moenchVirtualServer SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c OBJS = $(SRCS:%.c=%.o) -gotthardVirtualServer = $(PROGS) +moenchVirtualServer = $(PROGS) all: clean $(PROGS) diff --git a/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c b/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c index 3e72d265e..303fc52ad 100755 --- a/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c @@ -12,9 +12,10 @@ #include #include +#include //for memory mapping -u_int32_t CSP0BASE; +u_int64_t CSP0BASE; FILE *debugfp, *datafp; @@ -162,7 +163,7 @@ int mapCSP0(void) { #endif #ifdef VIRTUAL - CSP0BASE = (u_int32_t)malloc(MEM_SIZE); + CSP0BASE = malloc(MEM_SIZE); printf("memory allocated\n"); #endif #ifdef SHAREDMEMORY @@ -1071,6 +1072,9 @@ int64_t get64BitReg(int aLSB, int aMSB){ vMSB=bus_r(aMSB); v64=vMSB; v64=(v64<<32) | vLSB; + + printf("reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, v64); + return v64; } @@ -1079,6 +1083,7 @@ int64_t setFrames(int64_t value){ } int64_t getFrames(){ + printf("gf"); return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); } @@ -1512,6 +1517,7 @@ int configureMAC(int ipad,long long int macad,long long int detectormacad, int d mac_conf_regs->mac.mac_dest_mac4 =((macad>>(8*2))&0xFF);// 0x24; //pc7060 mac_conf_regs->mac.mac_dest_mac5 =((macad>>(8*1))&0xFF);// 0xEB; //pc7060 mac_conf_regs->mac.mac_dest_mac6 =((macad>>(8*0))&0xFF);// 0xEE; //pc7060 + /* mac_conf_regs->mac.mac_src_mac1 = 0x00; mac_conf_regs->mac.mac_src_mac2 = 0xAA; @@ -1529,6 +1535,7 @@ int configureMAC(int ipad,long long int macad,long long int detectormacad, int d mac_conf_regs->mac.mac_ether_type = 0x0800; //ipv4 + mac_conf_regs->ip.ip_ver = 0x4; mac_conf_regs->ip.ip_ihl = 0x5; mac_conf_regs->ip.ip_tos = 0x0; @@ -1542,7 +1549,7 @@ int configureMAC(int ipad,long long int macad,long long int detectormacad, int d mac_conf_regs->ip.ip_sourceip = detipad; //0x8181CA2E;129.129.202.46 mac_conf_regs->ip.ip_destip = ipad; //CA57 -#ifdef VERBOSE + //#ifdef VERBOSE printf("mac_dest:%llx %x:%x:%x:%x:%x:%x\n", macad, mac_conf_regs->mac.mac_dest_mac1, @@ -1560,7 +1567,10 @@ int configureMAC(int ipad,long long int macad,long long int detectormacad, int d mac_conf_regs->mac.mac_src_mac5, mac_conf_regs->mac.mac_src_mac6); printf("ip_ttl:%x\n",mac_conf_regs->ip.ip_ttl); -#endif + printf("det_ip: %x %x\n",detipad, mac_conf_regs->ip.ip_sourceip); + printf("dest_ip: %x %x\n",ipad, mac_conf_regs->ip.ip_destip); + + //#endif //checksum count=sizeof(mac_conf_regs->ip); @@ -1602,6 +1612,7 @@ int configureMAC(int ipad,long long int macad,long long int detectormacad, int d tse_conf_regs->tx_almost_full = 0x3; tse_conf_regs->mdio_addr0 = 0x12; tse_conf_regs->mdio_addr1 = 0x0; + mac_conf_regs->cdone = 0xFFFFFFFF; @@ -1641,7 +1652,7 @@ int getAdcConfigured(){ } u_int32_t runBusy(void) { - u_int32_t s = bus_r(STATUS_REG); + u_int32_t s = bus_r(STATUS_REG) & 1; #ifdef VERBOSE printf("status %04x\n",s); #endif @@ -1800,6 +1811,9 @@ u_int32_t fifo_full(void) u_int32_t* fifo_read_event() { + + int i=0; + #ifdef VIRTUAL return NULL; #endif @@ -1809,9 +1823,9 @@ u_int32_t* fifo_read_event() #endif volatile u_int32_t t = bus_r(LOOK_AT_ME_REG); -//#ifdef VERBOSE +#ifdef VERBOSE printf("lookatmereg=x%x\n",t); -//#endif +#endif /* while ((t&0x1)==0) { @@ -1823,8 +1837,8 @@ u_int32_t* fifo_read_event() */ while((t&0x1)==0) { -#ifdef VERBOSE - printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); +#ifdef VERYVERBOSE + printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); #endif #ifdef VERYVERBOSE printf("look at me reg:%08x\n",bus_r(LOOK_AT_ME_REG)); @@ -1842,6 +1856,7 @@ u_int32_t* fifo_read_event() #ifdef VERYVERBOSE printf("returning null\n"); #endif + printf("lookatmereg=x%x\n",t); return NULL; } else { #ifdef VERBOSE @@ -1854,11 +1869,14 @@ u_int32_t* fifo_read_event() #ifdef VERYVERBOSE printf("before starting while loop again: look at me reg:%08x\n\n",bus_r(LOOK_AT_ME_REG)); #endif + if (i%1000==0) + printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); + i++; } #ifdef VERYVERBOSE printf(" out of while loop!\n"); #endif -#ifdef VERBOSE +#ifdef VERYVERBOSE printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); #endif @@ -1874,7 +1892,7 @@ u_int32_t* fifo_read_event() printf("********\n"); //memcpy(now_ptr, values, dataBytes); #endif -#ifdef VERBOSE +#ifdef VERYVERBOSE printf("Copying to ptr %08x %d\n",(unsigned int)(now_ptr), dataBytes); printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); #endif @@ -1882,6 +1900,7 @@ u_int32_t* fifo_read_event() if (storeInRAM>0) { now_ptr+=dataBytes; } + printf("lookatmereg=x%x\n",t); return ram_values; } diff --git a/slsDetectorSoftware/moenchDetectorServer/moenchDetectorServer b/slsDetectorSoftware/moenchDetectorServer/moenchDetectorServer index 0e9b3729d..c7f094baa 100755 Binary files a/slsDetectorSoftware/moenchDetectorServer/moenchDetectorServer and b/slsDetectorSoftware/moenchDetectorServer/moenchDetectorServer differ diff --git a/slsDetectorSoftware/moenchDetectorServer/moenchVirtualServer b/slsDetectorSoftware/moenchDetectorServer/moenchVirtualServer new file mode 100755 index 000000000..969435789 Binary files /dev/null and b/slsDetectorSoftware/moenchDetectorServer/moenchVirtualServer differ diff --git a/slsDetectorSoftware/moenchDetectorServer/server_funcs.c b/slsDetectorSoftware/moenchDetectorServer/server_funcs.c index 8b76d18f5..db0f2f5fc 100755 --- a/slsDetectorSoftware/moenchDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/moenchDetectorServer/server_funcs.c @@ -62,6 +62,11 @@ int init_detector(int b, int checkType) { exit(1); } + // + + bus_w16(CONTROL_REG, SYNC_RESET); + bus_w16(CONTROL_REG, 0x0); + //confirm if it is really moench if(((bus_r(PCB_REV_REG) & DETECTOR_TYPE_MASK)>>DETECTOR_TYPE_OFFSET) != MOENCH_MODULE ){ if(checkType){ @@ -83,7 +88,10 @@ int init_detector(int b, int checkType) { printf("\nBoard Revision:0x%x\n",(bus_r(PCB_REV_REG)&BOARD_REVISION_MASK)); initDetector(); printf("Initializing Detector\n"); + bus_w16(CONTROL_REG, SYNC_RESET); // reset registers #endif + + testFpga(); testRAM(); printf("ADC_SYNC_REG:%x\n",bus_r(ADC_SYNC_REG)); @@ -2139,14 +2147,15 @@ int get_time_left(int file_des) { } -#ifdef VERBOSE + //#ifdef VERBOSE printf("getting time left on timer %d \n",ind); -#endif + //#endif if (ret==OK) { switch(ind) { case FRAME_NUMBER: + printf("getting frames \n"); retval=getFrames(); break; case ACQUISITION_TIME: @@ -2189,10 +2198,10 @@ int get_time_left(int file_des) { } else if (differentClients) ret=FORCE_UPDATE; -#ifdef VERBOSE + //#ifdef VERBOSE printf("time left on timer %d is %lld\n",ind, retval); -#endif + //#endif n = sendDataOnly(file_des,&ret,sizeof(ret)); if (ret!=OK) { diff --git a/slsDetectorSoftware/moenchDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/moenchDetectorServer/sls_receiver_defs.h new file mode 120000 index 000000000..a07bf98e7 --- /dev/null +++ b/slsDetectorSoftware/moenchDetectorServer/sls_receiver_defs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/includes/sls_receiver_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/moenchDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/moenchDetectorServer/sls_receiver_funcs.h new file mode 120000 index 000000000..67df52bf4 --- /dev/null +++ b/slsDetectorSoftware/moenchDetectorServer/sls_receiver_funcs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/includes/sls_receiver_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c index 1d563ffff..49cbdb982 100755 --- a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c @@ -16,9 +16,10 @@ #include #include +#include //for memory mapping -u_int32_t CSP0BASE; +u_int64_t CSP0BASE; FILE *debugfp, *datafp; @@ -85,7 +86,7 @@ int mapCSP0(void) { #endif #ifdef VIRTUAL - CSP0BASE = (u_int32_t)malloc(MEM_SIZE); + CSP0BASE = malloc(MEM_SIZE); printf("memory allocated\n"); #endif #ifdef SHAREDMEMORY diff --git a/slsDetectorSoftware/mythenDetectorServer/mythenVirtualServer b/slsDetectorSoftware/mythenDetectorServer/mythenVirtualServer new file mode 100755 index 000000000..10a35670a Binary files /dev/null and b/slsDetectorSoftware/mythenDetectorServer/mythenVirtualServer differ diff --git a/slsDetectorSoftware/mythenDetectorServer/server_defs.h b/slsDetectorSoftware/mythenDetectorServer/server_defs.h index c211a99d4..e91bb5685 100755 --- a/slsDetectorSoftware/mythenDetectorServer/server_defs.h +++ b/slsDetectorSoftware/mythenDetectorServer/server_defs.h @@ -39,5 +39,5 @@ #define THIS_SOFTWARE_VERSION 0x20120419 -#define THIS_REVISION "$Rev$" +#define THIS_REVISION "$Rev: 379 $" #endif diff --git a/slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h new file mode 120000 index 000000000..a07bf98e7 --- /dev/null +++ b/slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/includes/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 new file mode 120000 index 000000000..67df52bf4 --- /dev/null +++ b/slsDetectorSoftware/mythenDetectorServer/sls_receiver_funcs.h @@ -0,0 +1 @@ +../../slsReceiverSoftware/includes/sls_receiver_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 2abe57aa9..32f1eaae2 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -39,7 +39,7 @@ int slsDetector::initSharedMemory(detectorType type, int id) { nd=6; // dacs+adcs break; case GOTTHARD: - nch=128; + nch=128; nm=1; nc=10; nd=13; // dacs+adcs @@ -65,7 +65,7 @@ int slsDetector::initSharedMemory(detectorType type, int id) { } /** The size of the shared memory is: - size of shared structure + ffcoefficents +fferrors + modules+ dacs+adcs+chips+chans + size of shared structure + ffcoefficents +fferrors + modules+ dacs+adcs+chips+chans */ @@ -79,13 +79,13 @@ int slsDetector::initSharedMemory(detectorType type, int id) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return shm_id; } - + /** thisDetector pointer is set to the memory address of the shared memory */ thisDetector = (sharedSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ - + if (thisDetector == (void*)-1) { std::cout<<"*** shmat error (server) ***" << std::endl; return shm_id; @@ -120,10 +120,10 @@ int slsDetector::freeSharedMemory() { slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(), - thisDetector(NULL), + thisDetector(NULL), detId(id), parentDet(p), - shmId(-1), + shmId(-1), controlSocket(NULL), stopSocket(NULL), dataSocket(NULL), @@ -144,7 +144,7 @@ slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(), while (shmId<0) { /**Initlializes shared memory \sa initSharedMemory - + if it fails the detector id is incremented until it succeeds */ shmId=initSharedMemory(type,id); @@ -155,7 +155,7 @@ slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(), std::cout<< "Detector id is " << id << std::endl; #endif detId=id; - + /**Initializes the detector stucture \sa initializeDetectorSize */ @@ -170,10 +170,10 @@ slsDetector::slsDetector(int id,multiSlsDetector *p) :slsDetectorUtils(), slsDetector::slsDetector(detectorType type, int id,multiSlsDetector *p): slsDetectorUtils(), - thisDetector(NULL), + thisDetector(NULL), detId(id), parentDet(p), - shmId(-1), + shmId(-1), controlSocket(NULL), stopSocket(NULL), dataSocket(NULL), @@ -224,10 +224,10 @@ slsDetector::~slsDetector(){ }; slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : slsDetectorUtils(), - thisDetector(NULL), + thisDetector(NULL), detId(id), parentDet(p), - shmId(-1), + shmId(-1), controlSocket(NULL), stopSocket(NULL), dataSocket(NULL), @@ -243,11 +243,11 @@ slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : sl { detectorType type=(detectorType)getDetectorType(name, cport); - + while (shmId<0) { /**Initlializes shared memory \sa initSharedMemory - + if it fails the detector id is incremented until it succeeds */ shmId=initSharedMemory(type,id); @@ -258,8 +258,8 @@ slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : sl std::cout<< "Detector id is " << id << std::endl; #endif detId=id; - - + + /**Initializes the detector stucture \sa initializeDetectorSize */ initializeDetectorSize(type); @@ -267,14 +267,14 @@ slsDetector::slsDetector(char *name, int id, int cport,multiSlsDetector *p) : sl - + setTCPSocket(name, cport); updateDetector(); } slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int cport) { - + int retval=FAIL; detectorType t=GENERIC; int fnum=F_GET_DETECTOR_TYPE; @@ -286,14 +286,14 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int if (s->Connect()>=0) { s->SendDataOnly(&fnum,sizeof(fnum)); s->ReceiveDataOnly(&retval,sizeof(retval)); - + if (retval!=FAIL) { s->ReceiveDataOnly(&t,sizeof(t)); #ifdef VERBOSE cout << "Detector type is "<< t << endl; #endif - + } else { s->ReceiveDataOnly(m,sizeof(m)); std::cout<< "Detector returned error: " << m << std::endl; @@ -314,7 +314,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int std::cout << "Sending detector type to Receiver " << (int)thisDetector->myDetectorType << std::endl; #endif if (connectData() == OK) - retval=thisReceiver->sendInt(fnum,k,(int)t); + retval=thisReceiver->sendInt(fnum2,k,(int)t); if(retval==FAIL){ cout << "ERROR: Could not send detector type to receiver" << endl; setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTTYPE_NOT_SET)); @@ -352,13 +352,13 @@ int slsDetector::exists(int id) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return -1; } - + /** thisDetector pointer is set to the memory address of the shared memory */ sharedSlsDetector* det = (sharedSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ - + if (det == (void*)-1) { std::cout<<"*** shmat error (server) ***" << std::endl; return -1; @@ -402,7 +402,7 @@ int slsDetector::exists(int id) { slsDetectorDefs::detectorType slsDetector::getDetectorType(int id) { - + detectorType t=GENERIC; @@ -422,13 +422,13 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(int id) { std::cout<<"*** shmget error (server) ***"<< shm_id << std::endl; return t; } - + /** thisDetector pointer is set to the memory address of the shared memory */ sharedSlsDetector* det = (sharedSlsDetector*) shmat(shm_id, NULL, 0); /* attach */ - + if (det == (void*)-1) { std::cout<<"*** shmat error (server) ***" << std::endl; return t; @@ -575,7 +575,7 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->nDacs=0; thisDetector->nAdcs=0; thisDetector->nModMax[X]=0; - thisDetector->nModMax[Y]=0; + thisDetector->nModMax[Y]=0; thisDetector->dynamicRange=32; } thisDetector->nChans=thisDetector->nChan[X]*thisDetector->nChan[Y]; @@ -583,14 +583,14 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->nModsMax=thisDetector->nModMax[X]*thisDetector->nModMax[Y]; /** number of modules is initally the maximum number of modules */ thisDetector->nMod[X]=thisDetector->nModMax[X]; - thisDetector->nMod[Y]=thisDetector->nModMax[Y]; + thisDetector->nMod[Y]=thisDetector->nModMax[Y]; thisDetector->nMods=thisDetector->nModsMax; /** calculates the expected data size */ thisDetector->timerValue[PROBES_NUMBER]=0; thisDetector->timerValue[FRAME_NUMBER]=1; thisDetector->timerValue[MEASUREMENTS_NUMBER]=1; thisDetector->timerValue[CYCLES_NUMBER]=1; - + thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8; if(thisDetector->myDetectorType==MYTHEN){ @@ -663,7 +663,7 @@ int slsDetector::initializeDetectorSize(detectorType type) { for (int iscan=0; iscanscanMode[iscan]=0; strcpy(thisDetector->scanScript[iscan],"none"); strcpy(thisDetector->scanParameter[iscan],"none"); @@ -675,8 +675,8 @@ int slsDetector::initializeDetectorSize(detectorType type) { /** sets receiver onlineFlag to OFFLINE_FLAG */ thisDetector->receiverOnlineFlag=OFFLINE_FLAG; - - /** calculates the memory offsets for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ + + /** calculates the memory offsets for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ thisDetector->ffoff=sizeof(sharedSlsDetector); thisDetector->fferroff=thisDetector->ffoff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax; thisDetector->modoff= thisDetector->fferroff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax; @@ -684,15 +684,15 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->adcoff=thisDetector->dacoff+sizeof(dacs_t)*thisDetector->nDacs*thisDetector->nModsMax; thisDetector->chipoff=thisDetector->adcoff+sizeof(dacs_t)*thisDetector->nAdcs*thisDetector->nModsMax; thisDetector->chanoff=thisDetector->chipoff+sizeof(int)*thisDetector->nChips*thisDetector->nModsMax; - - + + //update?!?!?!? - } + } - /** also in case thisDetector alread existed initialize the pointer for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ + /** also in case thisDetector alread existed initialize the pointer for flat field coefficients and errors, module structures, dacs, adcs, chips and channels */ ffcoefficients=(double*)(goff+thisDetector->ffoff); fferrors=(double*)(goff+thisDetector->fferroff); detectorModules=(sls_detector_module*)(goff+ thisDetector->modoff); @@ -705,22 +705,22 @@ int slsDetector::initializeDetectorSize(detectorType type) { chipregs=(int*)(goff+thisDetector->chipoff); chanregs=(int*)(goff+thisDetector->chanoff); if (thisDetector->alreadyExisting==0) { - /** if thisDetector is new, initialize its structures \sa initializeDetectorStructure(); */ + /** if thisDetector is new, initialize its structures \sa initializeDetectorStructure(); */ initializeDetectorStructure(); - /** set thisDetector->alreadyExisting=1 */ + /** set thisDetector->alreadyExisting=1 */ thisDetector->alreadyExisting=1; - } + } #ifdef VERBOSE cout << "passing pointers" << endl; -#endif +#endif stoppedFlag=&thisDetector->stoppedFlag; threadedProcessing=&thisDetector->threadedProcessing; actionMask=&thisDetector->actionMask; - actionScript=thisDetector->actionScript; - actionParameter=thisDetector->actionParameter; + actionScript=thisDetector->actionScript; + actionParameter=thisDetector->actionParameter; nScanSteps=thisDetector->nScanSteps; scanMode=thisDetector->scanMode; scanScript=thisDetector->scanScript; @@ -761,7 +761,7 @@ int slsDetector::initializeDetectorSize(detectorType type) { #ifdef VERBOSE cout << "done" << endl; -#endif +#endif /** modifies the last PID accessing the detector */ @@ -778,11 +778,11 @@ int slsDetector::initializeDetectorStructure() { sls_detector_module *thisMod; char *p2; p2=(char*)thisDetector; - + /** for each of the detector modules up to the maximum number which can be installed initlialize the sls_detector_module structure \sa ::sls_detector_module*/ for (int imod=0; imodnModsMax; imod++) { - + thisMod=detectorModules+imod; thisMod->module=imod; @@ -792,7 +792,7 @@ int slsDetector::initializeDetectorStructure() { thisMod->nchip=thisDetector->nChips; thisMod->ndac=thisDetector->nDacs; thisMod->nadc=thisDetector->nAdcs; - + /** initializes the serial number and register to 0 */ thisMod->serialnumber=0; @@ -802,7 +802,7 @@ int slsDetector::initializeDetectorStructure() { for (int idac=0; idacnDacs; idac++) { *(dacs+idac+thisDetector->nDacs*imod)=0; } - + /** initializes the adc values to 0 */ for (int iadc=0; iadcnAdcs; iadc++) { @@ -815,7 +815,7 @@ int slsDetector::initializeDetectorStructure() { for (int ichip=0; ichipnChips; ichip++) { *(chipregs+ichip+thisDetector->nChips*imod)=-1; } - + /** initializes the channel registers to 0 */ for (int ichan=0; ichannChans*thisDetector->nChips; ichan++) { @@ -849,7 +849,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) nd=6; // dacs+adcs break; case GOTTHARD: - nch=128; + nch=128; nm=1; nc=10; nd=8; // dacs+adcs @@ -885,7 +885,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) myMod->nadc=na; myMod->nchip=nc; myMod->nchan=nch*nc; - + myMod->dacs=dacs; myMod->adcs=adcs; myMod->chipregs=chipregs; @@ -1018,7 +1018,7 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { myMod->adcs=adcptr; myMod->chipregs=chipptr; myMod->chanregs=chanptr; - + #ifdef VERBOSE std::cout<< "received module " << myMod->module << " of size "<< ts << " register " << myMod->reg << std::endl; #endif @@ -1038,7 +1038,7 @@ int slsDetector::receiveModule(sls_detector_module* myMod) { #ifdef VERBOSE std::cout<< "nchans= " << thisDetector->nChans << " nchips= " << thisDetector->nChips; std::cout<< "mod - nchans= " << myMod->nchan << " nchips= " <nchip; - + std::cout<< "received chans " << myMod->module << " of size "<< ts << std::endl; #endif #ifdef VERBOSE @@ -1105,8 +1105,8 @@ string slsDetector::checkOnline() { -/* - configure the socket communication and check that the server exists +/* + configure the socket communication and check that the server exists enum communicationProtocol{ TCP, UDP @@ -1142,7 +1142,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con std::cout<< "setting control port" << std::endl; #endif thisCP=control_port; - thisDetector->controlPort=thisCP; + thisDetector->controlPort=thisCP; if (controlSocket) { delete controlSocket; controlSocket=NULL; @@ -1188,7 +1188,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con delete stopSocket; stopSocket=NULL; retval=FAIL; - } + } #ifdef VERYVERBOSE else std::cout<< "Stop socket connected " << thisName << " " << thisSP << std::endl; @@ -1283,22 +1283,22 @@ int slsDetector::disconnectStop(){ // General purpose functions -/* - executes a system command on the server +/* + executes a system command on the server e.g. mount an nfs disk, reboot and returns answer etc. */ int slsDetector::execCommand(string cmd, string answer){ char arg[MAX_STR_LENGTH], retval[MAX_STR_LENGTH]; int fnum=F_EXEC_COMMAND; - + int ret=FAIL; strcpy(arg,cmd.c_str()); #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Sending command " << arg << std::endl; + std::cout<< "Sending command " << arg << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ @@ -1313,7 +1313,7 @@ int slsDetector::execCommand(string cmd, string answer){ controlSocket->Disconnect(); } #ifdef VERBOSE - std::cout<< "Detector answer is " << answer << std::endl; + std::cout<< "Detector answer is " << answer << std::endl; #endif } return ret; @@ -1321,8 +1321,8 @@ int slsDetector::execCommand(string cmd, string answer){ // Detector configuration functions -/* - the detector knows what type of detector it is +/* + the detector knows what type of detector it is enum detectorType{ GET_DETECTOR_TYPE, @@ -1337,9 +1337,9 @@ int slsDetector::execCommand(string cmd, string answer){ */ int slsDetector::setDetectorType(detectorType const type){ - + int arg, retval=FAIL; - int fnum=F_GET_DETECTOR_TYPE; + int fnum=F_GET_DETECTOR_TYPE,fnum2=F_GET_RECEIVER_TYPE; arg=int(type); detectorType retType=type; char mess[100]; @@ -1348,7 +1348,7 @@ int slsDetector::setDetectorType(detectorType const type){ #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting detector type to " << arg << std::endl; + std::cout<< "Setting detector type to " << arg << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ @@ -1374,7 +1374,7 @@ int slsDetector::setDetectorType(detectorType const type){ retval=OK; } #ifdef VERBOSE - std::cout<< "Detector type set to " << retType << std::endl; + std::cout<< "Detector type set to " << retType << std::endl; #endif if (retval==FAIL) { std::cout<< "Set detector type failed " << std::endl; @@ -1392,7 +1392,7 @@ int slsDetector::setDetectorType(detectorType const type){ std::cout << "Sending detector type to Receiver " << (int)thisDetector->myDetectorType << std::endl; #endif if (connectData() == OK) - retval=thisReceiver->sendInt(fnum,arg,(int)thisDetector->myDetectorType); + retval=thisReceiver->sendInt(fnum2,arg,(int)thisDetector->myDetectorType); if(retval==FAIL){ cout << "ERROR: Could not send detector type to receiver" << endl; setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTTYPE_NOT_SET)); @@ -1518,11 +1518,11 @@ int slsDetector::setNumberOfModules(int n, dimension d){ #endif } return thisDetector->nMod[d]; -}; +}; + - int slsDetector::getMaxNumberOfModules(dimension d){ int retval; @@ -1567,17 +1567,17 @@ int slsDetector::getMaxNumberOfModules(dimension d){ thisDetector->nModMax[d]=retval; thisDetector->nModsMax=thisDetector->nModMax[X]*thisDetector->nModMax[Y]; - + } return thisDetector->nModMax[d]; -}; +}; + - /* This function is used to set the polarity and meaning of the digital I/O signals (signal index) - + enum externalSignalFlag { GET_EXTERNAL_SIGNAL_FLAG, SIGNAL_OFF, @@ -1592,8 +1592,8 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(external - - int arg[2]; + + int arg[2]; externalSignalFlag retval; int ret=FAIL; int fnum=F_SET_EXTERNAL_SIGNAL_FLAG; @@ -1606,7 +1606,7 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(external #ifdef VERBOSE std::cout<< std::endl; - std::cout<< "Setting signal "<< signalindex << " to flag" << pol << std::endl; + std::cout<< "Setting signal "<< signalindex << " to flag" << pol << std::endl; #endif if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ @@ -1642,7 +1642,7 @@ slsDetectorDefs::externalSignalFlag slsDetector::setExternalSignalFlags(external }; -/* +/* this function is used to select wether the detector is triggered or gated and in which mode enum externalCommunicationMode{ GET_EXTERNAL_COMMUNICATION_MODE, @@ -1708,7 +1708,7 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication // Tests and identification -/* +/* Gets versions enum idMode{ @@ -1729,7 +1729,7 @@ slsDetectorDefs::externalCommunicationMode slsDetector::setExternalCommunication int64_t slsDetector::getId( idMode mode, int imod){ int64_t retval=-1; - int fnum=F_GET_ID; + int fnum=F_GET_ID,fnum2 = F_GET_RECEIVER_ID; int ret=FAIL; char mess[100]; @@ -1747,7 +1747,7 @@ int64_t slsDetector::getId( idMode mode, int imod){ } else if (mode==RECEIVER_VERSION) { if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (connectData() == OK) - ret=thisReceiver->getInt(fnum,retval); + ret=thisReceiver->getInt(fnum2,retval); if(ret==FORCE_UPDATE) ret=updateReceiver(); } @@ -1848,7 +1848,7 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){ -/* +/* analog test of the modules enum analogTestMode { COUNT_CALIBRATION_PULSES, @@ -1861,8 +1861,8 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){ std::cout<< "function not yet implemented " << std::endl; }; */ -/* - enable analog output of channel +/* + enable analog output of channel */ /* int slsDetector::enableAnalogOutput(int ichan){ @@ -1871,15 +1871,15 @@ int slsDetector::digitalTest( digitalTestMode mode, int imod){ int ichip=ichan/nChans; ichan-=ichip*(nChans); enableAnalogOutput(imod,ichip,ichan); - + }; int slsDetector::enableAnalogOutput(int imod, int ichip, int ichan){ std::cout<< "function not yet implemented " << std::endl; }; */ -/* - give a train of calibration pulses -*/ +/* + give a train of calibration pulses +*/ /* int slsDetector::giveCalibrationPulse(double vcal, int npulses){ std::cout<< "function not yet implemented " << std::endl; @@ -2101,10 +2101,10 @@ dacs_t slsDetector::getADC(dacIndex index, int imod){ -}; +}; -/* - configure single channel +/* + configure single channel enum channelRegisterBit { COMPARATOR_ENABLE_OFF, ANALOG_SIGNAL_ENABLE_OFF, @@ -2145,7 +2145,7 @@ int slsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod){ myChan.chip=ichip;//ichi; myChan.module=imod;//im; myChan.reg=reg; - ret=setChannel(myChan); + ret=setChannel(myChan); // } // } // } @@ -2286,7 +2286,7 @@ slsDetectorDefs::sls_detector_channel slsDetector::getChannel(int ichan, int ic return myChan; } -/* +/* configure chip enum chipRegisterBit { ENABLE_ANALOG_OUTPUT, @@ -2321,7 +2321,7 @@ int slsDetector::setChip(int reg, int ichip, int imod){ myChip.chip=ichi; myChip.module=im; if (chanregs) - myChip.chanregs=(chanregs+ichi*thisDetector->nChans+im*thisDetector->nChans*thisDetector->nChips); + myChip.chanregs=(chanregs+ichi*thisDetector->nChans+im*thisDetector->nChans*thisDetector->nChips); else { for (int i=0; inChans; i++) chregs[i]=-1; @@ -2432,8 +2432,8 @@ slsDetectorDefs::sls_detector_chip slsDetector::getChip(int ichip, int imod){ return myChip; }; - -/* + +/* configure module enum moduleRegisterBit { I_DON_T_KNOW, @@ -2443,31 +2443,31 @@ slsDetectorDefs::sls_detector_chip slsDetector::getChip(int ichip, int imod){ int slsDetector::setModule(int reg, int imod){ sls_detector_module myModule; - + #ifdef VERBOSE std::cout << "slsDetector set module " << std::endl; -#endif +#endif int charegs[thisDetector->nChans*thisDetector->nChips]; int chiregs[thisDetector->nChips]; dacs_t das[thisDetector->nDacs], ads[thisDetector->nAdcs]; int mmin=imod, mmax=imod+1; int ret=FAIL; - + if (imod==-1) { mmin=0; mmax=thisDetector->nModsMax; } - - + + for (int im=mmin; imnChans; myModule.nchip=thisDetector->nChips; myModule.ndac=thisDetector->nDacs; myModule.nadc=thisDetector->nAdcs; - + myModule.reg=reg; if (detectorModules) { myModule.gain=(detectorModules+im)->gain; @@ -2478,43 +2478,43 @@ int slsDetector::setModule(int reg, int imod){ myModule.offset=-1; myModule.serialnumber=-1; } - - + + for (int i=0; inAdcs; i++) ads[i]=-1; - + if (chanregs) myModule.chanregs=chanregs+im*thisDetector->nChips*thisDetector->nChans; - else { + else { for (int i=0; inChans*thisDetector->nChips; i++) charegs[i]=-1; myModule.chanregs=charegs; } if (chipregs) myModule.chipregs=chanregs+im*thisDetector->nChips; - else { + else { for (int ichip=0; ichipnChips; ichip++) chiregs[ichip]=-1; myModule.chipregs=chiregs; } if (dacs) myModule.dacs=dacs+im*thisDetector->nDacs; - else { + else { for (int i=0; inDacs; i++) - das[i]=-1; + das[i]=-1; myModule.dacs=das; } if (adcs) myModule.adcs=adcs+im*thisDetector->nAdcs; - else { + else { for (int i=0; inAdcs; i++) ads[i]=-1; - myModule.adcs=ads; + myModule.adcs=ads; } ret=setModule(myModule); } return ret; - + }; @@ -2602,7 +2602,7 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){ #ifdef VERBOSE std::cout << "slsDetector get module " << std::endl; -#endif +#endif int fnum=F_GET_MODULE; sls_detector_module *myMod=createModule(); @@ -2708,16 +2708,16 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){ really needed? int slsDetector::setCalibration(int imod, detectorSettings isettings, double gain, double offset){ - std::cout<< "function not yet implemented " << std::endl; - - + std::cout<< "function not yet implemented " << std::endl; + + return OK; } int slsDetector::getCalibration(int imod, detectorSettings isettings, double &gain, double &offset){ - std::cout<< "function not yet implemented " << std::endl; + std::cout<< "function not yet implemented " << std::endl; @@ -2748,16 +2748,16 @@ int slsDetector::getThresholdEnergy(int imod){ controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< mess << std::endl; } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); thisDetector->currentThresholdEV=retval; } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); } - } + } return thisDetector->currentThresholdEV; -}; +}; int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isettings){ @@ -2783,8 +2783,8 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti #ifdef VERBOSE std::cout<< "Detector returned OK "<< std::endl; #endif - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - thisDetector->currentThresholdEV=retval; + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + thisDetector->currentThresholdEV=retval; } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) @@ -2794,14 +2794,14 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti thisDetector->currentThresholdEV=e_eV; } return thisDetector->currentThresholdEV; -}; +}; /* select detector settings */ slsDetectorDefs::detectorSettings slsDetector::getSettings(int imod){ - + int fnum=F_SET_SETTINGS; int ret=FAIL; char mess[100]; @@ -3060,9 +3060,9 @@ int slsDetector::updateDetectorNoWait() { } thisDetector->nMods=thisDetector->nMod[Y]*thisDetector->nMod[X]; - if (thisDetector->nModsMaxnMods) + if (thisDetector->nModsMaxnMods) thisDetector->nModsMax=thisDetector->nMods; - + if (thisDetector->nModMax[X]nMod[X]) thisDetector->nModMax[X]=thisDetector->nMod[X]; @@ -3243,21 +3243,21 @@ slsDetectorDefs::runStatus slsDetector::getRunStatus(){ stopSocket->ReceiveDataOnly(&ret,sizeof(ret)); // cout << "________:::____________" << ret << endl; - + if (ret==FAIL) { stopSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - // cout << "____________________" << retval << endl; - } + stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); + // cout << "____________________" << retval << endl; + } stopSocket->Disconnect(); } } } return retval; - + }; @@ -3351,7 +3351,7 @@ int* slsDetector::getDataFromDetector(int *retval){ int* slsDetector::readAll(){ - + int fnum=F_READ_ALL; int* retval; // check what we return! @@ -3391,11 +3391,11 @@ int* slsDetector::readAll(){ int slsDetector::readAllNoWait(){ int fnum= F_READ_ALL; - + #ifdef VERBOSE std::cout<< "Reading all frames "<< std::endl; #endif - + if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -3414,12 +3414,12 @@ int slsDetector::readAllNoWait(){ int* slsDetector::startAndReadAll(){ - + int* retval; #ifdef VERBOSE int i=0; #endif - startAndReadAllNoWait(); + startAndReadAllNoWait(); //#ifdef VERBOSE // std::cout<< "started" << std::endl; //#endif @@ -3437,7 +3437,7 @@ int* slsDetector::startAndReadAll(){ #ifdef VERBOSE std::cout<< "received "<< i<< " frames" << std::endl; //#else - // std::cout << std::endl; + // std::cout << std::endl; #endif return dataQueue.front(); // check what we return! /* while ((retval=getDataFromDetectorNoWait())) @@ -3447,7 +3447,7 @@ int* slsDetector::startAndReadAll(){ #endif return dataQueue.front(); // check what we return! */ - + }; @@ -3455,7 +3455,7 @@ int* slsDetector::startAndReadAll(){ int slsDetector::startAndReadAllNoWait(){ int fnum= F_START_AND_READ_ALL; - + #ifdef VERBOSE std::cout<< "Starting and reading all frames "<< std::endl; #endif @@ -3493,8 +3493,8 @@ int slsDetector::startAndReadAllNoWait(){ -/* - set or read the acquisition timers +/* + set or read the acquisition timers enum timerIndex { FRAME_NUMBER, ACQUISITION_TIME, @@ -3507,17 +3507,17 @@ int slsDetector::startAndReadAllNoWait(){ } */ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ - - int fnum=F_SET_TIMER; + + int fnum=F_SET_TIMER,fnum2=F_SET_RECEIVER_TIMER; int64_t retval = -1; int64_t ut = -2; char mess[100]; int ret=OK; int n=0; - + if (index!=MEASUREMENTS_NUMBER) { - + #ifdef VERBOSE std::cout<< "Setting timer "<< index << " to " << t << "ns/value" << std::endl; @@ -3533,16 +3533,16 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ std::cout<< "Detector returned error: " << mess << std::endl; setErrorMask((getErrorMask())|(DETECTOR_TIMER_VALUE_NOT_SET)); } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); thisDetector->timerValue[index]=retval; - } + } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) { updateDetector(); #ifdef VERBOSE std::cout<< "Updated!" << std::endl; #endif - + } } } else { @@ -3555,7 +3555,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ } else { if (t>=0) thisDetector->timerValue[index]=t; - } + } #ifdef VERBOSE std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] << "ns" << std::endl; #endif @@ -3564,7 +3564,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ setDynamicRange(); //cout << "Changing probes: data size = " << thisDetector->dataBytes <sendIntArray(fnum,ut,args); + ret=thisReceiver->sendIntArray(fnum2,ut,args); if((ut != retval)|| (ret==FAIL)){ ret = FAIL; if(index==FRAME_PERIOD){ @@ -3622,7 +3622,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ } } return thisDetector->timerValue[index]; - + }; int slsDetector::lockServer(int lock) { @@ -3630,7 +3630,7 @@ int slsDetector::lockServer(int lock) { int retval=-1; int ret=OK; char mess[100]; - + if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -3640,8 +3640,8 @@ int slsDetector::lockServer(int lock) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); @@ -3653,14 +3653,14 @@ int slsDetector::lockServer(int lock) { } - + string slsDetector::getLastClientIP() { int fnum=F_GET_LAST_CLIENT_IP; char clientName[INET_ADDRSTRLEN]; char mess[100]; int ret=OK; - + if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -3669,8 +3669,8 @@ string slsDetector::getLastClientIP() { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - controlSocket->ReceiveDataOnly(clientName,sizeof(clientName)); - } + controlSocket->ReceiveDataOnly(clientName,sizeof(clientName)); + } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); @@ -3684,7 +3684,7 @@ string slsDetector::getLastClientIP() { int slsDetector::setPort(portType index, int num){ - int fnum=F_SET_PORT; + int fnum=F_SET_PORT, fnum2 = F_SET_RECEIVER_PORT; int retval; // uint64_t ut; char mess[100]; @@ -3785,6 +3785,8 @@ int slsDetector::setPort(portType index, int num){ if (online) { if (s) { if (s->Connect()>=0) { + if(s==dataSocket) + fnum = fnum2; s->SendDataOnly(&fnum,sizeof(fnum)); s->SendDataOnly(&index,sizeof(index)); s->SendDataOnly(&num,sizeof(num)); @@ -3880,7 +3882,7 @@ int slsDetector::setPort(portType index, int num){ #ifdef VERBOSE cout << thisDetector->controlPort<< " " << thisDetector->receiverTCPPort << " " << thisDetector->stopPort << endl; -#endif +#endif @@ -3904,7 +3906,7 @@ int slsDetector::setPort(portType index, int num){ int slsDetector::setTotalProgress() { int nf=1, npos=1, nscan[MAX_SCAN_LEVELS]={1,1}, nc=1, nm=1; - + if (thisDetector->timerValue[FRAME_NUMBER]) nf=thisDetector->timerValue[FRAME_NUMBER]; @@ -3923,7 +3925,7 @@ int slsDetector::setTotalProgress() { if ((thisDetector->nScanSteps[1]>0) && (thisDetector->actionMask & (1 << (MAX_ACTIONS+1)))) nscan[1]=thisDetector->nScanSteps[1]; - + thisDetector->totalProgress=nf*nc*npos*nm*nscan[0]*nscan[1]; #ifdef VERBOSE @@ -3963,9 +3965,9 @@ double slsDetector::getCurrentProgress() { important speed parameters enum speedVariable { - CLOCK_DIVIDER, - WAIT_STATES, - SET_SIGNAL_LENGTH + CLOCK_DIVIDER, + WAIT_STATES, + SET_SIGNAL_LENGTH }; */ @@ -3993,8 +3995,8 @@ int slsDetector::setSpeed(speedVariable sp, int value) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); @@ -4004,7 +4006,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) { std::cout<< "Speed set to "<< retval << std::endl; #endif return retval; - + } @@ -4023,7 +4025,7 @@ int slsDetector::setSpeed(speedVariable sp, int value) { int64_t slsDetector::getTimeLeft(timerIndex index){ - + int fnum=F_GET_TIME_LEFT; int64_t retval; @@ -4043,8 +4045,8 @@ int64_t slsDetector::getTimeLeft(timerIndex index){ stopSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); - } + stopSocket->ReceiveDataOnly(&retval,sizeof(retval)); + } stopSocket->Disconnect(); } } @@ -4053,7 +4055,7 @@ int64_t slsDetector::getTimeLeft(timerIndex index){ std::cout<< "Time left is "<< retval << std::endl; #endif return retval; - + }; @@ -4061,7 +4063,7 @@ int64_t slsDetector::getTimeLeft(timerIndex index){ int slsDetector::setDynamicRange(int n){ // cout << "single " << endl; - int fnum=F_SET_DYNAMIC_RANGE; + int fnum=F_SET_DYNAMIC_RANGE,fnum2=F_SET_RECEIVER_DYNAMIC_RANGE; int retval=-1,retval1; char mess[100]; int ret=OK; @@ -4080,7 +4082,7 @@ int slsDetector::setDynamicRange(int n){ controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) @@ -4091,7 +4093,7 @@ int slsDetector::setDynamicRange(int n){ thisDetector->dynamicRange=n; retval=thisDetector->dynamicRange; } - + if (ret!=FAIL && retval>0) { /* checking the number of probes to chose the data size */ @@ -4105,10 +4107,10 @@ int slsDetector::setDynamicRange(int n){ if (retval==32) thisDetector->dynamicRange=24; - else + else thisDetector->dynamicRange=retval; - - + + #ifdef VERBOSE std::cout<< "Dynamic range set to "<< thisDetector->dynamicRange << std::endl; std::cout<< "Data bytes "<< thisDetector->dataBytes << std::endl; @@ -4123,7 +4125,7 @@ int slsDetector::setDynamicRange(int n){ std::cout << "Sending/Getting dynamic range to/from receiver " << retval << std::endl; #endif if (connectData() == OK) - ret=thisReceiver->sendInt(fnum,retval1,retval); + ret=thisReceiver->sendInt(fnum2,retval1,retval); if((retval1 != retval)|| (ret==FAIL)){ ret = FAIL; cout << "ERROR:Acquisition Period in receiver set incorrectly to " << retval1 << " instead of " << retval << endl; @@ -4231,7 +4233,7 @@ int slsDetector::sendROI(int n,ROI roiLimits[]){ /* - + enum readOutFlags { NORMAL_READOUT, setReadOutFlags(STORE_IN_RAM, @@ -4239,12 +4241,12 @@ READ_HITS, ZERO_COMPRESSION, BACKGROUND_CORRECTION }{}; - + */ int slsDetector::setReadOutFlags(readOutFlags flag){ - + int fnum=F_SET_READOUT_FLAGS; readOutFlags retval; char mess[100]; @@ -4263,7 +4265,7 @@ int slsDetector::setReadOutFlags(readOutFlags flag){ controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); thisDetector->roFlags=retval; } controlSocket->Disconnect(); @@ -4292,7 +4294,7 @@ int slsDetector::setReadOutFlags(readOutFlags flag){ }{}; */ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){ - + int fnum= F_EXECUTE_TRIMMING; int retval=FAIL; char mess[100]; @@ -4325,7 +4327,7 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){ std::cout<< "Detector trimmed "<< ret << std::endl; #endif /* - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); thisDetector->roFlags=retval; */ retval=ret; @@ -4346,7 +4348,7 @@ double* slsDetector::decodeData(int *datain, double *fdata) { dataout=fdata; else dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods]; - + const int bytesize=8; int ival=0; @@ -4398,13 +4400,13 @@ double* slsDetector::decodeData(int *datain, double *fdata) { dataout[ichan]=ival; } break; - default: + default: for (ichan=0; ichanflatFieldDir,fname.c_str()); nch=readDataFile(string(ffffname),data); if (nch>0) { - + //???? bad ff chans? int nm=getNMods(); int chpm[nm]; @@ -4473,19 +4475,19 @@ int slsDetector::setFlatFieldCorrection(string fname) mMask[im]=im; } fillModuleMask(mMask); - + if ((postProcessingFuncs::calculateFlatField(&nm, chpm, mMask, badChannelMask, data, ffcoefficients, fferrors))>=0) { strcpy(thisDetector->flatFieldFile,fname.c_str()); - - + + thisDetector->correctionMask|=(1<correctionMask&=~(1<correctionMask)&(1<correctionMask&(1<correctionMask&(1<nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) { - + if (errin==NULL) { e=sqrt(datain[ichan]); } else e=errin[ichan]; - + postProcessingFuncs::rateCorrect(datain[ichan], e, dataout[ichan], errout[ichan], tau, t); } } - + return 0; }; @@ -4694,14 +4696,14 @@ int slsDetector::rateCorrect(double* datain, double *errin, double* dataout, dou int slsDetector::setBadChannelCorrection(string fname){ - + // int nbadmod; int ret=0; //int badchanlist[MAX_BADCHANS]; //int off; string fn=fname; - + if (fname=="default") fname=string(badChanFile); @@ -4790,11 +4792,11 @@ int slsDetector::getBadChannelCorrection(int *bad) { -int slsDetector::exitServer(){ - +int slsDetector::exitServer(){ + int retval; int fnum=F_EXIT_SERVER; - + if (thisDetector->onlineFlag==ONLINE_FLAG) { if (controlSocket) { controlSocket->Connect(); @@ -4840,7 +4842,7 @@ char* slsDetector::setNetworkParameter(networkParameter index, string value) { char* slsDetector::getNetworkParameter(networkParameter index) { - + switch (index) { case DETECTOR_MAC: return getDetectorMAC(); @@ -5010,7 +5012,7 @@ int slsDetector::setReceiverUDPPort(int udpport){ int slsDetector::setUDPConnection(){ int ret = FAIL; - int fnum = F_SETUP_UDP; + int fnum = F_SETUP_RECEIVER_UDP; char args[2][MAX_STR_LENGTH]; char retval[MAX_STR_LENGTH]=""; @@ -5074,7 +5076,7 @@ int slsDetector::setUDPConnection(){ int slsDetector::configureMAC(){ int i; int ret=FAIL; - int fnum=F_CONFIGURE_MAC; + int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME; char mess[100]; char arg[5][50]; char cword[50]="", *pcword; @@ -5196,6 +5198,7 @@ int slsDetector::configureMAC(){ setFramesPerFile(MAX_FRAMES_PER_FILE); else setFramesPerFile(SHORT_MAX_FRAMES_PER_FILE); + //connect to receiver if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){ @@ -5203,7 +5206,7 @@ int slsDetector::configureMAC(){ std::cout << "Sending adc val to receiver " << retval << std::endl; #endif if (connectData() == OK) - ret=thisReceiver->sendInt(fnum,retval,retval); + ret=thisReceiver->sendInt(fnum2,retval,retval); if(ret==FAIL) setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC)); } @@ -5417,14 +5420,14 @@ int slsDetector::resetCounterBlock(int startACQ){ int slsDetector::readConfigurationFile(string const fname){ - + string ans; string str; ifstream infile; //char *args[1000]; - + string sargname, sargval; int iline=0; #ifdef VERBOSE @@ -5447,7 +5450,7 @@ int slsDetector::readConfigurationFile(string const fname){ int slsDetector::readConfigurationFile(ifstream &infile){ - + @@ -5459,7 +5462,7 @@ int slsDetector::readConfigurationFile(ifstream &infile){ int interrupt=0; char *args[100]; char myargs[1000][1000]; - + string sargname, sargval; int iline=0; while (infile.good() and interrupt==0) { @@ -5487,7 +5490,7 @@ int slsDetector::readConfigurationFile(ifstream &infile){ while (ssstr.good()) { ssstr >> sargname; //if (ssstr.good()) { -#ifdef VERBOSE +#ifdef VERBOSE std::cout<< iargval << " " << sargname << std::endl; #endif strcpy(myargs[iargval],sargname.c_str()); @@ -5496,7 +5499,7 @@ int slsDetector::readConfigurationFile(ifstream &infile){ //} } ans=cmd->executeLine(iargval,args,PUT_ACTION); -#ifdef VERBOSE +#ifdef VERBOSE std::cout<< ans << std::endl; #endif } @@ -5517,11 +5520,11 @@ int slsDetector::readConfigurationFile(ifstream &infile){ int slsDetector::writeConfigurationFile(string const fname){ - + ofstream outfile; int ret; - + outfile.open(fname.c_str(),ios_base::out); if (outfile.is_open()) { ret=writeConfigurationFile(outfile); @@ -5541,7 +5544,7 @@ int slsDetector::writeConfigurationFile(string const fname){ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){ - + slsDetectorCommand *cmd=new slsDetectorCommand(this); int nvar=15; @@ -5565,7 +5568,7 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){ // to be added in the future // "trimen", // "receiverTCPPort", - + if ((thisDetector->myDetectorType==GOTTHARD)||(thisDetector->myDetectorType==MOENCH)) { names[0]= "hostname"; names[1]= "port"; @@ -5593,14 +5596,14 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){ int iv=0; char *args[100]; char myargs[100][1000]; - + for (int ia=0; ia<100; ia++) { //args[ia]=new char[1000]; - + args[ia]=myargs[ia]; } - - + + for (iv=0; iv=0) outfile << id << ":"; - + outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl; } } else { @@ -5660,7 +5663,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) { ostringstream ostfn; ostfn << fname; if (fname.find(".sn")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) { - ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); + ostfn << ".sn" << setfill('0') << setw(3) << hex << getId(MODULE_SERIAL_NUMBER, im); fn=ostfn.str(); } if (fname.find(".beb")==string::npos && fname.find(".trim")==string::npos && fname.find(".settings")==string::npos) { @@ -5675,7 +5678,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) { myMod->reg=thisDetector->currentSettings; setModule(*myMod); deleteModule(myMod); - } else + } else return FAIL; } return OK; @@ -5772,12 +5775,12 @@ int slsDetector::saveCalibrationFile(string fname, int imod) { -/* returns if the detector is Master, slave or nothing +/* returns if the detector is Master, slave or nothing \param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE \returns master flag of the detector */ slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) { - + int fnum=F_SET_MASTER; masterFlags retval=GET_MASTER; @@ -5787,7 +5790,7 @@ slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) { #ifdef VERBOSE std::cout<< "Setting master flags to "<< flag << std::endl; #endif - + if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -5797,13 +5800,13 @@ slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) { controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); } - } + } #ifdef VERBOSE std::cout<< "Master flag set to "<< retval << std::endl; @@ -5817,12 +5820,12 @@ slsDetectorDefs::masterFlags slsDetector::setMaster(masterFlags flag) { /* Sets/gets the synchronization mode of the various detectors \param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NO_SYNCHRONIZATION, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS - \returns current syncronization mode -*/ + \returns current syncronization mode +*/ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchronizationMode flag) { - - + + int fnum=F_SET_SYNCHRONIZATION_MODE; synchronizationMode retval=GET_SYNCHRONIZATION_MODE; char mess[100]; @@ -5831,7 +5834,7 @@ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchroniza #ifdef VERBOSE std::cout<< "Setting synchronization mode to "<< flag << std::endl; #endif - + if (thisDetector->onlineFlag==ONLINE_FLAG) { if (connectControl() == OK){ controlSocket->SendDataOnly(&fnum,sizeof(fnum)); @@ -5841,13 +5844,13 @@ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchroniza controlSocket->ReceiveDataOnly(mess,sizeof(mess)); std::cout<< "Detector returned error: " << mess << std::endl; } else { - controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); } controlSocket->Disconnect(); if (ret==FORCE_UPDATE) updateDetector(); } - } + } #ifdef VERBOSE std::cout<< "Readout flag set to "<< retval << std::endl; @@ -5993,7 +5996,7 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port string slsDetector::setFilePath(string s) { - int fnum = F_SET_FILE_PATH; + int fnum = F_SET_RECEIVER_FILE_PATH; int ret = FAIL; char arg[MAX_STR_LENGTH]; char retval[MAX_STR_LENGTH] = ""; @@ -6032,7 +6035,7 @@ string slsDetector::setFilePath(string s) { string slsDetector::setFileName(string s) { - int fnum=F_SET_FILE_NAME; + int fnum=F_SET_RECEIVER_FILE_NAME; int ret = FAIL; char arg[MAX_STR_LENGTH]; char retval[MAX_STR_LENGTH]=""; @@ -6070,7 +6073,7 @@ string slsDetector::setFileName(string s) { int slsDetector::setFileIndex(int i) { - int fnum=F_SET_FILE_INDEX; + int fnum=F_SET_RECEIVER_FILE_INDEX; int ret = FAIL; int retval=-1; int arg = i; @@ -6157,7 +6160,7 @@ int slsDetector::stopReceiver(){ slsDetectorDefs::runStatus slsDetector::startReceiverReadout(){ - int fnum=F_START_READOUT; + int fnum=F_START_RECEIVER_READOUT; int ret = FAIL; int retval=-1; runStatus s=ERROR; @@ -6237,7 +6240,7 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){ int slsDetector::getFramesCaughtByReceiver(){ - int fnum=F_GET_FRAMES_CAUGHT; + int fnum=F_GET_RECEIVER_FRAMES_CAUGHT; int ret = FAIL; int retval=-1; @@ -6257,7 +6260,7 @@ int slsDetector::getFramesCaughtByReceiver(){ int slsDetector::getReceiverCurrentFrameIndex(){ - int fnum=F_GET_FRAME_INDEX; + int fnum=F_GET_RECEIVER_FRAME_INDEX; int ret = FAIL; int retval=-1; @@ -6278,7 +6281,7 @@ int slsDetector::getReceiverCurrentFrameIndex(){ int slsDetector::resetFramesCaught(){ - int fnum=F_RESET_FRAMES_CAUGHT; + int fnum=F_RESET_RECEIVER_FRAMES_CAUGHT; int ret = FAIL; char mess[] = ""; @@ -6300,7 +6303,7 @@ int slsDetector::resetFramesCaught(){ int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){ - int fnum=F_READ_FRAME; + int fnum=F_READ_RECEIVER_FRAME; int nel=thisDetector->dataBytes/sizeof(int); int* retval=new int[nel]; int ret=FAIL; @@ -6353,7 +6356,7 @@ int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){ int slsDetector::lockReceiver(int lock){ - int fnum=F_LOCK_SERVER; + int fnum=F_LOCK_RECEIVER; int ret = FAIL; int retval=-1; int arg=lock; @@ -6378,7 +6381,7 @@ int slsDetector::lockReceiver(int lock){ string slsDetector::getReceiverLastClientIP(){ - int fnum=F_GET_LAST_CLIENT_IP; + int fnum=F_GET_LAST_RECEIVER_CLIENT_IP; int ret = FAIL; char retval[INET_ADDRSTRLEN]=""; @@ -6424,7 +6427,7 @@ int slsDetector::updateReceiverNoWait() { int slsDetector::updateReceiver() { - int fnum=F_UPDATE_CLIENT; + int fnum=F_UPDATE_RECEIVER_CLIENT; int ret=OK; char mess[100]; @@ -6453,7 +6456,7 @@ int slsDetector::updateReceiver() { int slsDetector::exitReceiver(){ int retval; - int fnum=F_EXIT_SERVER; + int fnum=F_EXIT_RECEIVER; if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (dataSocket) { @@ -6477,7 +6480,7 @@ int slsDetector::exitReceiver(){ int slsDetector::enableWriteToFile(int enable){ - int fnum=F_ENABLE_FILE_WRITE; + int fnum=F_ENABLE_RECEIVER_FILE_WRITE; int ret = FAIL; int retval=-1; int arg = enable; @@ -6507,7 +6510,7 @@ int slsDetector::enableWriteToFile(int enable){ int slsDetector::overwriteFile(int enable){ - int fnum=F_ENABLE_OVERWRITE; + int fnum=F_ENABLE_RECEIVER_OVERWRITE; int ret = FAIL; int retval=-1; int arg = enable; @@ -6537,7 +6540,7 @@ int slsDetector::overwriteFile(int enable){ int slsDetector::setFrameIndex(int index){ - int fnum=F_SET_FRAME_INDEX; + int fnum=F_SET_RECEIVER_FRAME_INDEX; int ret = FAIL; int retval=-1; int arg = index; @@ -6635,7 +6638,7 @@ int slsDetector::setReadReceiverFrequency(int getFromReceiver,int i){ int slsDetector::enableReceiverCompression(int i){ - int fnum=F_ENABLE_COMPRESSION; + int fnum=F_ENABLE_RECEIVER_COMPRESSION; int ret = FAIL; int retval=-1; @@ -6655,7 +6658,7 @@ int slsDetector::enableReceiverCompression(int i){ void slsDetector::setDetectorHostname(){ - int fnum=F_SET_DETECTOR_HOSTNAME; + int fnum=F_SEND_RECEIVER_DETHOSTNAME; int ret = FAIL; char retval[MAX_STR_LENGTH]=""; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index 25f48cf9c..d543b0281 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -48,6 +48,7 @@ #include "sls_detector_defs.h" +#include "sls_receiver_defs.h" #include "slsDetectorUsers.h" #include "error_defs.h" @@ -65,7 +66,7 @@ using namespace std; */ //public virtual slsDetectorUsers, -class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDefs { +class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDefs { public: @@ -327,6 +328,20 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef virtual int* readFrame()=0; + /** + get detector ids/versions for module=0 + \param mode which id/version has to be read + \param imod module number for module serial number + \returns id + */ + virtual int64_t getId(idMode mode, int imod=0)=0; + int64_t getModuleFirmwareVersion(){return getId(MODULE_FIRMWARE_VERSION,-1);}; + int64_t getModuleSerialNumber(int imod=-1){return getId(MODULE_SERIAL_NUMBER,imod);}; + int64_t getDetectorFirmwareVersion(){return getId(DETECTOR_FIRMWARE_VERSION,-1);}; + int64_t getDetectorSerialNumber(){return getId(DETECTOR_SERIAL_NUMBER,-1);}; + int64_t getDetectorSoftwareVersion(){return getId(DETECTOR_SOFTWARE_VERSION,-1);}; + int64_t getThisSoftwareVersion(){return getId(THIS_SOFTWARE_VERSION,-1);}; + /** start detector acquisition \returns OK/FAIL diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index 47c18b5bb..14ded7f7e 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -239,6 +239,31 @@ int slsDetectorUsers::setReceiverMode(int n){ +int64_t slsDetectorUsers::getModuleFirmwareVersion(){ + return myDetector->getModuleFirmwareVersion(); +} + +int64_t slsDetectorUsers::getModuleSerialNumber(int imod){ + return myDetector->getModuleSerialNumber(imod); +} + +int64_t slsDetectorUsers::getDetectorFirmwareVersion(){ + return myDetector->getDetectorFirmwareVersion(); +} + +int64_t slsDetectorUsers::getDetectorSerialNumber(){ + return myDetector->getDetectorSerialNumber(); +} + +int64_t slsDetectorUsers::getDetectorSoftwareVersion(){ + return myDetector->getDetectorSoftwareVersion(); +} + +int64_t slsDetectorUsers::getThisSoftwareVersion(){ + return myDetector->getThisSoftwareVersion(); +} + + void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, int, void*), void *pArg){ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index 4dd8e4300..fac8a5d45 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -450,7 +450,42 @@ class slsDetectorUsers virtual void finalizeDataset(double *a, double *v, double *e, int &np); + /** + get get Module Firmware Version + \returns id + */ + int64_t getModuleFirmwareVersion(); + /** + get get Module Serial Number + @param imod module number + \returns id + */ + int64_t getModuleSerialNumber(int imod=-1); + + /** + get get Detector Firmware Version + \returns id + */ + int64_t getDetectorFirmwareVersion(); + + /** + get get Detector Serial Number + \returns id + */ + int64_t getDetectorSerialNumber(); + + /** + get get Detector Software Version + \returns id + */ + int64_t getDetectorSoftwareVersion(); + + /** + get this Software Version + \returns id + */ + int64_t getThisSoftwareVersion(); /** @short register calbback for accessing detector final data diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 49b176cf3..10ab20e4b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -42,7 +42,7 @@ using namespace std; #define DEFAULT_HOSTNAME "localhost" #define DEFAULT_SHM_KEY 5678 -#define THIS_REVISION "$Rev$" +#define THIS_REVISION "$Rev: 822 $" //test @@ -188,14 +188,6 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing { */ virtual int setPort(portType t, int i=-1)=0; - /** - get detector ids/versions for module=0 - \param mode which id/version has to be read - \param imod module number for module serial number - \returns id - */ - virtual int64_t getId(idMode mode, int imod=0)=0; - /** checks if the detector(s) are online/offline \returns hostname if offline diff --git a/slsDetectorSoftware/slsReceiver/.cproject b/slsDetectorSoftware/slsReceiver/.cproject deleted file mode 100644 index d34dce296..000000000 --- a/slsDetectorSoftware/slsReceiver/.cproject +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/slsDetectorSoftware/slsReceiver/.project b/slsDetectorSoftware/slsReceiver/.project deleted file mode 100644 index 3c7b96561..000000000 --- a/slsDetectorSoftware/slsReceiver/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - Receiver - - - newMythenSoftware - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/slsDetectorSoftware/slsReceiver/Makefile b/slsDetectorSoftware/slsReceiver/Makefile deleted file mode 100644 index 7028cee60..000000000 --- a/slsDetectorSoftware/slsReceiver/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -include ../../Makefile.include - -DESTDIR ?= ../../bin -LIBDIR ?= $(DESTDIR) -PROGS = $(DESTDIR)/slsReceiver - - -CFLAGS += -DSLS_RECEIVER_FUNCTION_LIST -O3 -CPPFLAGS = ${CFLAGS} # for MAC -LDFLAG ?= -L$(LIBDIR) -lSlsDetector -L/usr/lib64/ -lpthread -LDFLAG += -lm -lstdc++ - - - -INCLUDES ?= -I ../MySocketTCP -I ../commonFiles -I ../../slsDetectorCalibration -I . -SRC_CLNT = slsReceiver.cpp -#../MySocketTCP/MySocketTCP.cpp slsReceiver_funcs.cpp UHRIXCallback.cpp slsReceiverFunctionList.cpp slsReceiverUsers.cpp - - -INSTMODE = 0777 -OBJS = $(SRC_CLNT:.cpp=.o) - - -.PHONY: all receiver clean static_receiver boot eigerReceiver lib - -all: receiver - -receiver: $(DESTDIR)/slsReceiver - -static_receiver: $(DESTDIR)/sslsReceiver - -boot: $(OBJS) - -$(DESTDIR)/sslsReceiver: lib - echo $(OBJS) - echo $(LDFLAG) - echo $(LIBS) - mkdir -p $(DESTDIR) - $(CXX) -static -o $@ $(SRC_CLNT) $(FLAGS) $(INCLUDES) $(CLAGS) $(LIBS) $(LDFLAG) - - -$(DESTDIR)/slsReceiver: eigerReceiver lib - $(CXX) -o $@ $(SRC_CLNT) $(FLAGS) $(INCLUDES) $(CLAGS) $(LIBS) $(LDFLAG) -fPIC -#$(EIGERFLAGS) - - -ifeq ($(EIGERSLS), yes) -eigerReceiver: - $(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiverTest.o eigerReceiverTest.cpp $(EIGERFLAGS) - $(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiver.o eigerReceiver.cpp $(EIGERFLAGS) - $(CXX) eigerReceiverTest.o eigerReceiver.o -o eigerReceiverTest $(EIGERFLAGS) -else ifeq ($(ROOTSLS), yes) -eigerReceiver: eigerReceiverDummy.cpp - echo "Compiling dummy EigerReceiver with root" - $(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiver.o eigerReceiverDummy.cpp $(ROOTFLAGS) -else -eigerReceiver: eigerReceiverDummy.cpp - echo "Compiling dummy EigerReceiver" - $(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiver.o eigerReceiverDummy.cpp -endif - -lib: - cd ../ && $(MAKE) DESTDIR=../bin LIBDIR=../bin - -clean: - rm -rf $(PROGS) *.o eigerReceiverTest - rm -rf $(DESTDIR)/libSlsDetector.a $(DESTDIR)/libSlsDetector.so core - - - diff --git a/slsDetectorSoftware/slsReceiver/RestHelper.h b/slsDetectorSoftware/slsReceiver/RestHelper.h deleted file mode 100644 index 6f423f5e1..000000000 --- a/slsDetectorSoftware/slsReceiver/RestHelper.h +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @file RestHelper.h - * @author Leonardo Sala - * @date Tue Mar 25 09:28:19 2014 - * - * @brief - * - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "JsonBox/Value.h" - -#include -#include -#include - -/// HTTP timeout in seconds, default is 8 -#define HTTP_TIMEOUT 10 -/// Number of connection tries -#define N_CONNECTION_TRIES 3 - -using namespace Poco::Net; -using namespace Poco; -using namespace std; - -class RestHelper { - public: - - ~RestHelper(){}; - - void init(string hostname, int port){ - /** Initialize the RestHelper. Hostname and port parameters are not supposed to change. - * - * - * @param hostname FQDN of the host to connect to , e.g. www.iamfake.org, or sodoi.org - * @param port - * - * @return - */ - - full_hostname = "http://"+hostname; - session = new HTTPClientSession(hostname,port ); - session->setKeepAliveTimeout( Timespan( HTTP_TIMEOUT,0) ); - }; - - - int get_json(string request, string* answer){ - /** Retrieves a reply from the RESTful webservice. - * - * - * @param request Request without the hostname, e.g. if the full request would have been http://fake.org/fakemethod, request=fakemethod - * @param answer - * - * @return 0 if successful, -1 if failure happens. - */ - URI * uri = new URI(full_hostname+"/"+request); - string path(uri->getPathAndQuery()); - if (path.empty()) path = "/"; - - // send request - HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1); - req.setContentType("application/json\r\n"); - int code = send_request(session, req, answer); - delete uri; - return code; - }; - - - int get_json(string request, JsonBox::Value* json_value){ - /** - * - * - * @param request - * @param json_value - * - * @return - */ - URI *uri = new URI(full_hostname+"/"+request); - string path(uri->getPathAndQuery()); - if (path.empty()) path = "/"; - // send request - HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1); - req.setContentType("application/json\r\n"); - string answer; - int code = send_request(session, req, &answer); - json_value->loadFromString(answer); - delete uri; - return code; - }; - - - int post_json(string request, string *answer, string request_body=""){ - /** - * - * - * @param request - * @param answer - * @param request_body Eventual arguments to the URL, e.g. action=login&name=mammamia - * - * @return - */ - //from: http://stackoverflow.com/questions/1499086/poco-c-net-ssl-how-to-post-https-request - URI *uri = new URI(full_hostname+"/"+request); - string path(uri->getPathAndQuery()); - if (path.empty()) path = "/"; - HTTPRequest req(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1 ); - req.setContentType("application/json\r\n"); - req.setContentLength( request.length() ); - int code = send_request(session, req, answer, request_body); - delete uri; - return code; - } - - - int post_json(string request, JsonBox::Value* json_value, string request_body=""){ - /** - * - * - * @param request - * @param json_value - * @param request_body Eventual arguments to the URL, e.g. action=login&name=mammamia - * - * @return - */ - - URI *uri = new URI(full_hostname+"/"+request); - string path(uri->getPathAndQuery()); - if (path.empty()) path = "/"; - HTTPRequest req(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1 ); - req.setContentType("application/json\r\n"); - req.setContentLength( request.length() ); - string answer; - int code = send_request(session, req, &answer, request_body); - json_value->loadFromString(answer); - delete uri; - return code; - } - - - private: - //URI * uri; - HTTPClientSession *session; - string full_hostname; - - int send_request(HTTPClientSession *session, HTTPRequest &req, string *answer, string request_body=""){ - /** - * - * - * @param session - * @param req - * @param answer - * @param request_body - * - * @return - */ - - int n=0; - int code = -1; - while(nsendRequest( (req) ); - else - session->sendRequest( (req) ) << request_body; - - HTTPResponse res; - istream &is = session->receiveResponse(res); - StreamCopier::copyToString(is, *answer); - code = res.getStatus(); - if (code != 200){ - cout << "HTTP ERROR " << res.getStatus() << ": " << res.getReason() << endl; - code = -1; - } - return code; - } - catch (exception& e){ - cout << "Exception connecting to "<< full_hostname << ": "<< e.what() << ", sleeping " << HTTP_TIMEOUT << " seconds\n"; - sleep(HTTP_TIMEOUT); - } - n+=1; - } - - return code; - } - -}; diff --git a/slsDetectorSoftware/slsReceiver/circularFifo.h b/slsDetectorSoftware/slsReceiver/circularFifo.h deleted file mode 100644 index 241a7aeb6..000000000 --- a/slsDetectorSoftware/slsReceiver/circularFifo.h +++ /dev/null @@ -1,261 +0,0 @@ -/* CircularFifo.h -* Not any company's property but Public-Domain -* Do with source-code as you will. No requirement to keep this -* header if need to use it/change it/ or do whatever with it -* -* Note that there is No guarantee that this code will work -* and I take no responsibility for this code and any problems you -* might get if using it. The code is highly platform dependent! -* -* Code & platform dependent issues with it was originally -* published at http://www.kjellkod.cc/threadsafecircularqueue -* 2009-11-02 -* @author Kjell Hedstr�m, hedstrom@kjellkod.cc */ - -#ifndef CIRCULARFIFO_H_ -#define CIRCULARFIFO_H_ - -//#include "sls_detector_defs.h" -#include -#include -#include -using namespace std; - -typedef double double32_t; -typedef float float32_t; -typedef int int32_t; - - - -/** Circular Fifo (a.k.a. Circular Buffer) -* Thread safe for one reader, and one writer */ -template -class CircularFifo { -public: - - CircularFifo(unsigned int Size) : tail(0), head(0){ - Capacity = Size + 1; - array.resize(Capacity); - sem_init(&free_mutex,0,0); - } - virtual ~CircularFifo() {} - - bool push(Element*& item_); - bool pop(Element*& item_); - - bool isEmpty() const; - bool isFull() const; - - int getSemValue(); - -private: - volatile unsigned int tail; // input index - vector array; - volatile unsigned int head; // output index - unsigned int Capacity; - sem_t free_mutex; - - unsigned int increment(unsigned int idx_) const; -}; - -template -int CircularFifo::getSemValue() -{ - int value; - sem_getvalue(&free_mutex, &value); - return value; -} - - -/** Producer only: Adds item to the circular queue. -* If queue is full at 'push' operation no update/overwrite -* will happen, it is up to the caller to handle this case -* -* \param item_ copy by reference the input item -* \return whether operation was successful or not */ -template -bool CircularFifo::push(Element*& item_) -{ - - int nextTail = increment(tail); - if(nextTail != head) - { - array[tail] = item_; - tail = nextTail; - sem_post(&free_mutex); - return true; - } - - // queue was full - return false; -} - -/** Consumer only: Removes and returns item from the queue -* If queue is empty at 'pop' operation no retrieve will happen -* It is up to the caller to handle this case -* -* \param item_ return by reference the wanted item -* \return whether operation was successful or not */ -template -bool CircularFifo::pop(Element*& item_) -{ - // if(head == tail) - // return false; // empty queue - sem_wait(&free_mutex); - - item_ = array[head]; - head = increment(head); - return true; -} - -/** Useful for testinng and Consumer check of status - * Remember that the 'empty' status can change quickly - * as the Procuder adds more items. - * - * \return true if circular buffer is empty */ -template -bool CircularFifo::isEmpty() const -{ - return (head == tail); -} - -/** Useful for testing and Producer check of status - * Remember that the 'full' status can change quickly - * as the Consumer catches up. - * - * \return true if circular buffer is full. */ -template -bool CircularFifo::isFull() const -{ - int tailCheck = (tail+1) % Capacity; - return (tailCheck == head); -} - -/** Increment helper function for index of the circular queue -* index is inremented or wrapped -* -* \param idx_ the index to the incremented/wrapped -* \return new value for the index */ -template -unsigned int CircularFifo::increment(unsigned int idx_) const -{ - // increment or wrap - // ================= - // index++; - // if(index == array.lenght) -> index = 0; - // - //or as written below: - // index = (index+1) % array.length - idx_ = (idx_+1) % Capacity; - return idx_; -} - -#endif /* CIRCULARFIFO_H_ */ - - - - - -/* -#ifndef CIRCULARFIFO_H_ -#define CIRCULARFIFO_H_ - -#include "sls_detector_defs.h" - -#include "/usr/include/alsa/atomic.h" -#include -using namespace std; - -template -class CircularFifo { -public: - - CircularFifo(unsigned int Size) : tail(0), head(0){ - Capacity = Size + 1; - array.resize(Capacity); - } - virtual ~CircularFifo() {} - - bool push(Element*& item_); - bool pop(Element*& item_); - - bool wasEmpty() const; - bool wasFull() const; - bool isLockFree() const; - -private: - vector array; - unsigned int Capacity; - - std::atomic tail; // input index - std::atomic head; // output index - - unsigned int increment(unsigned int idx_) const; -}; - - -template -bool CircularFifo::push(Element*& item_) -{ - auto currentTail = tail.load(); - auto nextTail = increment(currentTail); - if(nextTail != head.load()) - { - array[currentTail] = item_; - tail.store(nextTail); - return true; - } - - // queue was full - return false; -} - - -template -bool CircularFifo::pop(Element*& item_) -{ - const auto currentHead = head.load(); - if(currentHead == tail.load()) - return false; // empty queue - - item_ = array[currentHead]; - head.store(increment(currentHead)); - return true; -} - - -template -bool CircularFifo::wasEmpty() const -{ - return (head.load() == tail.load()); -} - - -template -bool CircularFifo::wasFull() const -{ - const auto nextTail = increment(tail.load()); - return (nextTail == head.load()); -} - -template -bool CircularFifo::isLockFree() const -{ - return (tail.is_lock_free() && head.is_lock_free()); -} - - -template -unsigned int CircularFifo::increment(unsigned int idx_) const -{ - // increment or wrap - // ================= - // index++; - // if(index == array.lenght) -> index = 0; - // - //or as written below: - // index = (index+1) % array.length - return (idx_ + 1) % Capacity; -} - -#endif */ diff --git a/slsDetectorSoftware/slsReceiver/eigerReceiver.cpp b/slsDetectorSoftware/slsReceiver/eigerReceiver.cpp deleted file mode 100644 index d75493d41..000000000 --- a/slsDetectorSoftware/slsReceiver/eigerReceiver.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* - * eigerReceiver.cpp - * - * Created on: Mar 11, 2014 - * Author: billich - */ - -#include -#include -#include "eigerReceiver.h" - - -/* uncomment next line to enable debug output */ -#define EIGER_DEBUG - -/* macro for debug output http://stackoverflow.com/a/14256296 */ -#ifdef EIGER_DEBUG -#define DEBUG(x) do { std::cerr << x << std::endl; } while (0) -#else -#define DEBUG(x) -#endif - - -using namespace std; - -struct EigerReceiverInitializationConfiguration { - - string detectorHostname; -}; - -struct EigerReceiverScanConfiguration { - - string fileName; - string filePath; - int dynamicRange; - int scanTag; - int numberOfFrames; - bool doFileWrite; - bool doFileOverWrite; - - EigerReceiverScanConfiguration(): - dynamicRange(-1), - scanTag(-1), - numberOfFrames(-1), - doFileWrite(false), - doFileOverWrite(false){}; -}; - -class EigerReceiverImplementation: public EigerReceiver { - -public: - - EigerReceiverImplementation() : isInitialized(false), status(slsDetectorDefs::ERROR) {}; - - void initialize(const char *detectorHostname) { - - string name; - if (detectorHostname != NULL) { - name = detectorHostname; - } - - if (name.empty()) { - DEBUG("initialize(): can't initialize with empty string or NULL for detectorHostname"); - } else if (isInitialized == true) { - DEBUG("initialize(): already initialized, can't initialize several times"); - } else { - DEBUG("initialize(): initialize() with: detectorHostName=" << name << "."); - init_config.detectorHostname = name; - isInitialized = true; - status = slsDetectorDefs::IDLE; - } - -#ifdef SALA - //REST call - hardcoded - RestHelper rest ; - rest.init("localhost",8080); - std::string answer; - std::cout << "---- REST test 1: true, string "<< std::endl; - int code = rest.get_json("status", &answer); - std::cout << "Answer: " << answer << std::endl; - - std::cout << "---- REST test 2: 404, string "<< std::endl; - code = rest.get_json("statuss", &answer); - if (code != 0){ - //throw -1; - std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl; - } - - std::cout << "---- REST test 3: true, json object "<< std::endl; - JsonBox::Value json_value; - code = rest.get_json("status", &json_value); - std::cout << "JSON " << json_value["status"] << std::endl; - - answer = ""; - std::cout << "---- REST test 4: POST, string "<< std::endl; - code = rest.post_json("recipes/cassoela", &answer); - std::cout << "POST answer: " << answer << std::endl; - if (code != 0){ - //throw -1; - std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl; - } - - RestHelper rest2 ; - rest2.init("reallyfake",8080); - std::cout << "---- REST test 4: host not found, json object "<< std::endl; - JsonBox::Value json_value2; - code = rest2.get_json("status", &json_value2); - if (code != 0){ - //throw -1; - std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl; - } - -#endif - } - - - char *getDetectorHostname() const { - string name = init_config.detectorHostname; - if (name.empty()) { - DEBUG("getDetectorHostname(): Return NULL"); - return(NULL); - } - char *c = new char[name.length()+1]; - name.copy(c, name.length()); - c[name.length()] = '\0'; - DEBUG("getDetectorHostname(): Return " << c << "."); - return(c); - } - - char *getFileName() const { - string name = scan_config.fileName; - - char *c = new char[name.length()+1]; - name.copy(c, name.length()); - c[name.length()] = '\0'; - DEBUG("getFileName(): Return " << c); - return(c); - } - - char *getFilePath() const { - string name = scan_config.filePath; - - char *c = new char[name.length()+1]; - name.copy(c, name.length()); - c[name.length()] = '\0'; - DEBUG("getFilePath(): Return " << c); - return(c); - } - - int getDynamicRange() const { - DEBUG("getDynamicRange(): Return " << scan_config.dynamicRange); - return(scan_config.dynamicRange); - } - - int getScanTag() const { - DEBUG("getScanTag(): returns " << scan_config.scanTag); - return(scan_config.scanTag); - } - - int getNumberOfFrames() const { - DEBUG("getNumberOfFrames(): return " << scan_config.numberOfFrames); - return(scan_config.numberOfFrames); - } - - int getEnableFileWrite() const { - DEBUG("getEnableFileWrite() returns " << scan_config.doFileWrite); - return(scan_config.doFileWrite); - } - - int getEnableOverwrite() const { - DEBUG("getEnableOverwrite() returns " << scan_config.doFileOverWrite); - return(scan_config.doFileOverWrite); - } - - slsDetectorDefs::runStatus getStatus() const { - DEBUG("getStatus(): return " <getFileName()); - } - - char *setFilePath(const char c[]) { - DEBUG("setFilePath() called with " << c << "."); - scan_config.filePath = c; - return(this->getFilePath()); - } - - int setDynamicRange (const int dr) { - DEBUG("setDynamicRange() called with " << dr << '.'); - scan_config.dynamicRange = dr; - return(getDynamicRange()); - } - - int setScanTag (const int tag) { - DEBUG("setScanTag() called with " << tag); - scan_config.scanTag = tag; - return(getScanTag()); - } - - int setNumberOfFrames (const int fnum) { - DEBUG("setNumberOfFrames() called with " << fnum); - scan_config.numberOfFrames = fnum; - return(getNumberOfFrames()); - } - - int setEnableFileWrite(const int i) { - DEBUG("enableFileWrite() called with " << i); - scan_config.doFileWrite = i; - return(getEnableFileWrite()); - } - - int setEnableOverwrite(const int i) { - DEBUG("setEnableOverwrite() called with " << i); - scan_config.doFileOverWrite = i; - return(getEnableOverwrite()); - } - - int startReceiver(char message[]) { - DEBUG("startReceiver(): return 0."); - status = slsDetectorDefs::RUNNING; - message = NULL; - return(0); - } - - int stopReceiver() { - DEBUG("stopReceiver(): return 0."); - status = slsDetectorDefs::IDLE; - return(0); - } - - void abort() { - DEBUG("abort(): return 0."); - status = slsDetectorDefs::IDLE; - } - -private: - EigerReceiverScanConfiguration scan_config; - EigerReceiverInitializationConfiguration init_config; - bool isInitialized; - slsDetectorDefs::runStatus status; -}; - -EigerReceiver *EigerReceiver::create(void) { - DEBUG("create(): Return new EigerReceiverImplementation instance."); - return new EigerReceiverImplementation(); -} - - - - diff --git a/slsDetectorSoftware/slsReceiver/eigerReceiver.h b/slsDetectorSoftware/slsReceiver/eigerReceiver.h deleted file mode 100644 index 100acb9be..000000000 --- a/slsDetectorSoftware/slsReceiver/eigerReceiver.h +++ /dev/null @@ -1,211 +0,0 @@ -#ifndef EIGERRECEIVER_H -#define EIGERRECEIVER_H -/*********************************************** - * @file eigerReceiver.h - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ - -/** - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - */ - -#include "sls_detector_defs.h" -#ifdef SALA -#include "RestHelper.h" -#endif -class EigerReceiver { - /* abstract class that defines the public interface of an eiger data receiver. - * - * Use the factory method EigerReceiver::create() to get an instance: - * - * EigerReceiver *receiver = EigerReceiver::create() - * - * supported sequence of method-calls: - * - * initialize() : once and only once after create() - * - * get*() : anytime after initialize(), multiples times - * set*() : anytime after initialize(), multiple times - * - * startReceiver(): anytime after initialize(). Will fail if state already is 'running' - * - * abort(), - * stopReceiver() : anytime after initialize(). Will do nothing if state already is idle. - * - * getStatus() returns the actual state of the data receiver - running or idle. All other - * get*() and set*() methods access the local cache of configuration values only and *do not* modify the data receiver settings. - * - * Only startReceiver() does change the data receiver configuration, it does pass the whole configuration cache to the data receiver. - * - * get- and set-methods that return a char array (char *) allocate a new array at each call. The caller is responsible to free the allocated space: - * - * char *c = receiver->getFileName(); - * .... - * delete[] c; - * - * always: 1:YES 0:NO for int as bool-like arguments - * - */ - -public: - - /** - * factory method to create instances - */ - static EigerReceiver *create(); - - /** - * Destructor - */ - virtual ~EigerReceiver() {}; - - /** - * Initialize the Receiver - @param detectorHostName detector hostname - * you can call this function only once. You must call it before you call startReceiver() for the first time. - */ - virtual void initialize(const char *detectorHostName) = 0; - - - /* Returns detector hostname - /returns hostname - * caller needs to deallocate the returned char array. - * if uninitialized, it must return NULL - */ - virtual char *getDetectorHostname() const = 0; - - /** - * Returns status of receiver: idle, running or error - */ - virtual slsDetectorDefs::runStatus getStatus() const = 0; - - /** - * Returns File Name - * caller is responsible to deallocate the returned char array. - */ - virtual char *getFileName() const = 0; - - - /** - * Returns File Path - * caller is responsible to deallocate the returned char array - */ - virtual char *getFilePath() const = 0; //FIXME: Does the caller need to free() the returned pointer? - - - /** - * Returns the number of bits per pixel - */ - virtual int getDynamicRange() const = 0; - - /** - * Returns scan tag - */ - virtual int getScanTag() const = 0; - - /* - * Returns number of frames to receive - * This is the number of frames to expect to receiver from the detector. - * The data receiver will change from running to idle when it got this number of frames - */ - virtual int getNumberOfFrames() const = 0; - - /** - * Returns file write enable - * 1: YES 0: NO - */ - virtual int getEnableFileWrite() const = 0; - - /** - * Returns file over write enable - * 1: YES 0: NO - */ - virtual int getEnableOverwrite() const = 0; - - /** - * Set File Name (without frame index, file index and extension) - @param c file name - /returns file name - * returns NULL on failure (like bad file name) - * does not check the existence of the file - we don't know which path we'll finally use, so no point to check. - * caller is responsible to deallocate the returned char array. - */ - virtual char* setFileName(const char c[]) = 0; - - /** - * Set File Path - @param c file path - /returns file path - * checks the existence of the directory. returns NULL if directory does not exist or is not readable. - * caller is responsible to deallocate the returned char array. - */ - virtual char* setFilePath(const char c[]) = 0; - - /** - * Returns the number of bits per pixel - @param dr sets dynamic range - /returns dynamic range - * returns -1 on failure - * FIXME: what are the allowd values - should we use an enum as argument? - */ - virtual int setDynamicRange(const int dr) = 0; - - - /** - * Set scan tag - @param tag scan tag - /returns scan tag (always non-negative) - * FIXME: valid range - only positive? 16bit ore 32bit? - * returns -1 on failure - */ - virtual int setScanTag(const int tag) = 0; - - /** - * Sets number of frames - @param fnum number of frames - /returns number of frames - */ - virtual int setNumberOfFrames(const int fnum) = 0; - - /** - * Set enable file write - * @param i file write enable - /returns file write enable - */ - virtual int setEnableFileWrite(const int i) = 0; - - /** - * Set enable file overwrite - * @param i file overwrite enable - /returns file overwrite enable - */ - virtual int setEnableOverwrite(const int i) = 0; - - /** - * Starts Receiver - activate all configuration settings to the eiger receiver and start to listen for packets - @param message is the error message if there is an error - /returns 0 on success or -1 on failure - */ - //FIXME: success == 0 or success == 1? - virtual int startReceiver(char message[]) = 0; //FIXME: who allocates message[]? - - /** - * Stops Receiver - stops listening for packets - /returns success - * same as abort(). Always returns 0. - */ - virtual int stopReceiver() = 0; - - /** - * abort acquisition with minimum damage: close open files, cleanup. - * does nothing if state already is 'idle' - */ - virtual void abort() = 0; - -protected: - -private: - -}; - -#endif /* #ifndef EIGERRECEIVER_H */ diff --git a/slsDetectorSoftware/slsReceiver/eigerReceiverDummy.cpp b/slsDetectorSoftware/slsReceiver/eigerReceiverDummy.cpp deleted file mode 100644 index f6498ca50..000000000 --- a/slsDetectorSoftware/slsReceiver/eigerReceiverDummy.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * eigerReceiver.cpp - * - * Created on: Mar 11, 2014 - * Author: billich - */ - -#include -#include -#include "eigerReceiver.h" - - -using namespace std; - -struct EigerReceiverInitializationConfiguration { - string detectorHostname; -}; - -struct EigerReceiverScanConfiguration { - - string fileName; - string filePath; - int dynamicRange; - int scanTag; - int numberOfFrames; - bool doFileWrite; - bool doFileOverWrite; - - EigerReceiverScanConfiguration(): - dynamicRange(-1), - scanTag(-1), - numberOfFrames(-1), - doFileWrite(false), - doFileOverWrite(false){}; -}; - -class EigerReceiverImplementation: public EigerReceiver { - -public: - - EigerReceiverImplementation(){}; - - ~EigerReceiverImplementation(){}; - - void initialize(const char *detectorHostname) {} - - char *getDetectorHostname() const { return (char*)"";} - - char *getFileName() const {return (char*)"";} - - char *getFilePath() const {return (char*)"";} - - int getDynamicRange() const { return 0;} - - int getScanTag() const {return 0;} - - int getNumberOfFrames() const {return 0;} - - int getEnableFileWrite() const {return 0;} - - int getEnableOverwrite() const {return 0;} - - slsDetectorDefs::runStatus getStatus() const { return slsDetectorDefs::IDLE;} - - char *setFileName(const char c[]) {return (char*)"";} - - char *setFilePath(const char c[]) {return (char*)"";} - - int setDynamicRange (const int dr) {return 0;} - - int setScanTag (const int tag) {return 0;} - - int setNumberOfFrames (const int fnum) {return 0;} - - int setEnableFileWrite(const int i) {return 0;} - - int setEnableOverwrite(const int i) {return 0;} - - int startReceiver(char message[]) {return 0;} - - int stopReceiver() {return 0;} - - void abort() {} - -private: - EigerReceiverScanConfiguration scan_config; - EigerReceiverInitializationConfiguration init_config; - bool isInitialized; - slsDetectorDefs::runStatus status; - -}; - -EigerReceiver *EigerReceiver::create(void) { - return new EigerReceiverImplementation(); -} - - - - diff --git a/slsDetectorSoftware/slsReceiver/eigerReceiverTest.cpp b/slsDetectorSoftware/slsReceiver/eigerReceiverTest.cpp deleted file mode 100644 index bdfcba7a1..000000000 --- a/slsDetectorSoftware/slsReceiver/eigerReceiverTest.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * eigerReceiverTest.cpp - - * - * Created on: Mar 11, 2014 - * Author: billich - */ - -#include -#include -#include "eigerReceiver.h" - -using namespace std; - -int main(int argc, char *argv[]){ - - const char *name = "detectors_host_name"; - const char *empty = ""; - std::string prefix = "main: "; - cout <getStatus(); - char *c0 = receiver->getDetectorHostname(); - if (c0 == NULL) { - cout <initialize(empty); - status = receiver->getStatus(); - receiver->initialize(name); - status = receiver->getStatus(); - receiver->initialize(name); - status = receiver->getStatus(); - receiver->initialize((char *)NULL); - - cout << endl; - - status = receiver->getStatus(); - char *c6 = receiver->getDetectorHostname(); - cout <getFileName(); - cout <." << endl; - delete[] c1; - - char *c2 = receiver->getFilePath(); - cout <." << endl; - delete[]c2; - - int range = receiver->getDynamicRange(); - cout <getScanTag(); - cout <setFileName( "some_other_name"); - cout < after setting to " << endl << endl; - delete[] c3; - - char *c4 = receiver->setFilePath( "some_other_path"); - cout < after setting to " << endl << endl; - delete[] c4; - - range = receiver->setDynamicRange(8); - cout <setScanTag(99); - cout << "got scan tag " << tag << " after setting to 99." << endl << endl; - - int n = receiver->setNumberOfFrames(11); - cout << "got number of frames " << n << " after setting to 11." << endl << endl; - - int w = receiver->setEnableFileWrite(1); - cout << "got enable file write " << w << " after setting to 1." << endl << endl; - - char *c5; - status = receiver->getStatus(); - receiver->startReceiver(c5); - status = receiver->getStatus(); - receiver->stopReceiver(); - status = receiver->getStatus(); - receiver->abort(); - status = receiver->getStatus(); - -} - - - - diff --git a/slsDetectorSoftware/slsReceiver/receiver.config b/slsDetectorSoftware/slsReceiver/receiver.config deleted file mode 100644 index fa4586e14..000000000 --- a/slsDetectorSoftware/slsReceiver/receiver.config +++ /dev/null @@ -1 +0,0 @@ -dataport 1955 diff --git a/slsDetectorSoftware/slsReceiver/receiver_defs.h b/slsDetectorSoftware/slsReceiver/receiver_defs.h deleted file mode 100755 index f8a0ec136..000000000 --- a/slsDetectorSoftware/slsReceiver/receiver_defs.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef RECEIVER_DEFS_H -#define RECEIVER_DEFS_H - -#include "sls_detector_defs.h" - -#include - -#define GOODBYE -200 - -#define DO_NOTHING 0 -#define CREATE_FILES 1 -#define DO_EVERYTHING 2 - -#define BUF_SIZE (16*1024*1024) //16mb -#define SAMPLE_TIME_IN_NS 100000000//100ms -#define MAX_JOBS_PER_THREAD 1000 -#define HEADER_SIZE_NUM_TOT_PACKETS 2 -#define HEADER_SIZE_NUM_FRAMES 2 -#define HEADER_SIZE_NUM_PACKETS 1 - - -//all max frames defined in sls_detector_defs.h. 20000 gotthard, 100000 for short gotthard, 1000 for moench - - -#define GOTTHARD_FIFO_SIZE 25000 //cannot be less than max jobs per thread = 1000 -/*#define GOTTHARD_ALIGNED_FRAME_SIZE 4096*/ -#define GOTTHARD_PACKETS_PER_FRAME 2 -#define GOTTHARD_ONE_PACKET_SIZE 1286 -#define GOTTHARD_BUFFER_SIZE (GOTTHARD_ONE_PACKET_SIZE*GOTTHARD_PACKETS_PER_FRAME) //1286*2 -#define GOTTHARD_DATA_BYTES (1280*GOTTHARD_PACKETS_PER_FRAME) //1280*2 - -#define GOTTHARD_SHORT_PACKETS_PER_FRAME 1 -#define GOTTHARD_SHORT_BUFFER_SIZE 518 -#define GOTTHARD_SHORT_DATABYTES 512 -#define GOTTHARD_SHORT_FRAME_INDEX_MASK 0xFFFFFFFF -#define GOTTHARD_SHORT_FRAME_INDEX_OFFSET 0 -#define GOTTHARD_SHORT_PACKET_INDEX_MASK 0 -#define GOTTHARD_SHORT_PIXELS_IN_ROW 256 -#define GOTTHARD_SHORT_PIXELS_IN_COL 1 - - -#define GOTTHARD_FRAME_INDEX_MASK 0xFFFFFFFE -#define GOTTHARD_FRAME_INDEX_OFFSET 1 -#define GOTTHARD_PACKET_INDEX_MASK 0x1 - -#define GOTTHARD_PIXELS_IN_ROW 1280 -#define GOTTHARD_PIXELS_IN_COL 1 - - - -#define MOENCH_FIFO_SIZE 2500 //cannot be less than max jobs per thread = 1000 -/*#define MOENCH_ALIGNED_FRAME_SIZE 65536*/ -#define MOENCH_PACKETS_PER_FRAME 40 -#define MOENCH_ONE_PACKET_SIZE 1286 -#define MOENCH_BUFFER_SIZE (MOENCH_ONE_PACKET_SIZE*MOENCH_PACKETS_PER_FRAME) //1286*40 -#define MOENCH_DATA_BYTES (1280*MOENCH_PACKETS_PER_FRAME) //1280*40 - -#define MOENCH_BYTES_PER_ADC (40*2) -#define MOENCH_PIXELS_IN_ONE_ROW 160 -#define MOENCH_BYTES_IN_ONE_ROW (MOENCH_PIXELS_IN_ONE_ROW*2) - - -#define MOENCH_FRAME_INDEX_MASK 0xFFFFFF00 -#define MOENCH_FRAME_INDEX_OFFSET 8 -#define MOENCH_PACKET_INDEX_MASK 0xFF - - - - - -//#define THIS_SOFTWARE_VERSION 0x20120919 -#endif diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver.cpp deleted file mode 100644 index 909baabc8..000000000 --- a/slsDetectorSoftware/slsReceiver/slsReceiver.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ - -#include "sls_detector_defs.h" -#include "slsReceiverUsers.h" - -#include -using namespace std; - - - - - - -int main(int argc, char *argv[]) { - int ret = slsDetectorDefs::OK; - - slsReceiverUsers *user = new slsReceiverUsers(argc, argv, ret); - - if(ret==slsDetectorDefs::FAIL) - return -1; - - - //register callbacks - - - /** - callback arguments are - filepath - filename - fileindex - datasize - - return value is - 0 raw data ready callback takes care of open,close,write file - 1 callback writes file, we have to open, close it - 2 we open, close, write file, callback does not do anything - - - registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg); - */ - - //receiver->registerCallBackStartAcquisition(func,arg); - - - /** - callback argument is - total farmes caught - registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg); - */ - - - //receiver->registerCallBackAcquisitionFinished(func,arg); - - - - /** - args to raw data ready callback are - framenum - datapointer - file descriptor - guidatapointer (NULL, no data required) - - NEVER DELETE THE DATA POINTER - REMEMBER THAT THE CALLBACK IS BLOCKING - - registerCallBackRawDataReady(void (*func)(int, char*, FILE*, char*, void*),void *arg); - - */ - - //receiver->registerCallBackRawDataReady(func,arg); - - - - - user->start(); - - - return 0; -} - diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp deleted file mode 100644 index 7b96c0498..000000000 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp +++ /dev/null @@ -1,1958 +0,0 @@ -#ifdef SLS_RECEIVER_FUNCTION_LIST -/********************************************//** - * @file slsReceiverFunctionList.cpp - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ - - -#include "slsReceiverFunctionList.h" - -#include "moench02ModuleData.h" -#include "gotthardModuleData.h" -#include "gotthardShortModuleData.h" - - -#include // SIGINT -#include // stat -#include // socket(), bind(), listen(), accept(), shut down -#include // sock_addr_in, htonl, INADDR_ANY -#include // exit() -#include //set precision -#include //munmap - - - -#include -#include -using namespace std; - - - - -slsReceiverFunctionList::slsReceiverFunctionList(): - receiver(NULL), - server_port(DEFAULT_UDP_PORTNO), - thread_started(0), - udpSocket(NULL), - eth(NULL), - latestData(NULL), - guiFileName(NULL), - mem0(NULL), - fifo(NULL), - fifoFree(NULL){ - - for(int i=0;i /proc/sys/net/core/rmem_max")) - cout << "\nWARNING: Could not change socket receiver buffer size in file /proc/sys/net/core/rmem_max" << endl; - else if(system("echo 250000 > /proc/sys/net/core/netdev_max_backlog")) - cout << "\nWARNING: Could not change max length of input queue in file /proc/sys/net/core/netdev_max_backlog" << endl; - /** permanent setting heiner - net.core.rmem_max = 104857600 # 100MiB - net.core.netdev_max_backlog = 250000 - sysctl -p - // from the manual - sysctl -w net.core.rmem_max=16777216 - sysctl -w net.core.netdev_max_backlog=250000 - */ -} - - - -slsReceiverFunctionList::~slsReceiverFunctionList(){ - createListeningThreads(true); - createWriterThreads(true); - deleteMembers(); -} - - - - -void slsReceiverFunctionList::deleteMembers(){ - //kill threads - if(thread_started){ - createListeningThreads(true); - createWriterThreads(true); - } - - for(int i=0;isetFileName(fileName); - } - - onePacketSize = bufferSize/packetsPerFrame; - latestData = new char[bufferSize]; - - - setupFifoStructure(); - - if(createListeningThreads() == FAIL){ - cout << "ERROR: Could not create listening thread" << endl; - exit (-1); - } - - if(createWriterThreads() == FAIL){ - cout << "ERROR: Could not create writer threads" << endl; - exit (-1); - } - - setThreadPriorities(); - - return OK; -} - - - - - -/*Frame indices and numbers caught*/ - -bool slsReceiverFunctionList::getAcquistionStarted(){return acqStarted;}; - -bool slsReceiverFunctionList::getMeasurementStarted(){return measurementStarted;}; - -int slsReceiverFunctionList::getFramesCaught(){return (packetsCaught/packetsPerFrame);} - -int slsReceiverFunctionList::getTotalFramesCaught(){return (totalPacketsCaught/packetsPerFrame);} - -uint32_t slsReceiverFunctionList::getStartFrameIndex(){return startFrameIndex;} - -uint32_t slsReceiverFunctionList::getFrameIndex(){ - if(!packetsCaught) - frameIndex=0; - else - frameIndex = currframenum - startFrameIndex; - return frameIndex; -} - -uint32_t slsReceiverFunctionList::getAcquisitionIndex(){ - if(!totalPacketsCaught) - acquisitionIndex=0; - else - acquisitionIndex = currframenum - startAcquisitionIndex; - return acquisitionIndex; -} - - -void slsReceiverFunctionList::resetTotalFramesCaught(){ - acqStarted = false; - startAcquisitionIndex = 0; - totalPacketsCaught = 0; -} - - - - - - - - - -/*file parameters*/ - -char* slsReceiverFunctionList::getFilePath(){ - if(myDetectorType == EIGER) - return receiver->getFilePath(); - else - return filePath; -} - -char* slsReceiverFunctionList::setFilePath(char c[]){ - if(strlen(c)){ - //check if filepath exists - struct stat st; - if(stat(c,&st) == 0){ - if(myDetectorType == EIGER) - receiver->setFilePath(c); - else - strcpy(filePath,c); - }else{ - strcpy(filePath,""); - cout << "FilePath does not exist:" << filePath << endl; - } - } - return getFilePath(); -} - - -char* slsReceiverFunctionList::getFileName(){ - if(myDetectorType == EIGER) - return receiver->getFileName(); - else - return fileName; -} - -char* slsReceiverFunctionList::setFileName(char c[]){ - if(strlen(c)){ - if(myDetectorType == EIGER) - receiver->setFileName(c); - else - strcpy(fileName,c); - - } - return getFileName(); - -} - - -int slsReceiverFunctionList::getFileIndex(){ - return fileIndex; -} - -int slsReceiverFunctionList::setFileIndex(int i){ - if(i>=0) - fileIndex = i; - return getFileIndex(); -} - - -int slsReceiverFunctionList::setFrameIndexNeeded(int i){ - frameIndexNeeded = i; - return frameIndexNeeded; -} - - -int slsReceiverFunctionList::setEnableFileWrite(int i){ - if(i!=-1){ - if(myDetectorType == EIGER) - receiver->setEnableFileWrite(i); - else - enableFileWrite=i; - - } - if(myDetectorType == EIGER) - return receiver->getEnableFileWrite(); - else - return enableFileWrite; - -} - - - -int slsReceiverFunctionList::enableOverwrite(int i){ - if(i!=-1){ - if(myDetectorType == EIGER) - receiver->setEnableOverwrite(i); - else - overwrite=i; - - } - if(myDetectorType == EIGER) - return receiver->getEnableOverwrite(); - else - return overwrite; - -} - - - - -/*other parameters*/ - -slsDetectorDefs::runStatus slsReceiverFunctionList::getStatus(){ - if(myDetectorType == EIGER) - return receiver->getStatus(); - else - return status; -} - - -char* slsReceiverFunctionList::setDetectorHostname(char c[]){ - if(strlen(c)){ - if(myDetectorType == EIGER){ - if(receiver->getDetectorHostname()== NULL) - receiver->initialize(c); - }else - strcpy(detHostname,c); - } - - if(myDetectorType == EIGER) - return receiver->getDetectorHostname(); - else - return detHostname; -} - - -void slsReceiverFunctionList::setEthernetInterface(char* c){ - strcpy(eth,c); -} - - -void slsReceiverFunctionList::setUDPPortNo(int p){ - server_port = p; -} - - -int32_t slsReceiverFunctionList::setNumberOfFrames(int32_t fnum){ - if(fnum >= 0){ - if(myDetectorType == EIGER) - receiver->setNumberOfFrames(fnum); - else - numberOfFrames = fnum; - } - - if(myDetectorType == EIGER) - return receiver->getNumberOfFrames(); - else - return numberOfFrames; -} - -int32_t slsReceiverFunctionList::setScanTag(int32_t stag){ - if(stag >= 0){ - if(myDetectorType == EIGER) - receiver->setScanTag(stag); - else - scanTag = stag; - } - - if(myDetectorType == EIGER) - return receiver->getScanTag(); - else - return scanTag; -} - -int32_t slsReceiverFunctionList::setDynamicRange(int32_t dr){ - if(dr >= 0){ - if(myDetectorType == EIGER) - receiver->setDynamicRange(dr); - else - dynamicRange = dr; - } - - if(myDetectorType == EIGER) - return receiver->getDynamicRange(); - else - return dynamicRange; -} - - - -int slsReceiverFunctionList::setShortFrame(int i){ - shortFrame=i; - - if(shortFrame!=-1){ - bufferSize = GOTTHARD_SHORT_BUFFER_SIZE; - maxPacketsPerFile = SHORT_MAX_FRAMES_PER_FILE * GOTTHARD_SHORT_PACKETS_PER_FRAME; - packetsPerFrame = GOTTHARD_SHORT_PACKETS_PER_FRAME; - frameIndexMask = GOTTHARD_SHORT_FRAME_INDEX_MASK; - frameIndexOffset = GOTTHARD_SHORT_FRAME_INDEX_OFFSET; - - }else{ - bufferSize = GOTTHARD_BUFFER_SIZE; - maxPacketsPerFile = MAX_FRAMES_PER_FILE * GOTTHARD_PACKETS_PER_FRAME; - packetsPerFrame = GOTTHARD_PACKETS_PER_FRAME; - frameIndexMask = GOTTHARD_FRAME_INDEX_MASK; - frameIndexOffset = GOTTHARD_FRAME_INDEX_OFFSET; - } - - onePacketSize = bufferSize/packetsPerFrame; - - deleteFilter(); - if(dataCompression) - setupFilter(); - - return shortFrame; -} - - -int slsReceiverFunctionList::setNFrameToGui(int i){ - if(i>=0){ - nFrameToGui = i; - setupFifoStructure(); - } - return nFrameToGui; -} - - - -int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){ - - if(index >= 0){ - if(index != acquisitionPeriod){ - acquisitionPeriod = index; - if(myDetectorType != EIGER) - setupFifoStructure(); - } - } - return acquisitionPeriod; -} - - -bool slsReceiverFunctionList::getDataCompression(){return dataCompression;} - -int slsReceiverFunctionList::enableDataCompression(bool enable){ - cout << "Data compression "; - if(enable) - cout << "enabled" << endl; - else - cout << "disabled" << endl; -#ifdef MYROOT1 - cout << " WITH ROOT" << endl; -#else - cout << " WITHOUT ROOT" << endl; -#endif - //delete filter for the current number of threads - deleteFilter(); - - dataCompression = enable; - pthread_mutex_lock(&status_mutex); - writerthreads_mask = 0x0; - pthread_mutex_unlock(&(status_mutex)); - - createWriterThreads(true); - - if(enable) - numWriterThreads = MAX_NUM_WRITER_THREADS; - else - numWriterThreads = 1; - - if(createWriterThreads() == FAIL){ - cout << "ERROR: Could not create writer threads" << endl; - return FAIL; - } - setThreadPriorities(); - - - if(enable) - setupFilter(); - - return OK; -} - - - - - - - - - - - - -/*other functions*/ - - -void slsReceiverFunctionList::deleteFilter(){ - int i; - cmSub=NULL; - - for(i=0;i(receiverdata[i], csize, sigma, sign, cmSub); - -} - - - - -void slsReceiverFunctionList::setupFifoStructure(){ - int64_t i; - int oldn = numJobsPerThread; - - //if every nth frame mode - if(nFrameToGui) - numJobsPerThread = nFrameToGui; - - //random nth frame mode - else{ - if(!acquisitionPeriod) - i = SAMPLE_TIME_IN_NS; - else - i = SAMPLE_TIME_IN_NS/acquisitionPeriod; - if (i > MAX_JOBS_PER_THREAD) - numJobsPerThread = MAX_JOBS_PER_THREAD; - else if (i < 1) - numJobsPerThread = 1; - else - numJobsPerThread = i; - } - - //if same, return - if(oldn == numJobsPerThread) - return; - - - //otherwise memory too much if numjobsperthread is at max = 1000 - fifosize = GOTTHARD_FIFO_SIZE; - if(myDetectorType == MOENCH) - fifosize = MOENCH_FIFO_SIZE; - - if(fifosize % numJobsPerThread) - fifosize = (fifosize/numJobsPerThread)+1; - else - fifosize = fifosize/numJobsPerThread; - - - cout << "Number of Frames per buffer:" << numJobsPerThread << endl; - cout << "Fifo Size:" << fifosize << endl; - - /* - //for testing - numJobsPerThread = 3; fifosize = 11; - */ - - //deleting old structure and creating fifo structure - if(fifoFree){ - while(!fifoFree->isEmpty()) - fifoFree->pop(buffer); - delete fifoFree; - } - if(fifo) delete fifo; - if(mem0) free(mem0); - fifoFree = new CircularFifo(fifosize); - fifo = new CircularFifo(fifosize); - - - //allocate memory - mem0=(char*)malloc((bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*fifosize); - /** shud let the client know about this */ - if (mem0==NULL){ - cout<<"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY FOR LISTENING !!!!!!!+++++++++++++++++++++" << endl; - exit(-1); - } - buffer=mem0; - //push the addresses into freed fifoFree and writingFifoFree - while (buffer<(mem0+(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*(fifosize-1))) { - fifoFree->push(buffer); - buffer+=(bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS); - } - - cout << "Fifo structure reconstructed" << endl; -} - - - - - - - -/** acquisition functions */ - -void slsReceiverFunctionList::readFrame(char* c,char** raw){ - //point to gui data - if (guiData == NULL) - guiData = latestData; - - //copy data and filename - strcpy(c,guiFileName); - - //could not get gui data - if(!guiDataReady){ - *raw = NULL; - } - //data ready, set guidata to receive new data - else{ - *raw = guiData; - guiData = NULL; - - pthread_mutex_lock(&dataReadyMutex); - guiDataReady = 0; - pthread_mutex_unlock(&dataReadyMutex); - if((nFrameToGui) && (writerthreads_mask)){ - //release after getting data - sem_post(&smp); - } - } -} - - - - - -void slsReceiverFunctionList::copyFrameToGui(char* startbuf){ - - //random read when gui not ready - if((!nFrameToGui) && (!guiData)){ - pthread_mutex_lock(&dataReadyMutex); - guiDataReady=0; - pthread_mutex_unlock(&dataReadyMutex); - } - - //random read or nth frame read, gui needs data now - else{ - //nth frame read, block current process if the guireader hasnt read it yet - if(nFrameToGui) - sem_wait(&smp); - - pthread_mutex_lock(&dataReadyMutex); - guiDataReady=0; - //send the first one - memcpy(latestData,startbuf,bufferSize); - strcpy(guiFileName,savefilename); - guiDataReady=1; - pthread_mutex_unlock(&dataReadyMutex); - } -} - - - - - -int slsReceiverFunctionList::createUDPSocket(){ - if(udpSocket) - udpSocket->ShutDownSocket(); - - //if eth is mistaken with ip address - if (strchr(eth,'.')!=NULL) - strcpy(eth,""); - - if(udpSocket){delete udpSocket; udpSocket = NULL;} - - //if no eth, listen to all - if(!strlen(eth)){ - cout<<"warning:eth is empty.listening to all"<getErrorStatus(); - if (iret){ -//#ifdef VERBOSE - cout << "Could not create UDP socket on port " << server_port << " error:" << iret << endl; -//#endif - - return FAIL; - } - return OK; -} - - - - -int slsReceiverFunctionList::createListeningThreads(bool destroy){ - void* status; - - killListeningThread = 0; - - pthread_mutex_lock(&status_mutex); - listening_thread_running = 0; - pthread_mutex_unlock(&(status_mutex)); - - if(!destroy){ - //listening thread - cout << "Creating Listening Thread" << endl; - sem_init(&listensmp,1,0); - if(pthread_create(&listening_thread, NULL,startListeningThread, (void*) this)){ - cout << "Could not create listening thread" << endl; - return FAIL; - } -#ifdef VERBOSE - cout << "Listening thread created successfully." << endl; -#endif - }else{ - cout<<"Destroying Listening Thread"<initEventTree(temp, &iframe); - //resets the pedestalSubtraction array and the commonModeSubtraction - singlePhotonDet[ithr]->newDataSet(); - if(myFile[ithr]==NULL){ - cout<<"file null"<IsOpen()){ - cout<<"file not open"< DO_NOTHING){ - //close - if(sfilefd){ - fclose(sfilefd); - sfilefd = NULL; - } - //open file - if(!overwrite){ - if (NULL == (sfilefd = fopen((const char *) (savefilename), "wx"))){ - cout << "Error: Could not create new file " << savefilename << endl; - return FAIL; - } - }else if (NULL == (sfilefd = fopen((const char *) (savefilename), "w"))){ - cout << "Error: Could not create file " << savefilename << endl; - return FAIL; - } - //setting buffer - setvbuf(sfilefd,NULL,_IOFBF,BUF_SIZE); - - //printing packet losses and file names - if(!packetsCaught) - cout << savefilename << endl; - else{ - cout << savefilename - << "\tpacket loss " - << setw(4)<GetCurrentFile(); - - if(myFile[ithr]->Write()) - //->Write(tall->GetName(),TObject::kOverwrite); - cout << "Thread " << ithr <<": wrote frames to file" << endl; - else - cout << "Thread " << ithr << ": could not write frames to file" << endl; - - }else - cout << "Thread " << ithr << ": could not write frames to file: No file or No Tree" << endl; - //close file - if(myTree[ithr] && myFile[ithr]) - myFile[ithr] = myTree[ithr]->GetCurrentFile(); - if(myFile[ithr] != NULL) - myFile[ithr]->Close(); - myFile[ithr] = NULL; - myTree[ithr] = NULL; - pthread_mutex_unlock(&write_mutex); - -#endif - } -} - - - - - -int slsReceiverFunctionList::startReceiver(char message[]){ - - if(myDetectorType == EIGER) - return receiver->startReceiver(message); - - -//#ifdef VERBOSE - cout << "Starting Receiver" << endl; -//#endif - - - //reset listening thread variables - measurementStarted = false; - startFrameIndex = 0; - totalListeningFrameCount = 0; - - //udp socket - if(createUDPSocket() == FAIL){ - strcpy(message,"Could not create UDP Socket.\n"); - cout << endl << message << endl; - return FAIL; - } - cout << "UDP socket created successfully on port " << server_port << endl; - - - if(setupWriter() == FAIL){ - //stop udp socket - if(udpSocket) - udpSocket->ShutDownSocket(); - - sprintf(message,"Could not create file %s.\n",savefilename); - return FAIL; - } - cout << "Successfully created file(s)" << endl; - - //done to give the gui some proper name instead of always the last file name - if(dataCompression) - sprintf(savefilename, "%s/%s_fxxx_%d_xx.root", filePath,fileName,fileIndex); - - //initialize semaphore - sem_init(&smp,1,0); - - //status - pthread_mutex_lock(&status_mutex); - status = RUNNING; - for(int i=0;istopReceiver(); - - -//#ifdef VERBOSE - cout << "Stopping Receiver" << endl; -//#endif - - if(status == RUNNING) - startReadout(); - - while(status == TRANSMITTING) - usleep(5000); - - //semaphore destroy - sem_post(&smp); - sem_destroy(&smp); - - //change status - pthread_mutex_lock(&status_mutex); - status = IDLE; - pthread_mutex_unlock(&(status_mutex)); - - cout << "Receiver Stopped.\nStatus:" << status << endl; - return OK; -} - - - - - -void slsReceiverFunctionList::startReadout(){ - - if(myDetectorType == EIGER){ - receiver->stopReceiver(); - return; - } - - - //wait so that all packets which take time has arrived - usleep(50000); - - pthread_mutex_lock(&status_mutex); - status = TRANSMITTING; - pthread_mutex_unlock(&status_mutex); - cout << "Status: Transmitting" << endl; - - //kill udp socket to tell the listening thread to push last packet - if(udpSocket) - udpSocket->ShutDownSocket(); - -} - - - -void* slsReceiverFunctionList::startListeningThread(void* this_pointer){ - ((slsReceiverFunctionList*)this_pointer)->startListening(); - - return this_pointer; -} - - - -void* slsReceiverFunctionList::startWritingThread(void* this_pointer){ - ((slsReceiverFunctionList*)this_pointer)->startWriting(); - return this_pointer; -} - - - - - - -int slsReceiverFunctionList::startListening(){ -#ifdef VERYVERBOSE - cout << "In startListening()" << endl; -#endif - - int lastpacketoffset, expected, rc, packetcount, maxBufferSize, carryonBufferSize; - uint32_t lastframeheader;// for moench to check for all the packets in last frame - char* tempchar = NULL; - - - while(1){ - //variables that need to be checked/set before each acquisition - carryonBufferSize = 0; - maxBufferSize = packetsPerFrame * numJobsPerThread * onePacketSize; - if(tempchar) {delete [] tempchar;tempchar = NULL;} - tempchar = new char[onePacketSize * (packetsPerFrame - 1)]; //gotthard: 1packet size, moench:39 packet size - - - while(listening_thread_running){ - - //pop - fifoFree->pop(buffer); -#ifdef VERYDEBUG - cout << "*** popped from fifo free" << (void*)buffer << endl; -#endif - - //receive - if(!carryonBufferSize){ - rc = udpSocket->ReceiveDataOnly(buffer + HEADER_SIZE_NUM_TOT_PACKETS, maxBufferSize); - expected = maxBufferSize; - }else{ -#ifdef VERYDEBUG - cout << "***carry on buffer" << carryonBufferSize << endl; - cout<<"framennum in temochar:"<<((((uint32_t)(*((uint32_t*)tempchar))) - & (frameIndexMask)) >> frameIndexOffset)<ReceiveDataOnly((buffer + HEADER_SIZE_NUM_TOT_PACKETS + carryonBufferSize),maxBufferSize - carryonBufferSize); - expected = maxBufferSize - carryonBufferSize; - } - -#ifdef VERYDEBUG - cout << "*** rc:" << dec << rc << endl; - cout << "*** expected:" << dec << expected << endl; -#endif - //start indices - //start of scan - if((!measurementStarted) && (rc > 0)){ - //gotthard has +1 for frame number - if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) - startFrameIndex = (((((uint32_t)(*((uint32_t*)(buffer + HEADER_SIZE_NUM_TOT_PACKETS))))+1) - & (frameIndexMask)) >> frameIndexOffset); - else - startFrameIndex = ((((uint32_t)(*((uint32_t*)(buffer+HEADER_SIZE_NUM_TOT_PACKETS)))) - & (frameIndexMask)) >> frameIndexOffset); - cout<<"startFrameIndex:"<push(buffer); - exit(-1); - continue; - } - //push the last buffer into fifo - if(rc > 0){ - packetcount = (rc/onePacketSize); -#ifdef VERYDEBUG - cout << "*** last packetcount:" << packetcount << endl; -#endif - (*((uint16_t*)(buffer))) = packetcount; - totalListeningFrameCount += packetcount; - while(!fifo->push(buffer)); -#ifdef VERYDEBUG - cout << "*** last lbuf1:" << (void*)buffer << endl; -#endif - } - - - //push dummy buffer - for(int i=0;ipop(buffer); - (*((uint16_t*)(buffer))) = 0xFFFF; - while(!fifo->push(buffer)); -#ifdef VERYDEBUG - cout << "pushed in dummy buffer:" << (void*)buffer << endl; -#endif - } - cout << "Total count listened to " << totalListeningFrameCount/packetsPerFrame << endl; - pthread_mutex_lock(&status_mutex); - listening_thread_running = 0; - pthread_mutex_unlock(&(status_mutex)); - break; - } - - - //reset - packetcount = packetsPerFrame * numJobsPerThread; - carryonBufferSize = 0; - - - //check if last packet valid and calculate packet count - switch(myDetectorType){ - - - - case MOENCH: - lastpacketoffset = (((numJobsPerThread * packetsPerFrame - 1) * onePacketSize) + HEADER_SIZE_NUM_TOT_PACKETS); -#ifdef VERYDEBUG - cout <<"first packet:"<< ((((uint32_t)(*((uint32_t*)(buffer+HEADER_SIZE_NUM_TOT_PACKETS))))) & (packetIndexMask)) << endl; - cout <<"first header:"<< (((((uint32_t)(*((uint32_t*)(buffer+HEADER_SIZE_NUM_TOT_PACKETS))))) & (frameIndexMask)) >> frameIndexOffset) << endl; - cout << "last packet offset:" << lastpacketoffset << endl; - cout <<"last packet:"<< ((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))) & (packetIndexMask)) << endl; - cout <<"last header:"<< (((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))) & (frameIndexMask)) >> frameIndexOffset) << endl; -#endif - //moench last packet value is 0 - if( ((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))) & (packetIndexMask))){ - lastframeheader = ((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))) & (frameIndexMask)) >> frameIndexOffset; - carryonBufferSize += onePacketSize; - lastpacketoffset -= onePacketSize; - --packetcount; - while (lastframeheader == (((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))) & (frameIndexMask)) >> frameIndexOffset)){ - carryonBufferSize += onePacketSize; - lastpacketoffset -= onePacketSize; - --packetcount; - } - memcpy(tempchar, buffer+(lastpacketoffset+onePacketSize), carryonBufferSize); -#ifdef VERYDEBUG - cout << "tempchar header:" << (((((uint32_t)(*((uint32_t*)(tempchar))))) - & (frameIndexMask)) >> frameIndexOffset) << endl; - cout <<"tempchar packet:"<< ((((uint32_t)(*((uint32_t*)(tempchar))))) - & (packetIndexMask)) << endl; -#endif - } - break; - - - - default: - if(shortFrame == -1){ - lastpacketoffset = (((numJobsPerThread * packetsPerFrame - 1) * onePacketSize) + HEADER_SIZE_NUM_TOT_PACKETS); -#ifdef VERYDEBUG - cout << "last packet offset:" << lastpacketoffset << endl; -#endif - - if((unsigned int)(packetsPerFrame -1) != ((((uint32_t)(*((uint32_t*)(buffer+lastpacketoffset))))+1) & (packetIndexMask))){ - memcpy(tempchar,buffer+lastpacketoffset, onePacketSize); -#ifdef VERYDEBUG - cout << "tempchar header:" << (((((uint32_t)(*((uint32_t*)(tempchar))))+1) - & (frameIndexMask)) >> frameIndexOffset) << endl; -#endif - carryonBufferSize = onePacketSize; - --packetcount; - } - } -#ifdef VERYDEBUG - cout << "header:" << (((((uint32_t)(*((uint32_t*)(buffer + HEADER_SIZE_NUM_TOT_PACKETS))))+1) - & (frameIndexMask)) >> frameIndexOffset) << endl; -#endif - break; - - - - - } -#ifdef VERYDEBUG - cout << "*** packetcount:" << packetcount << " carryonbuffer:" << carryonBufferSize << endl; -#endif - //write packet count and push - (*((uint16_t*)(buffer))) = packetcount; - totalListeningFrameCount += packetcount; - while(!fifo->push(buffer)); -#ifdef VERYDEBUG - cout << "*** pushed into listening fifo" << endl; -#endif - } - - sem_wait(&listensmp); - - //make sure its not exiting thread - if(killListeningThread) - pthread_exit(NULL); - } - - return OK; -} - - - - - - - - - - - - - - - -int slsReceiverFunctionList::startWriting(){ - int ithread = currentWriterThreadIndex; -#ifdef VERYVERBOSE - cout << ithread << "In startWriting()" <pop(wbuf); - numpackets = (uint16_t)(*((uint16_t*)wbuf)); -#ifdef VERYDEBUG - cout << ithread << " numpackets:" << dec << numpackets << endl; - cout << ithread << " *** popped from fifo " << numpackets << endl; -#endif - - - - - - - //last dummy packet - if(numpackets == 0xFFFF){ -#ifdef VERYDEBUG - cout << ithread << " **********************popped last dummy frame:" << (void*)wbuf << endl; -#endif - - //free fifo - while(!fifoFree->push(wbuf)); -#ifdef VERYDEBUG - cout << ithread << " fifo freed:" << (void*)wbuf << endl; -#endif - - - - //all threads need to close file, reset mask and exit loop - closeFile(ithread); - pthread_mutex_lock(&status_mutex); - writerthreads_mask^=(1<> frameIndexOffset); - else - tempframenum = ((((uint32_t)(*((uint32_t*)(wbuf + HEADER_SIZE_NUM_TOT_PACKETS))))& (frameIndexMask)) >> frameIndexOffset); - - if(numWriterThreads == 1) - currframenum = tempframenum; - else{ - pthread_mutex_lock(&progress_mutex); - if(tempframenum > currframenum) - currframenum = tempframenum; - pthread_mutex_unlock(&progress_mutex); - } -#ifdef VERYDEBUG - cout << ithread << " tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl; -#endif - - - - - - //without datacompression: write datacall back, or write data, free fifo - if(!dataCompression){ - if (cbAction < DO_EVERYTHING) - rawDataReadyCallBack(currframenum, wbuf, numpackets * onePacketSize, sfilefd, guiData,pRawDataReady); - else if (numpackets > 0){ - writeToFile_withoutCompression(wbuf, numpackets); - } - //copy to gui - copyFrameToGui(wbuf + HEADER_SIZE_NUM_TOT_PACKETS); - - while(!fifoFree->push(wbuf)); -#ifdef VERYVERBOSE - cout<<"buf freed:"<<(void*)wbuf<findNextFrame(data,ndata,remainingsize)){ - np = ndata/onePacketSize; - - //cout<<"buff framnum:"<> frameIndexOffset)<newFrame(); - - //only for moench - if(commonModeSubtractionEnable){ - for(ix = xmin - 1; ix < xmax+1; ix++){ - for(iy = ymin - 1; iy < ymax+1; iy++){ - thisEvent = singlePhotonDet[ithread]->getEventType(buff, ix, iy, 0); - } - } - } - - - for(ix = xmin - 1; ix < xmax+1; ix++) - for(iy = ymin - 1; iy < ymax+1; iy++){ - thisEvent=singlePhotonDet[ithread]->getEventType(buff, ix, iy, commonModeSubtractionEnable); - if (nf>1000) { - tot=0; - tl=0; - tr=0; - bl=0; - br=0; - if (thisEvent==PHOTON_MAX) { - - iFrame=receiverdata[ithread]->getFrameNumber(buff); -#ifdef MYROOT1 - myTree[ithread]->Fill(); - //cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl; -#else - pthread_mutex_lock(&write_mutex); - if((enableFileWrite) && (sfilefd)) - singlePhotonDet[ithread]->writeCluster(sfilefd); - pthread_mutex_unlock(&write_mutex); -#endif - } - } - } - - nf++; -#ifndef ALLFILE - pthread_mutex_lock(&progress_mutex); - packetsInFile += packetsPerFrame; - packetsCaught += packetsPerFrame; - totalPacketsCaught += packetsPerFrame; - if(packetsInFile >= maxPacketsPerFile) - createNewFile(); - pthread_mutex_unlock(&progress_mutex); - -#endif - if(!once){ - copyFrameToGui(buff); - once = 1; - } - } - - remainingsize -= ((buff + ndata) - data); - data = buff + ndata; - if(data > (wbuf + HEADER_SIZE_NUM_TOT_PACKETS + numpackets * onePacketSize) ) - cout <<" **************ERROR SHOULD NOT COME HERE, Error 142536!"<push(wbuf)); -#ifdef VERYVERBOSE - cout<<"buf freed:"<<(void*)wbuf< 0){ - - //for progress and packet loss calculation(new files) - if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) - tempframenum = (((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset); - else - tempframenum = ((((uint32_t)(*((uint32_t*)(buf + HEADER_SIZE_NUM_TOT_PACKETS))))& (frameIndexMask)) >> frameIndexOffset); - - if(numWriterThreads == 1) - currframenum = tempframenum; - else{ - if(tempframenum > currframenum) - currframenum = tempframenum; - } -#ifdef VERYDEBUG - cout << "tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl; -#endif - - //lock - if(numWriterThreads > 1) - pthread_mutex_lock(&write_mutex); - - - //to create new file when max reached - packetsToSave = maxPacketsPerFile - packetsInFile; - if(packetsToSave > numpackets) - packetsToSave = numpackets; - - fwrite(buf+offset, 1, packetsToSave * onePacketSize, sfilefd); - packetsInFile += packetsToSave; - packetsCaught += packetsToSave; - totalPacketsCaught += packetsToSave; - - - //new file - if(packetsInFile >= maxPacketsPerFile){ - //for packet loss - lastpacket = (((packetsToSave - 1) * onePacketSize) + offset); - if ((myDetectorType == GOTTHARD) && (shortFrame == -1)) - tempframenum = (((((uint32_t)(*((uint32_t*)(buf + lastpacket))))+1)& (frameIndexMask)) >> frameIndexOffset); - else - tempframenum = ((((uint32_t)(*((uint32_t*)(buf + lastpacket))))& (frameIndexMask)) >> frameIndexOffset); - - if(numWriterThreads == 1) - currframenum = tempframenum; - else{ - if(tempframenum > currframenum) - currframenum = tempframenum; - } -#ifdef VERYDEBUG - cout << "tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl; -#endif - //create - createNewFile(); - } - - //unlock - if(numWriterThreads > 1) - pthread_mutex_unlock(&write_mutex); - - - offset += (packetsToSave * onePacketSize); - numpackets -= packetsToSave; - } - - } - else{ - if(numWriterThreads > 1) - pthread_mutex_lock(&write_mutex); - packetsInFile += numpackets; - packetsCaught += numpackets; - totalPacketsCaught += numpackets; - if(numWriterThreads > 1) - pthread_mutex_unlock(&write_mutex); - } - - - -} - - -#endif diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h deleted file mode 100644 index bb10b45a7..000000000 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h +++ /dev/null @@ -1,686 +0,0 @@ -#ifdef SLS_RECEIVER_FUNCTION_LIST - -#ifndef SLS_RECEIVER_FUNCTION_LIST_H -#define SLS_RECEIVER_FUNCTION_LIST_H -/********************************************//** - * @file slsReceiverFunctionList.h - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - ***********************************************/ - - -#include "sls_detector_defs.h" -#include "receiver_defs.h" -#include "genericSocket.h" -#include "circularFifo.h" -#include "singlePhotonDetector.h" -#include "slsReceiverData.h" -#include "moenchCommonMode.h" -#include "eigerReceiver.h" - -#ifdef MYROOT1 -#include -#include -#endif - - -#include -#include -#include -#include - - -/** - * @short does all the functions for a receiver, set/get parameters, start/stop etc. - */ - -class slsReceiverFunctionList : private virtual slsDetectorDefs { - -public: - /** - * Constructor - */ - slsReceiverFunctionList(); - - /** - * Destructor - */ - virtual ~slsReceiverFunctionList(); - - /** - * delete and free member parameters - */ - void deleteMembers(); - - /** - * initialize member parameters - */ - void initializeMembers(); - - /** - * Set receiver type - * @param det detector type - * Returns success or FAIL - */ - int setDetectorType(detectorType det); - - - //Frame indices and numbers caught - /** - * Returns current Frame Index Caught for an entire acquisition (including all scans) - */ - uint32_t getAcquisitionIndex(); - - /** - * Returns if acquisition started - */ - bool getAcquistionStarted(); - - /** - * Returns Frames Caught for each real time acquisition (eg. for each scan) - */ - int getFramesCaught(); - - /** - * Returns Total Frames Caught for an entire acquisition (including all scans) - */ - int getTotalFramesCaught(); - - /** - * Returns the frame index at start of each real time acquisition (eg. for each scan) - */ - uint32_t getStartFrameIndex(); - - /** - * Returns current Frame Index for each real time acquisition (eg. for each scan) - */ - uint32_t getFrameIndex(); - - /** - * Returns if measurement started - */ - bool getMeasurementStarted(); - - /** - * Resets the Total Frames Caught - * This is how the receiver differentiates between entire acquisitions - * Returns 0 - */ - void resetTotalFramesCaught(); - - - - - //file parameters - /** - * Returns File Path - */ - char* getFilePath(); - - /** - * Set File Path - * @param c file path - */ - char* setFilePath(char c[]); - - /** - * Returns File Name - */ - char* getFileName(); - - /** - * Set File Name (without frame index, file index and extension) - * @param c file name - */ - char* setFileName(char c[]); - - /** - * Returns File Index - */ - int getFileIndex(); - - /** - * Set File Index - * @param i file index - */ - int setFileIndex(int i); - - /** - * Set Frame Index Needed - * @param i frame index needed - */ - int setFrameIndexNeeded(int i); - - /** - * Set enable file write - * @param i file write enable - * Returns file write enable - */ - int setEnableFileWrite(int i); - - /** - * Enable/disable overwrite - * @param i enable - * Returns enable over write - */ - int enableOverwrite(int i); - - - -//other parameters - - /** - * Returns status of receiver: idle, running or error - */ - runStatus getStatus(); - - /** - * Set detector hostname - * @param c hostname - */ - char* setDetectorHostname(char c[]); - - /** - * Set Ethernet Interface or IP to listen to - */ - void setEthernetInterface(char* c); - - /** - * Set UDP Port Number - */ - void setUDPPortNo(int p); - - /** - * set frame number if a positive number - */ - int32_t setNumberOfFrames(int32_t fnum); - - /** - * set scan tag if its is a positive number - */ - int32_t setScanTag(int32_t stag); - - /** - * set dynamic range if its is a positive number - */ - int32_t setDynamicRange(int32_t dr); - - /** - * Set short frame - * @param i if shortframe i=1 - */ - int setShortFrame(int i); - - /** - * Set the variable to send every nth frame to gui - * or if 0,send frame only upon gui request - */ - int setNFrameToGui(int i); - - /** set acquisition period if a positive number - */ - int64_t setAcquisitionPeriod(int64_t index); - - /** get data compression, by saving only hits - */ - bool getDataCompression(); - - /** enabl data compression, by saving only hits - /returns if failed - */ - int enableDataCompression(bool enable); - - - - - - -//other functions - - /** - * Returns the buffer-current frame read by receiver - * @param c pointer to current file name - * @param raw address of pointer, pointing to current frame to send to gui - */ - void readFrame(char* c,char** raw); - - /** - * Closes all files - * @param ithr thread index - */ - void closeFile(int ithr = -1); - - /** - * Starts Receiver - starts to listen for packets - * @param message is the error message if there is an error - * Returns success - */ - int startReceiver(char message[]); - - /** - * Stops Receiver - stops listening for packets - * Returns success - */ - int stopReceiver(); - - /** set status to transmitting and - * when fifo is empty later, sets status to run_finished - */ - void startReadout(); - - -private: - /** - * Deletes all the filter objects for single photon data - */ - void deleteFilter(); - - /** - * Constructs the filter for single photon data - */ - void setupFilter(); - - /** - * set up fifo according to the new numjobsperthread - */ - void setupFifoStructure (); - - /** - * Copy frames to gui - * uses semaphore for nth frame mode - */ - void copyFrameToGui(char* startbuf); - - /** - * creates udp socket - * \returns if success or fail - */ - int createUDPSocket(); - - /** - * create listening thread - * @param destroy is true to kill all threads and start again - */ - int createListeningThreads(bool destroy = false); - - /** - * create writer threads - * @param destroy is true to kill all threads and start again - */ - int createWriterThreads(bool destroy = false); - - /** - * set thread priorities - */ - void setThreadPriorities(); - - /** - * initializes variables and creates the first file - * also does the startAcquisitionCallBack - * \returns FAIL or OK - */ - int setupWriter(); - - /** - * Creates new tree and file for compression - * @param ithr thread number - * @param iframe frame number - *\returns OK for succces or FAIL for failure - */ - int createCompressionFile(int ithr, int iframe); - - /** - * Creates new file - *\returns OK for succces or FAIL for failure - */ - int createNewFile(); - - /** - * Static function - Thread started which listens to packets. - * Called by startReceiver() - * @param this_pointer pointer to this object - */ - static void* startListeningThread(void *this_pointer); - - /** - * Static function - Thread started which writes packets to file. - * Called by startReceiver() - * @param this_pointer pointer to this object - */ - static void* startWritingThread(void *this_pointer); - - /** - * Thread started which listens to packets. - * Called by startReceiver() - * - */ - int startListening(); - - /** - * Thread started which writes packets to file. - * Called by startReceiver() - * - */ - int startWriting(); - - - /** - * Writing to file without compression - * @param buf is the address of buffer popped out of fifo - * @param numpackets is the number of packets - */ - void writeToFile_withoutCompression(char* buf,int numpackets); - - - - - /** Eiger Receiver */ - EigerReceiver *receiver; - - /** detector type */ - detectorType myDetectorType; - - /** detector hostname */ - char detHostname[MAX_STR_LENGTH]; - - /** status of receiver */ - runStatus status; - - /** UDP Socket between Receiver and Detector */ - genericSocket* udpSocket; - - /** Server UDP Port*/ - int server_port; - - /** ethernet interface or IP to listen to */ - char *eth; - - /** max packets per file **/ - int maxPacketsPerFile; - - /** File write enable */ - int enableFileWrite; - - /** File over write enable */ - int overwrite; - - /** Complete File name */ - char savefilename[MAX_STR_LENGTH]; - - /** File Name without frame index, file index and extension*/ - char fileName[MAX_STR_LENGTH]; - - /** File Path */ - char filePath[MAX_STR_LENGTH]; - - /** File Index */ - int fileIndex; - - /** scan tag */ - int scanTag; - - /** if frame index required in file name */ - int frameIndexNeeded; - - /* Acquisition started */ - bool acqStarted; - - /* Measurement started */ - bool measurementStarted; - - /** Frame index at start of each real time acquisition (eg. for each scan) */ - uint32_t startFrameIndex; - - /** Actual current frame index of each time acquisition (eg. for each scan) */ - uint32_t frameIndex; - - /** Frames Caught for each real time acquisition (eg. for each scan) */ - int packetsCaught; - - /** Total packets caught for an entire acquisition (including all scans) */ - int totalPacketsCaught; - - /** Pckets currently in current file, starts new file when it reaches max */ - int packetsInFile; - - /** Frame index at start of an entire acquisition (including all scans) */ - uint32_t startAcquisitionIndex; - - /** Actual current frame index of an entire acquisition (including all scans) */ - uint32_t acquisitionIndex; - - /** number of packets per frame*/ - int packetsPerFrame; - - /** frame index mask */ - uint32_t frameIndexMask; - - /** packet index mask */ - uint32_t packetIndexMask; - - /** frame index offset */ - int frameIndexOffset; - - /** acquisition period */ - int64_t acquisitionPeriod; - - /** frame number */ - int32_t numberOfFrames; - - /** dynamic range */ - int dynamicRange; - - /** short frames */ - int shortFrame; - - /** current frame number */ - uint32_t currframenum; - - /** Previous Frame number from buffer */ - uint32_t prevframenum; - - /** buffer size can be 1286*2 or 518 or 1286*40 */ - int bufferSize; - - /** oen buffer size */ - int onePacketSize; - - /** latest data */ - char* latestData; - - /** gui data ready */ - int guiDataReady; - - /** points to the data to send to gui */ - char* guiData; - - /** points to the filename to send to gui */ - char* guiFileName; - - /** send every nth frame to gui or only upon gui request*/ - int nFrameToGui; - - /** fifo size */ - unsigned int fifosize; - - /** number of jobs per thread for data compression */ - int numJobsPerThread; - - /** memory allocated for the buffer */ - char *mem0; - - /** datacompression - save only hits */ - bool dataCompression; - - /** circular fifo to store addresses of data read */ - CircularFifo* fifo; - - /** circular fifo to store addresses of data already written and ready to be resued*/ - CircularFifo* fifoFree; - - /** Receiver buffer */ - char *buffer; - - /** max number of writer threads */ - const static int MAX_NUM_WRITER_THREADS = 15; - - /** number of writer threads */ - int numWriterThreads; - - /** to know if listening and writer threads created properly */ - int thread_started; - - /** current writer thread index*/ - int currentWriterThreadIndex; - - /** thread listening to packets */ - pthread_t listening_thread; - - /** thread writing packets */ - pthread_t writing_thread[MAX_NUM_WRITER_THREADS]; - - /** total frame count the listening thread has listened to */ - int totalListeningFrameCount; - - /** mask showing which threads are running */ - volatile uint32_t writerthreads_mask; - - /** mask showing which threads have created files*/ - volatile uint32_t createfile_mask; - - /** OK if file created was successful */ - int ret_createfile; - - /** 0 if listening thread is idle, 1 otherwise */ - int listening_thread_running; - - /** variable used to self terminate threads waiting for semaphores */ - int killListeningThread; - - /** variable used to self terminate threads waiting for semaphores */ - int killAllWritingThreads; - - - - -//semaphores - /** semaphore to synchronize writer and guireader threads */ - sem_t smp; - /** semaphore to synchronize listener thread */ - sem_t listensmp; - /** semaphore to synchronize writer threads */ - sem_t writersmp[MAX_NUM_WRITER_THREADS]; - - -//mutex - /** guiDataReady mutex */ - pthread_mutex_t dataReadyMutex; - - /** mutex for status */ - pthread_mutex_t status_mutex; - - /** mutex for progress variable currframenum */ - pthread_mutex_t progress_mutex; - - /** mutex for writing data to file */ - pthread_mutex_t write_mutex; - - /** File Descriptor */ - FILE *sfilefd; - - //filter - singlePhotonDetector *singlePhotonDet[MAX_NUM_WRITER_THREADS]; - slsReceiverData *receiverdata[MAX_NUM_WRITER_THREADS]; - moenchCommonMode *cmSub; - bool commonModeSubtractionEnable; - -#ifdef MYROOT1 - /** Tree where the hits are stored */ - TTree *myTree[MAX_NUM_WRITER_THREADS]; - - /** File where the tree is saved */ - TFile *myFile[MAX_NUM_WRITER_THREADS]; -#endif - - - - /** - callback arguments are - filepath - filename - fileindex - data size - - return value is - 0 callback takes care of open,close,write file - 1 callback writes file, we have to open, close it - 2 we open, close, write file, callback does not do anything - - */ - int (*startAcquisitionCallBack)(char*, char*,int, int, void*); - void *pStartAcquisition; - - /** - args to acquisition finished callback - total frames caught - - */ - void (*acquisitionFinishedCallBack)(int, void*); - void *pAcquisitionFinished; - - - /** - args to raw data ready callback are - framenum - datapointer - datasize in bytes - file descriptor - guidatapointer (NULL, no data required) - */ - void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*); - void *pRawDataReady; - - /** The action which decides what the user and default responsibilites to save data are - * 0 raw data ready callback takes care of open,close,write file - * 1 callback writes file, we have to open, close it - * 2 we open, close, write file, callback does not do anything */ - int cbAction; - - -public: - - - /** - callback arguments are - filepath - filename - fileindex - datasize - - return value is - 0 callback takes care of open,close,wrie file - 1 callback writes file, we have to open, close it - 2 we open, close, write file, callback does not do anything - */ - void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){startAcquisitionCallBack=func; pStartAcquisition=arg;}; - - /** - callback argument is - toatal frames caught - */ - void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){acquisitionFinishedCallBack=func; pAcquisitionFinished=arg;}; - - /** - args to raw data ready callback are - framenum - datapointer - datasize in bytes - file descriptor - guidatapointer (NULL, no data required) - */ - void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){rawDataReadyCallBack=func; pRawDataReady=arg;}; -}; - - -#endif - -#endif diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.cpp deleted file mode 100644 index cd78dc400..000000000 --- a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "slsReceiverUsers.h" -#include "slsReceiver_funcs.h" - -slsReceiverFuncs* slsReceiverUsers::receiver(NULL); - -slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) { - slsReceiverUsers::receiver=new slsReceiverFuncs(argc, argv, success); -} - -slsReceiverUsers::~slsReceiverUsers() { - delete slsReceiverUsers::receiver; -} - -void slsReceiverUsers::start() { - slsReceiverUsers::receiver->start(); -} - - -void slsReceiverUsers::closeFile(int p) { - slsReceiverUsers::receiver->closeFile(p); -} - - -void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){ - slsReceiverUsers::receiver->registerCallBackStartAcquisition(func,arg); -} - - - -void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){ - slsReceiverUsers::receiver->registerCallBackAcquisitionFinished(func,arg); -} - - -void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){ - slsReceiverUsers::receiver->registerCallBackRawDataReady(func,arg); -} - - diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h deleted file mode 100644 index c736ecdea..000000000 --- a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h +++ /dev/null @@ -1,78 +0,0 @@ - -#ifndef SLS_RECEIVER_USERS_H -#define SLS_RECEIVER_USERS_H - -#include - -class slsReceiverFuncs; - - /** -@short Class for implementing the SLS data receiver in the users application. Callbacks can be defined for processing and/or saving data - */ -/** - - - @libdoc slsReceiverUsers is a class that can be instantiated in the users software to receive the data from the detectors. Callbacks can be defined for processing and/or saving data - - - ***********************************************/ - -class slsReceiverUsers { - -public: - /** - * Constructor - * reads config file, creates socket, assigns function table - * @param argc from command line - * @param argv from command line - * @param succecc socket creation was successfull - */ - slsReceiverUsers(int argc, char *argv[], int &success); - - - /** Destructor */ - ~slsReceiverUsers(); - - /** Close File */ - void closeFile(int p); - - /** starts listening on the TCP port for client comminication */ - void start(); - - /** - - @sort register calbback for starting the acquisition - \param func callback to be called when starting the acquisition. Its arguments are filepath filename fileindex data size - - \returns 0 callback takes care of open,close,write file; 1 callback writes file, we have to open, close it; 2 we open, close, write file, callback does not do anything - - */ - - void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename,int fileindex, int datasize, void*),void *arg); - - - /** - @sort register callback for end of acquisition - \param func end of acquisition callback. Argument nf is total frames caught - \returns nothing - */ - - - void registerCallBackAcquisitionFinished(void (*func)(int nf, void*),void *arg); - - - - /** - @sort register callback to be called when data are available (to process and/or save the data). - \param func raw data ready callback. arguments are framenum datapointer datasize file descriptor guidatapointer (NULL, no data required) - \returns nothing - */ - - void registerCallBackRawDataReady(void (*func)(int framenumber, char* datapointer, int datasize, FILE* filedescriptor, char* guidatapointer, void*),void *arg); - - // made static to close thread files with ctrl+c - static slsReceiverFuncs* receiver; -}; - - -#endif diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp deleted file mode 100644 index cbbc6645c..000000000 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp +++ /dev/null @@ -1,1972 +0,0 @@ -/********************************************//** - * @file slsReceiver_funcs.h - * @short interface between receiver and client - ***********************************************/ - -#include "slsReceiver_funcs.h" -#include "slsReceiverFunctionList.h" -#include "svnInfoReceiver.h" -#include "slsReceiverUsers.h" -#include "slsDetectorBase.h" - -#include //SIGINT -#include //EXIT - -#include -#include -#include -#include -#include -using namespace std; - - -int slsReceiverFuncs::file_des(-1); -int slsReceiverFuncs::socketDescriptor(-1); - - -slsReceiverFuncs::~slsReceiverFuncs() { - if(socket) delete socket; - closeFile(0); -} - - -slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success): - myDetectorType(GOTTHARD), - ret(OK), - lockStatus(0), - shortFrame(-1), - packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME), - socket(NULL){ - - int port_no = DEFAULT_PORTNO+2; - ifstream infile; - string sLine,sargname; - int iline = 0; - - - success=OK; - string fname = ""; - - //parse command line for config - for(int iarg=1;iarg> sargname; - - //tcp port - if(sargname=="rx_tcpport"){ - if(sstr.good()) { - sstr >> sargname; - if(sscanf(sargname.c_str(),"%d",&port_no)) - cout<<"dataport:"<getErrorStatus()) { - success = FAIL; - delete socket; - socket=NULL; - } else { - //initialize variables - strcpy(socket->lastClientIP,"none"); - strcpy(socket->thisClientIP,"none1"); - strcpy(mess,"dummy message"); - - function_table(); -#ifdef VERBOSE - cout << "Function table assigned." << endl; -#endif - slsReceiverList = new slsReceiverFunctionList(); - - //Catch signal SIGINT to close files properly - signal(SIGINT,staticCloseFile); - - - file_des=socket->getFileDes(); - socketDescriptor=socket->getsocketDescriptor(); - - //success = OK; - } - } - -} - -void slsReceiverFuncs::start(){ - - int v=slsDetectorDefs::OK; - - while(v!=GOODBYE) { -#ifdef VERBOSE - cout<< endl; -#endif -#ifdef VERY_VERBOSE - cout << "Waiting for client call" << endl; -#endif - if(socket->Connect()>=0){ -#ifdef VERY_VERBOSE - cout << "Conenction accepted" << endl; -#endif - v = decode_function(); -#ifdef VERY_VERBOSE - cout << "function executed" << endl; -#endif - socket->Disconnect(); -#ifdef VERY_VERBOSE - cout << "connection closed" << endl; -#endif - } - } - - - -} - - -int slsReceiverFuncs::function_table(){ - - for (int i=0;iReceiveDataOnly(&fnum,sizeof(fnum)); - if (n <= 0) { -#ifdef VERBOSE - cout << "ERROR reading from socket " << n << ", " << fnum << endl; -#endif - return FAIL; - } -#ifdef VERBOSE - else - cout << "size of data received " << n <numberOfFunctions-1) - fnum = numberOfFunctions-1; - //calling function - (this->*flist[fnum])(); - if (ret==FAIL) - cout << "Error executing the function = " << fnum << endl; - - return ret; -} - - - - - - -int slsReceiverFuncs::M_nofunc(){ - - ret=FAIL; - sprintf(mess,"Unrecognized Function\n"); - cout << mess << endl; - - socket->SendDataOnly(&ret,sizeof(ret)); - socket->SendDataOnly(mess,sizeof(mess)); - - return GOODBYE; -} - - - - -void slsReceiverFuncs::closeFile(int p){ - cout<<"Closing Files... "<closeFile(); - cout << "Goodbye!" << endl; - exit(-1); -} - -void slsReceiverFuncs::staticCloseFile(int p){ - slsReceiverUsers::receiver->closeFile(p); -} - - -int slsReceiverFuncs::set_detector_type(){ - ret=OK; - int retval=FAIL; - detectorType dr; - strcpy(mess,"Could not set detector type range\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(&dr,sizeof(dr)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else{ - myDetectorType = dr; - ret=slsReceiverList->setDetectorType(dr); - retval = myDetectorType; - } - } -//#ifdef VERBOSE - if(ret!=FAIL) - cout << "detector type" << dr << endl; - else - cout << mess << endl; -//#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - - - - -int slsReceiverFuncs::set_file_name() { - ret=OK; - char retval[MAX_STR_LENGTH]=""; - char fName[MAX_STR_LENGTH]; - strcpy(mess,"Could not set file name"); - - // receive arguments - if(socket->ReceiveDataOnly(fName,MAX_STR_LENGTH) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else - strcpy(retval,slsReceiverList->setFileName(fName)); - } -#ifdef VERBOSE - if(ret!=FAIL) - cout << "file name:" << retval << endl; - else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(retval,MAX_STR_LENGTH); - - //return ok/fail - return ret; -} - - - - - - -int slsReceiverFuncs::set_file_dir() { - ret=OK; - char retval[MAX_STR_LENGTH]=""; - char fPath[MAX_STR_LENGTH]; - strcpy(mess,"Could not set file path\n"); - - // receive arguments - if(socket->ReceiveDataOnly(fPath,MAX_STR_LENGTH) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - }/* - else if((strlen(fPath))&&(slsReceiverList->getStatus()==RUNNING)){ - strcpy(mess,"Can not set file path while receiver running\n"); - ret = FAIL; - }*/ - else{ - strcpy(retval,slsReceiverList->setFilePath(fPath)); - // if file path doesnt exist - if(strlen(fPath)) - if (strcmp(retval,fPath)){ - strcpy(mess,"receiver file path does not exist\n"); - ret=FAIL; - } - } - - } -#ifdef VERBOSE - if(ret!=FAIL) - cout << "file path:" << retval << endl; - else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(retval,MAX_STR_LENGTH); - - //return ok/fail - return ret; -} - - - - - - -int slsReceiverFuncs::set_file_index() { - ret=OK; - int retval=-1; - int index; - strcpy(mess,"Could not set file index\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else - retval=slsReceiverList->setFileIndex(index); - } -#ifdef VERBOSE - if(ret!=FAIL) - cout << "file index:" << retval << endl; - else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - - - - - -int slsReceiverFuncs::set_frame_index() { - ret=OK; - int retval=-1; - int index; - strcpy(mess,"Could not set frame index\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else - retval=slsReceiverList->setFrameIndexNeeded(index); - } -#ifdef VERBOSE - if(ret!=FAIL) - cout << "frame index:" << retval << endl; - else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - - - - -int slsReceiverFuncs::setup_udp(){ - ret=OK; - strcpy(mess,"could not set up udp connection"); - char retval[MAX_STR_LENGTH]=""; - char args[2][MAX_STR_LENGTH]; - - string temp; - int udpport; - char eth[MAX_STR_LENGTH]; - - - // receive arguments - - if(socket->ReceiveDataOnly(args,sizeof(args)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else if(slsReceiverList->getStatus()==RUNNING){ - ret = FAIL; - strcpy(mess,"cannot set up udp when receiver is running\n"); - } - else{ - //set up udp port - sscanf(args[1],"%d",&udpport); - slsReceiverList->setUDPPortNo(udpport); - - //setup udpip - //get ethernet interface or IP to listen to - temp = genericSocket::ipToName(args[0]); - if(temp=="none"){ - ret = FAIL; - strcpy(mess, "failed to get ethernet interface or IP to listen to\n"); - } - else{ - strcpy(eth,temp.c_str()); - if (strchr(eth,'.')!=NULL) { - strcpy(eth,""); - ret = FAIL; - } - cout<<"eth:"<setEthernetInterface(eth); - - //get mac address from ethernet interface - if (ret != FAIL) - temp = genericSocket::nameToMac(eth); - - - if ((temp=="00:00:00:00:00:00") || (ret == FAIL)){ - ret = FAIL; - strcpy(mess,"failed to get mac adddress to listen to\n"); - cout << "mess:" << mess << endl; - } - else{ - strcpy(retval,temp.c_str()); - cout<<"mac:"<differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(retval,MAX_STR_LENGTH); - - //return ok/fail - return ret; -} - - - - - - -int slsReceiverFuncs::start_receiver(){ - ret=OK; - ret=OK; - enum runStatus s; - char cstatus[15]; - strcpy(mess,"Could not start receiver\n"); - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - /* - else if(!strlen(slsReceiverList->getFilePath())){ - strcpy(mess,"receiver not set up. set receiver ip again.\n"); - ret = FAIL; - } - */ - else { - s = slsReceiverList->getStatus(); - strcpy(cstatus, slsDetectorBase::runStatusType(s).c_str()); - if(s == IDLE) - ret=slsReceiverList->startReceiver(mess); - else{ - sprintf(mess,"Cannot start Receiver as it is in %s state\n",cstatus); - ret=FAIL; - } - } - -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - //return ok/fail - return ret; - - -} - - -int slsReceiverFuncs::stop_receiver(){ - ret=OK; - - strcpy(mess,"Could not stop receiver\n"); - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else if(slsReceiverList->getStatus()!=IDLE) - ret=slsReceiverList->stopReceiver(); -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - //return ok/fail - return ret; - - -} - - -int slsReceiverFuncs::get_status(){ - ret=OK; - enum runStatus retval; - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - retval=slsReceiverList->getStatus(); -#endif - - if(socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - socket->SendDataOnly(&retval,sizeof(retval)); - //return ok/fail - return ret; - - -} - - -int slsReceiverFuncs::get_frames_caught(){ - ret=OK; - int retval=-1; - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - retval=slsReceiverList->getTotalFramesCaught(); -#endif - if(socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - socket->SendDataOnly(&retval,sizeof(retval)); - //return ok/fail - return ret; - - -} - - -int slsReceiverFuncs::get_frame_index(){ - ret=OK; - int retval=-1; - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - retval=slsReceiverList->getAcquisitionIndex(); -#endif - - if(socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - socket->SendDataOnly(&retval,sizeof(retval)); - //return ok/fail - return ret; - - -} - - -int slsReceiverFuncs::reset_frames_caught(){ - ret=OK; - - strcpy(mess,"Could not reset frames caught\n"); - - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else - slsReceiverList->resetTotalFramesCaught(); - } -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - - //return ok/fail - return ret; - - -} - - - - - - -int slsReceiverFuncs::set_short_frame() { - ret=OK; - int index=0; - int retval=-100; - strcpy(mess,"Could not set/reset short frame for receiver\n"); - - //does not exist for moench - if(myDetectorType==MOENCH){ - strcpy(mess,"can not set short frame for moench\n"); - ret = FAIL; - } - - // receive arguments - if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else if(slsReceiverList->getStatus()==RUNNING){ - strcpy(mess,"Cannot set short frame while status is running\n"); - ret=FAIL; - } - else{ - retval=slsReceiverList->setShortFrame(index); - shortFrame = retval; - if(shortFrame==-1) - packetsPerFrame=GOTTHARD_PACKETS_PER_FRAME; - else - packetsPerFrame=GOTTHARD_SHORT_PACKETS_PER_FRAME; - } - } -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - -int slsReceiverFuncs::read_frame(){ - switch(myDetectorType){ - case MOENCH: - return moench_read_frame(); - default: - return gotthard_read_frame(); - } -} - - - -int slsReceiverFuncs::moench_read_frame(){ - ret=OK; - char fName[MAX_STR_LENGTH]=""; - int arg = -1,i; - - - int bufferSize = MOENCH_BUFFER_SIZE; - int rnel = bufferSize/(sizeof(int)); - int* retval = new int[rnel]; - int* origVal = new int[rnel]; - //all initialized to 0 - for(i=0;igetFramesCaught()){ - arg = -1; - cout<<"haven't caught any frame yet"<getStartFrameIndex(); - slsReceiverList->readFrame(fName,&raw); - - /**send garbage with -1 index to try again*/ - if (raw == NULL){ - arg = -1; -#ifdef VERBOSE - cout<<"data not ready for gui yet"<> MOENCH_FRAME_INDEX_OFFSET); - - uint32_t numPackets = MOENCH_PACKETS_PER_FRAME; //40 - uint32_t onePacketSize = MOENCH_DATA_BYTES / MOENCH_PACKETS_PER_FRAME; //1280*40 / 40 = 1280 - uint32_t packetDatabytes_row = onePacketSize * (MOENCH_BYTES_IN_ONE_ROW / MOENCH_BYTES_PER_ADC); //1280 * 4 = 5120 - uint32_t partsPerFrame = onePacketSize / MOENCH_BYTES_PER_ADC; // 1280 / 80 = 16 - uint32_t packetOffset = 0; - int packetIndex,x,y; - int iPacket = 0; - offset = 4; - - - while (iPacket < (int)numPackets){ -#ifdef VERBOSE - printf("iPacket:%d\n",iPacket);cout << endl; -#endif - //if missing packets, dont send to gui - bindex = (*((uint32_t*)(((char*)origVal)+packetOffset))); - if (bindex == 0xFFFFFFFF){ - cout << "Missing Packet,Not sending to gui" << endl; - index = startIndex - 1; - break;//use continue and change index above if you want to display missing packets with 0 value anyway in gui - } - - packetIndex = bindex & MOENCH_PACKET_INDEX_MASK; - //cout<<"packetIndex:"<= 40) && (packetIndex < 0)) - cout << "cannot decode packet index:" << packetIndex << endl; - else{ - - x = packetIndex / 10; - y = packetIndex % 10; -#ifdef VERBOSE - cout<<"x:"<differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL){ - cout << "mess:" << mess << endl; - socket->SendDataOnly(mess,sizeof(mess)); - } - else{ - socket->SendDataOnly(fName,MAX_STR_LENGTH); - socket->SendDataOnly(&arg,sizeof(arg)); - socket->SendDataOnly(retval,MOENCH_DATA_BYTES); - } - //return ok/fail - - - delete [] retval; - delete [] origVal; - delete [] raw; - - return ret; - -} - - - - -int slsReceiverFuncs::gotthard_read_frame(){ - ret=OK; - char fName[MAX_STR_LENGTH]=""; - int arg = -1,i; - - - //retval is a full frame - int bufferSize = GOTTHARD_BUFFER_SIZE; - int rnel = bufferSize/(sizeof(int)); - int* retval = new int[rnel]; - int* origVal = new int[rnel]; - //all initialized to 0 - for(i=0;igetFramesCaught()){ - arg=-1; - cout<<"haven't caught any frame yet"<getStartFrameIndex(); - slsReceiverList->readFrame(fName,&raw); - - /**send garbage with -1 index to try again*/ - if (raw == NULL){ - arg = -1; -#ifdef VERBOSE - cout<<"data not ready for gui yet"<> GOTTHARD_SHORT_FRAME_INDEX_OFFSET); -#ifdef VERBOSE - cout << "index:" << hex << index << endl; -#endif - }else{ - bindex = ((uint32_t)(*((uint32_t*)raw)))+1; - pindex = (bindex & GOTTHARD_PACKET_INDEX_MASK); - index = ((bindex & GOTTHARD_FRAME_INDEX_MASK) >> GOTTHARD_FRAME_INDEX_OFFSET); - bindex2 = ((uint32_t)(*((uint32_t*)((char*)(raw+onebuffersize)))))+1; - pindex2 =(bindex2 & GOTTHARD_PACKET_INDEX_MASK); - index2 =((bindex2 & GOTTHARD_FRAME_INDEX_MASK) >> GOTTHARD_FRAME_INDEX_OFFSET); -#ifdef VERBOSE - cout << "index1:" << hex << index << endl; - cout << "index2:" << hex << index << endl; -#endif - } - - memcpy(origVal,raw,bufferSize); - raw=NULL; - - - //1 adc - if(shortFrame!=-1){ - if(bindex != 0xFFFFFFFF) - memcpy((((char*)retval)+(GOTTHARD_SHORT_DATABYTES*shortFrame)),((char*) origVal)+4, GOTTHARD_SHORT_DATABYTES); - else{ - index = startIndex - 1; - cout << "Missing Packet,Not sending to gui" << endl; - } - } - //all adc - else{ - //ignore if half frame is missing - if ((bindex != 0xFFFFFFFF) && (bindex2 != 0xFFFFFFFF)){ - - //should be same frame - if (index == index2){ - //ideal situation (should be odd, even(index+1)) - if(!pindex){ - memcpy(retval,((char*) origVal)+4, onedatasize); - memcpy((((char*)retval)+onedatasize), ((char*) origVal)+10+onedatasize, onedatasize); - } - //swap to even,odd - else{ - memcpy((((char*)retval)+onedatasize),((char*) origVal)+4, onedatasize); - memcpy(retval, ((char*) origVal)+10+onedatasize, onedatasize); - index=index2; - } - }else - cout << "different frames caught. frame1:"<< hex << index << ":"<differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL){ - cout << "mess:" << mess << endl; - socket->SendDataOnly(mess,sizeof(mess)); - } - else{ - socket->SendDataOnly(fName,MAX_STR_LENGTH); - socket->SendDataOnly(&arg,sizeof(arg)); - socket->SendDataOnly(retval,GOTTHARD_DATA_BYTES); - } - - delete [] retval; - delete [] origVal; - delete [] raw; - - return ret; -} - - - - -int slsReceiverFuncs::set_read_frequency(){ - ret=OK; - int retval=-1; - int index; - strcpy(mess,"Could not set receiver read frequency\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - }/* - else if((slsReceiverList->getStatus()==RUNNING) && (index >= 0)){ - ret = FAIL; - strcpy(mess,"cannot set up receiver mode when receiver is running\n"); - }*/ - else - retval=slsReceiverList->setNFrameToGui(index); - } - -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - - - -int slsReceiverFuncs::enable_file_write(){ - ret=OK; - int retval=-1; - int enable; - strcpy(mess,"Could not set/get enable file write\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else{ - retval=slsReceiverList->setEnableFileWrite(enable); - if((enable!=-1)&&(enable!=retval)) - ret=FAIL; - } - } -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - -int slsReceiverFuncs::get_version(){ - ret=OK; - int64_t retval=-1; - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - retval= SVNREV; - retval= (retval <<32) | SVNDATE; -#endif - - if(socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - -int slsReceiverFuncs::start_readout(){ - ret=OK; - enum runStatus retval; - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - slsReceiverList->startReadout(); - retval = slsReceiverList->getStatus(); - if((retval == TRANSMITTING) || (retval == RUN_FINISHED) || (retval == IDLE)) - ret = OK; - else - ret = FAIL; -#endif - - if(socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - socket->SendDataOnly(&retval,sizeof(retval)); - //return ok/fail - return ret; - - -} - - - - -int slsReceiverFuncs::set_timer() { - ret=OK; - int64_t retval = -1; - int64_t index[2]; - index[1] = -1; - strcpy(mess,"Could not set acquisition period or frame number in receiver\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(index,sizeof(index)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else{ - if(index[0] == slsDetectorDefs::FRAME_PERIOD) - retval=slsReceiverList->setAcquisitionPeriod(index[1]); - else - retval=slsReceiverList->setNumberOfFrames(index[1]); - } - } -#ifdef VERBOSE - if(ret!=FAIL){ - if(index[0] == slsDetectorDefs::FRAME_PERIOD) - cout << "acquisition period:" << retval << endl; - else - cout << "frame number:" << retval << endl; - }else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - - - -int slsReceiverFuncs::enable_compression() { - ret=OK; - int enable=-1; - int retval=-100; - strcpy(mess,"Could not enable/disable compression for receiver\n"); - - // receive arguments - if(socket->ReceiveDataOnly(&enable,sizeof(enable)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if(enable >= 0){ - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else if(slsReceiverList->getStatus()==RUNNING){ - strcpy(mess,"Cannot enable/disable compression while status is running\n"); - ret=FAIL; - } - else - ret = slsReceiverList->enableDataCompression(enable); - } - - retval=slsReceiverList->getDataCompression(); - } -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - -int slsReceiverFuncs::set_detector_hostname() { - ret=OK; - char retval[MAX_STR_LENGTH]=""; - char hostname[MAX_STR_LENGTH]=""; - strcpy(mess,"Could not set detector hostname"); - - // receive arguments - if(socket->ReceiveDataOnly(hostname,MAX_STR_LENGTH) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else - strcpy(retval,slsReceiverList->setDetectorHostname(hostname)); - } -#ifdef VERBOSE - if(ret!=FAIL) - cout << "hostname:" << retval << endl; - else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(retval,MAX_STR_LENGTH); - - //return ok/fail - return ret; -} - - - - - - - -int slsReceiverFuncs::set_dynamic_range() { - ret=OK; - int retval=-1; - int dr; - strcpy(mess,"Could not set dynamic range\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(&dr,sizeof(dr)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else - retval=slsReceiverList->setDynamicRange(dr); - } -#ifdef VERBOSE - if(ret!=FAIL) - cout << "dynamic range" << dr << endl; - else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - - - - -int slsReceiverFuncs::enable_overwrite() { - ret=OK; - int retval=-1; - int index; - strcpy(mess,"Could not enable/disable overwrite\n"); - - - // receive arguments - if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - ret = FAIL; - } - - // execute action if the arguments correctly arrived -#ifdef SLS_RECEIVER_FUNCTION_LIST - if (ret==OK) { - if (lockStatus==1 && socket->differentClients==1){ - sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP); - ret=FAIL; - } - else - retval=slsReceiverList->enableOverwrite(index); - } -#ifdef VERBOSE - if(ret!=FAIL) - cout << "overwrite:" << retval << endl; - else - cout << mess << endl; -#endif -#endif - - if(ret==OK && socket->differentClients){ - cout << "Force update" << endl; - ret=FORCE_UPDATE; - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - socket->SendDataOnly(&retval,sizeof(retval)); - - //return ok/fail - return ret; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int slsReceiverFuncs::lock_receiver() { - ret=OK; - int lock; - - // receive arguments - if(socket->ReceiveDataOnly(&lock,sizeof(lock)) < 0 ){ - sprintf(mess,"Error reading from socket\n"); - cout << "Error reading from socket (lock)" << endl; - ret=FAIL; - } - // execute action if the arguments correctly arrived - if(ret==OK){ - if (lock>=0) { - if (lockStatus==0 || strcmp(socket->lastClientIP,socket->thisClientIP)==0 || strcmp(socket->lastClientIP,"none")==0) { - lockStatus=lock; - strcpy(socket->lastClientIP,socket->thisClientIP); - } else { - ret=FAIL; - sprintf(mess,"Receiver already locked by %s\n", socket->lastClientIP); - } - } - } - - if (socket->differentClients && ret==OK) - ret=FORCE_UPDATE; - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) - socket->SendDataOnly(mess,sizeof(mess)); - else - socket->SendDataOnly(&lockStatus,sizeof(lockStatus)); - - //return ok/fail - return ret; -} - - - - - - - -int slsReceiverFuncs::set_port() { - ret=OK; - MySocketTCP* mySocket=NULL; - int sd=-1; - enum portType p_type; /** data? control? stop? Unused! */ - int p_number; /** new port number */ - - // receive arguments - if(socket->ReceiveDataOnly(&p_type,sizeof(p_type)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - cout << mess << endl; - ret=FAIL; - } - - if(socket->ReceiveDataOnly(&p_number,sizeof(p_number)) < 0 ){ - strcpy(mess,"Error reading from socket\n"); - cout << mess << endl; - ret=FAIL; - } - - // execute action if the arguments correctly arrived - if (ret==OK) { - if (socket->differentClients==1 && lockStatus==1 ) { - ret=FAIL; - sprintf(mess,"Detector locked by %s\n",socket->lastClientIP); - } - else { - if (p_number<1024) { - sprintf(mess,"Too low port number %d\n", p_number); - cout << mess << endl; - ret=FAIL; - } - cout << "set port " << p_type << " to " << p_number <getErrorStatus(); - if (!sd){ - ret=OK; - if (mySocket->differentClients) - ret=FORCE_UPDATE; - } else { - ret=FAIL; - sprintf(mess,"Could not bind port %d\n", p_number); - cout << mess << endl; - if (sd==-10) { - sprintf(mess,"Port %d already set\n", p_number); - cout << mess << endl; - } - } - } - } - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if (ret==FAIL) { - socket->SendDataOnly(mess,sizeof(mess)); - } else { - socket->SendDataOnly(&p_number,sizeof(p_number)); - if(sd>=0){ - socket->Disconnect(); - delete socket; - socket = mySocket; - file_des=socket->getFileDes(); - } - } - - //return ok/fail - return ret; -} - - - - - - -int slsReceiverFuncs::get_last_client_ip() { - ret=OK; - - if (socket->differentClients ) - ret=FORCE_UPDATE; - - socket->SendDataOnly(&ret,sizeof(ret)); - socket->SendDataOnly(socket->lastClientIP,sizeof(socket->lastClientIP)); - - return ret; -} - - - - - - - -int slsReceiverFuncs::send_update() { - ret=OK; - int ind; - char path[MAX_STR_LENGTH]; - - socket->SendDataOnly(socket->lastClientIP,sizeof(socket->lastClientIP)); - - //index -#ifdef SLS_RECEIVER_FUNCTION_LIST - - /*if(myDetectorType != EIGER)*/ - ind=slsReceiverList->getFileIndex(); - - socket->SendDataOnly(&ind,sizeof(ind)); -#endif - - //filepath -#ifdef SLS_RECEIVER_FUNCTION_LIST - strcpy(path,slsReceiverList->getFilePath()); -#endif - socket->SendDataOnly(path,MAX_STR_LENGTH); - - - //filename -#ifdef SLS_RECEIVER_FUNCTION_LIST - strcpy(path,slsReceiverList->getFileName()); -#endif - socket->SendDataOnly(path,MAX_STR_LENGTH); - - - if (lockStatus==0) { - strcpy(socket->lastClientIP,socket->thisClientIP); - } - - return ret; - - -} - - - - - - -int slsReceiverFuncs::update_client() { - ret=OK; - socket->SendDataOnly(&ret,sizeof(ret)); - - return send_update(); -} - - - - - - - -int slsReceiverFuncs::exit_server() { - ret=GOODBYE; - socket->SendDataOnly(&ret,sizeof(ret)); - strcpy(mess,"closing server"); - socket->SendDataOnly(mess,sizeof(mess)); - cout << mess << endl; - return ret; -} - - - - - -int slsReceiverFuncs::exec_command() { - ret = OK; - char cmd[MAX_STR_LENGTH]; - char answer[MAX_STR_LENGTH]; - int sysret=0; - - // receive arguments - if(socket->ReceiveDataOnly(cmd,MAX_STR_LENGTH) < 0 ){ - sprintf(mess,"Error reading from socket\n"); - ret=FAIL; - } - - // execute action if the arguments correctly arrived - if (ret==OK) { -#ifdef VERBOSE - cout << "executing command " << cmd << endl; -#endif - if (lockStatus==0 || socket->differentClients==0) - sysret=system(cmd); - - //should be replaced by popen - if (sysret==0) { - strcpy(answer,"Succeeded\n"); - if (lockStatus==1 && socket->differentClients==1) - sprintf(answer,"Detector locked by %s\n", socket->lastClientIP); - } else { - strcpy(answer,"Failed\n"); - ret=FAIL; - } - } else - strcpy(answer,"Could not receive the command\n"); - - - // send answer - socket->SendDataOnly(&ret,sizeof(ret)); - if(socket->SendDataOnly(answer,MAX_STR_LENGTH) < 0){ - strcpy(mess,"Error writing to socket"); - ret=FAIL; - } - - //return ok/fail - return ret; -} - - - - - diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h deleted file mode 100644 index b7f2bef04..000000000 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h +++ /dev/null @@ -1,235 +0,0 @@ - /********************************************//** - * @file slsReceiver_funcs.h - * @short interface between receiver and client - ***********************************************/ -#ifndef RECEIVER_H -#define RECEIVER_H - - -#include "sls_detector_defs.h" -#include "receiver_defs.h" -#include "MySocketTCP.h" -#include "slsReceiverFunctionList.h" - - - -/** - *@short interface between receiver and client - */ - -class slsReceiverFuncs : private virtual slsDetectorDefs { - -public: - /** - * Constructor - * reads config file, creates socket, assigns function table - * @param argc from command line - * @param argv from command line - * @param succecc socket creation was successfull - */ - slsReceiverFuncs(int argc, char *argv[], int &success); - - - /** starts listening on the TCP port for client comminication */ - - void start(); - - /** Destructor */ - virtual ~slsReceiverFuncs(); - - /** Close all threaded Files and exit */ - void closeFile(int p); - - /** Static function to call closeFile */ - static void staticCloseFile(int p); - - /** - callback arguments are - filepath - filename - fileindex - data size - - return value is - 0 callback takes care of open,close,wrie file - 1 callback writes file, we have to open, close it - 2 we open, close, write file, callback does not do anything - - */ - - void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){slsReceiverList->registerCallBackStartAcquisition(func,arg);};; - - - /** - callback argument is - toatal farmes caught - - */ - - - void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){slsReceiverList->registerCallBackAcquisitionFinished(func,arg);}; - - - - /** - args to raw data ready callback are - framenum - datapointer - datasize in bytes - file descriptor - guidatapointer (NULL, no data required) - */ - - void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){slsReceiverList->registerCallBackRawDataReady(func,arg);}; - - - private: - /** assigns functions to the fnum enum */ - int function_table(); - - /** Decodes Function */ - int decode_function(); - - /** Unrecognized Function */ - int M_nofunc(); - - /** Set detector type */ - int set_detector_type(); - - /** Set File name without frame index, file index and extension */ - int set_file_name(); - - /** Set File path */ - int set_file_dir(); - - /** Set up UDP Details */ - int setup_udp(); - - /** Set File index */ - int set_file_index(); - - /** Set Frame index */ - int set_frame_index(); - - /** Start Receiver - starts listening to udp packets from detector */ - int start_receiver(); - - /** Stop Receiver - stops listening to udp packets from detector*/ - int stop_receiver(); - - /** Gets receiver status */ - int get_status(); - - /** Gets Total Frames Caught */ - int get_frames_caught(); - - /** Gets frame index for each acquisition */ - int get_frame_index(); - - /** Resets Total Frames Caught */ - int reset_frames_caught(); - - /** set short frame */ - int set_short_frame(); - - /** Reads Frame/ buffer */ - int read_frame(); - - /** gotthard specific read frame */ - int gotthard_read_frame(); - - /** moench specific read frame */ - int moench_read_frame(); - - /** Sets the receiver to send every nth frame to gui, or only upon gui request */ - int set_read_frequency(); - - /** Enable File Write*/ - int enable_file_write(); - - /** Get Version */ - int get_version(); - - /** set status to transmitting and - * when fifo is empty later, sets status to run_finished */ - int start_readout(); - - /** set acquisition period, frame number etc */ - int set_timer(); - - /** enable compression */ - int enable_compression(); - - /** set detector hostname */ - int set_detector_hostname(); - - /** set dynamic range */ - int set_dynamic_range(); - - /** enable overwrite */ - int enable_overwrite(); - - - //General Functions - /** Locks Receiver */ - int lock_receiver(); - - /** Set port */ - int set_port(); - - /** Get Last Client IP*/ - int get_last_client_ip(); - - /** Updates Client if different clients connect */ - int update_client(); - - /** Sends the updated parameters to client */ - int send_update(); - - /** Exit Receiver Server */ - int exit_server(); - - /** Execute command */ - int exec_command(); - - - - //private: - /** detector type */ - detectorType myDetectorType; - - /** slsReceiverFunctionList object */ - slsReceiverFunctionList *slsReceiverList; - - /** Number of functions */ - static const int numberOfFunctions = 256; - - /** Function List */ - int (slsReceiverFuncs::*flist[numberOfFunctions])(); - - /** Message */ - char mess[MAX_STR_LENGTH]; - - /** success/failure */ - int ret; - - /** Lock Status if server locked to a client */ - int lockStatus; - - /** Short frame */ - int shortFrame; - - /** Packets per frame */ - int packetsPerFrame; - - static int file_des; - static int socketDescriptor; - -//private: - protected: - /** Socket */ - MySocketTCP* socket; -}; - - -#endif diff --git a/slsDetectorSoftware/slsReceiver/sls_detector_defs.h b/slsDetectorSoftware/slsReceiver/sls_detector_defs.h deleted file mode 120000 index c5062e03f..000000000 --- a/slsDetectorSoftware/slsReceiver/sls_detector_defs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_defs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsReceiver/sls_detector_funcs.h b/slsDetectorSoftware/slsReceiver/sls_detector_funcs.h deleted file mode 120000 index 844b67129..000000000 --- a/slsDetectorSoftware/slsReceiver/sls_detector_funcs.h +++ /dev/null @@ -1 +0,0 @@ -../commonFiles/sls_detector_funcs.h \ No newline at end of file diff --git a/slsDetectorSoftware/slsReceiver/svnInfoReceiver.h b/slsDetectorSoftware/slsReceiver/svnInfoReceiver.h deleted file mode 100644 index 3675558b1..000000000 --- a/slsDetectorSoftware/slsReceiver/svnInfoReceiver.h +++ /dev/null @@ -1,11 +0,0 @@ -//#define SVNPATH "" -#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware/slsReceiver" -//#define SVNREPPATH "" -#define SVNREPUUID "951219d9-93cf-4727-9268-0efd64621fa3" -//#define SVNREV 0x746 -//#define SVNKIND "" -//#define SVNSCHED "" -#define SVNAUTH "l_maliakal_d" -#define SVNREV 0x746 -#define SVNDATE 0x20140304 -// diff --git a/slsDetectorSoftware/slsReceiver/svnInfoReceiverTmp.h b/slsDetectorSoftware/slsReceiver/svnInfoReceiverTmp.h deleted file mode 100644 index 58e48f497..000000000 --- a/slsDetectorSoftware/slsReceiver/svnInfoReceiverTmp.h +++ /dev/null @@ -1,11 +0,0 @@ -//#define SVNPATH "" -#define SVNURL "" -//#define SVNREPPATH "" -#define SVNREPUUID "" -//#define SVNREV "" -//#define SVNKIND "" -//#define SVNSCHED "" -#define SVNAUTH "" -#define SVNREV "" -#define SVNDATE "" -//