mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
added old (workaround) EigerReceiver. Still not using slsReceiverBase
This commit is contained in:
parent
3e36b603f9
commit
68dfe6f6a6
@ -11,7 +11,7 @@ CFLAGS= -g -DC_ONLY -fPIC
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
else
|
||||
echo "without root"
|
||||
echo $(INCLUDES)
|
||||
$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS)
|
||||
endif
|
||||
|
||||
|
@ -13,7 +13,7 @@ LDFLAGRXR ?= -L$(LIBDIR) -lSlsReceiver -L/usr/lib64/ -lpthread
|
||||
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
|
||||
|
||||
|
||||
@ -46,13 +46,13 @@ $(DESTDIR)/slsReceiver: eigerReceiver lib
|
||||
|
||||
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) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiverTest.o eigerReceiver/eigerReceiverTest.cpp $(EIGERFLAGS)
|
||||
$(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiver.cpp $(EIGERFLAGS)
|
||||
$(CXX) eigerReceiverTest.o eigerReceiver.o -o eigerReceiver/eigerReceiverTest $(EIGERFLAGS)
|
||||
else ifeq ($(ROOTSLS), yes)
|
||||
eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp
|
||||
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
|
||||
eigerReceiver: eigerReceiver/eigerReceiverDummy.cpp
|
||||
$(CXX) $(FLAGS) $(CFLAGS) $(INCLUDES) -fPIC -c -o eigerReceiver.o eigerReceiver/eigerReceiverDummy.cpp
|
||||
@ -63,6 +63,6 @@ lib:
|
||||
|
||||
clean:
|
||||
rm -rf $(PROGS) *.o eigerReceiverTest $(DESTDIR)/libSlsReceiver.a $(DESTDIR)/libSlsReceiver.so core
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -39,77 +39,77 @@ struct EigerReceiverScanConfiguration {
|
||||
bool doFileOverWrite;
|
||||
|
||||
EigerReceiverScanConfiguration():
|
||||
dynamicRange(-1),
|
||||
scanTag(-1),
|
||||
numberOfFrames(-1),
|
||||
doFileWrite(false),
|
||||
doFileOverWrite(false){};
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//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::d::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
|
||||
}
|
||||
|
||||
@ -120,31 +120,31 @@ public:
|
||||
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 *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 *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);
|
||||
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 {
|
||||
@ -237,6 +237,11 @@ public:
|
||||
status = slsReceiverDefs::IDLE;
|
||||
}
|
||||
|
||||
// Temporary workaround
|
||||
int setDetectorType(slsReceiverDefs::detectorType det){
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
EigerReceiverScanConfiguration scan_config;
|
||||
EigerReceiverInitializationConfiguration init_config;
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
char *getFileName() const {return (char*)"";}
|
||||
|
||||
char *getFilePath() const {return (char*)"";}
|
||||
|
||||
int getFileIndex() const {return 0;}
|
||||
|
||||
int getDynamicRange() const { return 0;}
|
||||
|
||||
|
@ -29,7 +29,7 @@ int main(int argc, char *argv[]){
|
||||
}
|
||||
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);
|
||||
status = receiver->getStatus();
|
||||
receiver->initialize(name);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#ifndef SLSRECEIVERBASE_H
|
||||
#define SLSRECEIVERBASE_H
|
||||
|
||||
/***********************************************
|
||||
* @file slsReceiverBase.h
|
||||
* @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.
|
||||
*/
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
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:
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
slsReceiverBase(){};
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~slsReceiverBase() {};
|
||||
|
||||
|
||||
// Using Factory instead
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
//slsReceiverBase(){};
|
||||
|
||||
/**
|
||||
* factory method to create instances
|
||||
*/
|
||||
static slsReceiverBase *create();
|
||||
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~slsReceiverBase() {};
|
||||
|
||||
/**
|
||||
* Initialize the Receiver
|
||||
@param detectorHostName detector hostname
|
||||
@ -44,8 +86,8 @@ public:
|
||||
/**
|
||||
* Returns status of receiver: idle, running or error
|
||||
*/
|
||||
virtual slsReceiverDefs::runStatus getStatus() const = 0;
|
||||
|
||||
virtual slsReceiverDefs::runStatus getStatus() const = 0;
|
||||
|
||||
/**
|
||||
* Returns File Name
|
||||
* caller is responsible to deallocate the returned char array.
|
||||
|
Loading…
x
Reference in New Issue
Block a user