mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 01:20:02 +02:00

make class EigerReceiver an abstract base class with pure virtual public member functions. So class EigerReceiver defines the interface, but does not expose the implementation. Add a preliminary dummy implementation for EigerReceiver. Add a test program eigerReceiverTest to test the newly created EigerReceiver class. Modify the Makefile accordingly. Example: $ make eigerReceiverTest g++ -DSLS_RECEIVER_FUNCTION_LIST -O3 -DEIGER_RECEIVER -c -o eigerReceiverTest.o eigerReceiverTest.cpp g++ -DSLS_RECEIVER_FUNCTION_LIST -O3 -DEIGER_RECEIVER -c -o eigerReceiver.o eigerReceiver.cpp g++ eigerReceiverTest.o eigerReceiver.o -o eigerReceiverTest $ ./eigerReceiverTest main: start EigerReceiver tests create(): Return new EigerReceiverImplementation instance. initialize() with: detectorHostName= detectors_host_name. getFileName(): Return some_file_name. main: got file name some_file_name getFilePath(): Return some_path. main: got path name some_path getDynamicRange(): Return 16. main: got dynamic range 16. getScanTag(): return 4711. main: got scan tag 4711. setFileName() called with some_other_name. getFileName(): Return some_file_name. main: got file name some_file_name after setting to <some_other_name> setFilePath() called withsome_other_path. getFilePath(): Return some_path. main: got file path some_path after setting to <some_other_path> setDynamicRange() called with 8. getDynamicRange(): Return 16. main: got dynamic range 16 after setting it to 8. setNumberOfFrames() called with 11. getNumberOfFrames(): return 42. enableFileWrite() called with 1. startReceiver(): return 0. stopReceiver(): return 0. abort(): return 0. getEnableFileWrite() returns 1. getDetectorHostname(): Return some_host_name. HeinerBillich/2014-03-11 git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@766 951219d9-93cf-4727-9268-0efd64621fa3
207 lines
5.7 KiB
C++
207 lines
5.7 KiB
C++
|
|
#ifdef EIGER_RECEIVER
|
|
|
|
#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.
|
|
*/
|
|
|
|
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;
|
|
|
|
/**
|
|
* Set detector hostname
|
|
@param c hostname
|
|
/returns hostname
|
|
*/
|
|
/*FIXME: char* setDetectorHostname(char c[]); Can/want we support this setter function? Can't change after initialization */
|
|
|
|
/* Returns detector hostname
|
|
/returns hostname
|
|
* caller needs to deallocate the returned char array.
|
|
*/
|
|
virtual char *getDetectorHostname() = 0;
|
|
|
|
/**
|
|
* Returns status of receiver: idle, running or error
|
|
*/
|
|
/*FIXME: need to implement runStatus getStatus();*/
|
|
/* the struct slsDetectorDefs is available in slsDetectorsPackage/slsDetectorSoftware/commonFiles/slsDetectorDefs.h */
|
|
|
|
|
|
/**
|
|
* Returns File Name
|
|
* caller is responsible to deallocate the returned char array.
|
|
*/
|
|
virtual char *getFileName() = 0;
|
|
|
|
|
|
/**
|
|
* Returns File Path
|
|
* caller is responsible to deallocate the returned char array
|
|
*/
|
|
virtual char *getFilePath() = 0; //FIXME: Does the caller need to free() the returned pointer?
|
|
|
|
|
|
/**
|
|
* Returns the number of bits per pixel
|
|
*/
|
|
virtual int getDynamicRange() = 0;
|
|
|
|
/**
|
|
* Returns scan tag
|
|
*/
|
|
virtual int getScanTag() = 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() = 0;
|
|
|
|
/**
|
|
* Returns file write enable
|
|
* 1: YES 0: NO
|
|
*/
|
|
virtual int getEnableFileWrite() = 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;
|
|
|
|
/**
|
|
* 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 */
|
|
#endif /* #ifdef EIGER_RECEIVER */
|
|
|