Merge branch '4.1.0-rc' of github.com:slsdetectorgroup/slsDetectorPackage into 4.1.0-rc

This commit is contained in:
maliakal_d 2019-08-16 15:33:04 +02:00
commit 5697393a70
11 changed files with 103 additions and 123 deletions

View File

@ -58,19 +58,10 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
/** /**
* Create master file * Create master file
* @param en ten giga enable * @param attr master file attributes
* @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 st sub exposure time
* @param sp sub period
* @param ap acquisition period
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int CreateMasterFile(bool en, uint32_t size, int CreateMasterFile(masterAttributes& attr);
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
uint64_t ap);
/** /**
* Close Current File * Close Current File

View File

@ -100,26 +100,11 @@ class BinaryFileStatic {
* @param fd pointer to file handle * @param fd pointer to file handle
* @param fname master file name * @param fname master file name
* @param owenable overwrite enable * @param owenable overwrite enable
* @param dr dynamic range * @param attr master file attributes
* @param tenE ten giga enable
* @param size image size
* @param nPixelsX number of pixels in x direction
* @param nPixelsY number of pixels in y direction
* @param nf number of images
* @param maxf maximum frames per file
* @param acquisitionTime acquisition time
* @param acquisitionPeriod acquisition period
* @param subexposuretime sub exposure time
* @param subperiod sub period
* @param version version of software for binary writing
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable, static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable,
uint32_t dr, bool tenE, uint32_t size, masterAttributes& attr)
uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf,
uint32_t maxf,
uint64_t acquisitionTime, uint64_t subexposuretime,
uint64_t subperiod, uint64_t acquisitionPeriod, double version)
{ {
if(!owenable){ if(!owenable){
if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){ if (NULL == (fd = fopen((const char *) fname.c_str(), "wx"))){
@ -136,17 +121,20 @@ class BinaryFileStatic {
char message[MAX_MASTER_FILE_LENGTH]; char message[MAX_MASTER_FILE_LENGTH];
sprintf(message, sprintf(message,
"Version : %.1f\n" "Version : %.1f\n"
"Detector Type : %d\n"
"Dynamic Range : %d\n" "Dynamic Range : %d\n"
"Ten Giga : %d\n" "Ten Giga : %d\n"
"Image Size : %d bytes\n" "Image Size : %d bytes\n"
"row : %d pixels\n" "nPixelsX : %d pixels\n"
"col : %d pixels\n" "nPixelsY : %d pixels\n"
"Max. Frames Per File : %u\n" "Max Frames Per File : %u\n"
"Total Frames : %lld\n" "Total Frames : %lld\n"
"Exptime (ns) : %lld\n" "Exptime (ns) : %lld\n"
"SubExptime (ns) : %lld\n" "SubExptime (ns) : %lld\n"
"SubPeriod(ns) : %lld\n" "SubPeriod(ns) : %lld\n"
"Period (ns) : %lld\n" "Period (ns) : %lld\n"
"Gap Pixels Enable : %d\n"
"Quad Enable : %d\n"
"Timestamp : %s\n\n" "Timestamp : %s\n\n"
"#Frame Header\n" "#Frame Header\n"
@ -165,18 +153,21 @@ class BinaryFileStatic {
"Header Version : 1 byte\n" "Header Version : 1 byte\n"
"Packets Caught Mask : 64 bytes\n" "Packets Caught Mask : 64 bytes\n"
, ,
version, attr.version,
dr, attr.detectorType,
tenE, attr.dynamicRange,
size, attr.tenGiga,
nPixelsX, attr.imageSize,
nPixelsY, attr.nPixelsX,
maxf, attr.nPixelsY,
(long long int)nf, attr.maxFramesPerFile,
(long long int)acquisitionTime, (long long int)attr.totalFrames,
(long long int)subexposuretime, (long long int)attr.exptimeNs,
(long long int)subperiod, (long long int)attr.subExptimeNs,
(long long int)acquisitionPeriod, (long long int)attr.subPeriodNs,
(long long int)attr.periodNs,
attr.gapPixelsEnable,
attr.quadEnable,
ctime(&t)); ctime(&t));
if (strlen(message) > MAX_MASTER_FILE_LENGTH) { if (strlen(message) > MAX_MASTER_FILE_LENGTH) {
cprintf(RED,"Master File Size %d is greater than max str size %d\n", cprintf(RED,"Master File Size %d is greater than max str size %d\n",

View File

@ -10,6 +10,7 @@
*/ */
#include "ThreadObject.h" #include "ThreadObject.h"
#include "receiver_defs.h"
class GeneralData; class GeneralData;
class Fifo; class Fifo;
@ -176,16 +177,10 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
/** /**
* Create New File * Create New File
* @param en ten giga enable * @param attr master file attributes
* @param nf number of frames
* @param at acquisition time
* @param st sub exposure time
* @param sp sub period
* @param ap acquisition period
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, int CreateNewFile(masterAttributes& attr);
uint64_t sp, uint64_t ap);
/** /**
* Closes files * Closes files

View File

@ -10,6 +10,7 @@
#include "sls_receiver_defs.h" #include "sls_receiver_defs.h"
#include "logger.h" #include "logger.h"
#include "receiver_defs.h"
#include <string> #include <string>
@ -121,19 +122,10 @@ class File : private virtual slsReceiverDefs {
/** /**
* Create master file * Create master file
* @param en ten giga enable * @param attr master file attributes
* @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 st sub exposure time
* @param sp sub period
* @param ap acquisition period
* @returns OK or FAIL * @returns OK or FAIL
*/ */
virtual int CreateMasterFile(bool en, uint32_t size, virtual int CreateMasterFile(masterAttributes& attr) {
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st,
uint64_t sp, uint64_t ap) {
cprintf(RED,"This is a generic function CreateMasterFile that " cprintf(RED,"This is a generic function CreateMasterFile that "
"should be overloaded by a derived class\n"); "should be overloaded by a derived class\n");
return OK; return OK;

View File

@ -93,19 +93,10 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
/** /**
* Create master file * Create master file
* @param en ten giga enable * @param attr master file attributes
* @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 st sub exposure time
* @param sp sub period
* @param ap acquisition period
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int CreateMasterFile(bool en, uint32_t size, int CreateMasterFile(masterAttributes& attr);
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
uint64_t ap);
/** /**
* End of Acquisition * End of Acquisition

View File

@ -294,26 +294,12 @@ public:
* Create master file * Create master file
* @param fname master file name * @param fname master file name
* @param owenable overwrite enable * @param owenable overwrite enable
* @param dr dynamic range * @param attr master file attributes
* @param tenE ten giga enable
* @param size image size
* @param nx number of pixels in x direction
* @param ny number of pixels in y direction
* @param nf number of images
* @param maxf maximum frames per file
* @param acquisitionTime acquisition time
* @param subexposuretime sub exposure time
* @param subperiod sub period
* @param acquisitionPeriod acquisition period
* @param version version of software for hdf5 writing * @param version version of software for hdf5 writing
* @returns 0 for success and 1 for fail * @returns 0 for success and 1 for fail
*/ */
static int CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable, static int CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable,
uint32_t dr, bool tenE, uint32_t size, masterAttributes& attr)
uint32_t nPixelsx, uint32_t nPixelsy, uint64_t nf,
uint32_t maxf,
uint64_t acquisitionTime, uint64_t subexposuretime,
uint64_t subperiod, uint64_t acquisitionPeriod, double version)
{ {
try { try {
Exception::dontPrint(); //to handle errors Exception::dontPrint(); //to handle errors
@ -340,7 +326,7 @@ public:
//create attributes //create attributes
//version //version
dValue=version; dValue=attr.version;
attribute = fd->createAttribute("version",PredType::NATIVE_DOUBLE, dataspace); attribute = fd->createAttribute("version",PredType::NATIVE_DOUBLE, dataspace);
attribute.write(PredType::NATIVE_DOUBLE, &dValue); attribute.write(PredType::NATIVE_DOUBLE, &dValue);
@ -352,63 +338,75 @@ public:
Group group5( group3.createGroup("detector") ); Group group5( group3.createGroup("detector") );
Group group6( group1.createGroup("sample") ); Group group6( group1.createGroup("sample") );
//Detector Type
dataset = group5.createDataSet ( "detector type", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.detectorType), PredType::NATIVE_INT);
//Dynamic Range //Dynamic Range
dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace );
dataset.write ( &dr, PredType::NATIVE_INT); dataset.write ( &(attr.dynamicRange), PredType::NATIVE_INT);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, std::string("bits")); attribute.write(strdatatype, std::string("bits"));
//Ten Giga //Ten Giga
iValue = tenE; iValue = attr.tenGiga;
dataset = group5.createDataSet ( "ten giga enable", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "ten giga enable", PredType::NATIVE_INT, dataspace );
dataset.write ( &iValue, PredType::NATIVE_INT); dataset.write ( &iValue, PredType::NATIVE_INT);
//Image Size //Image Size
dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace );
dataset.write ( &size, PredType::NATIVE_INT); dataset.write ( &(attr.imageSize), PredType::NATIVE_INT);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, std::string("bytes")); attribute.write(strdatatype, std::string("bytes"));
//x //x
dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace );
dataset.write ( &nPixelsx, PredType::NATIVE_INT); dataset.write ( &(attr.nPixelsX), PredType::NATIVE_INT);
//y //y
dataset = group5.createDataSet ( "number of pixels in y axis", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "number of pixels in y axis", PredType::NATIVE_INT, dataspace );
dataset.write ( &nPixelsy, PredType::NATIVE_INT); dataset.write ( &(attr.nPixelsY), PredType::NATIVE_INT);
//Maximum frames per file //Maximum frames per file
dataset = group5.createDataSet ( "maximum frames per file", PredType::NATIVE_INT, dataspace ); dataset = group5.createDataSet ( "maximum frames per file", PredType::NATIVE_INT, dataspace );
dataset.write ( &maxf, PredType::NATIVE_INT); dataset.write ( &(attr.maxFramesPerFile), PredType::NATIVE_INT);
//Total Frames //Total Frames
dataset = group5.createDataSet ( "total frames", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "total frames", PredType::STD_U64LE, dataspace );
dataset.write ( &nf, PredType::STD_U64LE); dataset.write ( &(attr.totalFrames), PredType::STD_U64LE);
//Exptime //Exptime
dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace );
dataset.write ( &acquisitionTime, PredType::STD_U64LE); dataset.write ( &(attr.exptimeNs), PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, std::string("ns")); attribute.write(strdatatype, std::string("ns"));
//SubExptime //SubExptime
dataset = group5.createDataSet ( "sub exposure time", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "sub exposure time", PredType::STD_U64LE, dataspace );
dataset.write ( &subexposuretime, PredType::STD_U64LE); dataset.write ( &(attr.subExptimeNs), PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, std::string("ns")); attribute.write(strdatatype, std::string("ns"));
//SubPeriod //SubPeriod
dataset = group5.createDataSet ( "sub period", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "sub period", PredType::STD_U64LE, dataspace );
dataset.write ( &subperiod, PredType::STD_U64LE); dataset.write ( &(attr.subPeriodNs), PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, std::string("ns")); attribute.write(strdatatype, std::string("ns"));
//Period //Period
dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace ); dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace );
dataset.write ( &acquisitionPeriod, PredType::STD_U64LE); dataset.write ( &(attr.periodNs), PredType::STD_U64LE);
attribute = dataset.createAttribute("unit",strdatatype, dataspace); attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, std::string("ns")); attribute.write(strdatatype, std::string("ns"));
//Gap Pixels Enable
dataset = group5.createDataSet ( "gap pixels enable", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.gapPixelsEnable), PredType::NATIVE_INT);
//Quad Enable
dataset = group5.createDataSet ( "quad enable", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.quadEnable), PredType::NATIVE_INT);
//Timestamp //Timestamp
time_t t = time(0); time_t t = time(0);
dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace ); dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace );

