somewhere

This commit is contained in:
Dhanya Maliakal
2017-02-10 10:08:00 +01:00
parent c89f6e649c
commit b260d08225
18 changed files with 1076 additions and 356 deletions

View File

@@ -18,17 +18,91 @@ class BinaryFileWriter : private virtual slsReceiverDefs, public FileWriter {
/**
* Constructor
* creates the File Writer
* @fname pointer to file name prefix
* @param ind self index
* @param fname pointer to file name prefix
* @param fpath pointer to file path
* @param findex pointer to file index
* @param frindexenable pointer to frame index enable
* @param owenable pointer to over write enable
* @param dindex pointer to detector index
* @param nunits pointer to number of theads/ units per detector
* @param maxf pointer to max frames per file
*/
BinaryFileWriter(char* fname);
BinaryFileWriter(int ind, char* fname, char* fpath, uint64_t* findex,
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint32_t maxf);
/**
* Destructor
*/
~BinaryFileWriter();
/**
* Print all member values
*/
void PrintMembers();
/**
* Set Max frames per file
* @param maxf maximum frames per file
*/
void SetMaxFramesPerFile(uint32_t maxf);
/**
* Create file
* @param fnum current frame index to include in file name
* @returns OK or FAIL
*/
int CreateFile(uint64_t fnum);
/**
* Close File
*/
void CloseFile();
/**
* Create File Name in format fpath/fnameprefix_fx_dy_z.raw,
* where x is fnum, y is (dindex * numunits + unitindex) and z is findex
* @param fpath file path
* @param fnameprefix file name prefix (includes scan and position variables)
* @param findex file index
* @param frindexenable frame index enable
* @param fnum frame number index
* @param dindex readout index
* @param numunits number of units per readout. eg. eiger has 2 udp units per readout
* @param unitindex unit index
* @returns complete file name created
*/
static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0);
/**
* Create File
* @param owenable overwrite enable
* @param fname complete file name
* @returns OK or FAIL
*/
static int CreateDataFile(bool owenable, char* fname);
/**
* Close File
*/
static void CloseDataFile();
private:
/**
* Get Type
* @return type
*/
fileFormat GetType();
/** Maximum frames per file */
uint32_t maxFramesPerFile;
};
#endif

View File

