added old (workaround) EigerReceiver. Still not using slsReceiverBase

This commit is contained in:
sala 2014-08-05 11:08:11 +02:00
parent 3e36b603f9
commit 68dfe6f6a6
6 changed files with 153 additions and 103 deletions

View File

@ -11,7 +11,7 @@ CFLAGS= -g -DC_ONLY -fPIC
DFLAGS= -g -DDACS_INT -DSLS_RECEIVER_UDP_FUNCTIONS DFLAGS= -g -DDACS_INT -DSLS_RECEIVER_UDP_FUNCTIONS
INCLUDES?= -I. -Iincludes -IMySocketTCP -IslsReceiver -IslsDetectorCalibration -IslsReceiver/eigerReceiver -I$(ASM) INCLUDES?= -I. -Iincludes -IMySocketTCP -IslsReceiver -IslsDetectorCalibration -IslsReceiver/eigerReceiver -I$(ASM) -I../slsDetectorSoftware/commonFiles
#-IslsReceiverInterface #-IslsReceiverInterface
SRC_CLNT= MySocketTCP/MySocketTCP.cpp slsReceiver/slsReceiver.cpp slsReceiver/slsReceiverUDPFunctions.cpp slsReceiver/slsReceiverTCPIPInterface.cpp slsReceiver/slsReceiverUsers.cpp SRC_CLNT= MySocketTCP/MySocketTCP.cpp slsReceiver/slsReceiver.cpp slsReceiver/slsReceiverUDPFunctions.cpp slsReceiver/slsReceiverTCPIPInterface.cpp slsReceiver/slsReceiverUsers.cpp
@ -37,6 +37,7 @@ else ifeq ($(ROOTSLS),yes)
$(CXX) -DROOTSLS -o $@ -c $< $(INCLUDES) $(DFLAGS) $(ROOTFLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/ #$(FLAGS) $(CXX) -DROOTSLS -o $@ -c $< $(INCLUDES) $(DFLAGS) $(ROOTFLAGS) -fPIC $(EPICSFLAGS) -L/usr/lib64/ #$(FLAGS)
else else
echo "without root" echo "without root"
echo $(INCLUDES)
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS) $(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS)
endif endif

View File

