mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
creating a separate receiver
This commit is contained in:
parent
4958d198d1
commit
8788a060dd
@ -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)
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -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"
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
MySocketTCP.cxx
|
@ -1 +0,0 @@
|
||||
MySocketTCP.cxx
|
@ -1,53 +0,0 @@
|
||||
|
||||
//version 1.0, base development, Ian 19/01/09
|
||||
|
||||
|
||||
#include "MySocketTCP.h"
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
@ -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 <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <ifaddrs.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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 "<<endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set some fields in the serverAddress structure.
|
||||
serverAddress.sin_family = AF_INET;
|
||||
serverAddress.sin_port = htons(port_number);
|
||||
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
|
||||
if (string(ip)!=string("0.0.0.0")) {
|
||||
if (inet_pton(AF_INET, ip, &(serverAddress.sin_addr)))
|
||||
;
|
||||
else
|
||||
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
}
|
||||
|
||||
|
||||
// reuse port
|
||||
int val=1;
|
||||
if (setsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&val,sizeof(int)) == -1) {
|
||||
cerr << "setsockopt" << endl;
|
||||
socketDescriptor=-1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//increase buffer size if its udp
|
||||
val = SOCKET_BUFFER_SIZE;
|
||||
if((p == UDP) && (setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &val, sizeof(int)) == -1))
|
||||
{
|
||||
cerr << "WARNING:Could not set socket receive buffer size" << endl;
|
||||
//socketDescriptor=-1;
|
||||
//return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(bind(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||
cerr << "Can not bind socket "<< endl;
|
||||
socketDescriptor=-1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (getProtocol()==SOCK_STREAM)
|
||||
listen(socketDescriptor, DEFAULT_BACKLOG);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The destructor: disconnects and close the socket
|
||||
@short the destructor
|
||||
|
||||
*/
|
||||
~genericSocket(){ \
|
||||
Disconnect();
|
||||
if (socketDescriptor >= 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"<<endl;
|
||||
|
||||
if(file_des>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"<<endl;
|
||||
switch(errno) {
|
||||
case EWOULDBLOCK:
|
||||
printf("ewouldblock eagain\n");
|
||||
break;
|
||||
case EBADF:
|
||||
printf("ebadf\n");
|
||||
break;
|
||||
case ECONNABORTED:
|
||||
printf("econnaborted\n");
|
||||
break;
|
||||
case EFAULT:
|
||||
printf("efault\n");
|
||||
break;
|
||||
case EINTR:
|
||||
printf("eintr\n");
|
||||
break;
|
||||
case EINVAL:
|
||||
printf("einval\n");
|
||||
break;
|
||||
case EMFILE:
|
||||
printf("emfile\n");
|
||||
break;
|
||||
case ENFILE:
|
||||
printf("enfile\n");
|
||||
break;
|
||||
case ENOTSOCK:
|
||||
printf("enotsock\n");
|
||||
break;
|
||||
case EOPNOTSUPP:
|
||||
printf("eOPNOTSUPP\n");
|
||||
break;
|
||||
case ENOBUFS:
|
||||
printf("ENOBUFS\n");
|
||||
break;
|
||||
case ENOMEM:
|
||||
printf("ENOMEM\n");
|
||||
break;
|
||||
case ENOSR:
|
||||
printf("ENOSR\n");
|
||||
break;
|
||||
case EPROTO:
|
||||
printf("EPROTO\n");
|
||||
break;
|
||||
default:
|
||||
printf("unknown error\n");
|
||||
}
|
||||
socketDescriptor=-1;
|
||||
}
|
||||
else{
|
||||
inet_ntop(AF_INET, &(clientAddress.sin_addr), dummyClientIP, INET_ADDRSTRLEN);
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "client connected "<< file_des << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
// file_des = socketDescriptor;
|
||||
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "fd " << file_des << endl;
|
||||
#endif
|
||||
} else {
|
||||
if (socketDescriptor<=0)
|
||||
socketDescriptor = socket(AF_INET, getProtocol(),0);
|
||||
// SetTimeOut(10);
|
||||
if (socketDescriptor < 0){
|
||||
cerr << "Can not create socket "<<endl;
|
||||
file_des = socketDescriptor;
|
||||
} else {
|
||||
|
||||
if(connect(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||
cerr << "Can not connect to socket "<<endl;
|
||||
file_des = -1;
|
||||
} else{
|
||||
file_des = socketDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return file_des;
|
||||
}
|
||||
|
||||
uint16_t getPortNumber(){
|
||||
return ntohs(serverAddress.sin_port);
|
||||
}
|
||||
|
||||
int getFileDes(){return file_des;};
|
||||
|
||||
int getsocketDescriptor(){return socketDescriptor;};
|
||||
|
||||
/** @short free connection */
|
||||
void Disconnect(){
|
||||
if (protocol==UDP){
|
||||
close(socketDescriptor);
|
||||
socketDescriptor=-1;
|
||||
}
|
||||
else{
|
||||
if(file_des>=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;i<packets_per_frame;i++){
|
||||
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;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "sent "<< total_sent << " Bytes" << endl;
|
||||
#endif
|
||||
if (total_sent>0)
|
||||
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
|
Binary file not shown.
@ -1,31 +0,0 @@
|
||||
|
||||
//version 1.0, base development ij 19/01/09
|
||||
|
||||
#include <iostream>
|
||||
#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 :"<<sock->ReceiveDataAndKeepConnection(data,23000)<<endl;
|
||||
cout<<"\tReceived :"<<sock->ReceiveData(data,32200)<<endl;
|
||||
cout<<"\tReceived :"<<sock->ReceiveData(data,33300)<<endl;
|
||||
|
||||
|
||||
|
||||
cout<<"\tReceived :"<<sock->ReceiveData(data,30000)<<endl;
|
||||
|
||||
|
||||
cout<<"\tReceived :"<<sock->ReceiveData(data,3222)<<endl;
|
||||
|
||||
delete sock;
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
@ -1,40 +0,0 @@
|
||||
|
||||
//version 1.0, base development ij 19/01/09
|
||||
|
||||
#include <iostream>
|
||||
#include "MySocketTCP.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
||||
if(argc!=2){
|
||||
cout<<"Usage: send ip_addess/hostName"<<endl;
|
||||
return 1;
|
||||
}
|
||||
cout<<"rec function must be first called."<<endl;
|
||||
|
||||
char ip_address[200];
|
||||
sprintf(ip_address,"%s",argv[1]);
|
||||
unsigned short int portnum = 1952;
|
||||
|
||||
|
||||
char data[50000];
|
||||
int length=50000;
|
||||
|
||||
MySocketTCP* sock = new MySocketTCP(ip_address,portnum);
|
||||
|
||||
cout<<"\tSending :"<<sock->SendDataAndKeepConnection(data,2000)<<endl;
|
||||
cout<<"\tSending :"<<sock->SendData(data,2200)<<endl;
|
||||
cout<<"\tSending :"<<sock->SendData(data,1200)<<endl;
|
||||
|
||||
|
||||
cout<<"\tSending :"<<sock->SendData(data,25000)<<endl;
|
||||
|
||||
cout<<"\tSending :"<<sock->SendData(data,222)<<endl;
|
||||
|
||||
delete sock;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
@ -7,10 +7,9 @@
|
||||
#define __cplusplus
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
//#include <stdint.h>
|
||||
#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; /**<is the chip register (e.g. output analogue buffer enable)
|
||||
int reg; /**<is the chip register (e.g. output analogue buffer enable)
|
||||
\see ::chipRegisterBit */
|
||||
int *chanregs; /**< is the pointer to the array of the channel registers
|
||||
int *chanregs; /**< is the pointer to the array of the channel registers
|
||||
\see ::channelRegisterBit */
|
||||
} sls_detector_chip;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
@short structure for a detector module
|
||||
|
||||
should not be used by unexperienced users
|
||||
|
||||
|
||||
\see :: moduleRegisterBit ::chipRegisterBit :channelRegisterBit
|
||||
|
||||
@li reg is the module register (e.g. dynamic range? see moduleRegisterBit)
|
||||
@ -130,21 +123,21 @@ typedef struct {
|
||||
int nchip; /**< is the number of chips on the module */
|
||||
int ndac; /**< is the number of dacs on the module */
|
||||
int nadc; /**< is the number of adcs on the module */
|
||||
int reg; /**< is the module register (e.g. dynamic range?)
|
||||
int reg; /**< is the module register (e.g. dynamic range?)
|
||||
\see moduleRegisterBit */
|
||||
dacs_t *dacs; /**< is the pointer to the array of the dac values (in V) */
|
||||
dacs_t *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/
|
||||
int *chipregs; /**< is the pointer to the array of the chip registers
|
||||
int *chipregs; /**< is the pointer to the array of the chip registers
|
||||
\see ::chipRegisterBit */
|
||||
int *chanregs; /**< is the pointer to the array of the channel registers
|
||||
int *chanregs; /**< is the pointer to the array of the channel registers
|
||||
\see ::channelRegisterBit */
|
||||
double gain; /**< is the module gain (V/keV) */
|
||||
double offset; /**< is the module offset (V) */
|
||||
} sls_detector_module;
|
||||
|
||||
/**
|
||||
/**
|
||||
@short structure for a region of interest
|
||||
|
||||
|
||||
xmin,xmax,ymin,ymax define the limits of the region
|
||||
*/
|
||||
typedef struct {
|
||||
@ -164,20 +157,7 @@ typedef struct {
|
||||
/* } iarray ; */
|
||||
|
||||
|
||||
/**
|
||||
Type of the detector
|
||||
*/
|
||||
enum detectorType {
|
||||
GET_DETECTOR_TYPE=-1, /**< the detector will return its type */
|
||||
GENERIC, /**< generic sls detector */
|
||||
MYTHEN, /**< mythen */
|
||||
PILATUS, /**< pilatus */
|
||||
EIGER, /**< eiger */
|
||||
GOTTHARD, /**< gotthard */
|
||||
PICASSO, /**< picasso */
|
||||
AGIPD, /**< agipd */
|
||||
MOENCH /**< moench */
|
||||
};
|
||||
|
||||
|
||||
/* /\** */
|
||||
/* Communication protocol (normally TCP) */
|
||||
@ -187,7 +167,7 @@ enum detectorType {
|
||||
/* UDP /\**< UDP *\/ */
|
||||
/* }; */
|
||||
|
||||
/**
|
||||
/**
|
||||
network parameters
|
||||
*/
|
||||
|
||||
@ -211,7 +191,7 @@ enum {GET_ONLINE_FLAG=-1, /**< returns wether the detector is in online or offli
|
||||
ONLINE_FLAG =1/**< detector in online state (i.e. communication to the detector updating the local structure) */
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
flags to get (or set) the size of the detector
|
||||
*/
|
||||
enum numberOf {
|
||||
@ -225,7 +205,7 @@ enum numberOf {
|
||||
NCHIPSY /**<number of chips in Y direction */
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
dimension indexes
|
||||
*/
|
||||
enum dimension {
|
||||
@ -234,17 +214,7 @@ enum dimension {
|
||||
Z=2 /**< Z dimension */
|
||||
};
|
||||
|
||||
/**
|
||||
return values
|
||||
*/
|
||||
enum {
|
||||
OK, /**< function succeeded */
|
||||
FAIL, /**< function failed */
|
||||
FINISHED, /**< acquisition finished */
|
||||
FORCE_UPDATE
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
enable/disable flags
|
||||
*/
|
||||
enum {
|
||||
@ -253,7 +223,7 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
use of the external signals
|
||||
*/
|
||||
enum externalSignalFlag {
|
||||
@ -276,7 +246,7 @@ enum externalSignalFlag {
|
||||
MASTER_SLAVE_SYNCHRONIZATION /**< reserved for master/slave synchronization in multi detector systems */
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
communication mode using external signals
|
||||
*/
|
||||
enum externalCommunicationMode{
|
||||
@ -287,7 +257,7 @@ enum externalCommunicationMode{
|
||||
GATE_FIX_NUMBER, /**< gated and reads out after a fixed number of gates */
|
||||
GATE_WITH_START_TRIGGER /**< gated with start trigger */
|
||||
};
|
||||
/**
|
||||
/**
|
||||
detector IDs/versions
|
||||
*/
|
||||
enum idMode{
|
||||
@ -299,7 +269,7 @@ enum idMode{
|
||||
THIS_SOFTWARE_VERSION, /**<return this software version */
|
||||
RECEIVER_VERSION /**<return receiver software version */
|
||||
};
|
||||
/**
|
||||
/**
|
||||
detector digital test modes
|
||||
*/
|
||||
enum digitalTestMode {
|
||||
@ -311,7 +281,7 @@ enum digitalTestMode {
|
||||
DETECTOR_SOFTWARE_TEST, /**< test detector system software */
|
||||
DIGITAL_BIT_TEST /**< gotthard digital bit test */
|
||||
};
|
||||
/**
|
||||
/**
|
||||
detector analogue test modes
|
||||
*/
|
||||
enum analogTestMode {
|
||||
@ -319,7 +289,7 @@ enum analogTestMode {
|
||||
MY_ANALOG_TEST_MODE /**< other possible test modes */
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
detector dacs indexes
|
||||
*/
|
||||
enum dacIndex {
|
||||
@ -339,12 +309,12 @@ enum dacIndex {
|
||||
VIO_POT, /**< chiptest board power supply va */
|
||||
HV_POT, /**< gotthard, chiptest board high voltage */
|
||||
G_VREF_DS, /**< gotthard */
|
||||
G_VCASCN_PB, /**< gotthard */
|
||||
G_VCASCP_PB, /**< gotthard */
|
||||
G_VOUT_CM, /**< gotthard */
|
||||
G_VCASC_OUT, /**< gotthard */
|
||||
G_VCASCN_PB, /**< gotthard */
|
||||
G_VCASCP_PB, /**< gotthard */
|
||||
G_VOUT_CM, /**< gotthard */
|
||||
G_VCASC_OUT, /**< gotthard */
|
||||
G_VIN_CM, /**< gotthard */
|
||||
G_VREF_COMP, /**< gotthard */
|
||||
G_VREF_COMP, /**< gotthard */
|
||||
G_IB_TESTC, /**< gotthard */
|
||||
V_DAC0, /**< moench */
|
||||
V_DAC1, /**< moench */
|
||||
@ -372,10 +342,10 @@ enum dacIndex {
|
||||
E_Vis /**< eiger */
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
detector settings indexes
|
||||
*/
|
||||
enum detectorSettings{
|
||||
enum detectorSettings{
|
||||
GET_SETTINGS=-1, /**< return current detector settings */
|
||||
STANDARD, /**< standard settings */
|
||||
FAST, /**< fast settings */
|
||||
@ -388,7 +358,7 @@ enum detectorSettings{
|
||||
UNDEFINED, /**< undefined or custom settings */
|
||||
UNINITIALIZED /**< uninitialiazed (status at startup) */
|
||||
};
|
||||
/**
|
||||
/**
|
||||
meaning of the channel register bits
|
||||
\see ::sls_detector_channel
|
||||
*/
|
||||
@ -400,7 +370,7 @@ enum channelRegisterBit {
|
||||
};
|
||||
|
||||
#define TRIMBITMASK 0x3f
|
||||
/**
|
||||
/**
|
||||
meaning of the chip register bits
|
||||
\see ::sls_detector_chip
|
||||
*/
|
||||
@ -408,7 +378,7 @@ enum chipRegisterBit {
|
||||
ENABLE_ANALOG_OUTPUT=0x1, /**< mask of the analogue output enable bit */
|
||||
CHIP_OUTPUT_WIDTH=0x2 /**< mask of the chip output width */
|
||||
};
|
||||
/**
|
||||
/**
|
||||
meaning of the module register bits
|
||||
*/
|
||||
enum moduleRegisterBit {
|
||||
@ -416,25 +386,8 @@ enum moduleRegisterBit {
|
||||
MODULE_OUTPUT_WIDTH /**< possibly module dynamic range */
|
||||
};
|
||||
|
||||
/**
|
||||
indexes for the acquisition timers
|
||||
*/
|
||||
enum timerIndex {
|
||||
FRAME_NUMBER, /**< number of real time frames: total number of acquisitions is number or frames*number of cycles */
|
||||
ACQUISITION_TIME, /**< exposure time */
|
||||
FRAME_PERIOD, /**< period between exposures */
|
||||
DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */
|
||||
GATES_NUMBER, /**< number of gates per frame (in gated mode) */
|
||||
PROBES_NUMBER, /**< number of probe types in pump-probe mode */
|
||||
CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */
|
||||
ACTUAL_TIME, /**< Actual time of the detector's internal timer */
|
||||
MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) */
|
||||
|
||||
PROGRESS, /**< fraction of measurement elapsed - only get! */
|
||||
MEASUREMENTS_NUMBER
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
important speed parameters
|
||||
*/
|
||||
enum speedVariable {
|
||||
@ -447,19 +400,8 @@ enum speedVariable {
|
||||
OVERSAMPLING /**< oversampling for analog detectors */
|
||||
};
|
||||
|
||||
/**
|
||||
staus mask
|
||||
*/
|
||||
enum runStatus {
|
||||
IDLE, /**< detector ready to start acquisition - no data in memory */
|
||||
ERROR, /**< error i.e. normally fifo full */
|
||||
WAITING, /**< waiting for trigger or gate signal */
|
||||
RUN_FINISHED, /**< acquisition not running but data in memory */
|
||||
TRANSMITTING, /**< acquisition running and data in memory */
|
||||
RUNNING /**< acquisition running, no data in memory */
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
readout flags
|
||||
*/
|
||||
enum readOutFlags {
|
||||
@ -473,7 +415,7 @@ enum readOutFlags {
|
||||
TOT_MODE=0x2000,/**<pump-probe mode */
|
||||
CONTINOUS_RO=0x4000/**<pump-probe mode */
|
||||
};
|
||||
/**
|
||||
/**
|
||||
trimming modes
|
||||
*/
|
||||
enum trimMode {
|
||||
@ -483,7 +425,7 @@ enum trimMode {
|
||||
FIXEDSETTINGS_TRIMMING,/**< trim without optimizing the threshold and the trimbit size */
|
||||
OFFLINE_TRIMMING /**< trimming is performed offline */
|
||||
};
|
||||
/**
|
||||
/**
|
||||
data correction flags
|
||||
*/
|
||||
enum correctionFlags {
|
||||
@ -498,10 +440,10 @@ enum correctionFlags {
|
||||
};
|
||||
/** port type */
|
||||
enum portType {
|
||||
CONTROL_PORT, /**< control port */
|
||||
CONTROL_PORT, /**< control port */
|
||||
STOP_PORT, /**<stop port */
|
||||
DATA_PORT /**< receiver tcp port with client*/
|
||||
};
|
||||
};
|
||||
|
||||
/** hierarchy in multi-detector structure, if any */
|
||||
enum masterFlags {
|
||||
@ -509,7 +451,7 @@ enum masterFlags {
|
||||
NO_MASTER, /**< no master/slave hierarchy defined */
|
||||
IS_MASTER, /**<is master */
|
||||
IS_SLAVE /**< is slave */
|
||||
};
|
||||
};
|
||||
|
||||
/** synchronization in a multidetector structure, if any */
|
||||
enum synchronizationMode {
|
||||
@ -550,7 +492,7 @@ enum angleConversionParameter {
|
||||
MOVE_FLAG, /**< wether the detector moves with the motor or not in a multi detector system */
|
||||
SAMPLE_X, /**< sample displacement in the beam direction */
|
||||
SAMPLE_Y /**< sample displacement orthogonal to the beam */
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -575,6 +517,7 @@ enum angleConversionParameter {
|
||||
|
||||
#ifndef MYROOT
|
||||
#include "sls_detector_funcs.h"
|
||||
//#include "sls_receiver_funcs.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -21,9 +21,7 @@ enum {
|
||||
F_SET_EXTERNAL_SIGNAL_FLAG, /**< set/get flag for external signal */
|
||||
F_SET_EXTERNAL_COMMUNICATION_MODE, /**< set/get external communication mode (obsolete) */
|
||||
|
||||
|
||||
// Tests and identification
|
||||
|
||||
F_GET_ID, /**< get detector id of version */
|
||||
F_DIGITAL_TEST, /**< digital test of the detector */
|
||||
F_ANALOG_TEST, /**<analog test of the detector */
|
||||
@ -38,7 +36,6 @@ enum {
|
||||
F_WRITE_MEMORY, /**< write to memory */
|
||||
F_READ_MEMORY, /**< read memory */
|
||||
|
||||
|
||||
F_SET_CHANNEL, /**< initialize channel */
|
||||
F_GET_CHANNEL, /**< get channel register */
|
||||
F_SET_ALL_CHANNELS, /**< initialize all channels */
|
||||
@ -51,12 +48,10 @@ enum {
|
||||
F_GET_MODULE, /**< get module status */
|
||||
F_SET_ALL_MODULES, /**< initialize all modules */
|
||||
|
||||
|
||||
F_SET_SETTINGS, /**< set detector settings */
|
||||
F_GET_THRESHOLD_ENERGY, /**< get detector threshold (in eV) */
|
||||
F_SET_THRESHOLD_ENERGY, /**< set detector threshold (in eV) */
|
||||
|
||||
|
||||
// Acquisition functions
|
||||
F_START_ACQUISITION, /**< start acquisition */
|
||||
F_STOP_ACQUISITION, /**< stop acquisition */
|
||||
@ -70,77 +65,30 @@ enum {
|
||||
F_SET_TIMER, /**< set/get timer value */
|
||||
F_GET_TIME_LEFT, /**< get current value of the timer (time left) */
|
||||
|
||||
|
||||
|
||||
F_SET_DYNAMIC_RANGE, /**< set/get detector dynamic range */
|
||||
F_SET_READOUT_FLAGS, /**< set/get readout flags */
|
||||
F_SET_ROI, /**< set/get region of interest */
|
||||
|
||||
F_SET_SPEED, /**< set/get readout speed parameters */
|
||||
|
||||
//Trimming
|
||||
F_EXECUTE_TRIMMING, /**< execute trimming */
|
||||
|
||||
F_EXIT_SERVER, /**< turn off detector server */
|
||||
|
||||
F_LOCK_SERVER, /**< Locks/Unlocks server communication to the given client */
|
||||
|
||||
F_GET_LAST_CLIENT_IP, /**< returns the IP of the client last connected to the detector */
|
||||
|
||||
F_SET_PORT, /**< Changes communication port of the server */
|
||||
|
||||
F_UPDATE_CLIENT, /**< Returns all the important parameters to update the shared memory of the client */
|
||||
|
||||
F_CONFIGURE_MAC, /**< Configures MAC for Gotthard readout */
|
||||
|
||||
F_LOAD_IMAGE, /**< Loads Dark/Gain image to the Gotthard detector */
|
||||
|
||||
// multi detector structures
|
||||
|
||||
F_SET_MASTER, /**< sets master/slave flag for multi detector structures */
|
||||
|
||||
F_SET_SYNCHRONIZATION_MODE, /**< sets master/slave synchronization mode for multidetector structures */
|
||||
|
||||
F_READ_COUNTER_BLOCK, /**< reads the counter block memory for gotthard */
|
||||
|
||||
F_RESET_COUNTER_BLOCK, /**< resets the counter block memory for gotthard */
|
||||
F_CALIBRATE_PEDESTAL /**< starts acquistion, calibrates pedestal and write back to fpga */
|
||||
|
||||
|
||||
//receiver
|
||||
|
||||
F_SET_FILE_PATH, /**< sets receiver file directory */
|
||||
|
||||
F_SET_FILE_NAME, /**< sets receiver file name */
|
||||
|
||||
F_SET_FILE_INDEX, /**< sets receiver file index */
|
||||
|
||||
F_START_RECEIVER, /**< starts the receiver listening mode */
|
||||
|
||||
F_STOP_RECEIVER, /**< stops the receiver listening mode */
|
||||
|
||||
F_GET_RECEIVER_STATUS, /**< gets the status of receiver listening mode */
|
||||
|
||||
F_GET_FRAMES_CAUGHT, /**< gets the number of frames caught by receiver */
|
||||
|
||||
F_GET_FRAME_INDEX, /**< gets the frame index */
|
||||
|
||||
F_RESET_FRAMES_CAUGHT, /**< resets the frames caught */
|
||||
|
||||
F_SETUP_UDP, /**< sets the receiver udp connection and returns receiver mac address */
|
||||
|
||||
F_ENABLE_FILE_WRITE, /**< sets the receiver file write */
|
||||
|
||||
F_SET_FRAME_INDEX, /**< sets the receiver frame index */
|
||||
|
||||
F_CALIBRATE_PEDESTAL, /**< starts acquistion, calibrates pedestal and write back to fpga */
|
||||
|
||||
F_READ_RECEIVER_FREQUENCY, /**< sets the frequency of receiver sending frames to gui */
|
||||
|
||||
F_ENABLE_COMPRESSION, /**< enable compression in receiver */
|
||||
|
||||
F_SET_DETECTOR_HOSTNAME, /**< set detector hostname in receiver */
|
||||
|
||||
F_ENABLE_OVERWRITE /**< set overwrite flag in receiver */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
};
|
||||
|
@ -12,9 +12,10 @@
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//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
|
||||
|
Binary file not shown.
BIN
slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer
Executable file
BIN
slsDetectorSoftware/gotthardDetectorServer/gotthardVirtualServer
Executable file
Binary file not shown.
1
slsDetectorSoftware/gotthardDetectorServer/sls_receiver_defs.h
Symbolic link
1
slsDetectorSoftware/gotthardDetectorServer/sls_receiver_defs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../slsReceiverSoftware/includes/sls_receiver_defs.h
|
1
slsDetectorSoftware/gotthardDetectorServer/sls_receiver_funcs.h
Symbolic link
1
slsDetectorSoftware/gotthardDetectorServer/sls_receiver_funcs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../slsReceiverSoftware/includes/sls_receiver_funcs.h
|
@ -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)
|
||||
|
||||
|
@ -12,9 +12,10 @@
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
BIN
slsDetectorSoftware/moenchDetectorServer/moenchVirtualServer
Executable file
BIN
slsDetectorSoftware/moenchDetectorServer/moenchVirtualServer
Executable file
Binary file not shown.
@ -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) {
|
||||
|
1
slsDetectorSoftware/moenchDetectorServer/sls_receiver_defs.h
Symbolic link
1
slsDetectorSoftware/moenchDetectorServer/sls_receiver_defs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../slsReceiverSoftware/includes/sls_receiver_defs.h
|
1
slsDetectorSoftware/moenchDetectorServer/sls_receiver_funcs.h
Symbolic link
1
slsDetectorSoftware/moenchDetectorServer/sls_receiver_funcs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../slsReceiverSoftware/includes/sls_receiver_funcs.h
|
@ -16,9 +16,10 @@
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//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
|
||||
|
BIN
slsDetectorSoftware/mythenDetectorServer/mythenVirtualServer
Executable file
BIN
slsDetectorSoftware/mythenDetectorServer/mythenVirtualServer
Executable file
Binary file not shown.
@ -39,5 +39,5 @@
|
||||
|
||||
|
||||
#define THIS_SOFTWARE_VERSION 0x20120419
|
||||
#define THIS_REVISION "$Rev$"
|
||||
#define THIS_REVISION "$Rev: 379 $"
|
||||
#endif
|
||||
|
1
slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h
Symbolic link
1
slsDetectorSoftware/mythenDetectorServer/sls_receiver_defs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../slsReceiverSoftware/includes/sls_receiver_defs.h
|
1
slsDetectorSoftware/mythenDetectorServer/sls_receiver_funcs.h
Symbolic link
1
slsDetectorSoftware/mythenDetectorServer/sls_receiver_funcs.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../slsReceiverSoftware/includes/sls_receiver_funcs.h
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
@ -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){
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="0.1592123610">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1592123610" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration buildProperties="" description="" id="0.1592123610" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.1592123610." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2043853512" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.2043853512.1428560959" name=""/>
|
||||
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1228246701" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.891716849" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1775606856" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.98773194" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.41809089" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.817253715" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1467561536" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.210475521" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="slsReceiver.null.670781774" name="slsReceiver"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="0.1592123610">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
</cproject>
|
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Receiver</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>newMythenSoftware</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -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
|
||||
|
||||
|
||||
|
@ -1,195 +0,0 @@
|
||||
/**
|
||||
* @file RestHelper.h
|
||||
* @author Leonardo Sala <leonardo.sala@psi.ch>
|
||||
* @date Tue Mar 25 09:28:19 2014
|
||||
*
|
||||
* @brief
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Poco/Net/HTTPClientSession.h>
|
||||
#include <Poco/Net/HTTPRequest.h>
|
||||
#include <Poco/Net/HTTPResponse.h>
|
||||
#include <Poco/StreamCopier.h>
|
||||
#include <Poco/Path.h>
|
||||
#include <Poco/URI.h>
|
||||
#include <Poco/Exception.h>
|
||||
#include <Poco/Timespan.h>
|
||||
|
||||
#include "JsonBox/Value.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
/// 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(n<N_CONNECTION_TRIES){
|
||||
try {
|
||||
if (request_body == "")
|
||||
session->sendRequest( (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;
|
||||
}
|
||||
|
||||
};
|
@ -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<EFBFBD>m, hedstrom@kjellkod.cc */
|
||||
|
||||
#ifndef CIRCULARFIFO_H_
|
||||
#define CIRCULARFIFO_H_
|
||||
|
||||
//#include "sls_detector_defs.h"
|
||||
#include <semaphore.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
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<typename Element>
|
||||
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 <Element*> array;
|
||||
volatile unsigned int head; // output index
|
||||
unsigned int Capacity;
|
||||
sem_t free_mutex;
|
||||
|
||||
unsigned int increment(unsigned int idx_) const;
|
||||
};
|
||||
|
||||
template<typename Element>
|
||||
int CircularFifo<Element>::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<typename Element>
|
||||
bool CircularFifo<Element>::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<typename Element>
|
||||
bool CircularFifo<Element>::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<typename Element>
|
||||
bool CircularFifo<Element>::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<typename Element>
|
||||
bool CircularFifo<Element>::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<typename Element>
|
||||
unsigned int CircularFifo<Element>::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 <vector>
|
||||
using namespace std;
|
||||
|
||||
template<typename Element>
|
||||
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 <Element*> array;
|
||||
unsigned int Capacity;
|
||||
|
||||
std::atomic<unsigned int> tail; // input index
|
||||
std::atomic<unsigned int> head; // output index
|
||||
|
||||
unsigned int increment(unsigned int idx_) const;
|
||||
};
|
||||
|
||||
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::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<typename Element>
|
||||
bool CircularFifo<Element>::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<typename Element>
|
||||
bool CircularFifo<Element>::wasEmpty() const
|
||||
{
|
||||
return (head.load() == tail.load());
|
||||
}
|
||||
|
||||
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::wasFull() const
|
||||
{
|
||||
const auto nextTail = increment(tail.load());
|
||||
return (nextTail == head.load());
|
||||
}
|
||||
|
||||
template<typename Element>
|
||||
bool CircularFifo<Element>::isLockFree() const
|
||||
{
|
||||
return (tail.is_lock_free() && head.is_lock_free());
|
||||
}
|
||||
|
||||
|
||||
template<typename Element>
|
||||
unsigned int CircularFifo<Element>::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 */
|
@ -1,254 +0,0 @@
|
||||
/*
|
||||
* eigerReceiver.cpp
|
||||
*
|
||||
* Created on: Mar 11, 2014
|
||||
* Author: billich
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#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 " <<status);
|
||||
return(status);
|
||||
}
|
||||
|
||||
char *setFileName(const char c[]) {
|
||||
DEBUG("setFileName() called with " << c <<".");
|
||||
scan_config.fileName = c;
|
||||
return(this->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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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 */
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* eigerReceiver.cpp
|
||||
*
|
||||
* Created on: Mar 11, 2014
|
||||
* Author: billich
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* eigerReceiverTest.cpp
|
||||
|
||||
*
|
||||
* Created on: Mar 11, 2014
|
||||
* Author: billich
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#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 <<prefix<< "start EigerReceiver tests" << endl;
|
||||
|
||||
|
||||
EigerReceiver *receiver = EigerReceiver::create();
|
||||
|
||||
int status = receiver->getStatus();
|
||||
char *c0 = receiver->getDetectorHostname();
|
||||
if (c0 == NULL) {
|
||||
cout <<prefix<< "getDetectorHostname() returned NULL, as expected before initialization." << endl;
|
||||
}
|
||||
delete[] c0;
|
||||
|
||||
cout <<prefix<< "initialize 4 times - only the second should work" << endl;
|
||||
receiver->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 <<prefix<< "got detector hostname " << c6 << " after initialization;" <<endl<<endl;
|
||||
delete[] c6;
|
||||
|
||||
cout <<prefix<< "try get*() methods before set*() - expect default values" <<endl;
|
||||
char *c1 = receiver->getFileName();
|
||||
cout <<prefix<< "got file name <" << c1 <<">." << endl;
|
||||
delete[] c1;
|
||||
|
||||
char *c2 = receiver->getFilePath();
|
||||
cout <<prefix<< "got path name <" << c2 <<">." << endl;
|
||||
delete[]c2;
|
||||
|
||||
int range = receiver->getDynamicRange();
|
||||
cout <<prefix<< "got dynamic range " << range << endl;
|
||||
|
||||
int tag = receiver->getScanTag();
|
||||
cout <<prefix<< "got scan tag " << tag << endl;
|
||||
cout << endl;
|
||||
|
||||
char *c3 = receiver->setFileName( "some_other_name");
|
||||
cout <<prefix<< "got file name <" << c3 << "> after setting to <some_other_name>" << endl << endl;
|
||||
delete[] c3;
|
||||
|
||||
char *c4 = receiver->setFilePath( "some_other_path");
|
||||
cout <<prefix<< "got file path <" << c4 << "> after setting to <some_other_path>" << endl << endl;
|
||||
delete[] c4;
|
||||
|
||||
range = receiver->setDynamicRange(8);
|
||||
cout <<prefix<< "got dynamic range " << range << " after setting it to 8." << endl << endl;
|
||||
|
||||
tag = receiver->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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
dataport 1955
|
@ -1,72 +0,0 @@
|
||||
#ifndef RECEIVER_DEFS_H
|
||||
#define RECEIVER_DEFS_H
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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
|
@ -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 <iostream>
|
||||
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;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 <TTree.h>
|
||||
#include <TFile.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
|
||||
/**
|
||||
* @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<char>* fifo;
|
||||
|
||||
/** circular fifo to store addresses of data already written and ready to be resued*/
|
||||
CircularFifo<char>* 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<uint16_t> *singlePhotonDet[MAX_NUM_WRITER_THREADS];
|
||||
slsReceiverData<uint16_t> *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
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1,78 +0,0 @@
|
||||
|
||||
#ifndef SLS_RECEIVER_USERS_H
|
||||
#define SLS_RECEIVER_USERS_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
File diff suppressed because it is too large
Load Diff
@ -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
|
@ -1 +0,0 @@
|
||||
../commonFiles/sls_detector_defs.h
|
@ -1 +0,0 @@
|
||||
../commonFiles/sls_detector_funcs.h
|
@ -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
|
||||
//
|
@ -1,11 +0,0 @@
|
||||
//#define SVNPATH ""
|
||||
#define SVNURL ""
|
||||
//#define SVNREPPATH ""
|
||||
#define SVNREPUUID ""
|
||||
//#define SVNREV ""
|
||||
//#define SVNKIND ""
|
||||
//#define SVNSCHED ""
|
||||
#define SVNAUTH ""
|
||||
#define SVNREV ""
|
||||
#define SVNDATE ""
|
||||
//
|
Loading…
x
Reference in New Issue
Block a user