mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
master hdf5 does not work, but so far good
This commit is contained in:
parent
54f92fb26c
commit
2cd38fefcd
@ -5,13 +5,15 @@
|
|||||||
***********************************************/
|
***********************************************/
|
||||||
#ifndef BINARY_FILE_H
|
#ifndef BINARY_FILE_H
|
||||||
#define BINARY_FILE_H
|
#define BINARY_FILE_H
|
||||||
|
|
||||||
#include "File.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@short sets/gets properties for the binary file, creates/closes the file and writes data to it
|
*@short sets/gets properties for the binary file, creates/closes the file and writes data to it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "File.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class BinaryFile : private virtual slsReceiverDefs, public File {
|
class BinaryFile : private virtual slsReceiverDefs, public File {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -26,10 +28,12 @@ class BinaryFile : private virtual slsReceiverDefs, public File {
|
|||||||
* @param owenable pointer to over write enable
|
* @param owenable pointer to over write enable
|
||||||
* @param dindex pointer to detector index
|
* @param dindex pointer to detector index
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
* @param nunits pointer to number of theads/ units per detector
|
||||||
* @param maxf pointer to max frames per file
|
* @param nf pointer to number of frames
|
||||||
|
* @param dr dynamic range
|
||||||
|
* @param maxf max frames per file
|
||||||
*/
|
*/
|
||||||
BinaryFile(int ind, char* fname, char* fpath, uint64_t* findex,
|
BinaryFile(int ind, char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint32_t maxf);
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t maxf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -55,9 +59,23 @@ class BinaryFile : private virtual slsReceiverDefs, public File {
|
|||||||
int CreateFile(uint64_t fnum);
|
int CreateFile(uint64_t fnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close File
|
* Close Current File
|
||||||
*/
|
*/
|
||||||
void CloseFile();
|
void CloseCurrentFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close all Files
|
||||||
|
*/
|
||||||
|
void CloseAllFiles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data to file
|
||||||
|
* @param buffer buffer to write from
|
||||||
|
* @param buffersize size of buffer
|
||||||
|
* @param fnum current image number
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int WriteToFile(char* buffer, int buffersize, uint64_t fnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create File Name in format fpath/fnameprefix_fx_dy_z.raw,
|
* Create File Name in format fpath/fnameprefix_fx_dy_z.raw,
|
||||||
@ -77,18 +95,41 @@ class BinaryFile : private virtual slsReceiverDefs, public File {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create File
|
* Create File
|
||||||
|
* @param fd file pointer
|
||||||
* @param owenable overwrite enable
|
* @param owenable overwrite enable
|
||||||
* @param fname complete file name
|
* @param fname complete file name
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
static int CreateDataFile(bool owenable, char* fname);
|
static int CreateDataFile(FILE*& fd, bool owenable, std::string fname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close File
|
* Close File
|
||||||
|
* @param fd file pointer
|
||||||
*/
|
*/
|
||||||
static void CloseDataFile();
|
static void CloseDataFile(FILE*& fd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data to file
|
||||||
|
* @param fd file pointer
|
||||||
|
* @param buf buffer to write from
|
||||||
|
* @param bsize size of buffer
|
||||||
|
* @param fnum current image number
|
||||||
|
* @returns number of elements written
|
||||||
|
*/
|
||||||
|
static int WriteDataFile(FILE* fd, char* buf, int bsize, uint64_t fnum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create common files
|
||||||
|
* @param en ten giga enable
|
||||||
|
* @param size image size
|
||||||
|
* @param nx number of pixels in x direction
|
||||||
|
* @param ny number of pixels in y direction
|
||||||
|
* @param at acquisition time
|
||||||
|
* @param ap acquisition period
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int CreateCommonFiles(bool en, uint32_t size,
|
||||||
|
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -97,11 +138,47 @@ class BinaryFile : private virtual slsReceiverDefs, public File {
|
|||||||
* Get Type
|
* Get Type
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
fileFormat GetType();
|
fileFormat GetFileType();
|
||||||
|
|
||||||
/** Maximum frames per file */
|
/** Maximum frames per file */
|
||||||
uint32_t maxFramesPerFile;
|
uint32_t maxFramesPerFile;
|
||||||
|
|
||||||
|
/** File Descriptor */
|
||||||
|
FILE* filefd;
|
||||||
|
|
||||||
|
/** Master File Descriptor */
|
||||||
|
static FILE* masterfd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create file names for master and virtual file
|
||||||
|
* @param m master file name
|
||||||
|
* @param fpath file path
|
||||||
|
* @param fnameprefix file name prefix (includes scan and position variables)
|
||||||
|
* @param findex file index
|
||||||
|
*/
|
||||||
|
void CreateCommonFileNames(std::string& m, char* fpath, char* fnameprefix, uint64_t findex);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close master and virtual files
|
||||||
|
*/
|
||||||
|
void CloseCommonDataFiles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create master and virtual files
|
||||||
|
* @param m master file name
|
||||||
|
* @param owenable overwrite enable
|
||||||
|
* @param tengigaEnable ten giga enable
|
||||||
|
* @param imageSize image size
|
||||||
|
* @param nPixelsX number of pixels in x direction
|
||||||
|
* @param nPixelsY number of pixels in y direction
|
||||||
|
* @param acquisitionTime acquisition time
|
||||||
|
* @param acquisitionPeriod acquisition period
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int CreateCommonDataFiles(std::string m, bool owenable,
|
||||||
|
bool tengigaEnable, uint32_t imageSize, uint32_t nPixelsX, uint32_t nPixelsY,
|
||||||
|
uint64_t acquisitionTime, uint64_t acquisitionPeriod);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,13 +58,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
static uint64_t GetRunningMask();
|
static uint64_t GetRunningMask();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set GeneralData pointer to the one given
|
|
||||||
* @param g address of GeneralData (Detector Data) pointer
|
|
||||||
*/
|
|
||||||
static void SetGeneralData(GeneralData*& g);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//*** non static functions ***
|
//*** non static functions ***
|
||||||
//*** getters ***
|
//*** getters ***
|
||||||
@ -127,9 +120,10 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
void ResetParametersforNewMeasurement();
|
void ResetParametersforNewMeasurement();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Max frames per file
|
* Set GeneralData pointer to the one given
|
||||||
|
* @param g address of GeneralData (Detector Data) pointer
|
||||||
*/
|
*/
|
||||||
void SetMaxFramesPerFile();
|
void SetGeneralData(GeneralData* g);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set File Format
|
* Set File Format
|
||||||
@ -146,20 +140,28 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* @param owenable pointer to over write enable
|
* @param owenable pointer to over write enable
|
||||||
* @param dindex pointer to detector index
|
* @param dindex pointer to detector index
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
* @param nunits pointer to number of theads/ units per detector
|
||||||
|
* @param nf pointer to number of images in acquisition
|
||||||
|
* @param dr dynamic range
|
||||||
|
* @param g address of GeneralData (Detector Data) pointer
|
||||||
*/
|
*/
|
||||||
void SetupFileWriter(char* fname, char* fpath, uint64_t* findex,
|
void SetupFileWriter(char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, GeneralData* g = 0);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create New File
|
* Create New File
|
||||||
|
* @param en ten giga enable
|
||||||
|
* @param nf number of frames
|
||||||
|
* @param at acquisition time
|
||||||
|
* @param ap acquisition period
|
||||||
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
int CreateNewFile();
|
int CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t ap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes file
|
* Closes files
|
||||||
*/
|
*/
|
||||||
void CloseFile();
|
void CloseFiles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -226,13 +228,14 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
static pthread_mutex_t Mutex;
|
static pthread_mutex_t Mutex;
|
||||||
|
|
||||||
/** GeneralData (Detector Data) object */
|
/** GeneralData (Detector Data) object */
|
||||||
static const GeneralData* generalData;
|
const GeneralData* generalData;
|
||||||
|
|
||||||
/** Fifo structure */
|
/** Fifo structure */
|
||||||
Fifo* fifo;
|
Fifo* fifo;
|
||||||
|
|
||||||
|
|
||||||
// individual members
|
// individual members
|
||||||
|
|
||||||
/** Aquisition Started flag */
|
/** Aquisition Started flag */
|
||||||
bool acquisitionStartedFlag;
|
bool acquisitionStartedFlag;
|
||||||
|
|
||||||
|
@ -29,9 +29,11 @@ class File : private virtual slsReceiverDefs {
|
|||||||
* @param owenable pointer to over write enable
|
* @param owenable pointer to over write enable
|
||||||
* @param dindex pointer to detector index
|
* @param dindex pointer to detector index
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
* @param nunits pointer to number of theads/ units per detector
|
||||||
|
* @param nf pointer to number of images in acquisition
|
||||||
|
* @param dr dynamic range
|
||||||
*/
|
*/
|
||||||
File(int ind, char* fname, char* fpath, uint64_t* findex,
|
File(int ind, char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -53,7 +55,7 @@ class File : private virtual slsReceiverDefs {
|
|||||||
* Get Type
|
* Get Type
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
virtual fileFormat GetType() = 0;
|
virtual fileFormat GetFileType() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Member Pointer Values before the object is destroyed
|
* Get Member Pointer Values before the object is destroyed
|
||||||
@ -64,9 +66,11 @@ class File : private virtual slsReceiverDefs {
|
|||||||
* @param owenable pointer to over write enable
|
* @param owenable pointer to over write enable
|
||||||
* @param dindex pointer to detector index
|
* @param dindex pointer to detector index
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
* @param nunits pointer to number of theads/ units per detector
|
||||||
|
* @param nf pointer to number of images in acquisition
|
||||||
|
* @param dr dynamic range
|
||||||
*/
|
*/
|
||||||
void GetMemberPointerValues(char* fname, char* fpath, uint64_t* findex,
|
void GetMemberPointerValues(char*& fname, char*& fpath, uint64_t*& findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
|
bool*& frindexenable, bool*& owenable, int*& dindex, int*& nunits, uint64_t*& nf, uint32_t* dr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create file
|
* Create file
|
||||||
@ -74,17 +78,51 @@ class File : private virtual slsReceiverDefs {
|
|||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
virtual int CreateFile(uint64_t fnum){
|
virtual int CreateFile(uint64_t fnum){
|
||||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
cprintf(RED,"This is a generic function CreateFile that should be overloaded by a derived class\n");
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close File
|
* Close Current File
|
||||||
*/
|
*/
|
||||||
virtual void CloseFile() {
|
virtual void CloseCurrentFile() {
|
||||||
|
cprintf(RED,"This is a generic function CloseCurrentFile that should be overloaded by a derived class\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Files
|
||||||
|
*/
|
||||||
|
virtual void CloseAllFiles() {
|
||||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data to file
|
||||||
|
* @param buffer buffer to write from
|
||||||
|
* @param fnum current image number
|
||||||
|
* @param OK or FAIL
|
||||||
|
*/
|
||||||
|
virtual int WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||||
|
cprintf(RED,"This is a generic function WriteToFile that should be overloaded by a derived class\n");
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create common files
|
||||||
|
* @param en ten giga enable
|
||||||
|
* @param size image size
|
||||||
|
* @param nx number of pixels in x direction
|
||||||
|
* @param ny number of pixels in y direction
|
||||||
|
* @param at acquisition time
|
||||||
|
* @param ap acquisition period
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
virtual int CreateCommonFiles(bool en, uint32_t size,
|
||||||
|
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) {
|
||||||
|
cprintf(RED,"This is a generic function CreateCommonFiles that should be overloaded by a derived class\n");
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Binary specific
|
// Binary specific
|
||||||
/**
|
/**
|
||||||
@ -92,13 +130,26 @@ class File : private virtual slsReceiverDefs {
|
|||||||
* @param maxf maximum frames per file
|
* @param maxf maximum frames per file
|
||||||
*/
|
*/
|
||||||
virtual void SetMaxFramesPerFile(uint32_t maxf) {
|
virtual void SetMaxFramesPerFile(uint32_t maxf) {
|
||||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
cprintf(RED,"This is a generic function SetMaxFramesPerFile that should be overloaded by a derived class\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// HDf5 specific
|
||||||
|
/**
|
||||||
|
* Set Number of pixels
|
||||||
|
* @param nx number of pixels in x direction
|
||||||
|
* @param ny number of pixels in y direction
|
||||||
|
*/
|
||||||
|
virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) {
|
||||||
|
cprintf(RED,"This is a generic function SetNumberofPixels that should be overloaded by a derived class\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/** master file writer/reader */
|
||||||
|
bool master;
|
||||||
|
|
||||||
/** Self Index */
|
/** Self Index */
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
@ -126,6 +177,12 @@ class File : private virtual slsReceiverDefs {
|
|||||||
/** Number of units per detector. Eg. Eiger has 2, others 1 */
|
/** Number of units per detector. Eg. Eiger has 2, others 1 */
|
||||||
int* numUnitsPerDetector;
|
int* numUnitsPerDetector;
|
||||||
|
|
||||||
|
/** Number of images in acquisition */
|
||||||
|
uint64_t* numImages;
|
||||||
|
|
||||||
|
/** Dynamic Range */
|
||||||
|
uint32_t* dynamicRange;
|
||||||
|
|
||||||
/** Current File Name */
|
/** Current File Name */
|
||||||
std::string currentFileName;
|
std::string currentFileName;
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,9 @@ public:
|
|||||||
/** Number of Pixels in y axis */
|
/** Number of Pixels in y axis */
|
||||||
uint32_t nPixelsY;
|
uint32_t nPixelsY;
|
||||||
|
|
||||||
|
/** Size of header in Packet */
|
||||||
|
uint32_t headerSizeinPacket;
|
||||||
|
|
||||||
/** Size of just data in 1 packet (in bytes) */
|
/** Size of just data in 1 packet (in bytes) */
|
||||||
uint32_t dataSize;
|
uint32_t dataSize;
|
||||||
|
|
||||||
@ -127,6 +130,7 @@ public:
|
|||||||
printf("\n\nDetector Data Variables:\n");
|
printf("\n\nDetector Data Variables:\n");
|
||||||
printf( "Pixels X: %d\n"
|
printf( "Pixels X: %d\n"
|
||||||
"Pixels Y: %d\n"
|
"Pixels Y: %d\n"
|
||||||
|
"Header Size in Packet: %d\n"
|
||||||
"Data Size: %d\n"
|
"Data Size: %d\n"
|
||||||
"Packet Size: %d\n"
|
"Packet Size: %d\n"
|
||||||
"Packets per Frame: %d\n"
|
"Packets per Frame: %d\n"
|
||||||
@ -143,6 +147,7 @@ public:
|
|||||||
"Header Packet Size: %d\n",
|
"Header Packet Size: %d\n",
|
||||||
nPixelsX,
|
nPixelsX,
|
||||||
nPixelsY,
|
nPixelsY,
|
||||||
|
headerSizeinPacket,
|
||||||
dataSize,
|
dataSize,
|
||||||
packetSize,
|
packetSize,
|
||||||
packetsPerFrame,
|
packetsPerFrame,
|
||||||
@ -169,6 +174,7 @@ class GotthardData : public GeneralData {
|
|||||||
GotthardData(){
|
GotthardData(){
|
||||||
nPixelsX = 1280;
|
nPixelsX = 1280;
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
|
headerSizeinPacket = 4;
|
||||||
dataSize = 1280;
|
dataSize = 1280;
|
||||||
packetSize = 1286;
|
packetSize = 1286;
|
||||||
packetsPerFrame = 2;
|
packetsPerFrame = 2;
|
||||||
@ -177,7 +183,7 @@ class GotthardData : public GeneralData {
|
|||||||
frameIndexOffset = 1;
|
frameIndexOffset = 1;
|
||||||
packetIndexMask = 1;
|
packetIndexMask = 1;
|
||||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
||||||
defaultFifoDepth = 25000;
|
defaultFifoDepth = 25000;
|
||||||
};
|
};
|
||||||
@ -192,13 +198,14 @@ class ShortGotthardData : public GeneralData {
|
|||||||
ShortGotthardData(){
|
ShortGotthardData(){
|
||||||
nPixelsX = 256;
|
nPixelsX = 256;
|
||||||
nPixelsY = 1;
|
nPixelsY = 1;
|
||||||
|
headerSizeinPacket = 4;
|
||||||
dataSize = 512;
|
dataSize = 512;
|
||||||
packetSize = 518;
|
packetSize = 518;
|
||||||
packetsPerFrame = 1;
|
packetsPerFrame = 1;
|
||||||
imageSize = dataSize*packetsPerFrame;
|
imageSize = dataSize*packetsPerFrame;
|
||||||
frameIndexMask = 0xFFFFFFFF;
|
frameIndexMask = 0xFFFFFFFF;
|
||||||
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
||||||
defaultFifoDepth = 25000;
|
defaultFifoDepth = 25000;
|
||||||
};
|
};
|
||||||
@ -209,8 +216,8 @@ class PropixData : public GeneralData {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** dynamic range for calculating image size */
|
/**bytes per pixel for calculating image size */
|
||||||
const static uint32_t dynamicRange = 16;
|
const static uint32_t bytesPerPixel = 2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -218,15 +225,16 @@ class PropixData : public GeneralData {
|
|||||||
PropixData(){
|
PropixData(){
|
||||||
nPixelsX = 22;
|
nPixelsX = 22;
|
||||||
nPixelsY = 22;
|
nPixelsY = 22;
|
||||||
|
headerSizeinPacket = 4;
|
||||||
dataSize = 1280;
|
dataSize = 1280;
|
||||||
packetSize = 1286;
|
packetSize = 1286;
|
||||||
packetsPerFrame = 2; //not really
|
packetsPerFrame = 2; //not really
|
||||||
imageSize = nPixelsX*nPixelsY*dynamicRange;
|
imageSize = nPixelsX*nPixelsY*bytesPerPixel;
|
||||||
frameIndexMask = 0xFFFFFFFE;
|
frameIndexMask = 0xFFFFFFFE;
|
||||||
frameIndexOffset = 1;
|
frameIndexOffset = 1;
|
||||||
packetIndexMask = 1;
|
packetIndexMask = 1;
|
||||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES;
|
||||||
defaultFifoDepth = 25000;
|
defaultFifoDepth = 25000;
|
||||||
};
|
};
|
||||||
@ -244,6 +252,7 @@ class Moench02Data : public GeneralData {
|
|||||||
Moench02Data(){
|
Moench02Data(){
|
||||||
nPixelsX = 160;
|
nPixelsX = 160;
|
||||||
nPixelsY = 160;
|
nPixelsY = 160;
|
||||||
|
headerSizeinPacket = 4;
|
||||||
dataSize = 1280;
|
dataSize = 1280;
|
||||||
packetSize = 1286;
|
packetSize = 1286;
|
||||||
packetsPerFrame = 40;
|
packetsPerFrame = 40;
|
||||||
@ -252,7 +261,7 @@ class Moench02Data : public GeneralData {
|
|||||||
frameIndexOffset = 8;
|
frameIndexOffset = 8;
|
||||||
packetIndexMask = 0xFF;
|
packetIndexMask = 0xFF;
|
||||||
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 2500;
|
defaultFifoDepth = 2500;
|
||||||
};
|
};
|
||||||
@ -271,33 +280,23 @@ class Moench03Data : public GeneralData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Size of packet header */
|
|
||||||
const static uint32_t packetHeaderSize = 22;
|
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
Moench03Data(){
|
Moench03Data(){
|
||||||
nPixelsX = 400;
|
nPixelsX = 400;
|
||||||
nPixelsY = 400;
|
nPixelsY = 400;
|
||||||
|
headerSizeinPacket = 22;
|
||||||
dataSize = 8192;
|
dataSize = 8192;
|
||||||
packetSize = packetHeaderSize + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
packetsPerFrame = 40;
|
packetsPerFrame = 40;
|
||||||
imageSize = dataSize*packetsPerFrame;
|
imageSize = dataSize*packetsPerFrame;
|
||||||
frameIndexMask = 0xFFFFFFFF;
|
frameIndexMask = 0xFFFFFFFF;
|
||||||
frameIndexOffset = (6+8);
|
frameIndexOffset = (6+8);
|
||||||
packetIndexMask = 0xFFFFFFFF;
|
packetIndexMask = 0xFFFFFFFF;
|
||||||
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 2500;
|
defaultFifoDepth = 2500;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Print all variables
|
|
||||||
*/
|
|
||||||
void Print() const {
|
|
||||||
GeneralData::Print();
|
|
||||||
printf("Packet Header Size: %d\n",packetHeaderSize);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -312,12 +311,13 @@ class JCTBData : public GeneralData {
|
|||||||
JCTBData(){
|
JCTBData(){
|
||||||
nPixelsX = 32;
|
nPixelsX = 32;
|
||||||
nPixelsY = 128;
|
nPixelsY = 128;
|
||||||
|
headerSizeinPacket = 22;
|
||||||
dataSize = 8192;
|
dataSize = 8192;
|
||||||
packetSize = 8224;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
packetsPerFrame = 1;
|
packetsPerFrame = 1;
|
||||||
imageSize = dataSize*packetsPerFrame;
|
imageSize = dataSize*packetsPerFrame;
|
||||||
maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 2500;
|
defaultFifoDepth = 2500;
|
||||||
};
|
};
|
||||||
@ -354,12 +354,13 @@ private:
|
|||||||
JungfrauData(){
|
JungfrauData(){
|
||||||
nPixelsX = (256*4);
|
nPixelsX = (256*4);
|
||||||
nPixelsY = 256;
|
nPixelsY = 256;
|
||||||
|
headerSizeinPacket = 22;
|
||||||
dataSize = 8192;
|
dataSize = 8192;
|
||||||
packetSize = packetHeaderSize + dataSize;
|
packetSize = headerSizeinPacket + dataSize;
|
||||||
packetsPerFrame = 128;
|
packetsPerFrame = 128;
|
||||||
imageSize = dataSize*packetsPerFrame;
|
imageSize = dataSize*packetsPerFrame;
|
||||||
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 2500;
|
defaultFifoDepth = 2500;
|
||||||
};
|
};
|
||||||
@ -422,16 +423,17 @@ private:
|
|||||||
EigerData(){
|
EigerData(){
|
||||||
nPixelsX = (256*2);
|
nPixelsX = (256*2);
|
||||||
nPixelsY = 256;
|
nPixelsY = 256;
|
||||||
|
headerSizeinPacket = 8;
|
||||||
dataSize = 1024;
|
dataSize = 1024;
|
||||||
packetSize = 1040;
|
packetSize = headerSizeinPacket + dataSize + 8;
|
||||||
packetsPerFrame = 256;
|
packetsPerFrame = 256;
|
||||||
imageSize = dataSize*packetsPerFrame;
|
imageSize = dataSize*packetsPerFrame;
|
||||||
frameIndexMask = 0xffffff;
|
frameIndexMask = 0xffffff;
|
||||||
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = imageSize;
|
||||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 100;
|
defaultFifoDepth = 100;
|
||||||
footerOffset = packetHeaderSize+dataSize;
|
footerOffset = headerSizeinPacket + dataSize;
|
||||||
threadsPerReceiver = 2;
|
threadsPerReceiver = 2;
|
||||||
headerPacketSize = 48;
|
headerPacketSize = 48;
|
||||||
};
|
};
|
||||||
|
@ -3,21 +3,30 @@
|
|||||||
* @short sets/gets properties for the HDF5 file,
|
* @short sets/gets properties for the HDF5 file,
|
||||||
* creates/closes the file and writes data to it
|
* creates/closes the file and writes data to it
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
//#define HDF5C
|
||||||
|
//#ifdef HDF5C
|
||||||
#ifndef HDF5_FILE_H
|
#ifndef HDF5_FILE_H
|
||||||
#define HDF5_FILE_H
|
#define HDF5_FILE_H
|
||||||
|
|
||||||
#include "File.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@short sets/gets properties for the HDF5 file, creates/closes the file and writes data to it
|
*@short sets/gets properties for the HDF5 file, creates/closes the file and writes data to it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "File.h"
|
||||||
|
#include "H5Cpp.h"
|
||||||
|
#ifndef H5_NO_NAMESPACE
|
||||||
|
using namespace H5;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class HDF5File : private virtual slsReceiverDefs, public File {
|
class HDF5File : private virtual slsReceiverDefs, public File {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* creates the File Writer
|
* creates the File Writer
|
||||||
|
* @param ind self index
|
||||||
* @param fname pointer to file name prefix
|
* @param fname pointer to file name prefix
|
||||||
* @param fpath pointer to file path
|
* @param fpath pointer to file path
|
||||||
* @param findex pointer to file index
|
* @param findex pointer to file index
|
||||||
@ -25,9 +34,14 @@ class HDF5File : private virtual slsReceiverDefs, public File {
|
|||||||
* @param owenable pointer to over write enable
|
* @param owenable pointer to over write enable
|
||||||
* @param dindex pointer to detector index
|
* @param dindex pointer to detector index
|
||||||
* @param nunits pointer to number of theads/ units per detector
|
* @param nunits pointer to number of theads/ units per detector
|
||||||
|
* @param nf pointer to number of frames
|
||||||
|
* @param dr dynamic range
|
||||||
|
* @param nx number of pixels in x direction
|
||||||
|
* @param ny number of pixels in y direction
|
||||||
*/
|
*/
|
||||||
HDF5File(int ind, char* fname, char* fpath, uint64_t* findex,
|
HDF5File(int ind, char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits);
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
|
||||||
|
int nx, int ny);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -39,6 +53,13 @@ class HDF5File : private virtual slsReceiverDefs, public File {
|
|||||||
*/
|
*/
|
||||||
void PrintMembers();
|
void PrintMembers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Number of pixels
|
||||||
|
* @param nx number of pixels in x direction
|
||||||
|
* @param ny number of pixels in y direction
|
||||||
|
*/
|
||||||
|
void SetNumberofPixels(uint32_t nx, uint32_t ny);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create file
|
* Create file
|
||||||
* @param fnum current frame index to include in file name
|
* @param fnum current frame index to include in file name
|
||||||
@ -47,9 +68,23 @@ class HDF5File : private virtual slsReceiverDefs, public File {
|
|||||||
int CreateFile(uint64_t fnum);
|
int CreateFile(uint64_t fnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close File
|
* Close Current File
|
||||||
*/
|
*/
|
||||||
void CloseFile();
|
void CloseCurrentFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close all Files
|
||||||
|
*/
|
||||||
|
void CloseAllFiles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data to file
|
||||||
|
* @param buffer buffer to write from
|
||||||
|
* @param bsize size of buffer (not used)
|
||||||
|
* @param fnum current image number
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int WriteToFile(char* buffer, int bsize, uint64_t fnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create File Name in format fpath/fnameprefix_fx_dy_z.raw,
|
* Create File Name in format fpath/fnameprefix_fx_dy_z.raw,
|
||||||
@ -69,16 +104,60 @@ class HDF5File : private virtual slsReceiverDefs, public File {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create File
|
* Create File
|
||||||
|
* @param ind object index for debugging
|
||||||
* @param owenable overwrite enable
|
* @param owenable overwrite enable
|
||||||
|
* @param numf number of images
|
||||||
* @param fname complete file name
|
* @param fname complete file name
|
||||||
|
* @param fnum current image number
|
||||||
|
* @param nx number of pixels in x dir
|
||||||
|
* @param ny number of pixels in y dir
|
||||||
|
* @param dtype data type
|
||||||
|
* @param fd file pointer
|
||||||
|
* @param dspace dataspace pointer
|
||||||
|
* @param dset dataset pointer
|
||||||
* @returns OK or FAIL
|
* @returns OK or FAIL
|
||||||
*/
|
*/
|
||||||
static int CreateDataFile(bool owenable, char* fname);
|
static int CreateDataFile(int ind, bool owenable, uint64_t numf, std::string fname, uint64_t fnum, int nx, int ny,
|
||||||
|
DataType dtype, H5File*& fd, DataSpace*& dspace, DataSet*& dset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close File
|
* Close File
|
||||||
|
* @param fd file pointer
|
||||||
|
* @param dp dataspace pointer
|
||||||
|
* @param ds dataset pointer
|
||||||
*/
|
*/
|
||||||
static void CloseDataFile();
|
|
||||||
|
static void CloseDataFile(H5File*& fd, DataSpace*& dp, DataSet*& ds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write data to file
|
||||||
|
* @param ind object index for debugging
|
||||||
|
* @param buf buffer to write from
|
||||||
|
* @param numImages number of images
|
||||||
|
* @param nx number of pixels in x direction
|
||||||
|
* @param ny number of pixels in y direction
|
||||||
|
* @param fnum current image number
|
||||||
|
* @param dspace dataspace pointer
|
||||||
|
* @param dset dataset pointer
|
||||||
|
* @param dtype datatype
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
static int WriteDataFile(int ind, char* buf, uint64_t numImages, int nx, int ny, uint64_t fnum,
|
||||||
|
DataSpace* dspace, DataSet* dset, DataType dtype);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create common files
|
||||||
|
* @param en ten giga enable
|
||||||
|
* @param size image size
|
||||||
|
* @param nx number of pixels in x direction
|
||||||
|
* @param ny number of pixels in y direction
|
||||||
|
* @param at acquisition time
|
||||||
|
* @param ap acquisition period
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int CreateCommonFiles(bool en, uint32_t size,
|
||||||
|
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -86,8 +165,73 @@ class HDF5File : private virtual slsReceiverDefs, public File {
|
|||||||
* Get Type
|
* Get Type
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
fileFormat GetType();
|
fileFormat GetFileType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates data type depending on current dynamic range
|
||||||
|
*/
|
||||||
|
void UpdateDataType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create file names for master and virtual file
|
||||||
|
* @param m master file name
|
||||||
|
* @param v virtual file name
|
||||||
|
* @param fpath file path
|
||||||
|
* @param fnameprefix file name prefix (includes scan and position variables)
|
||||||
|
* @param findex file index
|
||||||
|
*/
|
||||||
|
void CreateCommonFileNames(std::string& m, std::string& v, char* fpath, char* fnameprefix, uint64_t findex);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close master and virtual files
|
||||||
|
*/
|
||||||
|
void CloseCommonDataFiles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create master and virtual files
|
||||||
|
* @param m master file name
|
||||||
|
* @param v virtual file name
|
||||||
|
* @param owenable overwrite enable
|
||||||
|
* @param tengigaEnable ten giga enable
|
||||||
|
* @param imageSize image size
|
||||||
|
* @param nPixelsX number of pixels in x direction
|
||||||
|
* @param nPixelsY number of pixels in y direction
|
||||||
|
* @param acquisitionTime acquisition time
|
||||||
|
* @param acquisitionPeriod acquisition period
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int CreateCommonDataFiles(std::string m, std::string v, bool owenable,
|
||||||
|
bool tengigaEnable, uint32_t imageSize, uint32_t nPixelsX, uint32_t nPixelsY,
|
||||||
|
uint64_t acquisitionTime, uint64_t acquisitionPeriod);
|
||||||
|
|
||||||
|
|
||||||
|
/** mutex to update static items among objects (threads)*/
|
||||||
|
static pthread_mutex_t Mutex;
|
||||||
|
|
||||||
|
/** Master File handle */
|
||||||
|
static H5File* masterfd;
|
||||||
|
|
||||||
|
/** Virtual File handle */
|
||||||
|
static H5File* virtualfd;
|
||||||
|
|
||||||
|
/** File handle */
|
||||||
|
H5File* filefd;
|
||||||
|
|
||||||
|
/** Dataspace handle */
|
||||||
|
DataSpace* dataspace;
|
||||||
|
|
||||||
|
/** DataSet handle */
|
||||||
|
DataSet* dataset;
|
||||||
|
|
||||||
|
/** Datatype of dataset */
|
||||||
|
DataType datatype;
|
||||||
|
|
||||||
|
/** Number of pixels in x direction */
|
||||||
|
int nPixelsX;
|
||||||
|
|
||||||
|
/** Number of pixels in y direction */
|
||||||
|
int nPixelsY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -238,6 +238,10 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Carry over packet buffer */
|
/** Carry over packet buffer */
|
||||||
char* carryOverPacket;
|
char* carryOverPacket;
|
||||||
|
|
||||||
|
/** Listening buffer for one packet - might be removed when we can peek and eiger fnum is in header */
|
||||||
|
char* listeningPacket;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,6 +234,12 @@ private:
|
|||||||
*/
|
*/
|
||||||
void StartRunning();
|
void StartRunning();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies if the callbacks are registered for the callback variable
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int VerifyCallBackAction();
|
||||||
|
|
||||||
|
|
||||||
//*** Class Members ***
|
//*** Class Members ***
|
||||||
|
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
|
|
||||||
//binary
|
//binary
|
||||||
#define FILE_FRAME_HEADER_SIZE 16
|
#define FILE_FRAME_HEADER_SIZE 16
|
||||||
|
#define FILE_BUFFER_SIZE (16*1024*1024) //16mb
|
||||||
|
|
||||||
|
//hdf5
|
||||||
|
#define MAX_CHUNKED_IMAGES 1
|
||||||
|
|
||||||
|
//versions
|
||||||
|
#define HDF5_WRITER_VERSION 1.0
|
||||||
|
#define BINARY_WRITER_VERSION 1.0 //1 decimal places
|
||||||
|
|
||||||
//fifo
|
//fifo
|
||||||
#define FIFO_HEADER_NUMBYTES 4
|
#define FIFO_HEADER_NUMBYTES 4
|
||||||
|
@ -5,23 +5,28 @@
|
|||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
#include "BinaryFile.h"
|
#include "BinaryFile.h"
|
||||||
|
#include "receiver_defs.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <string.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
FILE* BinaryFile::masterfd = 0;
|
||||||
|
|
||||||
BinaryFile::BinaryFile(int ind, char* fname, char* fpath, uint64_t* findex,
|
BinaryFile::BinaryFile(int ind, char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint32_t maxf):
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, uint32_t maxf):
|
||||||
File(ind, fname, fpath, findex, frindexenable, owenable, dindex, nunits),
|
File(ind, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr),
|
||||||
maxFramesPerFile(maxf)
|
maxFramesPerFile(maxf),
|
||||||
|
filefd(0)
|
||||||
{
|
{
|
||||||
printf("%d BinaryFile constructor\n",index);
|
#ifdef VERBOSE
|
||||||
PrintMembers();
|
PrintMembers();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryFile::~BinaryFile() {
|
BinaryFile::~BinaryFile() {
|
||||||
printf("%d BinaryFile destructor\n",index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryFile::PrintMembers() {
|
void BinaryFile::PrintMembers() {
|
||||||
@ -29,7 +34,7 @@ void BinaryFile::PrintMembers() {
|
|||||||
printf("Max Frames Per File: %d\n",maxFramesPerFile);
|
printf("Max Frames Per File: %d\n",maxFramesPerFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
slsReceiverDefs::fileFormat BinaryFile::GetType() {
|
slsReceiverDefs::fileFormat BinaryFile::GetFileType() {
|
||||||
return BINARY;
|
return BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,15 +46,45 @@ int BinaryFile::CreateFile(uint64_t fnum) {
|
|||||||
currentFileName = CreateFileName(filePath, fileNamePrefix, *fileIndex,
|
currentFileName = CreateFileName(filePath, fileNamePrefix, *fileIndex,
|
||||||
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
|
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
|
||||||
|
|
||||||
printf("%d Binary File: %s\n", index, currentFileName.c_str());
|
if (CreateDataFile(filefd, *overWriteEnable, currentFileName) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
|
printf("%d Binary File created: %s\n", index, currentFileName.c_str());
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BinaryFile::CloseCurrentFile() {
|
||||||
void BinaryFile::CloseFile() {
|
CloseDataFile(filefd);
|
||||||
printf("%d Closing File: %s\n", index, currentFileName.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BinaryFile::CloseAllFiles() {
|
||||||
|
CloseDataFile(filefd);
|
||||||
|
if (master)
|
||||||
|
CloseCommonDataFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||||
|
if (WriteDataFile(filefd, buffer, buffersize, fnum) == buffersize)
|
||||||
|
return OK;
|
||||||
|
cprintf(RED,"%d Error: Write to file failed for image number %lld\n", index, (long long int)fnum);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int BinaryFile::CreateCommonFiles(bool en, uint32_t size,
|
||||||
|
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) {
|
||||||
|
if (master) {
|
||||||
|
string masterFileName="";
|
||||||
|
CreateCommonFileNames(masterFileName, filePath, fileNamePrefix, *fileIndex);
|
||||||
|
printf("Master HDF5 File: %s\n", masterFileName.c_str());
|
||||||
|
//create common files
|
||||||
|
return CreateCommonDataFiles(masterFileName, *overWriteEnable,
|
||||||
|
en, size, nx, ny, at, ap);
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** static function ***/
|
||||||
string BinaryFile::CreateFileName(char* fpath, char* fnameprefix, uint64_t findex,
|
string BinaryFile::CreateFileName(char* fpath, char* fnameprefix, uint64_t findex,
|
||||||
bool frindexenable, uint64_t fnum, int dindex, int numunits, int unitindex) {
|
bool frindexenable, uint64_t fnum, int dindex, int numunits, int unitindex) {
|
||||||
ostringstream osfn;
|
ostringstream osfn;
|
||||||
@ -61,10 +96,100 @@ string BinaryFile::CreateFileName(char* fpath, char* fnameprefix, uint64_t finde
|
|||||||
return osfn.str();
|
return osfn.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BinaryFile::CreateDataFile(bool owenable, char* fname) {
|
/*** static function ***/
|
||||||
|
int BinaryFile::CreateDataFile(FILE*& fd, bool owenable, string fname) {
|
||||||
|
if(!owenable){
|
||||||
|
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
|
||||||
|
FILE_LOG(logERROR) << "Could not create/overwrite file" << fname;
|
||||||
|
fd = 0;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}else if (NULL == (fd = fopen((const char *) fname.c_str(), "w"))){
|
||||||
|
FILE_LOG(logERROR) << "Could not create file" << fname;
|
||||||
|
fd = 0;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
//setting file buffer size to 16mb
|
||||||
|
setvbuf(fd,NULL,_IOFBF,FILE_BUFFER_SIZE);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryFile::CloseDataFile() {
|
/*** static function ***/
|
||||||
|
void BinaryFile::CloseDataFile(FILE*& fd) {
|
||||||
|
if (fd)
|
||||||
|
fclose(fd);
|
||||||
|
fd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** static function ***/
|
||||||
|
int BinaryFile::WriteDataFile(FILE* fd, char* buf, int bsize, uint64_t fnum) {
|
||||||
|
if (!fd)
|
||||||
|
return 0;
|
||||||
|
return fwrite(buf, 1, bsize, fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BinaryFile::CreateCommonFileNames(string& m, char* fpath, char* fnameprefix, uint64_t findex) {
|
||||||
|
ostringstream osfn;
|
||||||
|
osfn << fpath << "/" << fnameprefix;
|
||||||
|
osfn << "_master";
|
||||||
|
osfn << "_" << findex;
|
||||||
|
osfn << ".raw";
|
||||||
|
m = osfn.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BinaryFile::CloseCommonDataFiles() {
|
||||||
|
if(masterfd)
|
||||||
|
delete masterfd;
|
||||||
|
masterfd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int BinaryFile::CreateCommonDataFiles(string m, bool owenable,
|
||||||
|
bool tengigaEnable, uint32_t imageSize, uint32_t nPixelsX, uint32_t nPixelsY,
|
||||||
|
uint64_t acquisitionTime, uint64_t acquisitionPeriod) {
|
||||||
|
if(!owenable){
|
||||||
|
if (NULL == (masterfd = fopen((const char *) m.c_str(), "wx"))){
|
||||||
|
cprintf(RED,"Error in creating binary master file %s\n",m.c_str());
|
||||||
|
masterfd = 0;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}else if (NULL == (masterfd = fopen((const char *) m.c_str(), "w"))){
|
||||||
|
cprintf(RED,"Error in creating binary master file %s\n",m.c_str());
|
||||||
|
masterfd = 0;
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
time_t t = time(0);
|
||||||
|
char message[MAX_STR_LENGTH];
|
||||||
|
sprintf(message,
|
||||||
|
"Version\t\t: %.1f\n"
|
||||||
|
"Dynamic Range\t: %d\n"
|
||||||
|
"Ten Giga\t: %d\n"
|
||||||
|
"Image Size\t: %d bytes\n"
|
||||||
|
"x\t\t: %d pixels\n"
|
||||||
|
"y\t\t: %d pixels\n"
|
||||||
|
"Total Frames\t: %lld\n"
|
||||||
|
"Exptime (ns)\t: %lld\n"
|
||||||
|
"Period (ns)\t: %lld\n"
|
||||||
|
"Timestamp\t: %s\n\n",
|
||||||
|
BINARY_WRITER_VERSION,
|
||||||
|
*dynamicRange,
|
||||||
|
tengigaEnable,
|
||||||
|
imageSize,
|
||||||
|
nPixelsX,
|
||||||
|
nPixelsY,
|
||||||
|
(long long int)numImages,
|
||||||
|
(long long int)acquisitionTime,
|
||||||
|
(long long int)acquisitionPeriod,
|
||||||
|
ctime(&t));
|
||||||
|
if (strlen(message) > MAX_STR_LENGTH) {
|
||||||
|
cprintf(BG_RED,"Master File Size %d is greater than max str size %d\n",
|
||||||
|
(int)strlen(message), MAX_STR_LENGTH);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fwrite((void*)message, 1, strlen(message), masterfd) != strlen(message))
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
|
CloseDataFile(masterfd);
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,13 @@ uint64_t DataProcessor::RunningMask(0x0);
|
|||||||
|
|
||||||
pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
const GeneralData* DataProcessor::generalData(0);
|
|
||||||
|
|
||||||
|
|
||||||
DataProcessor::DataProcessor(Fifo*& f, runStatus* s, pthread_mutex_t* m, fileFormat* ftype, bool* fwenable,
|
DataProcessor::DataProcessor(Fifo*& f, runStatus* s, pthread_mutex_t* m, fileFormat* ftype, bool* fwenable,
|
||||||
int* cbaction,
|
int* cbaction,
|
||||||
void (*dataReadycb)(int, char*, int, FILE*, char*, void*),
|
void (*dataReadycb)(int, char*, int, FILE*, char*, void*),
|
||||||
void *pDataReadycb) :
|
void *pDataReadycb) :
|
||||||
ThreadObject(NumberofDataProcessors),
|
ThreadObject(NumberofDataProcessors),
|
||||||
|
generalData(0),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
acquisitionStartedFlag(false),
|
acquisitionStartedFlag(false),
|
||||||
measurementStartedFlag(false),
|
measurementStartedFlag(false),
|
||||||
@ -58,6 +57,7 @@ DataProcessor::DataProcessor(Fifo*& f, runStatus* s, pthread_mutex_t* m, fileFor
|
|||||||
ErrorMask ^= (1<<index);
|
ErrorMask ^= (1<<index);
|
||||||
pthread_mutex_unlock(&Mutex);
|
pthread_mutex_unlock(&Mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberofDataProcessors++;
|
NumberofDataProcessors++;
|
||||||
FILE_LOG (logDEBUG) << "Number of DataProcessors: " << NumberofDataProcessors << endl;
|
FILE_LOG (logDEBUG) << "Number of DataProcessors: " << NumberofDataProcessors << endl;
|
||||||
}
|
}
|
||||||
@ -79,14 +79,6 @@ uint64_t DataProcessor::GetRunningMask() {
|
|||||||
return RunningMask;
|
return RunningMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataProcessor::SetGeneralData(GeneralData*& g) {
|
|
||||||
generalData = g;
|
|
||||||
#ifdef VERY_VERBOSE
|
|
||||||
generalData->Print();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** non static functions */
|
/** non static functions */
|
||||||
/** getters */
|
/** getters */
|
||||||
string DataProcessor::GetType(){
|
string DataProcessor::GetType(){
|
||||||
@ -136,11 +128,9 @@ void DataProcessor::StopRunning() {
|
|||||||
|
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo*& f) {
|
void DataProcessor::SetFifo(Fifo*& f) {
|
||||||
|
|
||||||
fifo = f;
|
fifo = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataProcessor::ResetParametersforNewAcquisition() {
|
void DataProcessor::ResetParametersforNewAcquisition() {
|
||||||
numTotalFramesCaught = 0;
|
numTotalFramesCaught = 0;
|
||||||
firstAcquisitionIndex = 0;
|
firstAcquisitionIndex = 0;
|
||||||
@ -180,39 +170,41 @@ void DataProcessor::RecordFirstIndices(uint64_t fnum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataProcessor::SetMaxFramesPerFile() {
|
void DataProcessor::SetGeneralData(GeneralData* g) {
|
||||||
if (file->GetType() == BINARY)
|
generalData = g;
|
||||||
|
#ifdef VERY_VERBOSE
|
||||||
|
generalData->Print();
|
||||||
|
#endif
|
||||||
|
if (!file) {
|
||||||
|
cprintf(RED, "Error Calling SetGeneralData with no file object. Should not be here\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file->GetFileType() == BINARY)
|
||||||
file->SetMaxFramesPerFile(generalData->maxFramesPerFile);
|
file->SetMaxFramesPerFile(generalData->maxFramesPerFile);
|
||||||
|
else if (file->GetFileType() == HDF5) {
|
||||||
|
file->SetNumberofPixels(generalData->nPixelsX, generalData->nPixelsY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DataProcessor::SetFileFormat(const fileFormat f) {
|
void DataProcessor::SetFileFormat(const fileFormat f) {
|
||||||
|
if (file->GetFileType() != f) {
|
||||||
if (*fileFormatType != f) {
|
|
||||||
switch(f){
|
|
||||||
#ifdef HDF5C
|
|
||||||
case HDF5:
|
|
||||||
*fileFormatType = f;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
*fileFormatType = f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//remember the pointer values before they are destroyed
|
//remember the pointer values before they are destroyed
|
||||||
char* fname=0; char* fpath=0; uint64_t* findex=0; bool* frindexenable=0;
|
char* fname=0; char* fpath=0; uint64_t* findex=0; bool* frindexenable=0;
|
||||||
bool* fwenable=0; bool* owenable=0; int* dindex=0; int* nunits=0;
|
bool* owenable=0; int* dindex=0; int* nunits=0; uint64_t* nf = 0; uint32_t* dr = 0;
|
||||||
file->GetMemberPointerValues(fname, fpath, findex, frindexenable, owenable, dindex, nunits);
|
file->GetMemberPointerValues(fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr);
|
||||||
|
//create file writer with same pointers
|
||||||
SetupFileWriter(fname, fpath, findex, frindexenable, owenable, dindex, nunits);
|
SetupFileWriter(fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DataProcessor::SetupFileWriter(char* fname, char* fpath, uint64_t* findex,
|
void DataProcessor::SetupFileWriter(char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits)
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr, GeneralData* g)
|
||||||
{
|
{
|
||||||
|
if (g)
|
||||||
|
generalData = g;
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
delete file;
|
delete file;
|
||||||
@ -221,19 +213,21 @@ void DataProcessor::SetupFileWriter(char* fname, char* fpath, uint64_t* findex,
|
|||||||
#ifdef HDF5C
|
#ifdef HDF5C
|
||||||
case HDF5:
|
case HDF5:
|
||||||
file = new HDF5File(index, fname, fpath, findex,
|
file = new HDF5File(index, fname, fpath, findex,
|
||||||
frindexenable, owenable, dindex, nunits);
|
frindexenable, owenable, dindex, nunits, nf, dr, generalData->nPixelsX, generalData->nPixelsY);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
file = new BinaryFile(index, fname, fpath, findex,
|
file = new BinaryFile(index, fname, fpath, findex,
|
||||||
frindexenable, owenable, dindex, nunits, generalData->maxFramesPerFile);
|
frindexenable, owenable, dindex, nunits, nf, dr, generalData->maxFramesPerFile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DataProcessor::CreateNewFile() {
|
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t ap) {
|
||||||
if (!file)
|
file->CloseAllFiles();
|
||||||
|
if (file->CreateCommonFiles(en, generalData->imageSize, generalData->nPixelsX, generalData->nPixelsY,
|
||||||
|
at, ap) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
if (file->CreateFile(currentFrameIndex) == FAIL)
|
if (file->CreateFile(currentFrameIndex) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -241,10 +235,9 @@ int DataProcessor::CreateNewFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DataProcessor::CloseFiles() {
|
||||||
void DataProcessor::CloseFile() {
|
|
||||||
if (file)
|
if (file)
|
||||||
file->CloseFile();
|
file->CloseAllFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,7 +265,7 @@ void DataProcessor::ThreadExecution() {
|
|||||||
|
|
||||||
void DataProcessor::StopProcessing(char* buf) {
|
void DataProcessor::StopProcessing(char* buf) {
|
||||||
fifo->FreeAddress(buf);
|
fifo->FreeAddress(buf);
|
||||||
CloseFile();
|
file->CloseCurrentFile();
|
||||||
StopRunning();
|
StopRunning();
|
||||||
cprintf(BLUE,"%d: Processing Completed\n", index);
|
cprintf(BLUE,"%d: Processing Completed\n", index);
|
||||||
}
|
}
|
||||||
@ -282,11 +275,20 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
|||||||
numFramesCaught++;
|
numFramesCaught++;
|
||||||
numTotalFramesCaught++;
|
numTotalFramesCaught++;
|
||||||
|
|
||||||
|
|
||||||
uint64_t fnum = (*((uint64_t*)buf));
|
uint64_t fnum = (*((uint64_t*)buf));
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lld\n", index, (long long int)fnum);
|
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lld\n", index, (long long int)fnum);
|
||||||
//#endif
|
#endif
|
||||||
if (!measurementStartedFlag)
|
|
||||||
|
if (!measurementStartedFlag) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lld\n", index, (long long int)fnum);
|
||||||
|
#endif
|
||||||
RecordFirstIndices(fnum);
|
RecordFirstIndices(fnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileWriteEnable && *callbackAction == DO_EVERYTHING)
|
||||||
|
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES, generalData->fifoBufferSize + FILE_FRAME_HEADER_SIZE, fnum-firstMeasurementIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
File::File(int ind, char* fname, char* fpath, uint64_t* findex,
|
File::File(int ind, char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits):
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr):
|
||||||
index(ind),
|
index(ind),
|
||||||
fileNamePrefix(fname),
|
fileNamePrefix(fname),
|
||||||
filePath(fpath),
|
filePath(fpath),
|
||||||
@ -19,14 +19,14 @@ File::File(int ind, char* fname, char* fpath, uint64_t* findex,
|
|||||||
frameIndexEnable(frindexenable),
|
frameIndexEnable(frindexenable),
|
||||||
overWriteEnable(owenable),
|
overWriteEnable(owenable),
|
||||||
detIndex(dindex),
|
detIndex(dindex),
|
||||||
numUnitsPerDetector(nunits)
|
numUnitsPerDetector(nunits),
|
||||||
|
numImages(nf),
|
||||||
|
dynamicRange(dr)
|
||||||
{
|
{
|
||||||
printf("%d File constructor\n",index);
|
master = index?false:true;
|
||||||
}
|
}
|
||||||
|
|
||||||
File::~File() {
|
File::~File() {}
|
||||||
printf("%d File Destructor\n", index);
|
|
||||||
}
|
|
||||||
|
|
||||||
string File::GetCurrentFileName() {
|
string File::GetCurrentFileName() {
|
||||||
return currentFileName;
|
return currentFileName;
|
||||||
@ -53,8 +53,8 @@ void File::PrintMembers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void File::GetMemberPointerValues(char* fname, char* fpath, uint64_t* findex,
|
void File::GetMemberPointerValues(char*& fname, char*& fpath, uint64_t*& findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits)
|
bool*& frindexenable, bool*& owenable, int*& dindex, int*& nunits, uint64_t*& nf, uint32_t* dr)
|
||||||
{
|
{
|
||||||
fname = fileNamePrefix;
|
fname = fileNamePrefix;
|
||||||
fpath = filePath;
|
fpath = filePath;
|
||||||
@ -63,4 +63,6 @@ void File::GetMemberPointerValues(char* fname, char* fpath, uint64_t* findex,
|
|||||||
owenable = overWriteEnable;
|
owenable = overWriteEnable;
|
||||||
dindex = detIndex;
|
dindex = detIndex;
|
||||||
nunits = numUnitsPerDetector;
|
nunits = numUnitsPerDetector;
|
||||||
|
nf = numImages;
|
||||||
|
dr = dynamicRange;
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,36 @@
|
|||||||
* creates/closes the file and writes data to it
|
* creates/closes the file and writes data to it
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
|
|
||||||
|
//#define HDF5C /*********************?????????????????* Need to remove this in the header file to o*************************************?????????????????????***/
|
||||||
|
//#ifdef HDF5C
|
||||||
#include "HDF5File.h"
|
#include "HDF5File.h"
|
||||||
|
#include "receiver_defs.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
pthread_mutex_t HDF5File::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
H5File* HDF5File::masterfd = 0;
|
||||||
|
H5File* HDF5File::virtualfd = 0;
|
||||||
|
|
||||||
HDF5File::HDF5File(int ind, char* fname, char* fpath, uint64_t* findex,
|
HDF5File::HDF5File(int ind, char* fname, char* fpath, uint64_t* findex,
|
||||||
bool* frindexenable, bool* owenable, int* dindex, int* nunits):
|
bool* frindexenable, bool* owenable, int* dindex, int* nunits, uint64_t* nf, uint32_t* dr,
|
||||||
File(ind, fname, fpath, findex, frindexenable, owenable, dindex, nunits)
|
int nx, int ny):
|
||||||
|
File(ind, fname, fpath, findex, frindexenable, owenable, dindex, nunits, nf, dr),
|
||||||
|
filefd(0),
|
||||||
|
dataspace(0),
|
||||||
|
dataset(0),
|
||||||
|
datatype(PredType::STD_U16LE),
|
||||||
|
nPixelsX(nx),
|
||||||
|
nPixelsY(ny)
|
||||||
{
|
{
|
||||||
printf("%d HDF5File constructor\n",index);
|
printf("%d HDF5File constructor\n",index);
|
||||||
|
#ifdef VERBOSE
|
||||||
PrintMembers();
|
PrintMembers();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -26,25 +43,88 @@ HDF5File::~HDF5File() {
|
|||||||
|
|
||||||
void HDF5File::PrintMembers() {
|
void HDF5File::PrintMembers() {
|
||||||
File::PrintMembers();
|
File::PrintMembers();
|
||||||
printf("\nHDF5 Print Members \n");
|
UpdateDataType();
|
||||||
|
if (datatype == PredType::STD_U8LE) {
|
||||||
|
printf("Data Type: 4 or 8\n");
|
||||||
|
} else if (datatype == PredType::STD_U16LE) {
|
||||||
|
printf("Data Type: 16\n");
|
||||||
|
} else if (datatype == PredType::STD_U32LE) {
|
||||||
|
printf("Data Type: 32\n");
|
||||||
|
} else {
|
||||||
|
cprintf(BG_RED,"unknown data type\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HDF5File::SetNumberofPixels(uint32_t nx, uint32_t ny) {
|
||||||
|
nPixelsX = nx;
|
||||||
|
nPixelsY = ny;
|
||||||
|
}
|
||||||
|
|
||||||
slsReceiverDefs::fileFormat HDF5File::GetType() {
|
slsReceiverDefs::fileFormat HDF5File::GetFileType() {
|
||||||
return HDF5;
|
return HDF5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HDF5File::UpdateDataType() {
|
||||||
|
switch(*dynamicRange){
|
||||||
|
case 4: datatype = PredType::STD_U8LE; break;
|
||||||
|
case 8: datatype = PredType::STD_U8LE; break;
|
||||||
|
case 16: datatype = PredType::STD_U16LE; break;
|
||||||
|
case 32: datatype = PredType::STD_U32LE; break;
|
||||||
|
default: cprintf(BG_RED,"unknown dynamic range\n");
|
||||||
|
datatype = PredType::STD_U16LE; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int HDF5File::CreateFile(uint64_t fnum) {
|
int HDF5File::CreateFile(uint64_t fnum) {
|
||||||
currentFileName = CreateFileName(filePath, fileNamePrefix, *fileIndex,
|
currentFileName = CreateFileName(filePath, fileNamePrefix, *fileIndex,
|
||||||
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
|
*frameIndexEnable, fnum, *detIndex, *numUnitsPerDetector, index);
|
||||||
|
|
||||||
|
//create file
|
||||||
|
UpdateDataType();
|
||||||
|
if (CreateDataFile(index, *overWriteEnable, *numImages, currentFileName, fnum,
|
||||||
|
((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX), nPixelsY,
|
||||||
|
datatype, filefd, dataspace, dataset) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
printf("%d HDF5 File: %s\n", index, currentFileName.c_str());
|
printf("%d HDF5 File: %s\n", index, currentFileName.c_str());
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HDF5File::CloseCurrentFile() {
|
||||||
void HDF5File::CloseFile() {
|
CloseDataFile(filefd, dataspace, dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HDF5File::CloseAllFiles() {
|
||||||
|
CloseDataFile(filefd, dataspace, dataset);
|
||||||
|
if (master)
|
||||||
|
CloseCommonDataFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||||
|
if (WriteDataFile(index, buffer, *numImages,
|
||||||
|
((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX), nPixelsY, fnum,
|
||||||
|
dataspace, dataset, datatype) == OK)
|
||||||
|
return OK;
|
||||||
|
cprintf(RED,"%d Error: Write to file failed\n", index);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int HDF5File::CreateCommonFiles(bool en, uint32_t size,
|
||||||
|
uint32_t nx, uint32_t ny, uint64_t at, uint64_t ap) {
|
||||||
|
if (master) {
|
||||||
|
string masterFileName="", virtualFileName="";
|
||||||
|
CreateCommonFileNames(masterFileName, virtualFileName, filePath, fileNamePrefix, *fileIndex);
|
||||||
|
printf("Master HDF5 File: %s\nVirtual HDF5 File: %s\n", masterFileName.c_str(), virtualFileName.c_str());
|
||||||
|
//create common files
|
||||||
|
return CreateCommonDataFiles(masterFileName, virtualFileName, *overWriteEnable,
|
||||||
|
en, size, nx, ny, at, ap);
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** static function ***/
|
||||||
string HDF5File::CreateFileName(char* fpath, char* fnameprefix, uint64_t findex,
|
string HDF5File::CreateFileName(char* fpath, char* fnameprefix, uint64_t findex,
|
||||||
bool frindexenable, uint64_t fnum, int dindex, int numunits, int unitindex) {
|
bool frindexenable, uint64_t fnum, int dindex, int numunits, int unitindex) {
|
||||||
ostringstream osfn;
|
ostringstream osfn;
|
||||||
@ -56,10 +136,208 @@ string HDF5File::CreateFileName(char* fpath, char* fnameprefix, uint64_t findex,
|
|||||||
return osfn.str();
|
return osfn.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int HDF5File::CreateDataFile(bool owenable, char* fname) {
|
/*** static function ***/
|
||||||
|
int HDF5File::CreateDataFile(int ind, bool owenable, uint64_t numf, string fname, uint64_t fnum, int nx, int ny,
|
||||||
|
DataType dtype, H5File*& fd, DataSpace*& dspace, DataSet*& dset) {
|
||||||
|
pthread_mutex_lock(&Mutex);
|
||||||
|
try {
|
||||||
|
Exception::dontPrint(); //to handle errors
|
||||||
|
|
||||||
|
//file
|
||||||
|
FileAccPropList flist;
|
||||||
|
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||||
|
if(!owenable)
|
||||||
|
fd = new H5File( fname.c_str(), H5F_ACC_EXCL, NULL,flist );
|
||||||
|
else
|
||||||
|
fd = new H5File( fname.c_str(), H5F_ACC_TRUNC, NULL, flist );
|
||||||
|
|
||||||
|
//attributes - version
|
||||||
|
double dValue=HDF5_WRITER_VERSION;
|
||||||
|
DataSpace dataspace_attr = DataSpace (H5S_SCALAR);
|
||||||
|
Attribute attribute = fd->createAttribute("version",PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||||
|
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
||||||
|
|
||||||
|
//dataspace
|
||||||
|
char dsetname[100];
|
||||||
|
hsize_t srcdims[3] = {numf,ny,nx};
|
||||||
|
dspace = new DataSpace (3,srcdims);
|
||||||
|
sprintf(dsetname, "/data_%012lld", (long long int)fnum);
|
||||||
|
|
||||||
|
//dataset
|
||||||
|
//create chunked dataset if greater than max_chunked_images
|
||||||
|
if(numf > MAX_CHUNKED_IMAGES){
|
||||||
|
DSetCreatPropList plist;
|
||||||
|
hsize_t chunk_dims[3] ={MAX_CHUNKED_IMAGES, ny, nx};
|
||||||
|
plist.setChunk(3, chunk_dims);
|
||||||
|
dset = new DataSet (fd->createDataSet(dsetname, dtype, *dspace, plist));
|
||||||
|
}else
|
||||||
|
dset = new DataSet (fd->createDataSet(dsetname, dtype, *dspace));
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(Exception error){
|
||||||
|
cprintf(RED,"Error in creating HDF5 handles in object %d\n",ind);
|
||||||
|
error.printError();
|
||||||
|
fd->close();
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDF5File::CloseDataFile() {
|
|
||||||
|
|
||||||
|
|
||||||
|
/*** static function ***/
|
||||||
|
void HDF5File::CloseDataFile(H5File*& fd, DataSpace*& dp, DataSet*& ds) {
|
||||||
|
pthread_mutex_lock(&Mutex);
|
||||||
|
try {
|
||||||
|
Exception::dontPrint(); //to handle errors
|
||||||
|
if(dp) {delete dp; dp = 0;}
|
||||||
|
if(ds) {delete ds; ds = 0;}
|
||||||
|
if(fd) {delete fd; fd = 0;}
|
||||||
|
} catch(Exception error) {
|
||||||
|
cprintf(RED,"Error in closing HDF5 handles\n");
|
||||||
|
error.printError();
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** static function ***/
|
||||||
|
int HDF5File::WriteDataFile(int ind, char* buf, uint64_t numImages, int nx, int ny, uint64_t fnum,
|
||||||
|
DataSpace* dspace, DataSet* dset, DataType dtype) {
|
||||||
|
pthread_mutex_lock(&Mutex);
|
||||||
|
hsize_t count[3] = {1, ny,nx};
|
||||||
|
hsize_t start[3] = {fnum%numImages, 0 , 0};
|
||||||
|
hsize_t dims2[2]={ny,nx};
|
||||||
|
try{
|
||||||
|
Exception::dontPrint(); //to handle errors
|
||||||
|
|
||||||
|
dspace->selectHyperslab( H5S_SELECT_SET, count, start);
|
||||||
|
DataSpace memspace(2,dims2);
|
||||||
|
dset->write(buf, dtype, memspace, *dspace);
|
||||||
|
memspace.close();
|
||||||
|
}
|
||||||
|
catch(Exception error){
|
||||||
|
cprintf(RED,"Error in writing to file in object %d\n",ind);
|
||||||
|
error.printError();
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HDF5File::CreateCommonFileNames(string& m, string& v, char* fpath, char* fnameprefix, uint64_t findex) {
|
||||||
|
ostringstream osfn;
|
||||||
|
osfn << fpath << "/" << fnameprefix;
|
||||||
|
osfn << "_master";
|
||||||
|
osfn << "_" << findex;
|
||||||
|
osfn << ".h5";
|
||||||
|
m = osfn.str();
|
||||||
|
v.assign(m);
|
||||||
|
v.replace(v.find("_master", 0), 7, "_virtual");
|
||||||
|
}
|
||||||
|
|
||||||
|
void HDF5File::CloseCommonDataFiles() {
|
||||||
|
pthread_mutex_lock(&Mutex);
|
||||||
|
try {
|
||||||
|
Exception::dontPrint(); //to handle errors
|
||||||
|
if(masterfd) {delete masterfd; masterfd = 0;}
|
||||||
|
if(virtualfd) {delete virtualfd; virtualfd = 0;}
|
||||||
|
} catch(Exception error) {
|
||||||
|
cprintf(RED,"Error in closing common HDF5 handles\n");
|
||||||
|
error.printError();
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int HDF5File::CreateCommonDataFiles(string m, string v, bool owenable,
|
||||||
|
bool tengigaEnable, uint32_t imageSize, uint32_t nPixelsX, uint32_t nPixelsY,
|
||||||
|
uint64_t acquisitionTime, uint64_t acquisitionPeriod) {
|
||||||
|
pthread_mutex_lock(&Mutex);
|
||||||
|
try {
|
||||||
|
//Exception::dontPrint(); //to handle errors
|
||||||
|
|
||||||
|
FileAccPropList flist;
|
||||||
|
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||||
|
if(!owenable)
|
||||||
|
masterfd = new H5File( m.c_str(), H5F_ACC_EXCL, NULL, flist );
|
||||||
|
else
|
||||||
|
masterfd = new H5File( m.c_str(), H5F_ACC_TRUNC, NULL, flist );
|
||||||
|
|
||||||
|
//variables
|
||||||
|
DataSpace dataspace = DataSpace (H5S_SCALAR);
|
||||||
|
Attribute attribute;
|
||||||
|
DataSet dataset;
|
||||||
|
int iValue=0;
|
||||||
|
double dValue=0;
|
||||||
|
StrType strdatatype(PredType::C_S1,256);
|
||||||
|
|
||||||
|
//create attributes
|
||||||
|
//version
|
||||||
|
dValue=HDF5_WRITER_VERSION;
|
||||||
|
attribute = masterfd->createAttribute("version",PredType::NATIVE_DOUBLE, dataspace);
|
||||||
|
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
||||||
|
|
||||||
|
//Create a group in the file
|
||||||
|
Group group1( masterfd->createGroup( "entry" ) );
|
||||||
|
Group group2( group1.createGroup("data") );
|
||||||
|
Group group3( group1.createGroup("instrument") );
|
||||||
|
Group group4( group3.createGroup("beam") );
|
||||||
|
Group group5( group3.createGroup("detector") );
|
||||||
|
Group group6( group1.createGroup("sample") );
|
||||||
|
|
||||||
|
//Dynamic Range
|
||||||
|
dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace );
|
||||||
|
dataset.write ( dynamicRange, PredType::NATIVE_INT);
|
||||||
|
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||||
|
attribute.write(strdatatype, string("bits"));
|
||||||
|
//Ten Giga
|
||||||
|
iValue = tengigaEnable;
|
||||||
|
dataset = group5.createDataSet ( "ten giga enable", PredType::NATIVE_INT, dataspace );
|
||||||
|
dataset.write ( &iValue, PredType::NATIVE_INT);
|
||||||
|
//Image Size
|
||||||
|
dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace );
|
||||||
|
dataset.write ( &imageSize, PredType::NATIVE_INT);
|
||||||
|
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||||
|
attribute.write(strdatatype, string("bytes"));
|
||||||
|
//x
|
||||||
|
dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace );
|
||||||
|
dataset.write ( &nPixelsX, PredType::NATIVE_INT);
|
||||||
|
//y
|
||||||
|
dataset = group5.createDataSet ( "number of pixels in y axis", PredType::NATIVE_INT, dataspace );
|
||||||
|
dataset.write ( &nPixelsY, PredType::NATIVE_INT);
|
||||||
|
//Total Frames
|
||||||
|
dataset = group5.createDataSet ( "total frames", PredType::STD_U64LE, dataspace );
|
||||||
|
dataset.write ( &numImages, PredType::STD_U64LE);
|
||||||
|
//Exptime
|
||||||
|
dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace );
|
||||||
|
dataset.write ( &acquisitionTime, PredType::STD_U64LE);
|
||||||
|
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||||
|
attribute.write(strdatatype, string("ns"));
|
||||||
|
//Period
|
||||||
|
dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace );
|
||||||
|
dataset.write ( &acquisitionPeriod, PredType::STD_U64LE);
|
||||||
|
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||||
|
attribute.write(strdatatype, string("ns"));
|
||||||
|
//Timestamp
|
||||||
|
time_t t = time(0);
|
||||||
|
dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace );
|
||||||
|
dataset.write ( string(ctime(&t)), strdatatype );
|
||||||
|
|
||||||
|
masterfd->close();
|
||||||
|
|
||||||
|
} catch(Exception error) {
|
||||||
|
cprintf(RED,"Error in creating common HDF5 handles\n");
|
||||||
|
error.printError();
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&Mutex);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//#endif
|
||||||
|
@ -44,7 +44,8 @@ Listener::Listener(Fifo*& f, runStatus* s, uint32_t* portno, char* e) :
|
|||||||
currentFrameIndex(0),
|
currentFrameIndex(0),
|
||||||
lastCaughtFrameIndex(0),
|
lastCaughtFrameIndex(0),
|
||||||
carryOverFlag(0),
|
carryOverFlag(0),
|
||||||
carryOverPacket(0)
|
carryOverPacket(0),
|
||||||
|
listeningPacket(0)
|
||||||
{
|
{
|
||||||
if(ThreadObject::CreateThread()){
|
if(ThreadObject::CreateThread()){
|
||||||
pthread_mutex_lock(&Mutex);
|
pthread_mutex_lock(&Mutex);
|
||||||
@ -58,6 +59,7 @@ Listener::Listener(Fifo*& f, runStatus* s, uint32_t* portno, char* e) :
|
|||||||
|
|
||||||
Listener::~Listener() {
|
Listener::~Listener() {
|
||||||
if (carryOverPacket) delete carryOverPacket;
|
if (carryOverPacket) delete carryOverPacket;
|
||||||
|
if (listeningPacket) delete listeningPacket;
|
||||||
ThreadObject::DestroyThread();
|
ThreadObject::DestroyThread();
|
||||||
NumberofListeners--;
|
NumberofListeners--;
|
||||||
}
|
}
|
||||||
@ -145,6 +147,9 @@ void Listener::ResetParametersforNewMeasurement(){
|
|||||||
if (carryOverPacket)
|
if (carryOverPacket)
|
||||||
delete carryOverPacket;
|
delete carryOverPacket;
|
||||||
carryOverPacket = new char[generalData->packetSize];
|
carryOverPacket = new char[generalData->packetSize];
|
||||||
|
if (listeningPacket)
|
||||||
|
delete listeningPacket;
|
||||||
|
listeningPacket = new char[generalData->packetSize];
|
||||||
|
|
||||||
if(RunningMask){
|
if(RunningMask){
|
||||||
pthread_mutex_lock(&Mutex);
|
pthread_mutex_lock(&Mutex);
|
||||||
@ -167,7 +172,7 @@ void Listener::RecordFirstIndices(uint64_t fnum) {
|
|||||||
acquisitionStartedFlag = true;
|
acquisitionStartedFlag = true;
|
||||||
firstAcquisitionIndex = fnum;
|
firstAcquisitionIndex = fnum;
|
||||||
}
|
}
|
||||||
if (!index) cprintf(GREEN,"%d First Acquisition Index:%lld\n"
|
if (!index) cprintf(MAGENTA,"%d First Acquisition Index:%lld\n"
|
||||||
"%d First Measurement Index:%lld\n",
|
"%d First Measurement Index:%lld\n",
|
||||||
index, (long long int)firstAcquisitionIndex,
|
index, (long long int)firstAcquisitionIndex,
|
||||||
index, (long long int)firstMeasurementIndex);
|
index, (long long int)firstMeasurementIndex);
|
||||||
@ -266,12 +271,12 @@ void Listener::StopListening(char* buf) {
|
|||||||
uint32_t Listener::ListenToAnImage(char* buf) {
|
uint32_t Listener::ListenToAnImage(char* buf) {
|
||||||
uint32_t rc = 0;
|
uint32_t rc = 0;
|
||||||
uint64_t fnum = 0; uint32_t pnum = 0;
|
uint64_t fnum = 0; uint32_t pnum = 0;
|
||||||
uint32_t offset = 0;
|
int dsize = generalData->dataSize;
|
||||||
uint32_t currentpnum = 0;
|
|
||||||
int psize = generalData->packetSize;
|
|
||||||
|
|
||||||
//reset to -1
|
//reset to -1
|
||||||
memset(buf,0xFF,psize);
|
memset(buf,0xFF,dsize);
|
||||||
|
|
||||||
|
|
||||||
//look for carry over
|
//look for carry over
|
||||||
if (carryOverFlag) {
|
if (carryOverFlag) {
|
||||||
@ -281,45 +286,41 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
|||||||
return generalData->imageSize;
|
return generalData->imageSize;
|
||||||
}
|
}
|
||||||
carryOverFlag = false;
|
carryOverFlag = false;
|
||||||
memcpy(buf,carryOverPacket, psize);
|
memcpy(buf + (pnum * dsize), carryOverPacket + generalData->headerSizeinPacket, dsize);
|
||||||
offset += psize;
|
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE))) = fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (offset < generalData->fifoBufferSize) {
|
|
||||||
|
while (pnum < (generalData->packetsPerFrame-1)) {
|
||||||
|
|
||||||
//listen to new packet
|
//listen to new packet
|
||||||
rc += udpSocket->ReceiveDataOnly(buf + offset);
|
rc += udpSocket->ReceiveDataOnly(listeningPacket);
|
||||||
if (rc <= 0) return 0;
|
if (rc <= 0) return 0;
|
||||||
|
|
||||||
|
|
||||||
//update parameters
|
//update parameters
|
||||||
numPacketsCaught++; //record immediately to get more time before socket shutdown
|
numPacketsCaught++; //record immediately to get more time before socket shutdown
|
||||||
numTotalPacketsCaught++;
|
numTotalPacketsCaught++;
|
||||||
generalData->GetHeaderInfo(index,buf + offset,fnum,pnum);
|
generalData->GetHeaderInfo(index,listeningPacket,fnum,pnum);
|
||||||
lastCaughtFrameIndex = fnum;
|
lastCaughtFrameIndex = fnum;
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
if (!index && !pnum) cprintf(BLUE,"Listening %d: fnum:%lld, pnum:%d\n", index, (long long int)fnum, pnum);
|
if (!index && !pnum) cprintf(GREEN,"Listening %d: fnum:%lld, pnum:%d\n", index, (long long int)fnum, pnum);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
if (!measurementStartedFlag)
|
if (!measurementStartedFlag)
|
||||||
RecordFirstIndices(fnum);
|
RecordFirstIndices(fnum);
|
||||||
|
|
||||||
|
|
||||||
//future packet
|
//future packet
|
||||||
if(fnum != currentFrameIndex) {
|
if(fnum != currentFrameIndex) {
|
||||||
carryOverFlag = true;
|
carryOverFlag = true;
|
||||||
memcpy(carryOverPacket,buf + offset, psize);
|
memcpy(carryOverPacket,listeningPacket, generalData->packetSize);
|
||||||
return generalData->imageSize;
|
return generalData->imageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//copy packet and update fnum
|
||||||
|
memcpy(buf + (pnum * dsize), listeningPacket + generalData->headerSizeinPacket, dsize);
|
||||||
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE))) = fnum;
|
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE))) = fnum;
|
||||||
|
|
||||||
//future packet of same frame
|
|
||||||
if(pnum != currentpnum) {
|
|
||||||
memcpy(buf + (pnum * psize), buf + offset, psize);
|
|
||||||
memset(buf + offset, 0xFF, psize);
|
|
||||||
}
|
|
||||||
|
|
||||||
//update offset & current frame index
|
|
||||||
offset = (pnum + 1) * psize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return generalData->imageSize;
|
return generalData->imageSize;
|
||||||
|
@ -19,20 +19,20 @@ using namespace std;
|
|||||||
/** cosntructor & destructor */
|
/** cosntructor & destructor */
|
||||||
|
|
||||||
UDPStandardImplementation::UDPStandardImplementation() {
|
UDPStandardImplementation::UDPStandardImplementation() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
InitializeMembers();
|
InitializeMembers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UDPStandardImplementation::~UDPStandardImplementation() {
|
UDPStandardImplementation::~UDPStandardImplementation() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
DeleteMembers();
|
DeleteMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::DeleteMembers() {
|
void UDPStandardImplementation::DeleteMembers() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
if (generalData) { delete generalData; generalData=0;}
|
if (generalData) { delete generalData; generalData=0;}
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
@ -51,7 +51,7 @@ void UDPStandardImplementation::DeleteMembers() {
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::InitializeMembers() {
|
void UDPStandardImplementation::InitializeMembers() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
UDPBaseImplementation::initializeMembers();
|
UDPBaseImplementation::initializeMembers();
|
||||||
acquisitionPeriod = SAMPLE_TIME_IN_NS;
|
acquisitionPeriod = SAMPLE_TIME_IN_NS;
|
||||||
@ -76,7 +76,7 @@ void UDPStandardImplementation::InitializeMembers() {
|
|||||||
/*** Overloaded Functions called by TCP Interface ***/
|
/*** Overloaded Functions called by TCP Interface ***/
|
||||||
|
|
||||||
uint64_t UDPStandardImplementation::getTotalFramesCaught() const {
|
uint64_t UDPStandardImplementation::getTotalFramesCaught() const {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
@ -94,7 +94,7 @@ uint64_t UDPStandardImplementation::getTotalFramesCaught() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t UDPStandardImplementation::getFramesCaught() const {
|
uint64_t UDPStandardImplementation::getFramesCaught() const {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
@ -111,7 +111,7 @@ uint64_t UDPStandardImplementation::getFramesCaught() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t UDPStandardImplementation::getAcquisitionIndex() const {
|
int64_t UDPStandardImplementation::getAcquisitionIndex() const {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
uint32_t flagsum = 0;
|
uint32_t flagsum = 0;
|
||||||
@ -131,6 +131,15 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const {
|
|||||||
void UDPStandardImplementation::setFileFormat(const fileFormat f){
|
void UDPStandardImplementation::setFileFormat(const fileFormat f){
|
||||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||||
|
|
||||||
|
switch(f){
|
||||||
|
#ifdef HDF5C
|
||||||
|
case HDF5:
|
||||||
|
fileFormatType = f;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
fileFormatType = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
//destroy file writer, set file format and create file writer
|
//destroy file writer, set file format and create file writer
|
||||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
(*it)->SetFileFormat(f);
|
(*it)->SetFileFormat(f);
|
||||||
@ -141,7 +150,7 @@ void UDPStandardImplementation::setFileFormat(const fileFormat f){
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::setFileName(const char c[]) {
|
void UDPStandardImplementation::setFileName(const char c[]) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
if (strlen(c)) {
|
if (strlen(c)) {
|
||||||
strcpy(fileName, c); //automatically update fileName in Filewriter (pointer)
|
strcpy(fileName, c); //automatically update fileName in Filewriter (pointer)
|
||||||
@ -163,7 +172,7 @@ void UDPStandardImplementation::setFileName(const char c[]) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (myDetectorType != GOTTHARD) {
|
if (myDetectorType != GOTTHARD) {
|
||||||
cprintf(RED, "Error: Can not set short frame for this detector\n");
|
cprintf(RED, "Error: Can not set short frame for this detector\n");
|
||||||
@ -183,12 +192,10 @@ int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
|||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
Listener::SetGeneralData(generalData);
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
DataProcessor::SetGeneralData(generalData);
|
(*it)->SetGeneralData(generalData);
|
||||||
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
(*it)->SetGeneralData(generalData);
|
||||||
(*it)->SetMaxFramesPerFile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FILE_LOG (logINFO) << "Short Frame Enable: " << shortFrameEnable;
|
FILE_LOG (logINFO) << "Short Frame Enable: " << shortFrameEnable;
|
||||||
return OK;
|
return OK;
|
||||||
@ -196,7 +203,7 @@ int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
|
int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (frameToGuiFrequency != freq) {
|
if (frameToGuiFrequency != freq) {
|
||||||
frameToGuiFrequency = freq;
|
frameToGuiFrequency = freq;
|
||||||
@ -218,7 +225,7 @@ int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (dataStreamEnable != enable) {
|
if (dataStreamEnable != enable) {
|
||||||
dataStreamEnable = enable;
|
dataStreamEnable = enable;
|
||||||
@ -247,7 +254,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
|
int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (acquisitionPeriod != i) {
|
if (acquisitionPeriod != i) {
|
||||||
acquisitionPeriod = i;
|
acquisitionPeriod = i;
|
||||||
@ -269,7 +276,7 @@ int UDPStandardImplementation::setAcquisitionPeriod(const uint64_t i) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
|
int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (acquisitionTime != i) {
|
if (acquisitionTime != i) {
|
||||||
acquisitionTime = i;
|
acquisitionTime = i;
|
||||||
@ -291,7 +298,7 @@ int UDPStandardImplementation::setAcquisitionTime(const uint64_t i) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
|
int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (numberOfFrames != i) {
|
if (numberOfFrames != i) {
|
||||||
numberOfFrames = i;
|
numberOfFrames = i;
|
||||||
@ -313,10 +320,11 @@ int UDPStandardImplementation::setNumberOfFrames(const uint64_t i) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
|
int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (dynamicRange != i) {
|
if (dynamicRange != i) {
|
||||||
dynamicRange = i;
|
dynamicRange = i;
|
||||||
|
|
||||||
//side effects
|
//side effects
|
||||||
generalData->SetDynamicRange(i,tengigaEnable);
|
generalData->SetDynamicRange(i,tengigaEnable);
|
||||||
|
|
||||||
@ -330,7 +338,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setTenGigaEnable(const bool b) {
|
int UDPStandardImplementation::setTenGigaEnable(const bool b) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (tengigaEnable != b) {
|
if (tengigaEnable != b) {
|
||||||
tengigaEnable = b;
|
tengigaEnable = b;
|
||||||
@ -347,7 +355,7 @@ int UDPStandardImplementation::setTenGigaEnable(const bool b) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
|
int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
if (fifoDepth != i) {
|
if (fifoDepth != i) {
|
||||||
fifoDepth = i;
|
fifoDepth = i;
|
||||||
@ -363,7 +371,7 @@ int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
FILE_LOG (logDEBUG) << "Setting receiver type";
|
FILE_LOG (logDEBUG) << "Setting receiver type";
|
||||||
|
|
||||||
@ -395,8 +403,6 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
case JUNGFRAU: generalData = new JungfrauData(); break;
|
case JUNGFRAU: generalData = new JungfrauData(); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
Listener::SetGeneralData(generalData);
|
|
||||||
DataProcessor::SetGeneralData(generalData);
|
|
||||||
numThreads = generalData->threadsPerReceiver;
|
numThreads = generalData->threadsPerReceiver;
|
||||||
fifoDepth = generalData->defaultFifoDepth;
|
fifoDepth = generalData->defaultFifoDepth;
|
||||||
|
|
||||||
@ -428,11 +434,12 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set up writer and callbacks
|
//set up writer and callbacks
|
||||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
(*it)->SetupFileWriter(fileName, filePath, &fileIndex, &frameIndexEnable,
|
(*it)->SetGeneralData(generalData);
|
||||||
&overwriteEnable, &detID, &numThreads);
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||||
|
(*it)->SetupFileWriter(fileName, filePath, &fileIndex, &frameIndexEnable,
|
||||||
|
&overwriteEnable, &detID, &numThreads, &numberOfFrames, &dynamicRange, generalData);
|
||||||
|
}
|
||||||
FILE_LOG (logDEBUG) << " Detector type set to " << getDetectorType(d);
|
FILE_LOG (logDEBUG) << " Detector type set to " << getDetectorType(d);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -440,7 +447,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::resetAcquisitionCount() {
|
void UDPStandardImplementation::resetAcquisitionCount() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
|
||||||
|
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
(*it)->ResetParametersforNewAcquisition();
|
(*it)->ResetParametersforNewAcquisition();
|
||||||
@ -451,13 +458,39 @@ void UDPStandardImplementation::resetAcquisitionCount() {
|
|||||||
FILE_LOG (logINFO) << "Acquisition Count has been reset";
|
FILE_LOG (logINFO) << "Acquisition Count has been reset";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UDPStandardImplementation::VerifyCallBackAction() {
|
||||||
|
/** file path and file index not required?? or need to include detector index? do they need the datasize? its given for write data anyway */
|
||||||
|
|
||||||
|
callbackAction=startAcquisitionCallBack(filePath, fileName, fileIndex,
|
||||||
|
(generalData->fifoBufferSize) * numberofJobs + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
||||||
|
switch(callbackAction) {
|
||||||
|
case 0:
|
||||||
|
if (acquisitionFinishedCallBack == NULL || rawDataReadyCallBack == NULL) {
|
||||||
|
FILE_LOG(logERROR) << "Callback action 0: All the call backs must be registered";
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
cout << "Start Acquisition, Acquisition Finished and Data Write has been defined externally" << endl;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (rawDataReadyCallBack == NULL) {
|
||||||
|
FILE_LOG(logERROR) << "Callback action 1: RawDataReady call backs must be registered";
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
cout << "Data Write defined externally" << endl;
|
||||||
|
break;
|
||||||
|
case 2:break;
|
||||||
|
default:
|
||||||
|
cprintf(RED,"Error: Unknown call back action.\n");
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
int UDPStandardImplementation::startReceiver(char *c) {
|
int UDPStandardImplementation::startReceiver(char *c) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
ResetParametersforNewMeasurement();
|
ResetParametersforNewMeasurement();
|
||||||
|
|
||||||
|
//listener
|
||||||
if (CreateUDPSockets() == FAIL) {
|
if (CreateUDPSockets() == FAIL) {
|
||||||
strcpy(c,"Could not create UDP Socket(s).");
|
strcpy(c,"Could not create UDP Socket(s).");
|
||||||
FILE_LOG(logERROR) << c;
|
FILE_LOG(logERROR) << c;
|
||||||
@ -465,33 +498,24 @@ int UDPStandardImplementation::startReceiver(char *c) {
|
|||||||
}
|
}
|
||||||
cout << "Listener Ready ..." << endl;
|
cout << "Listener Ready ..." << endl;
|
||||||
|
|
||||||
if(fileWriteEnable){
|
//callbacks
|
||||||
if (SetupWriter() == FAIL) {
|
callbackAction = DO_EVERYTHING;
|
||||||
|
if (startAcquisitionCallBack)
|
||||||
|
if (VerifyCallBackAction() == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
|
//processor->writer
|
||||||
|
if (fileWriteEnable) {
|
||||||
|
if (callbackAction > DO_NOTHING && SetupWriter() == FAIL) {
|
||||||
strcpy(c,"Could not create file.");
|
strcpy(c,"Could not create file.");
|
||||||
FILE_LOG(logERROR) << c;
|
FILE_LOG(logERROR) << c;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
cout << "Data will not be saved" << endl;
|
||||||
cout << "Processor Ready ..." << endl;
|
cout << "Processor Ready ..." << endl;
|
||||||
|
|
||||||
|
//status
|
||||||
//callbacks
|
|
||||||
callbackAction = DO_EVERYTHING;
|
|
||||||
|
|
||||||
if (startAcquisitionCallBack) /** file path and file index not required?? or need to include detector index? do they need the datasize? its given for write data anyway */
|
|
||||||
callbackAction=startAcquisitionCallBack(filePath, fileName, fileIndex,
|
|
||||||
(generalData->fifoBufferSize) * numberofJobs + (generalData->fifoBufferHeaderSize), pStartAcquisition);
|
|
||||||
if (callbackAction < DO_EVERYTHING) {
|
|
||||||
FILE_LOG(logINFO) << "Call back activated. Data saving must be taken care of by user in call back.";
|
|
||||||
if (rawDataReadyCallBack) {
|
|
||||||
FILE_LOG(logINFO) << "Data Write has been defined externally";
|
|
||||||
}
|
|
||||||
} else if(!fileWriteEnable) {
|
|
||||||
FILE_LOG(logINFO) << "Data will not be saved";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//change status
|
|
||||||
pthread_mutex_lock(&statusMutex);
|
pthread_mutex_lock(&statusMutex);
|
||||||
status = RUNNING;
|
status = RUNNING;
|
||||||
pthread_mutex_unlock(&(statusMutex));
|
pthread_mutex_unlock(&(statusMutex));
|
||||||
@ -612,7 +636,7 @@ void UDPStandardImplementation::startReadout(){
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::shutDownUDPSockets() {
|
void UDPStandardImplementation::shutDownUDPSockets() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
(*it)->ShutDownUDPSocket();
|
(*it)->ShutDownUDPSocket();
|
||||||
}
|
}
|
||||||
@ -620,15 +644,15 @@ void UDPStandardImplementation::shutDownUDPSockets() {
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::closeFiles() {
|
void UDPStandardImplementation::closeFiles() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
(*it)->CloseFile();
|
(*it)->CloseFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::SetLocalNetworkParameters() {
|
void UDPStandardImplementation::SetLocalNetworkParameters() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
|
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
|
||||||
if (myDetectorType == EIGER)
|
if (myDetectorType == EIGER)
|
||||||
@ -657,7 +681,7 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::SetupFifoStructure() {
|
int UDPStandardImplementation::SetupFifoStructure() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
|
|
||||||
//recalculate number of jobs & fifodepth, return if no change
|
//recalculate number of jobs & fifodepth, return if no change
|
||||||
@ -721,7 +745,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::ResetParametersforNewMeasurement() {
|
void UDPStandardImplementation::ResetParametersforNewMeasurement() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
(*it)->ResetParametersforNewMeasurement();
|
(*it)->ResetParametersforNewMeasurement();
|
||||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
@ -731,7 +755,7 @@ void UDPStandardImplementation::ResetParametersforNewMeasurement() {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::CreateUDPSockets() {
|
int UDPStandardImplementation::CreateUDPSockets() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
for (unsigned int i = 0; i < listener.size(); ++i)
|
for (unsigned int i = 0; i < listener.size(); ++i)
|
||||||
@ -750,11 +774,11 @@ int UDPStandardImplementation::CreateUDPSockets() {
|
|||||||
|
|
||||||
|
|
||||||
int UDPStandardImplementation::SetupWriter() {
|
int UDPStandardImplementation::SetupWriter() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
for (unsigned int i = 0; i < dataProcessor.size(); ++i)
|
for (unsigned int i = 0; i < dataProcessor.size(); ++i)
|
||||||
if (dataProcessor[i]->CreateNewFile() == FAIL) {
|
if (dataProcessor[i]->CreateNewFile(tengigaEnable,
|
||||||
|
numberOfFrames, acquisitionTime, acquisitionPeriod) == FAIL) {
|
||||||
error = true;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -770,7 +794,7 @@ int UDPStandardImplementation::SetupWriter() {
|
|||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::StartRunning() {
|
void UDPStandardImplementation::StartRunning() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
|
||||||
|
|
||||||
//set running mask and post semaphore to start the inner loop in execution thread
|
//set running mask and post semaphore to start the inner loop in execution thread
|
||||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user