@ -13,7 +13,7 @@ LDFLAGRXR ?= -L$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -lpthread
LDFLAGRXR += -lm -lstdc++ LDFLAGRXR += -lm -lstdc++
INCLUDES ?= -I ../MySocketTCP -I ../slsDetectorCalibration -I ../includes -I eigerReceiver -I . INCLUDES ?= -I ../MySocketTCP -I ../slsDetectorCalibration -I ../includes -I eigerReceiver -I . -I ../slsDetectorSoftware/commonFiles
SRC_CLNT = main.cpp SRC_CLNT = main.cpp
@ -46,13 +46,13 @@ $(DESTDIR)/slsReceiver: eigerReceiver lib
ifeq ($(EIGERSLS), yes) ifeq ($(EIGERSLS), yes)
eigerReceiver: eigerReceiver:
$(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiverTest.o eigerReceiver/eigerReceiverTest.cpp $(EIGERFLAGS) $(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiverTest.o eigerReceiver/eigerReceiverTest.cpp $(EIGERFLAGS)
$(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiver.cpp $(EIGERFLAGS) $(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiver.cpp $(EIGERFLAGS)
$(CXX) eigerReceiverTest.o eigerReceiver.o -o eigerReceiver/eigerReceiverTest $(EIGERFLAGS) $(CXX) eigerReceiverTest.o eigerReceiver.o -o eigerReceiver/eigerReceiverTest $(EIGERFLAGS)
else ifeq ($(ROOTSLS), yes) else ifeq ($(ROOTSLS), yes)
eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp
echo "Compiling with root" echo "Compiling with root"
$(CXX) $(FLAGS) $(CFLAGS) -fPIC -c -o eigerReceiver.o eigerReceiver/eeigerReceiverDummy.cpp $(ROOTFLAGS) $(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiverDummy.cpp $(ROOTFLAGS)
else else
eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp
$(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiverDummy.cpp $(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiverDummy.cpp
@ -63,6 +63,6 @@ lib:
clean: clean:
rm -rf $(PROGS) *.o eigerReceiverTest $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so core rm -rf $(PROGS) *.o eigerReceiverTest $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so core

View File

@ -39,77 +39,77 @@ struct EigerReceiverScanConfiguration {
bool doFileOverWrite; bool doFileOverWrite;
EigerReceiverScanConfiguration(): EigerReceiverScanConfiguration():
dynamicRange(-1), dynamicRange(-1),
scanTag(-1), scanTag(-1),
numberOfFrames(-1), numberOfFrames(-1),
doFileWrite(false), doFileWrite(false),
doFileOverWrite(false){}; doFileOverWrite(false){};
}; };
class EigerReceiverImplementation: public EigerReceiver { class EigerReceiverImplementation: public EigerReceiver {
public: public:
EigerReceiverImplementation() : isInitialized(false), status(slsReceiverDefs::ERROR) {}; EigerReceiverImplementation() : isInitialized(false), status(slsReceiverDefs::ERROR) {};
void initialize(const char *detectorHostname) { void initialize(const char *detectorHostname) {
string name; string name;
if (detectorHostname != NULL) { if (detectorHostname != NULL) {
name = detectorHostname; name = detectorHostname;
} }
if (name.empty()) { if (name.empty()) {
DEBUG("initialize(): can't initialize with empty string or NULL for detectorHostname"); DEBUG("initialize(): can't initialize with empty string or NULL for detectorHostname");
} else if (isInitialized == true) { } else if (isInitialized == true) {
DEBUG("initialize(): already initialized, can't initialize several times"); DEBUG("initialize(): already initialized, can't initialize several times");
} else { } else {
DEBUG("initialize(): initialize() with: detectorHostName=" << name << "."); DEBUG("initialize(): initialize() with: detectorHostName=" << name << ".");
init_config.detectorHostname = name; init_config.detectorHostname = name;
isInitialized = true; isInitialized = true;
status = slsReceiverDefs::IDLE; status = slsReceiverDefs::IDLE;
} }
#ifdef SALA #ifdef SALA
//REST call - hardcoded //REST call - hardcoded
RestHelper rest ; RestHelper rest ;
rest.init("localhost",8080); rest.init("localhost",8080);
std::string answer; std::string answer;
std::cout << "---- REST test 1: true, string "<< std::endl; std::cout << "---- REST test 1: true, string "<< std::endl;
int code = rest.get_json("status", &answer); int code = rest.get_json("status", &answer);
std::cout << "Answer: " << answer << std::endl; std::cout << "Answer: " << answer << std::d::endl;
std::cout << "---- REST test 2: 404, string "<< std::endl; std::cout << "---- REST test 2: 404, string "<< std::endl;
code = rest.get_json("statuss", &answer); code = rest.get_json("statuss", &answer);
if (code != 0){ if (code != 0){
//throw -1; //throw -1;
std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl; std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl;
} }
std::cout << "---- REST test 3: true, json object "<< std::endl; std::cout << "---- REST test 3: true, json object "<< std::endl;
JsonBox::Value json_value; JsonBox::Value json_value;
code = rest.get_json("status", &json_value); code = rest.get_json("status", &json_value);
std::cout << "JSON " << json_value["status"] << std::endl; std::cout << "JSON " << json_value["status"] << std::endl;
answer = ""; answer = "";
std::cout << "---- REST test 4: POST, string "<< std::endl; std::cout << "---- REST test 4: POST, string "<< std::endl;
code = rest.post_json("recipes/cassoela", &answer); code = rest.post_json("recipes/cassoela", &answer);
std::cout << "POST answer: " << answer << std::endl; std::cout << "POST answer: " << answer << std::endl;
if (code != 0){ if (code != 0){
//throw -1; //throw -1;
std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl; std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl;
} }
RestHelper rest2 ; RestHelper rest2 ;
rest2.init("reallyfake",8080); rest2.init("reallyfake",8080);
std::cout << "---- REST test 4: host not found, json object "<< std::endl; std::cout << "---- REST test 4: host not found, json object "<< std::endl;
JsonBox::Value json_value2; JsonBox::Value json_value2;
code = rest2.get_json("status", &json_value2); code = rest2.get_json("status", &json_value2);
if (code != 0){ if (code != 0){
//throw -1; //throw -1;
std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl; std::cout << "I SHOULD THROW AN EXCEPTION!!!" << std::endl;
} }
#endif #endif
} }
@ -120,31 +120,31 @@ public:
DEBUG("getDetectorHostname(): Return NULL"); DEBUG("getDetectorHostname(): Return NULL");
return(NULL); return(NULL);
} }
char *c = new char[name.length()+1]; char *c = new char[name.length()+1];
name.copy(c, name.length()); name.copy(c, name.length());
c[name.length()] = '\0'; c[name.length()] = '\0';
DEBUG("getDetectorHostname(): Return " << c << "."); DEBUG("getDetectorHostname(): Return " << c << ".");
return(c); return(c);
} }
char *getFileName() const { char *getFileName() const {
string name = scan_config.fileName; string name = scan_config.fileName;
char *c = new char[name.length()+1]; char *c = new char[name.length()+1];
name.copy(c, name.length()); name.copy(c, name.length());
c[name.length()] = '\0'; c[name.length()] = '\0';
DEBUG("getFileName(): Return " << c); DEBUG("getFileName(): Return " << c);
return(c); return(c);
} }
char *getFilePath() const { char *getFilePath() const {
string name = scan_config.filePath; string name = scan_config.filePath;
char *c = new char[name.length()+1]; char *c = new char[name.length()+1];
name.copy(c, name.length()); name.copy(c, name.length());
c[name.length()] = '\0'; c[name.length()] = '\0';
DEBUG("getFilePath(): Return " << c); DEBUG("getFilePath(): Return " << c);
return(c); return(c);
} }
int getDynamicRange() const { int getDynamicRange() const {
@ -237,6 +237,11 @@ public:
status = slsReceiverDefs::IDLE; status = slsReceiverDefs::IDLE;
} }
// Temporary workaround
int setDetectorType(slsReceiverDefs::detectorType det){
return 0;
}
private: private:
EigerReceiverScanConfiguration scan_config; EigerReceiverScanConfiguration scan_config;
EigerReceiverInitializationConfiguration init_config; EigerReceiverInitializationConfiguration init_config;

View File

@ -49,6 +49,8 @@ public:
char *getFileName() const {return (char*)"";} char *getFileName() const {return (char*)"";}
char *getFilePath() const {return (char*)"";} char *getFilePath() const {return (char*)"";}
int getFileIndex() const {return 0;}
int getDynamicRange() const { return 0;} int getDynamicRange() const { return 0;}

View File

@ -29,7 +29,7 @@ int main(int argc, char *argv[]){
} }
delete[] c0; delete[] c0;
cout <<prefix<< "initialize 4 times - only the second should work" << endl; cout <<prefix<< "initialize 4 times - only the second should work" << endl;
receiver->initialize(empty); receiver->initialize(empty);
status = receiver->getStatus(); status = receiver->getStatus();
receiver->initialize(name); receiver->initialize(name);

View File

@ -1,5 +1,6 @@
#ifndef SLSRECEIVERBASE_H #ifndef SLSRECEIVERBASE_H
#define SLSRECEIVERBASE_H #define SLSRECEIVERBASE_H
/*********************************************** /***********************************************
* @file slsReceiverBase.h * @file slsReceiverBase.h
* @short base class with all the functions for a receiver, set/get parameters, start/stop etc. * @short base class with all the functions for a receiver, set/get parameters, start/stop etc.
@ -12,20 +13,61 @@
* @short base class with all the functions for a receiver, set/get parameters, start/stop etc. * @short base class with all the functions for a receiver, set/get parameters, start/stop etc.
*/ */
#include "sls_detector_defs.h"
class slsReceiverBase { class slsReceiverBase {
/* abstract class that defines the public interface of an sls detector data receiver.
*
* Use the factory method slsReceiverBase::create() to get an instance:
*
* slsReceiverBase *receiver = slsReceiverBase::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: public:
/** // Using Factory instead
* constructor /**
*/ * constructor
slsReceiverBase(){}; */
//slsReceiverBase(){};
/**
* Destructor /**
*/ * factory method to create instances
virtual ~slsReceiverBase() {}; */
static slsReceiverBase *create();
/**
* Destructor
*/
virtual ~slsReceiverBase() {};
/** /**
* Initialize the Receiver * Initialize the Receiver
@param detectorHostName detector hostname @param detectorHostName detector hostname
@ -44,8 +86,8 @@ public:
/** /**
* Returns status of receiver: idle, running or error * Returns status of receiver: idle, running or error
*/ */
virtual slsReceiverDefs::runStatus getStatus() const = 0; virtual slsReceiverDefs::runStatus getStatus() const = 0;
/** /**
* Returns File Name * Returns File Name
* caller is responsible to deallocate the returned char array. * caller is responsible to deallocate the returned char array.