View File

@ -28,8 +28,8 @@
#define MAX_CHUNKED_IMAGES 1 #define MAX_CHUNKED_IMAGES 1
//versions //versions
#define HDF5_WRITER_VERSION 3.0 //1 decimal places #define HDF5_WRITER_VERSION 4.0 //1 decimal places
#define BINARY_WRITER_VERSION 3.0 //1 decimal places #define BINARY_WRITER_VERSION 4.0 //1 decimal places
//parameters to calculate fifo depth //parameters to calculate fifo depth
@ -48,3 +48,21 @@
#define STREAMER_PRIORITY 10 #define STREAMER_PRIORITY 10
#define TCP_PRIORITY 10 #define TCP_PRIORITY 10
struct masterAttributes {
double version;
uint32_t detectorType;
uint32_t dynamicRange;
uint32_t tenGiga;
uint32_t imageSize;
uint32_t nPixelsX;
uint32_t nPixelsY;
uint32_t maxFramesPerFile;
uint64_t totalFrames;
uint64_t exptimeNs;
uint64_t subExptimeNs;
uint64_t subPeriodNs;
uint64_t periodNs;
uint32_t gapPixelsEnable;
uint32_t quadEnable;
};

View File

@ -114,9 +114,7 @@ int BinaryFile::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_
} }
int BinaryFile::CreateMasterFile(bool en, uint32_t size, int BinaryFile::CreateMasterFile(masterAttributes& attr) {
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
uint64_t ap) {
//beginning of every acquisition //beginning of every acquisition
numFramesInFile = 0; numFramesInFile = 0;
numActualPacketsInFile = 0; numActualPacketsInFile = 0;
@ -127,10 +125,9 @@ int BinaryFile::CreateMasterFile(bool en, uint32_t size,
if(!(*silentMode)) { if(!(*silentMode)) {
FILE_LOG(logINFO) << "Master File: " << masterFileName; FILE_LOG(logINFO) << "Master File: " << masterFileName;
} }
attr.version = BINARY_WRITER_VERSION;
return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName, return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName,
*overWriteEnable, *overWriteEnable, attr);
*dynamicRange, en, size, nx, ny, *numImages, *maxFramesPerFile,
at, st, sp, ap, BINARY_WRITER_VERSION);
} }
return OK; return OK;
} }