@@ -27,8 +27,16 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* @param f address of Fifo pointer
* @param s pointer to receiver status
* @param m pointer to mutex for status
* @param ftype pointer to file format type
* @param fwenable pointer to file writer enable
* @param cbaction pointer to call back action
* @param dataReadycb pointer to data ready call back function
* @param pDataReadycb pointer to arguments of data ready call back function
*/
DataProcessor(Fifo*& f, runStatus* s, pthread_mutex_t* m);
DataProcessor(Fifo*& f, runStatus* s, pthread_mutex_t* m, fileFormat* ftype, bool* fwenable,
int* cbaction,
void (*dataReadycb)(int, char*, int, FILE*, char*, void*),
void *pDataReadycb);
/**
* Destructor
@@ -37,23 +45,18 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
~DataProcessor();
//*** static functions ***
/**
* Get RunningMask
* @return RunningMask
* Get ErrorMask
* @return ErrorMask
*/
static uint64_t GetErrorMask();
/**
* Get acquisition started flag
* @return acquisition started flag
* Get RunningMask
* @return RunningMask
*/
static bool GetAcquisitionStartedFlag();
/**
* Get measurement started flag
* @return measurement started flag
*/
static bool GetMeasurementStartedFlag();
static uint64_t GetRunningMask();
/**
* Set GeneralData pointer to the one given
@@ -61,6 +64,22 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
*/
static void SetGeneralData(GeneralData*& g);
//*** non static functions ***
//*** getters ***
/**
* Get acquisition started flag
* @return acquisition started flag
*/
bool GetAcquisitionStartedFlag();
/**
* Get measurement started flag
* @return measurement started flag
*/
bool GetMeasurementStartedFlag();
/**
* Get Total Complete Frames Caught for an entire acquisition (including all scans)
* @return total number of frames caught for entire acquisition
@@ -79,6 +98,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
*/
uint64_t GetProcessedAcquisitionIndex();
//*** setters ***
/**
* Set bit in RunningMask to allow thread to run
*/
@@ -105,6 +126,31 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
*/
void ResetParametersforNewMeasurement();
/**
* Set Max frames per file
*/
void SetMaxFramesPerFile();
/**
* Set File Format
* @param f file format
*/
void SetFileFormat(const fileFormat fs);
/**
* Set up file writer object and call backs
* @param fname pointer to file name prefix
* @param fpath pointer to file path
* @param findex pointer to file index
* @param frindexenable pointer to frame index enable
* @param owenable pointer to over write enable
* @param dindex pointer to detector index
* @param nunits pointer to number of theads/ units per detector
*/
void SetupFileWriter(char* fname, char* fpath, uint64_t* findex,
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
/**
* Create New File
*/
@@ -129,6 +175,18 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
*/
bool IsRunning();
/**
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
* @param fnum frame index to record
*/
void RecordFirstIndices(uint64_t fnum);
/**
* Destroy file writer object
* @return OK or FAIL
*/
void DestroyFileWriter();
/**
* Thread Exeution for DataProcessor Class
* Pop bound addresses, process them,
@@ -143,6 +201,13 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
*/
void StopProcessing(char* buf);
/**
* Process an image popped from fifo,
* write to file if fw enabled & update parameters
* @param buffer
*/
void ProcessAnImage(char* buf);
/** type of thread */
@@ -169,10 +234,10 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
// individual members
/** Aquisition Started flag */
static bool acquisitionStartedFlag;
bool acquisitionStartedFlag;
/** Measurement Started flag */
static bool measurementStartedFlag;
bool measurementStartedFlag;
/** Receiver Status */
runStatus* status;
@@ -196,7 +261,37 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
uint64_t currentFrameIndex;
/** File writer implemented as binary or hdf5 filewriter */
std::vector <FileWriter*> fileWriter;
FileWriter* fileWriter;
/** File Format Type */
fileFormat* fileFormatType;
/** File Write Enable */
bool* fileWriteEnable;
//***callback parameters***
/** Pointer to the action which decides what the user and default responsibilities to save data are
* 0 raw data ready callback takes care of open,close,write file
* 1 callback writes file, we have to open, close it
* 2 we open, close, write file, callback does not do anything */
int* callbackAction;
/**
* function being called back for raw data
* args to raw data ready callback are
* framenum
* datapointer
* datasize in bytes
* file descriptor
* guidatapointer (NULL, no data required)
*/
void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*);
void *pRawDataReady;
};
#endif

View File

