moved .h into include. Second round of cleaning

This commit is contained in:
sala 2014-09-10 09:39:11 +02:00
parent 3d08fc3e58
commit 59fc6fbaf8
19 changed files with 25 additions and 936 deletions

View File

@ -1,5 +1,6 @@
*~
*.o
build
GPATH
GRTAGS
GSYMS

View File

@ -5,6 +5,8 @@ DESTDIR ?= ../bin
LIBDIR ?= $(DESTDIR)
DOCDIR ?= docs
SRCDIR = src
TESTDIR = test
BUILDDIR = build
PROGS = $(DESTDIR)/slsReceiver
@ -13,24 +15,24 @@ CFLAGS= -g -DC_ONLY -fPIC
DFLAGS= -g -DDACS_INT -DSLS_RECEIVER_UDP_FUNCTIONS
INCLUDES?= -Iinclude -IMySocketTCP -I../slsDetectorCalibration -I$(ASM)
INCLUDES?= -Iinclude -I../slsDetectorCalibration -I$(ASM)
#-I$(SRCDIR)Interface
SRC_CLNT = $(SRCDIR)/MySocketTCP.cpp $(SRCDIR)/UDPInterface.cpp $(SRCDIR)/UDPBaseImplementation.cpp $(SRCDIR)/UDPStandardImplementation.cpp $(SRCDIR)/slsReceiverTCPIPInterface.cpp $(SRCDIR)/slsReceiver.cpp $(SRCDIR)/slsReceiverUsers.cpp $(SRCDIR)/utilities.cpp
MAIN_SRC = $(SRCDIR)/main.cpp
SRC_CLNT = MySocketTCP.cpp UDPInterface.cpp UDPBaseImplementation.cpp UDPStandardImplementation.cpp slsReceiverTCPIPInterface.cpp slsReceiver.cpp slsReceiverUsers.cpp utilities.cpp
MAIN_SRC = main.cpp
OBJS=$(SRC_CLNT:.cpp=.o)
OBJS=$(SRC_CLNT:%.cpp=$(BUILDDIR)/%.o)
.PHONY: all intdoc package eigerReceiver clean
all: lib $(SRC_CLNT) receiver
all: lib receiver
intdoc: $(SRC_H) $(SRC_CLNT)
doxygen doxy.config
%.o : %.cpp Makefile
$(BUILDDIR)/%.o : $(SRCDIR)/%.cpp Makefile
ifeq ($(ROOTSLS),yes)
$(CXX) -DROOTSLS -o $@ -c $< $(INCLUDES) $(DFLAGS) $(ROOTFLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/ #$(FLAGS)
else
@ -53,22 +55,30 @@ $(DESTDIR)/libSlsReceiver.a: $(OBJS)
$(DESTDIR)/slsReceiver: lib
$(CXX) -o $@ $(MAIN_SRC) $(FLAGS) $(INCLUDES) $(CLAGS) $(LIBS) $(LDFLAGRXR) -fPIC
$(CXX) -o $@ $(SRCDIR)/$(MAIN_SRC) $(FLAGS) $(INCLUDES) $(CLAGS) $(LIBS) $(LDFLAGRXR) -fPIC
#$(EIGERFLAGS)
# Stand-alone Mysocket tests
mysocket_test:
g++ -c $(SRCDIR)/MySocketTCP.cpp -I include
g++ -o rec MySocketTCP.o $(SRCDIR)/rec.cxx -I include
g++ -o send MySocketTCP.o $(SRCDIR)/send.cxx -I include
g++ -o $(TESTDIR)/MySocketTCP.o -c $(SRCDIR)/MySocketTCP.cpp -I include
g++ -o $(TESTDIR)/rec $(TESTDIR)/MySocketTCP.o $(TESTDIR)/rec.cxx -I include
g++ -o $(TESTDIR)/send $(TESTDIR)/MySocketTCP.o $(TESTDIR)/send.cxx -I include
clean:
rm -rf $(OBJS)
clean: buildclean
rm $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so
rm $(PROGS)
rm $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so
cd
ifeq (,$(wildcard $(TESTDIR/rec)))
make testclean
endif
buildclean:
rm -rf $(OBJS)
testclean:
cd $(TESTDIR) && rm *.o rec send
#-------------------------------------------------------------------------------

View File

@ -1,66 +0,0 @@
include ../../Makefile.include
DESTDIR ?= ../../bin
LIBDIR ?= $(DESTDIR)
PROGS = $(DESTDIR)/slsReceiver
CFLAGS += -DSLS_RECEIVER_UDP_FUNCTIONS -O3
CPPFLAGS = ${CFLAGS} # for MAC
LDFLAGRXR ?= -L$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -lpthread
LDFLAGRXR += -lm -lstdc++
INCLUDES ?= -I ../MySocketTCP -I ../slsDetectorCalibration -I ../includes/ -I eigerReceiver -I .
SRC_CLNT = main.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
mkdir -p $(DESTDIR)
$(CXX) -static -o $@ $(SRC_CLNT) $(FLAGS) $(INCLUDES) $(CLAGS) $(LIBS) $(LDFLAGRXR)
$(DESTDIR)/slsReceiver: lib
$(CXX) -o $@ $(SRC_CLNT) $(FLAGS) $(INCLUDES) $(CLAGS) $(LIBS) $(LDFLAGRXR) -fPIC
#$(EIGERFLAGS)
#ifeq ($(EIGERSLS), yes)
#eigerReceiver:
# $(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiverTest.o eigerReceiver/eigerReceiverTest.cpp #$(EIGERFLAGS)
# $(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiver.cpp $(EIGERFLAGS)
# $(CXX) eigerReceiverTest.o eigerReceiver.o -o eigerReceiver/eigerReceiverTest $(EIGERFLAGS)
# $(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiverImplementation.cpp $(EIGERFLAGS)
#else ifeq ($(ROOTSLS), yes)
#eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp
# echo "Compiling with root"
# $(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiverDummy.cpp $(ROOTFLAGS)
#else
#eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp
# $(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiverDummy.cpp
#endif
lib:
cd ../ && $(MAKE) DESTDIR=../bin LIBDIR=../bin
clean:
rm -rf $(PROGS) *.o eigerReceiverTest $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so core

View File

@ -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;
}
};

View File

@ -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(slsReceiverDefs::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 = slsReceiverDefs::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);
}
slsReceiverDefs::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 = slsReceiverDefs::RUNNING;
message = NULL;
return(0);
}
int stopReceiver() {
DEBUG("stopReceiver(): return 0.");
status = slsReceiverDefs::IDLE;
return(0);
}
void abort() {
DEBUG("abort(): return 0.");
status = slsReceiverDefs::IDLE;
}
private:
EigerReceiverScanConfiguration scan_config;
EigerReceiverInitializationConfiguration init_config;
bool isInitialized;
slsReceiverDefs::runStatus status;
};
EigerReceiver *EigerReceiver::create(void) {
DEBUG("create(): Return new EigerReceiverImplementation instance.");
return new EigerReceiverImplementation();
}

View File

@ -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_receiver_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 slsReceiverDefs::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 */

View File

@ -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;}
slsReceiverDefs::runStatus getStatus() const { return slsReceiverDefs::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;
slsReceiverDefs::runStatus status;
};
EigerReceiver *EigerReceiver::create(void) {
return new EigerReceiverImplementation();
}

View File

@ -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();
}