View File

@ -249,14 +249,11 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
} }
// only the first file // only the first file
int DataProcessor::CreateNewFile(bool en, uint64_t nf, uint64_t at, uint64_t st, int DataProcessor::CreateNewFile(masterAttributes& attr) {
uint64_t sp, uint64_t ap) {
if (file == NULL) if (file == NULL)
return FAIL; return FAIL;
file->CloseAllFiles(); file->CloseAllFiles();
if (file->CreateMasterFile(en, generalData->imageSize, if (file->CreateMasterFile(attr) == FAIL)
generalData->nPixelsX, generalData->nPixelsY,
at, st, sp, ap) == FAIL)
return FAIL; return FAIL;
if (file->CreateFile(currentFrameIndex) == FAIL) if (file->CreateFile(currentFrameIndex) == FAIL)
return FAIL; return FAIL;

View File

@ -243,9 +243,7 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
} }
int HDF5File::CreateMasterFile(bool en, uint32_t size, int HDF5File::CreateMasterFile(masterAttributes& attr) {
uint32_t nx, uint32_t ny, uint64_t at, uint64_t st, uint64_t sp,
uint64_t ap) {
//beginning of every acquisition //beginning of every acquisition
numFramesInFile = 0; numFramesInFile = 0;
@ -260,11 +258,9 @@ int HDF5File::CreateMasterFile(bool en, uint32_t size,
FILE_LOG(logINFO) << "Master File: " << masterFileName; FILE_LOG(logINFO) << "Master File: " << masterFileName;
} }
pthread_mutex_lock(&Mutex); pthread_mutex_lock(&Mutex);
attr.version = HDF5_WRITER_VERSION;
int ret = HDF5FileStatic::CreateMasterDataFile(masterfd, masterFileName, int ret = HDF5FileStatic::CreateMasterDataFile(masterfd, masterFileName,
*overWriteEnable, *overWriteEnable, attr);
*dynamicRange, en, size, nx, ny, *numImages, *maxFramesPerFile,
at, st, sp, ap,
HDF5_WRITER_VERSION);
pthread_mutex_unlock(&Mutex); pthread_mutex_unlock(&Mutex);
return ret; return ret;
} }