@@ -13,33 +13,121 @@
#include "logger.h"
#include <string>
class FileWriter : private virtual slsReceiverDefs {
public:
/**
* Constructor
* creates the File Writer
* @fname pointer to file name prefix
* @param ind self index
* @param fname pointer to file name prefix
* @param fpath pointer to file path
* @param findex pointer to file index
* @param frindexenable pointer to frame index enable
* @param owenable pointer to over write enable
* @param dindex pointer to detector index
* @param nunits pointer to number of theads/ units per detector
*/
FileWriter(char* fname);
FileWriter(int ind, char* fname, char* fpath, uint64_t* findex,
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
/**
* Destructor
*/
~FileWriter();
virtual ~FileWriter();
/**
* Get File Name prefix
* @returns file name prefix
* Get Current File Name
* @returns current file name
*/
char* GetFileName();
std::string GetCurrentFileName();
/**
* Print all member values
*/
virtual void PrintMembers();
/**
* Get Type
* @return type
*/
virtual fileFormat GetType() = 0;
/**
* Get Member Pointer Values before the object is destroyed
* @param fname pointer to file name prefix
* @param fpath pointer to file path
* @param findex pointer to file index
* @param frindexenable pointer to frame index enable
* @param owenable pointer to over write enable
* @param dindex pointer to detector index
* @param nunits pointer to number of theads/ units per detector
*/
void GetMemberPointerValues(char* fname, char* fpath, uint64_t* findex,
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
/**
* Create file
* @param fnum current frame index to include in file name
* @returns OK or FAIL
*/
virtual int CreateFile(uint64_t fnum){
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
return OK;
}
/**
* Close File
*/
virtual void CloseFile() {
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
}
// Binary specific
/**
* Set Max frames per file
* @param maxf maximum frames per file
*/
virtual void SetMaxFramesPerFile(uint32_t maxf) {
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
}
protected:
char* fileName;
/** Self Index */
int index;
/** File Name Prefix */
char* fileNamePrefix;
/** File Path */
char* filePath;
/** File Index */
uint64_t* fileIndex;
/** Frame Index */
bool* frameIndexEnable;
/** File Write Enable */
bool* fileWriteEnable;
/** Over write enable */
bool* overWriteEnable;
/** Detector Index */
int* detIndex;
/** Number of units per detector. Eg. Eiger has 2, others 1 */
int* numUnitsPerDetector;
/** Current File Name */
std::string currentFileName;
};
#endif

View File

@@ -73,6 +73,20 @@ public:
/** Destructor */
virtual ~GeneralData(){};
/**
* Get Header Infomation (frame number, packet number)
* @param index thread index for debugging purposes
* @param packetData pointer to data
* @param frameNumber frame number
* @param packetNumber packet number
*/
virtual void GetHeaderInfo(int index, char* packetData, uint64_t& frameNumber, uint32_t& packetNumber) const {
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
frameNumber++;
packetNumber = frameNumber&packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
}
/**
* Get Header Infomation (frame number, packet number)
* @param index thread index for debugging purposes
@@ -83,14 +97,9 @@ public:
* @param subFrameNumber sub frame number if applicable
* @param bunchId bunch id
*/
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
virtual void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t bunchId) const {
subFrameNumber = 0;
bunchId = 0;
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
frameNumber++;
packetNumber = frameNumber&packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
}
/**
@@ -99,7 +108,7 @@ public:
* @param tgEnable true if 10GbE is enabled, else false
*/
virtual void SetDynamicRange(int dr, bool tgEnable) {
//This is a generic function that is overloaded by a dervied class
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
};
/**
@@ -108,13 +117,13 @@ public:
* @param dr dynamic range
*/
virtual void SetTenGigaEnable(bool tgEnable, int dr) {
//This is a generic function that is overloaded by a dervied class
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
};
/**
* Print all variables
*/
void Print() const {
virtual void Print() const {
printf("\n\nDetector Data Variables:\n");
printf( "Pixels X: %d\n"
"Pixels Y: %d\n"
@@ -169,7 +178,7 @@ class GotthardData : public GeneralData {
packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
defaultFifoDepth = 25000;
};
};
@@ -190,7 +199,7 @@ class ShortGotthardData : public GeneralData {
frameIndexMask = 0xFFFFFFFF;
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
defaultFifoDepth = 25000;
};
};
@@ -218,7 +227,7 @@ class PropixData : public GeneralData {
packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
defaultFifoDepth = 25000;
};
};
@@ -244,7 +253,7 @@ class Moench02Data : public GeneralData {
packetIndexMask = 0xFF;
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 2500;
};
@@ -278,7 +287,7 @@ class Moench03Data : public GeneralData {
packetIndexMask = 0xFFFFFFFF;
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 2500;
};
@@ -309,7 +318,7 @@ class JCTBData : public GeneralData {
imageSize = dataSize*packetsPerFrame;
maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 2500;
};
@@ -351,7 +360,7 @@ private:
imageSize = dataSize*packetsPerFrame;
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 2500;
};
@@ -420,13 +429,26 @@ private:
frameIndexMask = 0xffffff;
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
fifoBufferSize = packetSize*packetsPerFrame;
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
defaultFifoDepth = 100;
footerOffset = packetHeaderSize+dataSize;
threadsPerReceiver = 2;
headerPacketSize = 48;
};
/**
* Get Header Infomation (frame number, packet number)
* @param index thread index for debugging purposes
* @param packetData pointer to data
* @param frameNumber frame number
* @param packetNumber packet number
*/
void GetHeaderInfo(int index, char* packetData, uint64_t& frameNumber, uint32_t& packetNumber) const {
eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(packetData + footerOffset);
frameNumber = (uint64_t)((*( (uint64_t*) footer)) & frameIndexMask);
packetNumber = (uint32_t)(*( (uint16_t*) footer->packetNumber))-1;
}
/**
* Get Header Infomation (frame number, packet number)
* @param index thread index for debugging purposes
@@ -480,7 +502,7 @@ private:
*/
void Print() const {
GeneralData::Print();
printf( "Packet Header Size: %d"
printf( "Packet Header Size: %d\n"
"Footer Offset : %d\n",
packetHeaderSize,
footerOffset);

View File

@@ -18,17 +18,76 @@ class HDF5FileWriter : private virtual slsReceiverDefs, public FileWriter {
/**
* Constructor
* creates the File Writer
* @fname pointer to file name prefix
* @param fname pointer to file name prefix
* @param fpath pointer to file path
* @param findex pointer to file index
* @param frindexenable pointer to frame index enable
* @param owenable pointer to over write enable
* @param dindex pointer to detector index
* @param nunits pointer to number of theads/ units per detector
*/
HDF5FileWriter(char* fname);
HDF5FileWriter(int ind, char* fname, char* fpath, uint64_t* findex,
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
/**
* Destructor
*/
~HDF5FileWriter();
/**
* Print all member values
*/
void PrintMembers();
/**
* Create file
* @param fnum current frame index to include in file name
* @returns OK or FAIL
*/
int CreateFile(uint64_t fnum);
/**
* Close File
*/
void CloseFile();
/**
* Create File Name in format fpath/fnameprefix_fx_dy_z.raw,
* where x is fnum, y is (dindex * numunits + unitindex) and z is findex
* @param fpath file path
* @param fnameprefix file name prefix (includes scan and position variables)
* @param findex file index
* @param frindexenable frame index enable
* @param fnum frame number index
* @param dindex readout index
* @param numunits number of units per readout. eg. eiger has 2 udp units per readout
* @param unitindex unit index
* @returns complete file name created
*/
static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0);
/**
* Create File
* @param owenable overwrite enable
* @param fname complete file name
* @returns OK or FAIL
*/
static int CreateDataFile(bool owenable, char* fname);
/**
* Close File
*/
static void CloseDataFile();
private:
/**
* Get Type
* @return type
*/
fileFormat GetType();
};
#endif

View File

@@ -25,8 +25,9 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
* @param f address of Fifo pointer
* @param s pointer to receiver status
* @param portno pointer to udp port number
* @param e ethernet interface
*/
Listener(Fifo*& f, runStatus* s, uint32_t* portno);
Listener(Fifo*& f, runStatus* s, uint32_t* portno, char* e);
/**
* Destructor
@@ -35,23 +36,18 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
~Listener();
//*** static functions ***
/**
* Get RunningMask
* @return RunningMask
* Get ErrorMask
* @return ErrorMask
*/
static uint64_t GetErrorMask();
/**
* Get acquisition started flag
* @return acquisition started flag
* Get RunningMask
* @return RunningMask
*/
static bool GetAcquisitionStartedFlag();
/**
* Get measurement started flag
* @return measurement started flag
*/
static bool GetMeasurementStartedFlag();
static uint64_t GetRunningMask();
/**
* Set GeneralData pointer to the one given
@@ -59,6 +55,22 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
*/
static void SetGeneralData(GeneralData*& g);
//*** non static functions ***
//*** getters ***
/**
* Get acquisition started flag
* @return acquisition started flag
*/
bool GetAcquisitionStartedFlag();
/**
* Get measurement started flag
* @return measurement started flag
*/
bool GetMeasurementStartedFlag();
/**
* Get Total Packets caught in an acquisition
* @return Total Packets caught in an acquisition
@@ -66,10 +78,13 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
uint64_t GetTotalPacketsCaught();
/**
* Get number of bytes currently received in udp buffer
* Get Last Frame index caught
* @return last frame index caught
*/
uint64_t GetNumReceivedinUDPBuffer();
uint64_t GetLastFrameIndexCaught();
//*** setters ***
/**
* Set bit in RunningMask to allow thread to run
*/
@@ -99,10 +114,9 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/**
* Creates UDP Sockets
* @param eth ethernet interface or null
* @return OK or FAIL
*/
int CreateUDPSockets(const char* eth);
int CreateUDPSockets();
/**
* Shuts down and deletes UDP Sockets
@@ -126,6 +140,12 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
*/
bool IsRunning();
/**
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
* @param fnum frame index to record
*/
void RecordFirstIndices(uint64_t fnum);
/**
* Thread Exeution for Listener Class
* Pop free addresses, listen to udp socket,
@@ -141,6 +161,15 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
*/
void StopListening(char* buf);
/**
* Listen to the UDP Socket for an image,
* place them in the right order
* @param buffer
* @returns number of bytes of relevant data, can be image size or 0
*/
uint32_t ListenToAnImage(char* buf);
/** type of thread */
static const std::string TypeName;
@@ -166,10 +195,10 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
// individual members
/** Aquisition Started flag */
static bool acquisitionStartedFlag;
bool acquisitionStartedFlag;
/** Measurement Started flag */
static bool measurementStartedFlag;
bool measurementStartedFlag;
/** Receiver Status */
runStatus* status;
@@ -180,6 +209,9 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/** UDP Port Number */
uint32_t* udpPortNumber;
/** ethernet interface */
char* eth;
/**Number of complete Packets caught for an entire acquisition (including all scans) */
uint64_t numTotalPacketsCaught;
@@ -192,6 +224,20 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/** Frame Number of First Frame for each real time acquisition (eg. for each scan) */
uint64_t firstMeasurementIndex;
/** Current Frame Index, default value is 0
* ( always check acquisitionStartedFlag for validity first)
*/
uint64_t currentFrameIndex;
/** Last Frame Index caught from udp network */
uint64_t lastCaughtFrameIndex;
/** True if there is a packet carry over from previous Image */
bool carryOverFlag;
/** Carry over packet buffer */
char* carryOverPacket;
};
#endif

View File

@@ -55,6 +55,12 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
*/
int64_t getAcquisitionIndex() const;
/**
* Set File Format
* @param f fileformat binary or hdf5
*/
void setFileFormat(slsReceiverDefs::fileFormat f);
/**
* Set File Name Prefix (without frame index, file index and extension (_f000000000000_8.raw))
* Does not check for file existence since it is created only at startReceiver
@@ -243,6 +249,12 @@ private:
/** Number of Jobs */
int numberofJobs;
/** Pointer to the action which decides what the user and default responsibilities to save data are
* 0 raw data ready callback takes care of open,close,write file
* 1 callback writes file, we have to open, close it
* 2 we open, close, write file, callback does not do anything */
int callbackAction;
//*** mutex ***
/** Status mutex */
pthread_mutex_t statusMutex;

View File

@@ -83,12 +83,6 @@ using namespace std;
#define DEFAULT_GUI_PORTNO 65000
#define DEFAULT_ZMQ_PORTNO 70001
/** Structure of an eiger packet footer */
typedef struct {
unsigned char frameNumber[6];
unsigned char packetNumber[2];
} eiger_packet_footer_t;
class genericSocket{
public:
@@ -617,25 +611,16 @@ enum communicationProtocol{
if (socketDescriptor<0) return -1;
//if length given, listens to length, else listens for packetsize till length is reached
if(length){
/*int k = 0;*/
while(length>0){
nsending = (length>packet_size) ? packet_size:length;
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
cprintf(CYAN,"nsent:%d\n",nsent);
if(nsent == header_packet_size)
continue;
if(nsent != nsending){ //if((nsent != nsending)){ && (nsent < packet_size)){
if(nsent != nsending){
if(nsent && (nsent != -1))
cprintf(RED,"Incomplete Packet size %d\n",nsent);
break;
}
eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(buf + 1024+8);
cprintf(MAGENTA,"generic fnum:%lld, pnum:%d \n",
(long long int)(uint64_t)((*( (uint64_t*) footer)) ),
(uint32_t)(*( (uint16_t*) footer->packetNumber)));
length-=nsent;
total_sent+=nsent;
}
@@ -646,8 +631,10 @@ enum communicationProtocol{
nsending=packet_size;
while(1){
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
if(nsent<=0 || nsent == packet_size)
//break out of loop only if read one packets size or read didnt work (cuz of shutdown)
if(nsent<=0 || nsent == packet_size)
break;
//incomplete packets or header packets ignored and read buffer again
if(nsent != packet_size && nsent != header_packet_size)
cprintf(RED,"Incomplete Packet size %d\n",nsent);
}

View File

@@ -18,7 +18,7 @@
#define FILE_FRAME_HEADER_SIZE 16
//fifo
#define FIFO_BUFFER_HEADER_SIZE 4
#define FIFO_HEADER_NUMBYTES 4
//parameters to calculate fifo depth
#define SAMPLE_TIME_IN_NS 100000000//100ms

View File

@@ -188,6 +188,19 @@ public:
default: return std::string("idle"); \
}};
/** returns string from file format index
\param s can be BINARY, ASCII, HDF5
\returns string binary, ascii, hdf5
*/
static std::string getFileFormatType(fileFormat f){\
switch (f) { \
case ASCII: return std::string("ascii"); \
case HDF5: return std::string("hdf5"); \
case BINARY: return std::string("binary"); \
default: return std::string("unknown"); \
}};
#endif
#ifdef __cplusplus