add getStatus() method to EigerReceiverImplementation.

implement basic configuration cache for EigerReceiverImplementation
adapt eigerReceiverTest to do more checks and make output more readable
improve error tests in EigerReceiverImplementation::initialize()


git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@789 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
billich
2014-03-17 20:37:10 +00:00
parent 540c3b1971
commit 3ec2a602c2
3 changed files with 152 additions and 45 deletions

View File

@@ -20,16 +20,63 @@
#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;
EigerReceiverScanConfiguration():
dynamicRange(-1),
scanTag(-1),
numberOfFrames(-1),
doFileWrite(false) {};
};
class EigerReceiverImplementation: public EigerReceiver {
public:
void initialize(const char *detectorHostName) {
DEBUG("initialize() with: detectorHostName= " << detectorHostName << ".");
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;
}
}
char *getDetectorHostname() const {
const std::string name = "some_host_name";
char *c = new char[name.length()];
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 << ".");
@@ -37,8 +84,9 @@ public:
}
char *getFileName() const {
const std::string name = "some_file_name";
char *c = new char[name.length()];
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);
@@ -46,8 +94,9 @@ public:
}
char *getFilePath() const {
std::string name = "some_path";
char *c = new char[name.length()];
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);
@@ -55,69 +104,89 @@ public:
}
int getDynamicRange() const {
DEBUG("getDynamicRange(): Return 16.");
return(16);
DEBUG("getDynamicRange(): Return " << scan_config.dynamicRange);
return(scan_config.dynamicRange);
}
int getScanTag() const {
DEBUG("getScanTag(): return 4711.");
return(4711);
DEBUG("getScanTag(): returns " << scan_config.scanTag);
return(scan_config.scanTag);
}
int getNumberOfFrames() const {
DEBUG("getNumberOfFrames(): return 42.");
return(42);
}
char * setFileName(const char c[]) {
DEBUG("setFileName() called with " << c <<".");
return(this->getFileName());
}
char * setFilePath(const char c[]) {
DEBUG("setFilePath() called with" << c << ".");
return(this->getFilePath());
DEBUG("getNumberOfFrames(): return " << scan_config.numberOfFrames);
return(scan_config.numberOfFrames);
}
int getEnableFileWrite() const {
DEBUG("getEnableFileWrite() returns 1.");
return(1);
DEBUG("getEnableFileWrite() returns " << scan_config.doFileWrite);
return(scan_config.doFileWrite);
}
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 << '.');
return(this->getDynamicRange());
scan_config.dynamicRange = dr;
return(getDynamicRange());
}
int setScanTag (const int tag) {
DEBUG("setScanTag() called with " << tag);
return(this->getScanTag());
scan_config.scanTag = tag;
return(getScanTag());
}
int setNumberOfFrames (const int fnum) {
DEBUG("setNumberOfFrames() called with " << fnum);
return(this->getNumberOfFrames());
scan_config.numberOfFrames = fnum;
return(getNumberOfFrames());
}
int setEnableFileWrite(const int i) {
DEBUG("enableFileWrite() called with " << i);
return(0);
scan_config.doFileWrite = i;
return(getEnableFileWrite());
}
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) {