View File

@ -876,9 +876,23 @@ int UDPStandardImplementation::CreateUDPSockets() {
int UDPStandardImplementation::SetupWriter() { int UDPStandardImplementation::SetupWriter() {
bool error = false; bool error = false;
masterAttributes attr;
attr.detectorType = myDetectorType;
attr.dynamicRange = dynamicRange;
attr.tenGiga = tengigaEnable;
attr.imageSize = generalData->imageSize;
attr.nPixelsX = generalData->nPixelsX;
attr.nPixelsY = generalData->nPixelsY;
attr.maxFramesPerFile = framesPerFile;
attr.totalFrames = numberOfFrames;
attr.exptimeNs = acquisitionTime;
attr.subExptimeNs = subExpTime;
attr.subPeriodNs = subPeriod;
attr.periodNs = acquisitionPeriod;
attr.gapPixelsEnable = gapPixelsEnable;
attr.quadEnable = quadEnable;
for (unsigned int i = 0; i < dataProcessor.size(); ++i) for (unsigned int i = 0; i < dataProcessor.size(); ++i)
if (dataProcessor[i]->CreateNewFile(tengigaEnable, if (dataProcessor[i]->CreateNewFile(attr) == FAIL) {
numberOfFrames, acquisitionTime, subExpTime, subPeriod, acquisitionPeriod) == FAIL) {
error = true; error = true;
break; break;
} }